[3444] | 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 | } |
---|
| 147 | /* Get status values */ |
---|
| 148 | foreach (get_enums(USER_INFOS_TABLE, 'status') as $status) |
---|
| 149 | { |
---|
| 150 | $status_options[$status] = l10n('user_status_'.$status); |
---|
| 151 | if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status) |
---|
| 152 | { |
---|
| 153 | $Valid_Status = $status; |
---|
| 154 | } |
---|
| 155 | /* Template initialization for unvalidated users group */ |
---|
| 156 | $template->assign( |
---|
| 157 | 'Confirm_Status', |
---|
| 158 | array( |
---|
| 159 | 'Status_options' => $status_options, |
---|
| 160 | 'Status_selected' => $Valid_Status |
---|
| 161 | ) |
---|
| 162 | ); |
---|
| 163 | |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | $template->assign( |
---|
| 168 | array( |
---|
| 169 | 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , |
---|
| 170 | 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , |
---|
| 171 | 'UserAdvManager_MAILINFO_TEXT' => $conf_nbc_UserAdvManager[10], |
---|
| 172 | 'UserAdvManager_NO_CASSE_TRUE' => $conf_nbc_UserAdvManager[1]=='true' ? 'checked="checked"' : '' , |
---|
| 173 | 'UserAdvManager_NO_CASSE_FALSE' => $conf_nbc_UserAdvManager[1]=='false' ? 'checked="checked"' : '' , |
---|
| 174 | 'UserAdvManager_USERNAME_CHAR_TRUE' => $conf_nbc_UserAdvManager[7]=='true' ? 'checked="checked"' : '' , |
---|
| 175 | 'UserAdvManager_USERNAME_CHAR_FALSE' => $conf_nbc_UserAdvManager[7]=='false' ? 'checked="checked"' : '' , |
---|
| 176 | 'UserAdvManager_USERNAME_CHAR_LIST' => $conf_nbc_UserAdvManager[8], |
---|
| 177 | 'UserAdvManager_CONFIRM_MAIL_TRUE' => $conf_nbc_UserAdvManager[2]=='true' ? 'checked="checked"' : '' , |
---|
| 178 | 'UserAdvManager_CONFIRM_MAIL_FALSE' => $conf_nbc_UserAdvManager[2]=='false' ? 'checked="checked"' : '' , |
---|
| 179 | 'UserAdvManager_CONFIRMMAIL_TEXT' => $conf_nbc_UserAdvManager[11], |
---|
| 180 | 'UserAdvManager_No_Confirm_Group' => $conf_nbc_UserAdvManager[3], |
---|
| 181 | 'UserAdvManager_Validated_Group' => $conf_nbc_UserAdvManager[4], |
---|
| 182 | 'UserAdvManager_No_Confirm_Status' => $conf_nbc_UserAdvManager[9], |
---|
| 183 | 'UserAdvManager_Validated_Status' => $conf_nbc_UserAdvManager[5], |
---|
| 184 | 'UserAdvManager_NO_COMMENT_ANO_TRUE' => $conf_nbc_UserAdvManager[6]=='true' ? 'checked="checked"' : '' , |
---|
| 185 | 'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ? 'checked="checked"' : '' , |
---|
| 186 | 'UserAdvManager_MAILEXCLUSION_TRUE' => $conf_nbc_UserAdvManager[12]=='true' ? 'checked="checked"' : '' , |
---|
| 187 | 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , |
---|
| 188 | 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], |
---|
| 189 | ) |
---|
| 190 | ); |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | if ( isset($_POST['audit']) or isset($_POST['submit']) ) |
---|
| 194 | { |
---|
| 195 | $msg_error1 = ''; |
---|
| 196 | |
---|
| 197 | /* username insensible a la casse */ |
---|
| 198 | if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true') |
---|
| 199 | { |
---|
| 200 | $query = " |
---|
| 201 | SELECT ".$conf['user_fields']['username']." |
---|
| 202 | FROM ".USERS_TABLE." p1 |
---|
| 203 | WHERE EXISTS( |
---|
| 204 | SELECT ".$conf['user_fields']['username']." |
---|
| 205 | FROM ".USERS_TABLE." p2 |
---|
| 206 | WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']." |
---|
| 207 | AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].") |
---|
| 208 | ) |
---|
| 209 | ;"; |
---|
| 210 | |
---|
| 211 | $result = pwg_query($query); |
---|
| 212 | |
---|
| 213 | while($row = mysql_fetch_array($result)) |
---|
| 214 | { |
---|
| 215 | $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; |
---|
| 216 | } |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | $msg_error2 = ''; |
---|
| 221 | |
---|
| 222 | /* Username without forbidden keys */ |
---|
| 223 | if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' ) |
---|
| 224 | { |
---|
| 225 | $query = " |
---|
| 226 | SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']." |
---|
| 227 | FROM ".USERS_TABLE." |
---|
| 228 | ;"; |
---|
| 229 | |
---|
| 230 | $result = pwg_query($query); |
---|
| 231 | |
---|
| 232 | while($row = mysql_fetch_array($result)) |
---|
| 233 | { |
---|
| 234 | if ( !ValidateUsername($row['username']) ) |
---|
| 235 | $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username']; |
---|
| 236 | } |
---|
| 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 = split (",",$conf_nbc_UserAdvManager[13]); |
---|
| 256 | for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) |
---|
| 257 | { |
---|
| 258 | if (ereg($conf_nbc_MailExclusion[$i], $row['mail_address'])) |
---|
| 259 | { |
---|
| 260 | $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | if ($msg_error1 <> '') |
---|
| 267 | $errors[] = $msg_error1.'<br/><br/>'; |
---|
| 268 | |
---|
| 269 | if ($msg_error2 <> '') |
---|
| 270 | $errors[] = $msg_error2.'<br/><br/>'; |
---|
| 271 | |
---|
| 272 | if ($msg_error3 <> '') |
---|
| 273 | $errors[] = $msg_error3.'<br/><br/>'; |
---|
| 274 | |
---|
| 275 | if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') |
---|
| 276 | array_push($page['errors'], l10n('Err_audit_advise')); |
---|
| 277 | else |
---|
| 278 | array_push($page['infos'], l10n('UserAdvManager_audit_ok')); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | |
---|
| 282 | // +-----------------------------------------------------------------------+ |
---|
| 283 | // | errors display | |
---|
| 284 | // +-----------------------------------------------------------------------+ |
---|
| 285 | if ( isset ($errors) and count($errors) != 0) |
---|
| 286 | { |
---|
| 287 | $template->assign('errors',array()); |
---|
| 288 | foreach ($errors as $error) |
---|
| 289 | { |
---|
| 290 | array_push($page['errors'], $error); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | // +-----------------------------------------------------------------------+ |
---|
| 295 | // | templates display | |
---|
| 296 | // +-----------------------------------------------------------------------+ |
---|
| 297 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); |
---|
| 298 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 299 | |
---|
| 300 | break; |
---|
| 301 | |
---|
| 302 | // +-----------------------------------------------------------------------+ |
---|
[3460] | 303 | // | ConfirmMail Config | |
---|
[3444] | 304 | // +-----------------------------------------------------------------------+ |
---|
| 305 | case 'confirmmail': |
---|
| 306 | |
---|
| 307 | $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); |
---|
| 308 | |
---|
| 309 | if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' ) |
---|
| 310 | { |
---|
| 311 | if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) ) |
---|
| 312 | { |
---|
| 313 | $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay']; |
---|
| 314 | |
---|
| 315 | $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; |
---|
| 316 | |
---|
| 317 | $query = ' |
---|
| 318 | UPDATE '.CONFIG_TABLE.' |
---|
| 319 | SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" |
---|
| 320 | WHERE param="nbc_UserAdvManager_ConfirmMail" |
---|
| 321 | LIMIT 1 |
---|
| 322 | ;'; |
---|
| 323 | |
---|
| 324 | pwg_query($query); |
---|
| 325 | |
---|
| 326 | array_push($page['infos'], l10n('UserAdvManager_save_config')); |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
| 330 | |
---|
| 331 | function get_unvalid_user_list() |
---|
| 332 | { |
---|
[3460] | 333 | global $conf, $page; |
---|
| 334 | |
---|
| 335 | $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); |
---|
| 336 | |
---|
| 337 | $users = array(); |
---|
[3444] | 338 | |
---|
[3460] | 339 | // search users depending on filters and order |
---|
[3444] | 340 | $query = ' |
---|
[3460] | 341 | SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, |
---|
[3444] | 342 | u.'.$conf['user_fields']['username'].' AS username, |
---|
| 343 | u.'.$conf['user_fields']['email'].' AS email, |
---|
| 344 | ui.status, |
---|
| 345 | ui.adviser, |
---|
| 346 | ui.enabled_high, |
---|
[3460] | 347 | ui.level, |
---|
| 348 | ui.registration_date |
---|
| 349 | FROM '.USERS_TABLE.' AS u |
---|
| 350 | INNER JOIN '.USER_INFOS_TABLE.' AS ui |
---|
| 351 | ON u.'.$conf['user_fields']['id'].' = ui.user_id |
---|
| 352 | LEFT JOIN '.USER_GROUP_TABLE.' AS ug |
---|
| 353 | ON u.'.$conf['user_fields']['id'].' = ug.user_id |
---|
| 354 | WHERE u.'.$conf['user_fields']['id'].' > 0 |
---|
| 355 | AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) <= '.$conf_nbc_UserAdvManager_ConfirmMail[1].' |
---|
| 356 | ORDER BY id ASC |
---|
| 357 | ;'; |
---|
| 358 | |
---|
[3444] | 359 | $result = pwg_query($query); |
---|
| 360 | while ($row = mysql_fetch_array($result)) |
---|
| 361 | { |
---|
[3460] | 362 | $user = $row; |
---|
| 363 | $user['groups'] = array(); |
---|
| 364 | |
---|
[3444] | 365 | array_push($users, $user); |
---|
| 366 | } |
---|
[3460] | 367 | |
---|
[3444] | 368 | // add group lists |
---|
| 369 | $user_ids = array(); |
---|
| 370 | foreach ($users as $i => $user) |
---|
| 371 | { |
---|
| 372 | $user_ids[$i] = $user['id']; |
---|
| 373 | } |
---|
| 374 | $user_nums = array_flip($user_ids); |
---|
| 375 | |
---|
| 376 | if (count($user_ids) > 0) |
---|
| 377 | { |
---|
| 378 | $query = ' |
---|
[3460] | 379 | SELECT user_id, group_id |
---|
| 380 | FROM '.USER_GROUP_TABLE.' |
---|
| 381 | WHERE user_id IN ('.implode(',', $user_ids).') |
---|
| 382 | ;'; |
---|
| 383 | $result = pwg_query($query); |
---|
[3444] | 384 | while ($row = mysql_fetch_array($result)) |
---|
| 385 | { |
---|
| 386 | array_push( |
---|
| 387 | $users[$user_nums[$row['user_id']]]['groups'], |
---|
| 388 | $row['group_id'] |
---|
| 389 | ); |
---|
| 390 | } |
---|
| 391 | } |
---|
| 392 | |
---|
[3460] | 393 | return $users; |
---|
[3444] | 394 | } |
---|
| 395 | |
---|
| 396 | // +-----------------------------------------------------------------------+ |
---|
| 397 | // | initialization | |
---|
| 398 | // +-----------------------------------------------------------------------+ |
---|
| 399 | |
---|
| 400 | if (!defined('PHPWG_ROOT_PATH')) |
---|
| 401 | { |
---|
| 402 | die('Hacking attempt!'); |
---|
| 403 | } |
---|
[3460] | 404 | |
---|
[3444] | 405 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
| 406 | |
---|
[3460] | 407 | // +-----------------------------------------------------------------------+ |
---|
| 408 | // | Check Access and exit when user status is not ok | |
---|
| 409 | // +-----------------------------------------------------------------------+ |
---|
| 410 | check_status(ACCESS_ADMINISTRATOR); |
---|
[3444] | 411 | |
---|
[3460] | 412 | $page['order_by_items'] = array( |
---|
| 413 | 'id' => l10n('registration_date'), |
---|
| 414 | 'username' => l10n('Username'), |
---|
| 415 | 'level' => l10n('Privacy level'), |
---|
| 416 | 'language' => l10n('language'), |
---|
| 417 | ); |
---|
[3444] | 418 | |
---|
| 419 | // +-----------------------------------------------------------------------+ |
---|
[3460] | 420 | // | user list | |
---|
| 421 | // +-----------------------------------------------------------------------+ |
---|
| 422 | |
---|
| 423 | $page['filtered_users'] = get_unvalid_user_list(); |
---|
| 424 | |
---|
| 425 | // +-----------------------------------------------------------------------+ |
---|
| 426 | // | selected users | |
---|
| 427 | // +-----------------------------------------------------------------------+ |
---|
| 428 | |
---|
| 429 | if (isset($_POST['delete'])) |
---|
| 430 | { |
---|
| 431 | $collection = array(); |
---|
| 432 | |
---|
| 433 | switch ($_POST['target']) |
---|
| 434 | { |
---|
| 435 | case 'all' : |
---|
| 436 | { |
---|
| 437 | foreach($page['filtered_users'] as $local_user) |
---|
| 438 | { |
---|
| 439 | array_push($collection, $local_user['id']); |
---|
| 440 | } |
---|
| 441 | break; |
---|
| 442 | } |
---|
| 443 | case 'selection' : |
---|
| 444 | { |
---|
| 445 | if (isset($_POST['selection'])) |
---|
| 446 | { |
---|
| 447 | $collection = $_POST['selection']; |
---|
| 448 | } |
---|
| 449 | break; |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | if (count($collection) == 0) |
---|
| 454 | { |
---|
| 455 | array_push($page['errors'], l10n('Select at least one user')); |
---|
| 456 | } |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | // +-----------------------------------------------------------------------+ |
---|
| 460 | // | delete users | |
---|
| 461 | // +-----------------------------------------------------------------------+ |
---|
| 462 | if (isset($_POST['delete']) and count($collection) > 0) |
---|
| 463 | { |
---|
| 464 | if (in_array($conf['guest_id'], $collection)) |
---|
| 465 | { |
---|
| 466 | array_push($page['errors'], l10n('Guest cannot be deleted')); |
---|
| 467 | } |
---|
| 468 | if (($conf['guest_id'] != $conf['default_user_id']) and |
---|
| 469 | in_array($conf['default_user_id'], $collection)) |
---|
| 470 | { |
---|
| 471 | array_push($page['errors'], l10n('Default user cannot be deleted')); |
---|
| 472 | } |
---|
| 473 | if (in_array($conf['webmaster_id'], $collection)) |
---|
| 474 | { |
---|
| 475 | array_push($page['errors'], l10n('Webmaster cannot be deleted')); |
---|
| 476 | } |
---|
| 477 | if (in_array($user['id'], $collection)) |
---|
| 478 | { |
---|
| 479 | array_push($page['errors'], l10n('You cannot delete your account')); |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | if (count($page['errors']) == 0) |
---|
| 483 | { |
---|
| 484 | if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion']) |
---|
| 485 | { |
---|
| 486 | foreach ($collection as $user_id) |
---|
| 487 | { |
---|
| 488 | delete_user($user_id); |
---|
| 489 | } |
---|
| 490 | array_push( |
---|
| 491 | $page['infos'], |
---|
| 492 | l10n_dec( |
---|
| 493 | '%d user deleted', '%d users deleted', |
---|
| 494 | count($collection) |
---|
| 495 | ) |
---|
| 496 | ); |
---|
| 497 | foreach ($page['filtered_users'] as $filter_key => $filter_user) |
---|
| 498 | { |
---|
| 499 | if (in_array($filter_user['id'], $collection)) |
---|
| 500 | { |
---|
| 501 | unset($page['filtered_users'][$filter_key]); |
---|
| 502 | } |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | else |
---|
| 506 | { |
---|
| 507 | array_push($page['errors'], l10n('You need to confirm deletion')); |
---|
| 508 | } |
---|
| 509 | } |
---|
| 510 | } |
---|
| 511 | |
---|
| 512 | // +-----------------------------------------------------------------------+ |
---|
| 513 | // | groups list | |
---|
| 514 | // +-----------------------------------------------------------------------+ |
---|
| 515 | |
---|
| 516 | $groups[-1] = '------------'; |
---|
| 517 | |
---|
| 518 | $query = ' |
---|
| 519 | SELECT id, name |
---|
| 520 | FROM '.GROUPS_TABLE.' |
---|
| 521 | ORDER BY name ASC |
---|
| 522 | ;'; |
---|
| 523 | $result = pwg_query($query); |
---|
| 524 | |
---|
| 525 | while ($row = mysql_fetch_array($result)) |
---|
| 526 | { |
---|
| 527 | $groups[$row['id']] = $row['name']; |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | // +-----------------------------------------------------------------------+ |
---|
[3444] | 531 | // | Template Init | |
---|
| 532 | // +-----------------------------------------------------------------------+ |
---|
[3460] | 533 | $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; |
---|
| 534 | |
---|
| 535 | if (isset($_GET['start']) and is_numeric($_GET['start'])) |
---|
| 536 | { |
---|
| 537 | $start = $_GET['start']; |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | $start = 0; |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | $template->assign( |
---|
| 545 | array( |
---|
| 546 | 'F_ADD_ACTION' => $base_url, |
---|
| 547 | 'F_USERNAME' => @htmlentities($_GET['username']), |
---|
| 548 | 'F_FILTER_ACTION' => get_root_url().'admin.php' |
---|
| 549 | )); |
---|
| 550 | |
---|
| 551 | // Hide radio-button if not allow to assign adviser |
---|
| 552 | if ($conf['allow_adviser']) |
---|
| 553 | { |
---|
| 554 | $template->assign('adviser', true); |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | |
---|
| 558 | // +-----------------------------------------------------------------------+ |
---|
| 559 | // | user list | |
---|
| 560 | // +-----------------------------------------------------------------------+ |
---|
| 561 | |
---|
| 562 | $profile_url = get_root_url().'admin.php?page=profile&user_id='; |
---|
| 563 | $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; |
---|
| 564 | |
---|
| 565 | $visible_user_list = array(); |
---|
| 566 | foreach ($page['filtered_users'] as $num => $local_user) |
---|
| 567 | { |
---|
| 568 | // simulate LIMIT $start, $conf['users_page'] |
---|
| 569 | if ($num < $start) |
---|
| 570 | { |
---|
| 571 | continue; |
---|
| 572 | } |
---|
| 573 | if ($num >= $start + $conf['users_page']) |
---|
| 574 | { |
---|
| 575 | break; |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | $visible_user_list[] = $local_user; |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | foreach ($visible_user_list as $local_user) |
---|
| 582 | { |
---|
| 583 | $groups_string = preg_replace( |
---|
| 584 | '/(\d+)/e', |
---|
| 585 | "\$groups['$1']", |
---|
| 586 | implode( |
---|
| 587 | ', ', |
---|
| 588 | $local_user['groups'] |
---|
| 589 | ) |
---|
| 590 | ); |
---|
| 591 | |
---|
| 592 | if (isset($_POST['pref_submit']) |
---|
| 593 | and isset($_POST['selection']) |
---|
| 594 | and in_array($local_user['id'], $_POST['selection'])) |
---|
| 595 | { |
---|
| 596 | $checked = 'checked="checked"'; |
---|
| 597 | } |
---|
| 598 | else |
---|
| 599 | { |
---|
| 600 | $checked = ''; |
---|
| 601 | } |
---|
| 602 | |
---|
| 603 | $properties = array(); |
---|
| 604 | if ( $local_user['level'] != 0 ) |
---|
| 605 | { |
---|
| 606 | $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); |
---|
| 607 | } |
---|
| 608 | $properties[] = |
---|
| 609 | (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) |
---|
| 610 | ? l10n('is_high_enabled') : l10n('is_high_disabled'); |
---|
| 611 | |
---|
| 612 | $template->append( |
---|
| 613 | 'users', |
---|
| 614 | array( |
---|
| 615 | 'ID' => $local_user['id'], |
---|
| 616 | 'CHECKED' => $checked, |
---|
| 617 | 'U_PROFILE' => $profile_url.$local_user['id'], |
---|
| 618 | 'U_PERM' => $perm_url.$local_user['id'], |
---|
| 619 | 'USERNAME' => $local_user['username'] |
---|
| 620 | .($local_user['id'] == $conf['guest_id'] |
---|
| 621 | ? '<BR />['.l10n('is_the_guest').']' : '') |
---|
| 622 | .($local_user['id'] == $conf['default_user_id'] |
---|
| 623 | ? '<BR />['.l10n('is_the_default').']' : ''), |
---|
| 624 | 'STATUS' => l10n('user_status_'. |
---|
| 625 | $local_user['status']).(($local_user['adviser'] == 'true') |
---|
| 626 | ? '<BR />['.l10n('adviser').']' : ''), |
---|
| 627 | 'EMAIL' => get_email_address_as_display_text($local_user['email']), |
---|
| 628 | 'GROUPS' => $groups_string, |
---|
| 629 | 'ACTION' => implode( ', ', $properties), |
---|
| 630 | ) |
---|
| 631 | ); |
---|
| 632 | } |
---|
| 633 | |
---|
[3444] | 634 | $template->assign( |
---|
| 635 | array( |
---|
| 636 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , |
---|
| 637 | 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , |
---|
| 638 | 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], |
---|
| 639 | ) |
---|
[3460] | 640 | ); |
---|
[3444] | 641 | |
---|
| 642 | // +-----------------------------------------------------------------------+ |
---|
| 643 | // | errors display | |
---|
| 644 | // +-----------------------------------------------------------------------+ |
---|
| 645 | if ( isset ($errors) and count($errors) != 0) |
---|
| 646 | { |
---|
| 647 | $template->assign('errors',array()); |
---|
| 648 | foreach ($errors as $error) |
---|
| 649 | { |
---|
| 650 | array_push($page['errors'], $error); |
---|
| 651 | } |
---|
| 652 | } |
---|
| 653 | |
---|
| 654 | // +-----------------------------------------------------------------------+ |
---|
| 655 | // | templates display | |
---|
| 656 | // +-----------------------------------------------------------------------+ |
---|
| 657 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl'); |
---|
| 658 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 659 | } |
---|
| 660 | else |
---|
| 661 | { |
---|
| 662 | array_push($page['infos'], l10n('Err_ConfirmMail_Settings')); |
---|
| 663 | |
---|
| 664 | } |
---|
| 665 | break; |
---|
| 666 | |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | ?> |
---|