PageRenderTime 43ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/phpBB/phpbb/notification/type/admin_activate_user.php

https://github.com/Jipem/phpbb
PHP | 169 lines | 86 code | 24 blank | 59 comment | 4 complexity | 43cb0362ba77e34733b51f13fea481bd MD5 | raw file
Possible License(s): AGPL-1.0
  1. <?php
  2. /**
  3. *
  4. * This file is part of the phpBB Forum Software package.
  5. *
  6. * @copyright (c) phpBB Limited <https://www.phpbb.com>
  7. * @license GNU General Public License, version 2 (GPL-2.0)
  8. *
  9. * For full copyright and license information, please see
  10. * the docs/CREDITS.txt file.
  11. *
  12. */
  13. namespace phpbb\notification\type;
  14. /**
  15. * Admin activation notifications class
  16. * This class handles notifications for users requiring admin activation
  17. */
  18. class admin_activate_user extends \phpbb\notification\type\base
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function get_type()
  24. {
  25. return 'admin_activate_user';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. protected $language_key = 'NOTIFICATION_ADMIN_ACTIVATE_USER';
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public static $notification_option = array(
  35. 'lang' => 'NOTIFICATION_TYPE_ADMIN_ACTIVATE_USER',
  36. 'group' => 'NOTIFICATION_GROUP_ADMINISTRATION',
  37. );
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function is_available()
  42. {
  43. return ($this->auth->acl_get('a_user') && $this->config['require_activation'] == USER_ACTIVATION_ADMIN);
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public static function get_item_id($user)
  49. {
  50. return (int) $user['user_id'];
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public static function get_item_parent_id($post)
  56. {
  57. return 0;
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function find_users_for_notification($user, $options = array())
  63. {
  64. $options = array_merge(array(
  65. 'ignore_users' => array(),
  66. ), $options);
  67. // Grab admins that have permission to administer users.
  68. $admin_ary = $this->auth->acl_get_list(false, 'a_user', false);
  69. $users = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array();
  70. // Grab founders
  71. $sql = 'SELECT user_id
  72. FROM ' . USERS_TABLE . '
  73. WHERE user_type = ' . USER_FOUNDER;
  74. $result = $this->db->sql_query($sql);
  75. while ($row = $this->db->sql_fetchrow($result))
  76. {
  77. $users[] = (int) $row['user_id'];
  78. }
  79. $this->db->sql_freeresult($result);
  80. if (empty($users))
  81. {
  82. return array();
  83. }
  84. $users = array_unique($users);
  85. return $this->check_user_notification_options($users, $options);
  86. }
  87. /**
  88. * {@inheritdoc}
  89. */
  90. public function get_avatar()
  91. {
  92. return $this->user_loader->get_avatar($this->item_id);
  93. }
  94. /**
  95. * {@inheritdoc}
  96. */
  97. public function get_title()
  98. {
  99. $username = $this->user_loader->get_username($this->item_id, 'no_profile');
  100. return $this->user->lang($this->language_key, $username);
  101. }
  102. /**
  103. * {@inheritdoc}
  104. */
  105. public function get_email_template()
  106. {
  107. return 'admin_activate';
  108. }
  109. /**
  110. * {@inheritdoc}
  111. */
  112. public function get_email_template_variables()
  113. {
  114. $board_url = generate_board_url();
  115. $username = $this->user_loader->get_username($this->item_id, 'no_profile');
  116. return array(
  117. 'USERNAME' => htmlspecialchars_decode($username),
  118. 'U_USER_DETAILS' => "{$board_url}/memberlist.{$this->php_ext}?mode=viewprofile&u={$this->item_id}",
  119. 'U_ACTIVATE' => "{$board_url}/ucp.{$this->php_ext}?mode=activate&u={$this->item_id}&k={$this->get_data('user_actkey')}",
  120. );
  121. }
  122. /**
  123. * {@inheritdoc}
  124. */
  125. public function get_url()
  126. {
  127. return $this->user_loader->get_username($this->item_id, 'profile');
  128. }
  129. /**
  130. * {@inheritdoc}
  131. */
  132. public function users_to_query()
  133. {
  134. return array($this->item_id);
  135. }
  136. /**
  137. * {@inheritdoc}
  138. */
  139. public function create_insert_array($user, $pre_create_data)
  140. {
  141. $this->set_data('user_actkey', $user['user_actkey']);
  142. $this->notification_time = $user['user_regdate'];
  143. return parent::create_insert_array($user, $pre_create_data);
  144. }
  145. }