Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 40 |
|
0.00% |
0 / 14 |
CRAP | |
0.00% |
0 / 1 |
admin_activate_user | |
0.00% |
0 / 40 |
|
0.00% |
0 / 14 |
342 | |
0.00% |
0 / 1 |
get_type | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
set_config | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
set_user_loader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
is_available | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
get_item_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_item_parent_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
find_users_for_notification | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
20 | |||
get_avatar | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_title | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
get_email_template | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_email_template_variables | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
get_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
users_to_query | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
create_insert_array | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
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 | |
14 | namespace phpbb\notification\type; |
15 | |
16 | /** |
17 | * Admin activation notifications class |
18 | * This class handles notifications for users requiring admin activation |
19 | */ |
20 | |
21 | class admin_activate_user extends \phpbb\notification\type\base |
22 | { |
23 | /** |
24 | * {@inheritdoc} |
25 | */ |
26 | public function get_type() |
27 | { |
28 | return 'notification.type.admin_activate_user'; |
29 | } |
30 | |
31 | /** |
32 | * Language key used to output the text |
33 | * |
34 | * @var string |
35 | */ |
36 | protected $language_key = 'NOTIFICATION_ADMIN_ACTIVATE_USER'; |
37 | |
38 | /** |
39 | * {@inheritdoc} |
40 | */ |
41 | public static $notification_option = array( |
42 | 'lang' => 'NOTIFICATION_TYPE_ADMIN_ACTIVATE_USER', |
43 | 'group' => 'NOTIFICATION_GROUP_ADMINISTRATION', |
44 | ); |
45 | |
46 | /** @var \phpbb\user_loader */ |
47 | protected $user_loader; |
48 | |
49 | /** @var \phpbb\config\config */ |
50 | protected $config; |
51 | |
52 | public function set_config(\phpbb\config\config $config) |
53 | { |
54 | $this->config = $config; |
55 | } |
56 | |
57 | public function set_user_loader(\phpbb\user_loader $user_loader) |
58 | { |
59 | $this->user_loader = $user_loader; |
60 | } |
61 | |
62 | /** |
63 | * {@inheritdoc} |
64 | */ |
65 | public function is_available() |
66 | { |
67 | return ($this->auth->acl_get('a_user') && $this->config['require_activation'] == USER_ACTIVATION_ADMIN); |
68 | } |
69 | |
70 | /** |
71 | * {@inheritdoc} |
72 | */ |
73 | public static function get_item_id($type_data) |
74 | { |
75 | return (int) $type_data['user_id']; |
76 | } |
77 | |
78 | /** |
79 | * {@inheritdoc} |
80 | */ |
81 | public static function get_item_parent_id($type_data) |
82 | { |
83 | return 0; |
84 | } |
85 | |
86 | /** |
87 | * {@inheritdoc} |
88 | */ |
89 | public function find_users_for_notification($type_data, $options = array()) |
90 | { |
91 | $options = array_merge(array( |
92 | 'ignore_users' => array(), |
93 | ), $options); |
94 | |
95 | // Grab admins that have permission to administer users. |
96 | $admin_ary = $this->auth->acl_get_list(false, 'a_user', false); |
97 | $users = (!empty($admin_ary[0]['a_user'])) ? $admin_ary[0]['a_user'] : array(); |
98 | |
99 | // Grab founders |
100 | $sql = 'SELECT user_id |
101 | FROM ' . USERS_TABLE . ' |
102 | WHERE user_type = ' . USER_FOUNDER; |
103 | $result = $this->db->sql_query($sql); |
104 | |
105 | while ($row = $this->db->sql_fetchrow($result)) |
106 | { |
107 | $users[] = (int) $row['user_id']; |
108 | } |
109 | $this->db->sql_freeresult($result); |
110 | |
111 | if (empty($users)) |
112 | { |
113 | return array(); |
114 | } |
115 | $users = array_unique($users); |
116 | |
117 | return $this->check_user_notification_options($users, $options); |
118 | } |
119 | |
120 | /** |
121 | * {@inheritdoc} |
122 | */ |
123 | public function get_avatar() |
124 | { |
125 | return $this->user_loader->get_avatar($this->item_id, false, true); |
126 | } |
127 | |
128 | /** |
129 | * {@inheritdoc} |
130 | */ |
131 | public function get_title() |
132 | { |
133 | $username = $this->user_loader->get_username($this->item_id, 'no_profile'); |
134 | |
135 | return $this->language->lang($this->language_key, $username); |
136 | } |
137 | |
138 | /** |
139 | * {@inheritdoc} |
140 | */ |
141 | public function get_email_template() |
142 | { |
143 | return 'admin_activate'; |
144 | } |
145 | |
146 | /** |
147 | * {@inheritdoc} |
148 | */ |
149 | public function get_email_template_variables() |
150 | { |
151 | $board_url = generate_board_url(); |
152 | $username = $this->user_loader->get_username($this->item_id, 'username'); |
153 | |
154 | return array( |
155 | 'USERNAME' => html_entity_decode($username, ENT_COMPAT), |
156 | 'U_USER_DETAILS' => "{$board_url}/memberlist.{$this->php_ext}?mode=viewprofile&u={$this->item_id}", |
157 | 'U_ACTIVATE' => "{$board_url}/ucp.{$this->php_ext}?mode=activate&u={$this->item_id}&k={$this->get_data('user_actkey')}", |
158 | ); |
159 | } |
160 | |
161 | /** |
162 | * {@inheritdoc} |
163 | */ |
164 | public function get_url() |
165 | { |
166 | return $this->user_loader->get_username($this->item_id, 'profile'); |
167 | } |
168 | |
169 | /** |
170 | * {@inheritdoc} |
171 | */ |
172 | public function users_to_query() |
173 | { |
174 | return array($this->item_id); |
175 | } |
176 | |
177 | /** |
178 | * {@inheritdoc} |
179 | */ |
180 | public function create_insert_array($type_data, $pre_create_data = array()) |
181 | { |
182 | $this->set_data('user_actkey', $type_data['user_actkey']); |
183 | $this->notification_time = $type_data['user_regdate']; |
184 | |
185 | parent::create_insert_array($type_data, $pre_create_data); |
186 | } |
187 | } |