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('usermanager', |
---|
36 | l10n('Tab_UserManager'), |
---|
37 | $my_base_url.'&tab=usermanager'); |
---|
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 | // +-----------------------------------------------------------------------+ |
---|
52 | // | Global Config | |
---|
53 | // +-----------------------------------------------------------------------+ |
---|
54 | // ************************************************************************* |
---|
55 | case 'global': |
---|
56 | |
---|
57 | 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']) ) |
---|
58 | { |
---|
59 | $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text'])); |
---|
60 | $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text'])); |
---|
61 | |
---|
62 | $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']; |
---|
63 | |
---|
64 | $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager; |
---|
65 | |
---|
66 | $query = ' |
---|
67 | UPDATE '.CONFIG_TABLE.' |
---|
68 | SET value="'.$newconf_nbc_UserAdvManager.'" |
---|
69 | WHERE param="nbc_UserAdvManager" |
---|
70 | LIMIT 1 |
---|
71 | ;'; |
---|
72 | |
---|
73 | pwg_query($query); |
---|
74 | |
---|
75 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
76 | } |
---|
77 | |
---|
78 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
79 | |
---|
80 | /* Group setting for unvalidated and validated users */ |
---|
81 | $groups[-1] = '---------'; |
---|
82 | $No_Valid = -1; |
---|
83 | $Valid = -1; |
---|
84 | |
---|
85 | /* Check groups list in database */ |
---|
86 | $query = ' |
---|
87 | SELECT id, name |
---|
88 | FROM '.GROUPS_TABLE.' |
---|
89 | ORDER BY name ASC |
---|
90 | ;'; |
---|
91 | |
---|
92 | $result = pwg_query($query); |
---|
93 | |
---|
94 | while ($row = mysql_fetch_array($result)) |
---|
95 | { |
---|
96 | $groups[$row['id']] = $row['name']; |
---|
97 | /* configuration value for unvalidated users */ |
---|
98 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id']) |
---|
99 | { |
---|
100 | $No_Valid = $row['id']; |
---|
101 | } |
---|
102 | /* configuration value for validated users */ |
---|
103 | if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id']) |
---|
104 | { |
---|
105 | $Valid = $row['id']; |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | /* Template initialization for unvalidated users group */ |
---|
110 | $template->assign( |
---|
111 | 'No_Confirm_Group', |
---|
112 | array( |
---|
113 | 'group_options'=> $groups, |
---|
114 | 'group_selected' => $No_Valid |
---|
115 | ) |
---|
116 | ); |
---|
117 | /* Template initialization for validated users group */ |
---|
118 | $template->assign( |
---|
119 | 'Validated_Group', |
---|
120 | array( |
---|
121 | 'group_options'=> $groups, |
---|
122 | 'group_selected' => $Valid |
---|
123 | ) |
---|
124 | ); |
---|
125 | |
---|
126 | /* Status setting for unvalidated and validated users */ |
---|
127 | $status_options[-1] = '------------'; |
---|
128 | $No_Valid_Status = -1; |
---|
129 | $Valid_Status = -1; |
---|
130 | |
---|
131 | /* Get status values */ |
---|
132 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
133 | { |
---|
134 | $status_options[$status] = l10n('user_status_'.$status); |
---|
135 | if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status) |
---|
136 | { |
---|
137 | $No_Valid_Status = $status; |
---|
138 | } |
---|
139 | |
---|
140 | /* Template initialization for unvalidated users group */ |
---|
141 | $template->assign( |
---|
142 | 'No_Confirm_Status', |
---|
143 | array( |
---|
144 | 'Status_options' => $status_options, |
---|
145 | 'Status_selected' => $No_Valid_Status |
---|
146 | ) |
---|
147 | ); |
---|
148 | } |
---|
149 | |
---|
150 | /* Get status values */ |
---|
151 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
152 | { |
---|
153 | $status_options[$status] = l10n('user_status_'.$status); |
---|
154 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
---|
155 | { |
---|
156 | $Valid_Status = $status; |
---|
157 | } |
---|
158 | |
---|
159 | /* Template initialization for unvalidated users group */ |
---|
160 | $template->assign( |
---|
161 | 'Confirm_Status', |
---|
162 | array( |
---|
163 | 'Status_options' => $status_options, |
---|
164 | 'Status_selected' => $Valid_Status |
---|
165 | ) |
---|
166 | ); |
---|
167 | } |
---|
168 | |
---|
169 | $template->assign( |
---|
170 | array( |
---|
171 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
---|
172 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
---|
173 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
---|
174 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
---|
175 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
---|
176 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
---|
177 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
---|
178 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
---|
179 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
---|
180 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
---|
181 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
---|
182 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
---|
183 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
---|
184 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
---|
185 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
---|
186 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
---|
187 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
---|
188 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
---|
189 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
---|
190 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
---|
191 | ) |
---|
192 | ); |
---|
193 | |
---|
194 | |
---|
195 | if ( isset($_POST['audit']) or isset($_POST['submit']) ) |
---|
196 | { |
---|
197 | $msg_error1 = ''; |
---|
198 | |
---|
199 | /* username insensible a la casse */ |
---|
200 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
---|
201 | { |
---|
202 | $query = " |
---|
203 | SELECT ".$conf['user_fields']['username']." |
---|
204 | FROM ".USERS_TABLE." p1 |
---|
205 | WHERE EXISTS( |
---|
206 | SELECT ".$conf['user_fields']['username']." |
---|
207 | FROM ".USERS_TABLE." p2 |
---|
208 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
---|
209 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
---|
210 | ) |
---|
211 | ;"; |
---|
212 | |
---|
213 | $result = pwg_query($query); |
---|
214 | |
---|
215 | while($row = mysql_fetch_array($result)) |
---|
216 | { |
---|
217 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; |
---|
218 | } |
---|
219 | } |
---|
220 | |
---|
221 | $msg_error2 = ''; |
---|
222 | |
---|
223 | /* Username without forbidden keys */ |
---|
224 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
---|
225 | { |
---|
226 | $query = " |
---|
227 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
228 | FROM ".USERS_TABLE." |
---|
229 | ;"; |
---|
230 | |
---|
231 | $result = pwg_query($query); |
---|
232 | |
---|
233 | while($row = mysql_fetch_array($result)) |
---|
234 | { |
---|
235 | if (!ValidateUsername($row['username'])) |
---|
236 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; |
---|
237 | } |
---|
238 | } |
---|
239 | |
---|
240 | $msg_error3 = ''; |
---|
241 | |
---|
242 | /* Email without forbidden domain */ |
---|
243 | if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' ) |
---|
244 | { |
---|
245 | $query = " |
---|
246 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
247 | FROM ".USERS_TABLE." |
---|
248 | ;"; |
---|
249 | |
---|
250 | $result = pwg_query($query); |
---|
251 | |
---|
252 | while($row = mysql_fetch_array($result)) |
---|
253 | { |
---|
254 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
255 | $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); |
---|
256 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
257 | { |
---|
258 | $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; |
---|
259 | if (preg_match($pattern, $row['mail_address'])) |
---|
260 | { |
---|
261 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; |
---|
262 | } |
---|
263 | } |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | if ($msg_error1 <> '') |
---|
268 | $errors[] = $msg_error1.'<br/><br/>'; |
---|
269 | |
---|
270 | if ($msg_error2 <> '') |
---|
271 | $errors[] = $msg_error2.'<br/><br/>'; |
---|
272 | |
---|
273 | if ($msg_error3 <> '') |
---|
274 | $errors[] = $msg_error3.'<br/><br/>'; |
---|
275 | |
---|
276 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
---|
277 | array_push($page['errors'], l10n('Err_audit_advise')); |
---|
278 | else |
---|
279 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
---|
280 | } |
---|
281 | |
---|
282 | |
---|
283 | // +-----------------------------------------------------------------------+ |
---|
284 | // | errors display | |
---|
285 | // +-----------------------------------------------------------------------+ |
---|
286 | if ( isset ($errors) and count($errors) != 0) |
---|
287 | { |
---|
288 | $template->assign('errors',array()); |
---|
289 | foreach ($errors as $error) |
---|
290 | { |
---|
291 | array_push($page['errors'], $error); |
---|
292 | } |
---|
293 | } |
---|
294 | |
---|
295 | // +-----------------------------------------------------------------------+ |
---|
296 | // | templates display | |
---|
297 | // +-----------------------------------------------------------------------+ |
---|
298 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); |
---|
299 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
300 | |
---|
301 | break; |
---|
302 | |
---|
303 | // ************************************************************************* |
---|
304 | // +-----------------------------------------------------------------------+ |
---|
305 | // | ConfirmMail Config | |
---|
306 | // +-----------------------------------------------------------------------+ |
---|
307 | // ************************************************************************* |
---|
308 | case 'confirmmail': |
---|
309 | |
---|
310 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
311 | |
---|
312 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true') |
---|
313 | { |
---|
314 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) ) |
---|
315 | { |
---|
316 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'])); |
---|
317 | $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'])); |
---|
318 | |
---|
319 | $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'].';'.$_POST['UserAdvManager_ConfirmMail_Remail'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']; |
---|
320 | |
---|
321 | //NODO:Adding new option [Auto deletion : True | False] - No access to cron functionnalities |
---|
322 | |
---|
323 | $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; |
---|
324 | |
---|
325 | $query = ' |
---|
326 | UPDATE '.CONFIG_TABLE.' |
---|
327 | SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" |
---|
328 | WHERE param="nbc_UserAdvManager_ConfirmMail" |
---|
329 | LIMIT 1 |
---|
330 | ;'; |
---|
331 | |
---|
332 | pwg_query($query); |
---|
333 | |
---|
334 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
335 | } |
---|
336 | |
---|
337 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
338 | |
---|
339 | $template->assign( |
---|
340 | array( |
---|
341 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
---|
342 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
---|
343 | 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], |
---|
344 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='true' ? 'checked="checked"' : '', |
---|
345 | 'UserAdvManager_CONFIRMMAIL_REMAIL_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[3]=='false' ? 'checked="checked"' : '', |
---|
346 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT1' => $conf_nbc_UserAdvManager_ConfirmMail[2], |
---|
347 | 'UserAdvManager_CONFIRMMAIL_REMAIL_TXT2' => $conf_nbc_UserAdvManager_ConfirmMail[4], |
---|
348 | ) |
---|
349 | ); |
---|
350 | |
---|
351 | // +-----------------------------------------------------------------------+ |
---|
352 | // | errors display | |
---|
353 | // +-----------------------------------------------------------------------+ |
---|
354 | if ( isset ($errors) and count($errors) != 0) |
---|
355 | { |
---|
356 | $template->assign('errors',array()); |
---|
357 | foreach ($errors as $error) |
---|
358 | { |
---|
359 | array_push($page['errors'], $error); |
---|
360 | } |
---|
361 | } |
---|
362 | |
---|
363 | // +-----------------------------------------------------------------------+ |
---|
364 | // | templates display | |
---|
365 | // +-----------------------------------------------------------------------+ |
---|
366 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl'); |
---|
367 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
368 | } |
---|
369 | else |
---|
370 | { |
---|
371 | array_push($page['infos'], l10n('Err_ConfirmMail_Settings')); |
---|
372 | } |
---|
373 | break; |
---|
374 | |
---|
375 | |
---|
376 | // ************************************************************************* |
---|
377 | // +-----------------------------------------------------------------------+ |
---|
378 | // | Users manager page | |
---|
379 | // +-----------------------------------------------------------------------+ |
---|
380 | // ************************************************************************* |
---|
381 | case 'usermanager': |
---|
382 | |
---|
383 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
384 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
385 | |
---|
386 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' and isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] <> '-1' and isset($conf_nbc_UserAdvManager_ConfirmMail[0]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true') |
---|
387 | { |
---|
388 | // +-----------------------------------------------------------------------+ |
---|
389 | // | initialization | |
---|
390 | // +-----------------------------------------------------------------------+ |
---|
391 | |
---|
392 | if (!defined('PHPWG_ROOT_PATH')) |
---|
393 | { |
---|
394 | die('Hacking attempt!'); |
---|
395 | } |
---|
396 | |
---|
397 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
398 | |
---|
399 | // +-----------------------------------------------------------------------+ |
---|
400 | // | Check Access and exit when user status is not ok | |
---|
401 | // +-----------------------------------------------------------------------+ |
---|
402 | check_status(ACCESS_ADMINISTRATOR); |
---|
403 | |
---|
404 | $page['order_by_items'] = array( |
---|
405 | 'id' => l10n('registration_date'), |
---|
406 | 'username' => l10n('Username'), |
---|
407 | 'level' => l10n('Privacy level'), |
---|
408 | 'language' => l10n('language'), |
---|
409 | ); |
---|
410 | |
---|
411 | // +-----------------------------------------------------------------------+ |
---|
412 | // | user list | |
---|
413 | // +-----------------------------------------------------------------------+ |
---|
414 | |
---|
415 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
416 | |
---|
417 | // +-----------------------------------------------------------------------+ |
---|
418 | // | selected users | |
---|
419 | // +-----------------------------------------------------------------------+ |
---|
420 | if (isset($_POST['Del_Selected'])) |
---|
421 | { |
---|
422 | $collection = array(); |
---|
423 | |
---|
424 | switch ($_POST['target']) |
---|
425 | { |
---|
426 | case 'all' : |
---|
427 | { |
---|
428 | foreach($page['filtered_users'] as $local_user) |
---|
429 | { |
---|
430 | array_push($collection, $local_user['id']); |
---|
431 | } |
---|
432 | break; |
---|
433 | } |
---|
434 | case 'selection' : |
---|
435 | { |
---|
436 | if (isset($_POST['selection'])) |
---|
437 | { |
---|
438 | $collection = $_POST['selection']; |
---|
439 | } |
---|
440 | break; |
---|
441 | } |
---|
442 | } |
---|
443 | |
---|
444 | if (count($collection) == 0) |
---|
445 | { |
---|
446 | array_push($page['errors'], l10n('Select at least one user')); |
---|
447 | } |
---|
448 | } |
---|
449 | |
---|
450 | // +-----------------------------------------------------------------------+ |
---|
451 | // | delete users | |
---|
452 | // +-----------------------------------------------------------------------+ |
---|
453 | if (isset($_POST['Del_Selected']) and count($collection) > 0) |
---|
454 | { |
---|
455 | if (in_array($conf['guest_id'], $collection)) |
---|
456 | { |
---|
457 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
458 | } |
---|
459 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
460 | in_array($conf['default_user_id'], $collection)) |
---|
461 | { |
---|
462 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
463 | } |
---|
464 | if (in_array($conf['webmaster_id'], $collection)) |
---|
465 | { |
---|
466 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
467 | } |
---|
468 | if (in_array($user['id'], $collection)) |
---|
469 | { |
---|
470 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
471 | } |
---|
472 | |
---|
473 | if (count($page['errors']) == 0) |
---|
474 | { |
---|
475 | foreach ($collection as $user_id) |
---|
476 | { |
---|
477 | delete_user($user_id); |
---|
478 | } |
---|
479 | array_push( |
---|
480 | $page['infos'], |
---|
481 | l10n_dec( |
---|
482 | '%d user deleted', '%d users deleted', |
---|
483 | count($collection) |
---|
484 | ) |
---|
485 | ); |
---|
486 | |
---|
487 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
488 | { |
---|
489 | if (in_array($filter_user['id'], $collection)) |
---|
490 | { |
---|
491 | unset($page['filtered_users'][$filter_key]); |
---|
492 | } |
---|
493 | } |
---|
494 | } |
---|
495 | } |
---|
496 | |
---|
497 | // +-----------------------------------------------------------------------+ |
---|
498 | // | Resend new validation key to users | |
---|
499 | // +-----------------------------------------------------------------------+ |
---|
500 | // +-----------------------------------------------------------------------+ |
---|
501 | // | selected users | |
---|
502 | // +-----------------------------------------------------------------------+ |
---|
503 | if (isset($_POST['Mail_With_Key'])) |
---|
504 | { |
---|
505 | $collection = array(); |
---|
506 | |
---|
507 | switch ($_POST['target']) |
---|
508 | { |
---|
509 | case 'all' : |
---|
510 | { |
---|
511 | foreach($page['filtered_users'] as $local_user) |
---|
512 | { |
---|
513 | array_push($collection, $local_user['id']); |
---|
514 | } |
---|
515 | break; |
---|
516 | } |
---|
517 | case 'selection' : |
---|
518 | { |
---|
519 | if (isset($_POST['selection'])) |
---|
520 | { |
---|
521 | $collection = $_POST['selection']; |
---|
522 | } |
---|
523 | break; |
---|
524 | } |
---|
525 | } |
---|
526 | |
---|
527 | if (count($collection) == 0) |
---|
528 | { |
---|
529 | array_push($page['errors'], l10n('Select at least one user')); |
---|
530 | } |
---|
531 | } |
---|
532 | // +-----------------------------------------------------------------------+ |
---|
533 | // | Resend new validation key to users | |
---|
534 | // +-----------------------------------------------------------------------+ |
---|
535 | if (isset($_POST['Mail_With_Key']) and count($collection) > 0) |
---|
536 | { |
---|
537 | if (in_array($conf['guest_id'], $collection)) |
---|
538 | { |
---|
539 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
540 | } |
---|
541 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
542 | in_array($conf['default_user_id'], $collection)) |
---|
543 | { |
---|
544 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
545 | } |
---|
546 | if (in_array($conf['webmaster_id'], $collection)) |
---|
547 | { |
---|
548 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
549 | } |
---|
550 | if (in_array($user['id'], $collection)) |
---|
551 | { |
---|
552 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
553 | } |
---|
554 | |
---|
555 | if (count($page['errors']) == 0) |
---|
556 | { |
---|
557 | foreach ($collection as $user_id) |
---|
558 | { |
---|
559 | $typemail = 1; |
---|
560 | $query = " |
---|
561 | SELECT id, username, mail_address |
---|
562 | FROM ".USERS_TABLE." |
---|
563 | WHERE id = '".$user_id."' |
---|
564 | ;"; |
---|
565 | $data = mysql_fetch_array(pwg_query($query)); |
---|
566 | |
---|
567 | ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],true); |
---|
568 | } |
---|
569 | array_push( |
---|
570 | $page['infos'], |
---|
571 | l10n_dec( |
---|
572 | '%d_Mail_With_Key', '%d_Mails_With_Key', |
---|
573 | count($collection) |
---|
574 | ) |
---|
575 | ); |
---|
576 | |
---|
577 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | // +-----------------------------------------------------------------------+ |
---|
582 | // | Send reminder without new key to users | |
---|
583 | // +-----------------------------------------------------------------------+ |
---|
584 | // +-----------------------------------------------------------------------+ |
---|
585 | // | selected users | |
---|
586 | // +-----------------------------------------------------------------------+ |
---|
587 | if (isset($_POST['Mail_Without_Key'])) |
---|
588 | { |
---|
589 | $collection = array(); |
---|
590 | |
---|
591 | switch ($_POST['target']) |
---|
592 | { |
---|
593 | case 'all' : |
---|
594 | { |
---|
595 | foreach($page['filtered_users'] as $local_user) |
---|
596 | { |
---|
597 | array_push($collection, $local_user['id']); |
---|
598 | } |
---|
599 | break; |
---|
600 | } |
---|
601 | case 'selection' : |
---|
602 | { |
---|
603 | if (isset($_POST['selection'])) |
---|
604 | { |
---|
605 | $collection = $_POST['selection']; |
---|
606 | } |
---|
607 | break; |
---|
608 | } |
---|
609 | } |
---|
610 | |
---|
611 | if (count($collection) == 0) |
---|
612 | { |
---|
613 | array_push($page['errors'], l10n('Select at least one user')); |
---|
614 | } |
---|
615 | } |
---|
616 | // +-----------------------------------------------------------------------+ |
---|
617 | // | Send reminder without new key to users | |
---|
618 | // +-----------------------------------------------------------------------+ |
---|
619 | if (isset($_POST['Mail_Without_Key']) and count($collection) > 0) |
---|
620 | { |
---|
621 | if (in_array($conf['guest_id'], $collection)) |
---|
622 | { |
---|
623 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
624 | } |
---|
625 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
626 | in_array($conf['default_user_id'], $collection)) |
---|
627 | { |
---|
628 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
629 | } |
---|
630 | if (in_array($conf['webmaster_id'], $collection)) |
---|
631 | { |
---|
632 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
633 | } |
---|
634 | if (in_array($user['id'], $collection)) |
---|
635 | { |
---|
636 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
637 | } |
---|
638 | |
---|
639 | if (count($page['errors']) == 0) |
---|
640 | { |
---|
641 | foreach ($collection as $user_id) |
---|
642 | { |
---|
643 | $typemail = 2; |
---|
644 | $query = " |
---|
645 | SELECT id, username, mail_address |
---|
646 | FROM ".USERS_TABLE." |
---|
647 | WHERE id = '".$user_id."' |
---|
648 | ;"; |
---|
649 | |
---|
650 | $data = mysql_fetch_array(pwg_query($query)); |
---|
651 | |
---|
652 | ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],false); |
---|
653 | } |
---|
654 | array_push( |
---|
655 | $page['infos'], |
---|
656 | l10n_dec( |
---|
657 | '%d_Reminder_Sent', '%d_Reminders_Sent', |
---|
658 | count($collection) |
---|
659 | ) |
---|
660 | ); |
---|
661 | |
---|
662 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
663 | } |
---|
664 | } |
---|
665 | |
---|
666 | // +-----------------------------------------------------------------------+ |
---|
667 | // | Force validation | |
---|
668 | // +-----------------------------------------------------------------------+ |
---|
669 | // +-----------------------------------------------------------------------+ |
---|
670 | // | selected users | |
---|
671 | // +-----------------------------------------------------------------------+ |
---|
672 | if (isset($_POST['Force_Validation'])) |
---|
673 | { |
---|
674 | $collection = array(); |
---|
675 | |
---|
676 | switch ($_POST['target']) |
---|
677 | { |
---|
678 | case 'all' : |
---|
679 | { |
---|
680 | foreach($page['filtered_users'] as $local_user) |
---|
681 | { |
---|
682 | array_push($collection, $local_user['id']); |
---|
683 | } |
---|
684 | break; |
---|
685 | } |
---|
686 | case 'selection' : |
---|
687 | { |
---|
688 | if (isset($_POST['selection'])) |
---|
689 | { |
---|
690 | $collection = $_POST['selection']; |
---|
691 | } |
---|
692 | break; |
---|
693 | } |
---|
694 | } |
---|
695 | |
---|
696 | if (count($collection) == 0) |
---|
697 | { |
---|
698 | array_push($page['errors'], l10n('Select at least one user')); |
---|
699 | } |
---|
700 | } |
---|
701 | // +-----------------------------------------------------------------------+ |
---|
702 | // | Force validation | |
---|
703 | // +-----------------------------------------------------------------------+ |
---|
704 | if (isset($_POST['Force_Validation']) and count($collection) > 0) |
---|
705 | { |
---|
706 | if (in_array($conf['guest_id'], $collection)) |
---|
707 | { |
---|
708 | array_push($page['errors'], l10n('No_validation_for_Guest')); |
---|
709 | } |
---|
710 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
711 | in_array($conf['default_user_id'], $collection)) |
---|
712 | { |
---|
713 | array_push($page['errors'], l10n('No_validation_for_default_user')); |
---|
714 | } |
---|
715 | if (in_array($conf['webmaster_id'], $collection)) |
---|
716 | { |
---|
717 | array_push($page['errors'], l10n('No_validation_for_Webmaster')); |
---|
718 | } |
---|
719 | if (in_array($user['id'], $collection)) |
---|
720 | { |
---|
721 | array_push($page['errors'], l10n('No_validation_for_your_account')); |
---|
722 | } |
---|
723 | |
---|
724 | if (count($page['errors']) == 0) |
---|
725 | { |
---|
726 | foreach ($collection as $user_id) |
---|
727 | { |
---|
728 | $query = " |
---|
729 | SELECT id, username, mail_address |
---|
730 | FROM ".USERS_TABLE." |
---|
731 | WHERE id = '".$user_id."' |
---|
732 | ;"; |
---|
733 | |
---|
734 | $data = mysql_fetch_array(pwg_query($query)); |
---|
735 | |
---|
736 | ForceValidation($data['id']); |
---|
737 | } |
---|
738 | array_push( |
---|
739 | $page['infos'], |
---|
740 | l10n_dec( |
---|
741 | '%d_Validated_User', '%d_Validated_Users', |
---|
742 | count($collection) |
---|
743 | ) |
---|
744 | ); |
---|
745 | |
---|
746 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
747 | } |
---|
748 | } |
---|
749 | |
---|
750 | // +-----------------------------------------------------------------------+ |
---|
751 | // | groups list | |
---|
752 | // +-----------------------------------------------------------------------+ |
---|
753 | |
---|
754 | $groups[-1] = '------------'; |
---|
755 | |
---|
756 | $query = ' |
---|
757 | SELECT id, name |
---|
758 | FROM '.GROUPS_TABLE.' |
---|
759 | ORDER BY name ASC |
---|
760 | ;'; |
---|
761 | |
---|
762 | $result = pwg_query($query); |
---|
763 | |
---|
764 | while ($row = mysql_fetch_array($result)) |
---|
765 | { |
---|
766 | $groups[$row['id']] = $row['name']; |
---|
767 | } |
---|
768 | |
---|
769 | // +-----------------------------------------------------------------------+ |
---|
770 | // | Template Init | |
---|
771 | // +-----------------------------------------------------------------------+ |
---|
772 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
773 | |
---|
774 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
775 | { |
---|
776 | $start = $_GET['start']; |
---|
777 | } |
---|
778 | else |
---|
779 | { |
---|
780 | $start = 0; |
---|
781 | } |
---|
782 | |
---|
783 | $template->assign( |
---|
784 | array( |
---|
785 | 'F_ADD_ACTION' => $base_url, |
---|
786 | 'F_USERNAME' => @htmlentities($_GET['username']), |
---|
787 | 'F_FILTER_ACTION' => get_root_url().'admin.php' |
---|
788 | ) |
---|
789 | ); |
---|
790 | |
---|
791 | /* Hide radio-button if not allow to assign adviser */ |
---|
792 | if ($conf['allow_adviser']) |
---|
793 | { |
---|
794 | $template->assign('adviser', true); |
---|
795 | } |
---|
796 | |
---|
797 | // +-----------------------------------------------------------------------+ |
---|
798 | // | user list | |
---|
799 | // +-----------------------------------------------------------------------+ |
---|
800 | |
---|
801 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
802 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
803 | |
---|
804 | $visible_user_list = array(); |
---|
805 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
806 | { |
---|
807 | /* simulate LIMIT $start, $conf['users_page'] */ |
---|
808 | if ($num < $start) |
---|
809 | { |
---|
810 | continue; |
---|
811 | } |
---|
812 | if ($num >= $start + $conf['users_page']) |
---|
813 | { |
---|
814 | break; |
---|
815 | } |
---|
816 | |
---|
817 | $visible_user_list[] = $local_user; |
---|
818 | } |
---|
819 | |
---|
820 | foreach ($visible_user_list as $local_user) |
---|
821 | { |
---|
822 | $groups_string = preg_replace( |
---|
823 | '/(\d+)/e', |
---|
824 | "\$groups['$1']", |
---|
825 | implode( |
---|
826 | ', ', |
---|
827 | $local_user['groups'] |
---|
828 | ) |
---|
829 | ); |
---|
830 | |
---|
831 | if (isset($_POST['pref_submit']) |
---|
832 | and isset($_POST['selection']) |
---|
833 | and in_array($local_user['id'], $_POST['selection'])) |
---|
834 | { |
---|
835 | $checked = 'checked="checked"'; |
---|
836 | } |
---|
837 | else |
---|
838 | { |
---|
839 | $checked = ''; |
---|
840 | } |
---|
841 | |
---|
842 | $properties = array(); |
---|
843 | if ( $local_user['level'] != 0 ) |
---|
844 | { |
---|
845 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
846 | } |
---|
847 | $properties[] = |
---|
848 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
849 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
850 | |
---|
851 | if (isset($conf_nbc_UserAdvManager_ConfirmMail[1]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ) |
---|
852 | { |
---|
853 | $template->append( |
---|
854 | 'users', |
---|
855 | array( |
---|
856 | 'ID' => $local_user['id'], |
---|
857 | 'CHECKED' => $checked, |
---|
858 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
859 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
860 | 'USERNAME' => $local_user['username'] |
---|
861 | .($local_user['id'] == $conf['guest_id'] |
---|
862 | ? '<BR />['.l10n('is_the_guest').']' : '') |
---|
863 | .($local_user['id'] == $conf['default_user_id'] |
---|
864 | ? '<BR />['.l10n('is_the_default').']' : ''), |
---|
865 | 'STATUS' => l10n('user_status_'. |
---|
866 | $local_user['status']).(($local_user['adviser'] == 'true') |
---|
867 | ? '<BR />['.l10n('adviser').']' : ''), |
---|
868 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
869 | 'GROUPS' => $groups_string, |
---|
870 | 'REGISTRATION' => $local_user['registration_date'], |
---|
871 | ) |
---|
872 | ); |
---|
873 | } |
---|
874 | } |
---|
875 | |
---|
876 | // +-----------------------------------------------------------------------+ |
---|
877 | // | errors display | |
---|
878 | // +-----------------------------------------------------------------------+ |
---|
879 | if ( isset ($errors) and count($errors) != 0) |
---|
880 | { |
---|
881 | $template->assign('errors',array()); |
---|
882 | foreach ($errors as $error) |
---|
883 | { |
---|
884 | array_push($page['errors'], $error); |
---|
885 | } |
---|
886 | } |
---|
887 | |
---|
888 | // +-----------------------------------------------------------------------+ |
---|
889 | // | templates display | |
---|
890 | // +-----------------------------------------------------------------------+ |
---|
891 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/usermanager.tpl'); |
---|
892 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
893 | } |
---|
894 | else |
---|
895 | { |
---|
896 | array_push($page['infos'], l10n('Err_UserManager_Settings')); |
---|
897 | } |
---|
898 | break; |
---|
899 | } |
---|
900 | ?> |
---|