1 | <?php |
---|
2 | |
---|
3 | global $user, $lang, $conf, $errors; |
---|
4 | |
---|
5 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | Check Access and exit when user status is not ok | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | check_status(ACCESS_ADMINISTRATOR); |
---|
10 | |
---|
11 | //ini_set('error_reporting', E_ALL); |
---|
12 | //ini_set('display_errors', true); |
---|
13 | |
---|
14 | include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
15 | include_once (PHPWG_ROOT_PATH.'/include/constants.php'); |
---|
16 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
17 | |
---|
18 | load_language('plugin.lang', NBC_UserAdvManager_PATH); |
---|
19 | |
---|
20 | // +-----------------------------------------------------------------------+ |
---|
21 | // | Tabssheet | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | if (!isset($_GET['tab'])) |
---|
24 | $page['tab'] = 'global'; |
---|
25 | else |
---|
26 | $page['tab'] = $_GET['tab']; |
---|
27 | |
---|
28 | $tabsheet = new tabsheet(); |
---|
29 | $tabsheet->add('global', |
---|
30 | l10n('Tab_Global'), |
---|
31 | $my_base_url.'&tab=global'); |
---|
32 | $tabsheet->add('confirmmail', |
---|
33 | l10n('Tab_ConfirmMail'), |
---|
34 | $my_base_url.'&tab=confirmmail'); |
---|
35 | //$tabsheet->add('Misc_Options', |
---|
36 | // l10n('Tab_Misc_Options'), |
---|
37 | // $my_base_url.'&tab=Misc_Options'); |
---|
38 | $tabsheet->select($page['tab']); |
---|
39 | $tabsheet->assign(); |
---|
40 | |
---|
41 | $page['global'] = array(); |
---|
42 | $error = array(); |
---|
43 | |
---|
44 | // +-----------------------------------------------------------------------+ |
---|
45 | // | Tabssheet select | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | |
---|
48 | switch ($page['tab']) |
---|
49 | { |
---|
50 | // +-----------------------------------------------------------------------+ |
---|
51 | // | Global Config | |
---|
52 | // +-----------------------------------------------------------------------+ |
---|
53 | case 'global': |
---|
54 | |
---|
55 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_Mail_Info']) and isset($_POST['UserAdvManager_No_Casse']) and isset($_POST['UserAdvManager_Username_Char']) and isset($_POST['UserAdvManager_Confirm_Mail']) and isset($_POST['UserAdvManager_No_Comment_Anonymous']) ) |
---|
56 | { |
---|
57 | $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text'])); |
---|
58 | $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); |
---|
59 | |
---|
60 | $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List']; |
---|
61 | |
---|
62 | $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; |
---|
63 | |
---|
64 | $query = ' |
---|
65 | UPDATE '.CONFIG_TABLE.' |
---|
66 | SET value="'.$newconf_nbc_UserAdvManager.'" |
---|
67 | WHERE param="nbc_UserAdvManager" |
---|
68 | LIMIT 1 |
---|
69 | ;'; |
---|
70 | |
---|
71 | pwg_query($query); |
---|
72 | |
---|
73 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
74 | } |
---|
75 | |
---|
76 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
77 | |
---|
78 | /* Group setting for unvalidated and validated users */ |
---|
79 | $groups[-1] = '---------'; |
---|
80 | $No_Valid = -1; |
---|
81 | $Valid = -1; |
---|
82 | |
---|
83 | /* Check groups list in database */ |
---|
84 | $query = ' |
---|
85 | SELECT id, name |
---|
86 | FROM '.GROUPS_TABLE.' |
---|
87 | ORDER BY name ASC |
---|
88 | ;'; |
---|
89 | |
---|
90 | $result = pwg_query($query); |
---|
91 | |
---|
92 | while ($row = mysql_fetch_array($result)) |
---|
93 | { |
---|
94 | $groups[$row['id']] = $row['name']; |
---|
95 | /* configuration value for unvalidated users */ |
---|
96 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id']) |
---|
97 | { |
---|
98 | $No_Valid = $row['id']; |
---|
99 | } |
---|
100 | /* configuration value for validated users */ |
---|
101 | if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id']) |
---|
102 | { |
---|
103 | $Valid = $row['id']; |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /* Template initialization for unvalidated users group */ |
---|
108 | $template->assign( |
---|
109 | 'No_Confirm_Group', |
---|
110 | array( |
---|
111 | 'group_options'=> $groups, |
---|
112 | 'group_selected' => $No_Valid |
---|
113 | ) |
---|
114 | ); |
---|
115 | /* Template initialization for validated users group */ |
---|
116 | $template->assign( |
---|
117 | 'Validated_Group', |
---|
118 | array( |
---|
119 | 'group_options'=> $groups, |
---|
120 | 'group_selected' => $Valid |
---|
121 | ) |
---|
122 | ); |
---|
123 | |
---|
124 | /* Status setting for unvalidated and validated users */ |
---|
125 | $status_options[-1] = '------------'; |
---|
126 | $No_Valid_Status = -1; |
---|
127 | $Valid_Status = -1; |
---|
128 | |
---|
129 | /* Get status values */ |
---|
130 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
131 | { |
---|
132 | $status_options[$status] = l10n('user_status_'.$status); |
---|
133 | if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status) |
---|
134 | { |
---|
135 | $No_Valid_Status = $status; |
---|
136 | } |
---|
137 | /* Template initialization for unvalidated users group */ |
---|
138 | $template->assign( |
---|
139 | 'No_Confirm_Status', |
---|
140 | array( |
---|
141 | 'Status_options' => $status_options, |
---|
142 | 'Status_selected' => $No_Valid_Status |
---|
143 | ) |
---|
144 | ); |
---|
145 | } |
---|
146 | /* Get status values */ |
---|
147 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
148 | { |
---|
149 | $status_options[$status] = l10n('user_status_'.$status); |
---|
150 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
---|
151 | { |
---|
152 | $Valid_Status = $status; |
---|
153 | } |
---|
154 | /* Template initialization for unvalidated users group */ |
---|
155 | $template->assign( |
---|
156 | 'Confirm_Status', |
---|
157 | array( |
---|
158 | 'Status_options' => $status_options, |
---|
159 | 'Status_selected' => $Valid_Status |
---|
160 | ) |
---|
161 | ); |
---|
162 | } |
---|
163 | |
---|
164 | $template->assign( |
---|
165 | array( |
---|
166 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
---|
167 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
---|
168 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
---|
169 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
---|
170 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
---|
171 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
---|
172 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
---|
173 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
---|
174 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
---|
175 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
---|
176 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
---|
177 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
---|
178 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
---|
179 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
---|
180 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
---|
181 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
---|
182 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
---|
183 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
---|
184 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
---|
185 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
---|
186 | ) |
---|
187 | ); |
---|
188 | |
---|
189 | |
---|
190 | if ( isset($_POST['audit']) or isset($_POST['submit']) ) |
---|
191 | { |
---|
192 | $msg_error1 = ''; |
---|
193 | |
---|
194 | /* username insensible a la casse */ |
---|
195 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
---|
196 | { |
---|
197 | $query = " |
---|
198 | SELECT ".$conf['user_fields']['username']." |
---|
199 | FROM ".USERS_TABLE." p1 |
---|
200 | WHERE EXISTS( |
---|
201 | SELECT ".$conf['user_fields']['username']." |
---|
202 | FROM ".USERS_TABLE." p2 |
---|
203 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
---|
204 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
---|
205 | ) |
---|
206 | ;"; |
---|
207 | |
---|
208 | $result = pwg_query($query); |
---|
209 | |
---|
210 | while($row = mysql_fetch_array($result)) |
---|
211 | { |
---|
212 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | $msg_error2 = ''; |
---|
217 | |
---|
218 | /* Username without forbidden keys */ |
---|
219 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
---|
220 | { |
---|
221 | $query = " |
---|
222 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
223 | FROM ".USERS_TABLE." |
---|
224 | ;"; |
---|
225 | |
---|
226 | $result = pwg_query($query); |
---|
227 | |
---|
228 | while($row = mysql_fetch_array($result)) |
---|
229 | { |
---|
230 | if ( !ValidateUsername($row['username']) ) |
---|
231 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | $msg_error3 = ''; |
---|
236 | |
---|
237 | /* Email without forbidden domain */ |
---|
238 | if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) |
---|
239 | { |
---|
240 | $query = " |
---|
241 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
242 | FROM ".USERS_TABLE." |
---|
243 | ;"; |
---|
244 | |
---|
245 | $result = pwg_query($query); |
---|
246 | |
---|
247 | while($row = mysql_fetch_array($result)) |
---|
248 | { |
---|
249 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
250 | $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); |
---|
251 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
252 | { |
---|
253 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; |
---|
254 | if (preg_match($pattern, $row['mail_address'])) |
---|
255 | { |
---|
256 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; |
---|
257 | } |
---|
258 | } |
---|
259 | } |
---|
260 | } |
---|
261 | |
---|
262 | if ($msg_error1 <> '') |
---|
263 | $errors[] = $msg_error1.'<br/><br/>'; |
---|
264 | |
---|
265 | if ($msg_error2 <> '') |
---|
266 | $errors[] = $msg_error2.'<br/><br/>'; |
---|
267 | |
---|
268 | if ($msg_error3 <> '') |
---|
269 | $errors[] = $msg_error3.'<br/><br/>'; |
---|
270 | |
---|
271 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
---|
272 | array_push($page['errors'], l10n('Err_audit_advise')); |
---|
273 | else |
---|
274 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
---|
275 | } |
---|
276 | |
---|
277 | |
---|
278 | // +-----------------------------------------------------------------------+ |
---|
279 | // | errors display | |
---|
280 | // +-----------------------------------------------------------------------+ |
---|
281 | if ( isset ($errors) and count($errors) != 0) |
---|
282 | { |
---|
283 | $template->assign('errors',array()); |
---|
284 | foreach ($errors as $error) |
---|
285 | { |
---|
286 | array_push($page['errors'], $error); |
---|
287 | } |
---|
288 | } |
---|
289 | |
---|
290 | // +-----------------------------------------------------------------------+ |
---|
291 | // | templates display | |
---|
292 | // +-----------------------------------------------------------------------+ |
---|
293 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); |
---|
294 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
295 | |
---|
296 | break; |
---|
297 | |
---|
298 | // +-----------------------------------------------------------------------+ |
---|
299 | // | ConfirmMail Config | |
---|
300 | // +-----------------------------------------------------------------------+ |
---|
301 | case 'confirmmail': |
---|
302 | |
---|
303 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
304 | |
---|
305 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' ) |
---|
306 | { |
---|
307 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) ) |
---|
308 | { |
---|
309 | $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay']; |
---|
310 | //TODO:Adding new option [Auto deletion : True | False] |
---|
311 | //TODO:Adding new option [Resend_new_validation_key : True | False] |
---|
312 | $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; |
---|
313 | |
---|
314 | $query = ' |
---|
315 | UPDATE '.CONFIG_TABLE.' |
---|
316 | SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" |
---|
317 | WHERE param="nbc_UserAdvManager_ConfirmMail" |
---|
318 | LIMIT 1 |
---|
319 | ;'; |
---|
320 | |
---|
321 | pwg_query($query); |
---|
322 | |
---|
323 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
324 | } |
---|
325 | |
---|
326 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
327 | |
---|
328 | function get_unvalid_user_list() |
---|
329 | { |
---|
330 | global $conf, $page; |
---|
331 | |
---|
332 | /* Get ConfirmMail configuration */ |
---|
333 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
334 | |
---|
335 | /* Get UserAdvManager configuration */ |
---|
336 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
337 | |
---|
338 | $users = array(); |
---|
339 | |
---|
340 | /* search users depending expiration date */ |
---|
341 | $query = ' |
---|
342 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
343 | u.'.$conf['user_fields']['username'].' AS username, |
---|
344 | u.'.$conf['user_fields']['email'].' AS email, |
---|
345 | ui.status, |
---|
346 | ui.adviser, |
---|
347 | ui.enabled_high, |
---|
348 | ui.level, |
---|
349 | ui.registration_date, |
---|
350 | ug.group_id |
---|
351 | FROM '.USERS_TABLE.' AS u |
---|
352 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
353 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
354 | INNER JOIN '.USER_GROUP_TABLE.' AS ug |
---|
355 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
356 | WHERE u.'.$conf['user_fields']['id'].' >= 0 |
---|
357 | AND ug.group_id = "'.$conf_nbc_UserAdvManager[3].'" |
---|
358 | AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) <= "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'" |
---|
359 | ORDER BY id ASC |
---|
360 | ;'; |
---|
361 | |
---|
362 | $result = pwg_query($query); |
---|
363 | |
---|
364 | while ($row = mysql_fetch_array($result)) |
---|
365 | { |
---|
366 | $user = $row; |
---|
367 | $user['groups'] = array(); |
---|
368 | |
---|
369 | array_push($users, $user); |
---|
370 | } |
---|
371 | |
---|
372 | /* add group lists */ |
---|
373 | $user_ids = array(); |
---|
374 | foreach ($users as $i => $user) |
---|
375 | { |
---|
376 | $user_ids[$i] = $user['id']; |
---|
377 | } |
---|
378 | $user_nums = array_flip($user_ids); |
---|
379 | |
---|
380 | if (count($user_ids) > 0) |
---|
381 | { |
---|
382 | $query = ' |
---|
383 | SELECT user_id, group_id |
---|
384 | FROM '.USER_GROUP_TABLE.' |
---|
385 | WHERE user_id IN ('.implode(',', $user_ids).') |
---|
386 | ;'; |
---|
387 | |
---|
388 | $result = pwg_query($query); |
---|
389 | |
---|
390 | while ($row = mysql_fetch_array($result)) |
---|
391 | { |
---|
392 | array_push( |
---|
393 | $users[$user_nums[$row['user_id']]]['groups'], |
---|
394 | $row['group_id'] |
---|
395 | ); |
---|
396 | } |
---|
397 | } |
---|
398 | |
---|
399 | return $users; |
---|
400 | } |
---|
401 | |
---|
402 | // +-----------------------------------------------------------------------+ |
---|
403 | // | initialization | |
---|
404 | // +-----------------------------------------------------------------------+ |
---|
405 | |
---|
406 | if (!defined('PHPWG_ROOT_PATH')) |
---|
407 | { |
---|
408 | die('Hacking attempt!'); |
---|
409 | } |
---|
410 | |
---|
411 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
412 | |
---|
413 | // +-----------------------------------------------------------------------+ |
---|
414 | // | Check Access and exit when user status is not ok | |
---|
415 | // +-----------------------------------------------------------------------+ |
---|
416 | check_status(ACCESS_ADMINISTRATOR); |
---|
417 | |
---|
418 | $page['order_by_items'] = array( |
---|
419 | 'id' => l10n('registration_date'), |
---|
420 | 'username' => l10n('Username'), |
---|
421 | 'level' => l10n('Privacy level'), |
---|
422 | 'language' => l10n('language'), |
---|
423 | ); |
---|
424 | |
---|
425 | // +-----------------------------------------------------------------------+ |
---|
426 | // | user list | |
---|
427 | // +-----------------------------------------------------------------------+ |
---|
428 | |
---|
429 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
430 | |
---|
431 | // +-----------------------------------------------------------------------+ |
---|
432 | // | selected users | |
---|
433 | // +-----------------------------------------------------------------------+ |
---|
434 | //TODO:Link deletion to all users selected or single user |
---|
435 | if (isset($_POST['delete'])) |
---|
436 | { |
---|
437 | $collection = array(); |
---|
438 | |
---|
439 | switch ($_POST['target']) |
---|
440 | { |
---|
441 | case 'all' : |
---|
442 | { |
---|
443 | foreach($page['filtered_users'] as $local_user) |
---|
444 | { |
---|
445 | array_push($collection, $local_user['id']); |
---|
446 | } |
---|
447 | break; |
---|
448 | } |
---|
449 | case 'selection' : |
---|
450 | { |
---|
451 | if (isset($_POST['selection'])) |
---|
452 | { |
---|
453 | $collection = $_POST['selection']; |
---|
454 | } |
---|
455 | break; |
---|
456 | } |
---|
457 | } |
---|
458 | |
---|
459 | if (count($collection) == 0) |
---|
460 | { |
---|
461 | array_push($page['errors'], l10n('Select at least one user')); |
---|
462 | } |
---|
463 | } |
---|
464 | |
---|
465 | // +-----------------------------------------------------------------------+ |
---|
466 | // | delete users | |
---|
467 | // +-----------------------------------------------------------------------+ |
---|
468 | if (isset($_POST['delete']) and count($collection) > 0) |
---|
469 | { |
---|
470 | if (in_array($conf['guest_id'], $collection)) |
---|
471 | { |
---|
472 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
473 | } |
---|
474 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
475 | in_array($conf['default_user_id'], $collection)) |
---|
476 | { |
---|
477 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
478 | } |
---|
479 | if (in_array($conf['webmaster_id'], $collection)) |
---|
480 | { |
---|
481 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
482 | } |
---|
483 | if (in_array($user['id'], $collection)) |
---|
484 | { |
---|
485 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
486 | } |
---|
487 | |
---|
488 | if (count($page['errors']) == 0) |
---|
489 | { |
---|
490 | if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion']) |
---|
491 | { |
---|
492 | foreach ($collection as $user_id) |
---|
493 | { |
---|
494 | delete_user($user_id); |
---|
495 | } |
---|
496 | array_push( |
---|
497 | $page['infos'], |
---|
498 | l10n_dec( |
---|
499 | '%d user deleted', '%d users deleted', |
---|
500 | count($collection) |
---|
501 | ) |
---|
502 | ); |
---|
503 | |
---|
504 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
505 | { |
---|
506 | if (in_array($filter_user['id'], $collection)) |
---|
507 | { |
---|
508 | unset($page['filtered_users'][$filter_key]); |
---|
509 | } |
---|
510 | } |
---|
511 | } |
---|
512 | else |
---|
513 | { |
---|
514 | array_push($page['errors'], l10n('You need to confirm deletion')); |
---|
515 | } |
---|
516 | } |
---|
517 | } |
---|
518 | // +-----------------------------------------------------------------------+ |
---|
519 | // | Resend new validation key to users | |
---|
520 | // +-----------------------------------------------------------------------+ |
---|
521 | |
---|
522 | //TODO:Function to send a new validation key to all | single | selected users |
---|
523 | |
---|
524 | // +-----------------------------------------------------------------------+ |
---|
525 | // | groups list | |
---|
526 | // +-----------------------------------------------------------------------+ |
---|
527 | |
---|
528 | $groups[-1] = '------------'; |
---|
529 | |
---|
530 | $query = ' |
---|
531 | SELECT id, name |
---|
532 | FROM '.GROUPS_TABLE.' |
---|
533 | ORDER BY name ASC |
---|
534 | ;'; |
---|
535 | |
---|
536 | $result = pwg_query($query); |
---|
537 | |
---|
538 | while ($row = mysql_fetch_array($result)) |
---|
539 | { |
---|
540 | $groups[$row['id']] = $row['name']; |
---|
541 | } |
---|
542 | |
---|
543 | // +-----------------------------------------------------------------------+ |
---|
544 | // | Template Init | |
---|
545 | // +-----------------------------------------------------------------------+ |
---|
546 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
547 | |
---|
548 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
549 | { |
---|
550 | $start = $_GET['start']; |
---|
551 | } |
---|
552 | else |
---|
553 | { |
---|
554 | $start = 0; |
---|
555 | } |
---|
556 | |
---|
557 | $template->assign( |
---|
558 | array( |
---|
559 | 'F_ADD_ACTION' => $base_url, |
---|
560 | 'F_USERNAME' => @htmlentities($_GET['username']), |
---|
561 | 'F_FILTER_ACTION' => get_root_url().'admin.php' |
---|
562 | ) |
---|
563 | ); |
---|
564 | |
---|
565 | /* Hide radio-button if not allow to assign adviser */ |
---|
566 | if ($conf['allow_adviser']) |
---|
567 | { |
---|
568 | $template->assign('adviser', true); |
---|
569 | } |
---|
570 | |
---|
571 | // +-----------------------------------------------------------------------+ |
---|
572 | // | user list | |
---|
573 | // +-----------------------------------------------------------------------+ |
---|
574 | |
---|
575 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
576 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
577 | |
---|
578 | $visible_user_list = array(); |
---|
579 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
580 | { |
---|
581 | /* simulate LIMIT $start, $conf['users_page'] */ |
---|
582 | if ($num < $start) |
---|
583 | { |
---|
584 | continue; |
---|
585 | } |
---|
586 | if ($num >= $start + $conf['users_page']) |
---|
587 | { |
---|
588 | break; |
---|
589 | } |
---|
590 | |
---|
591 | $visible_user_list[] = $local_user; |
---|
592 | } |
---|
593 | |
---|
594 | foreach ($visible_user_list as $local_user) |
---|
595 | { |
---|
596 | $groups_string = preg_replace( |
---|
597 | '/(\d+)/e', |
---|
598 | "\$groups['$1']", |
---|
599 | implode( |
---|
600 | ', ', |
---|
601 | $local_user['groups'] |
---|
602 | ) |
---|
603 | ); |
---|
604 | |
---|
605 | if (isset($_POST['pref_submit']) |
---|
606 | and isset($_POST['selection']) |
---|
607 | and in_array($local_user['id'], $_POST['selection'])) |
---|
608 | { |
---|
609 | $checked = 'checked="checked"'; |
---|
610 | } |
---|
611 | else |
---|
612 | { |
---|
613 | $checked = ''; |
---|
614 | } |
---|
615 | |
---|
616 | $properties = array(); |
---|
617 | if ( $local_user['level'] != 0 ) |
---|
618 | { |
---|
619 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
620 | } |
---|
621 | $properties[] = |
---|
622 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
623 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
624 | |
---|
625 | if (isset($conf_nbc_UserAdvManager_ConfirmMail[1]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ) |
---|
626 | { |
---|
627 | $template->append( |
---|
628 | 'users', |
---|
629 | array( |
---|
630 | 'ID' => $local_user['id'], |
---|
631 | 'CHECKED' => $checked, |
---|
632 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
633 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
634 | 'USERNAME' => $local_user['username'] |
---|
635 | .($local_user['id'] == $conf['guest_id'] |
---|
636 | ? '<BR />['.l10n('is_the_guest').']' : '') |
---|
637 | .($local_user['id'] == $conf['default_user_id'] |
---|
638 | ? '<BR />['.l10n('is_the_default').']' : ''), |
---|
639 | 'STATUS' => l10n('user_status_'. |
---|
640 | $local_user['status']).(($local_user['adviser'] == 'true') |
---|
641 | ? '<BR />['.l10n('adviser').']' : ''), |
---|
642 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
643 | 'GROUPS' => $groups_string, |
---|
644 | //TODO:Changing ACTION from $properties to Single_Deletion |
---|
645 | //TODO:Addin new ACTION to Resend new validation key |
---|
646 | 'ACTION' => implode( ', ', $properties), |
---|
647 | ) |
---|
648 | ); |
---|
649 | } |
---|
650 | } |
---|
651 | |
---|
652 | $template->assign( |
---|
653 | array( |
---|
654 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
---|
655 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
---|
656 | 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], |
---|
657 | //TODO:Adding new option [Auto Deletion : True | False] |
---|
658 | //TODO:Adding new option [Resend_new_validation_key : True | False] |
---|
659 | ) |
---|
660 | ); |
---|
661 | |
---|
662 | // +-----------------------------------------------------------------------+ |
---|
663 | // | errors display | |
---|
664 | // +-----------------------------------------------------------------------+ |
---|
665 | if ( isset ($errors) and count($errors) != 0) |
---|
666 | { |
---|
667 | $template->assign('errors',array()); |
---|
668 | foreach ($errors as $error) |
---|
669 | { |
---|
670 | array_push($page['errors'], $error); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | // +-----------------------------------------------------------------------+ |
---|
675 | // | templates display | |
---|
676 | // +-----------------------------------------------------------------------+ |
---|
677 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl'); |
---|
678 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
679 | } |
---|
680 | else |
---|
681 | { |
---|
682 | array_push($page['infos'], l10n('Err_ConfirmMail_Settings')); |
---|
683 | } |
---|
684 | break; |
---|
685 | } |
---|
686 | ?> |
---|