Changeset 3470
- Timestamp:
- Jun 27, 2009, 12:00:31 AM (15 years ago)
- Location:
- extensions/NBC_UserAdvManager-Trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager-Trunk/admin/UserAdvManager_admin.php
r3460 r3470 22 22 // +-----------------------------------------------------------------------+ 23 23 if (!isset($_GET['tab'])) 24 24 $page['tab'] = 'global'; 25 25 else 26 26 $page['tab'] = $_GET['tab']; 27 27 28 28 $tabsheet = new tabsheet(); … … 51 51 // | Global Config | 52 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']) ) 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']) 56 102 { 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')); 103 $Valid = $row['id']; 74 104 } 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']; 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; 99 153 } 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 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 113 160 ) 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( 161 ); 162 } 163 164 $template->assign( 165 array( 169 166 'UserAdvManager_MAIL_INFO_TRUE' => $conf_nbc_UserAdvManager[0]=='true' ? 'checked="checked"' : '' , 170 167 'UserAdvManager_MAIL_INFO_FALSE' => $conf_nbc_UserAdvManager[0]=='false' ? 'checked="checked"' : '' , … … 187 184 'UserAdvManager_MAILEXCLUSION_FALSE' => $conf_nbc_UserAdvManager[12]=='false' ? 'checked="checked"' : '' , 188 185 'UserAdvManager_MAILEXCLUSION_LIST' => $conf_nbc_UserAdvManager[13], 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 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 ;"; 210 207 211 208 $result = pwg_query($query); 212 209 213 214 215 210 while($row = mysql_fetch_array($result)) 211 { 212 $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username']; 216 213 } 217 214 } 218 215 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 ;"; 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 ;"; 229 225 230 226 $result = pwg_query($query); 231 227 232 233 234 235 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']; 236 232 } 237 233 } 238 234 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 ;"; 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 ;"; 249 244 250 245 $result = pwg_query($query); 251 246 252 253 254 255 256 257 258 259 260 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 = split (",",$conf_nbc_UserAdvManager[13]); 251 for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 252 { 253 if (ereg($conf_nbc_MailExclusion[$i], $row['mail_address'])) 254 { 255 $msg_error3 .= (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')'; 261 256 } 262 257 } … … 264 259 } 265 260 266 267 268 269 270 271 272 273 274 275 276 277 278 279 261 if ($msg_error1 <> '') 262 $errors[] = $msg_error1.'<br/><br/>'; 263 264 if ($msg_error2 <> '') 265 $errors[] = $msg_error2.'<br/><br/>'; 266 267 if ($msg_error3 <> '') 268 $errors[] = $msg_error3.'<br/><br/>'; 269 270 if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '') 271 array_push($page['errors'], l10n('Err_audit_advise')); 272 else 273 array_push($page['infos'], l10n('UserAdvManager_audit_ok')); 274 } 280 275 281 276 … … 283 278 // | errors display | 284 279 // +-----------------------------------------------------------------------+ 285 286 287 288 289 290 280 if ( isset ($errors) and count($errors) != 0) 281 { 282 $template->assign('errors',array()); 283 foreach ($errors as $error) 284 { 285 array_push($page['errors'], $error); 291 286 } 292 287 } … … 295 290 // | templates display | 296 291 // +-----------------------------------------------------------------------+ 297 298 299 300 292 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl'); 293 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 294 295 break; 301 296 302 297 // +-----------------------------------------------------------------------+ 303 298 // | ConfirmMail Config | 304 299 // +-----------------------------------------------------------------------+ 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')); 300 case 'confirmmail': 301 302 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 303 304 if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' ) 305 { 306 if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) ) 307 { 308 $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay']; 309 //TODO:Adding new option [Auto deletion : True | False] 310 //TODO:Adding new option [Resend_new_validation_key : True | False] 311 $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail; 312 313 $query = ' 314 UPDATE '.CONFIG_TABLE.' 315 SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'" 316 WHERE param="nbc_UserAdvManager_ConfirmMail" 317 LIMIT 1 318 ;'; 319 320 pwg_query($query); 321 322 array_push($page['infos'], l10n('UserAdvManager_save_config')); 327 323 } 328 324 329 330 331 function get_unvalid_user_list()332 {333 global $conf, $page;325 $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 326 327 function get_unvalid_user_list() 328 { 329 global $conf, $page; 334 330 335 $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();331 $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 336 332 337 $users = array(); 338 339 // search users depending on filters and order 340 $query = ' 341 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 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, 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 359 $result = pwg_query($query); 360 while ($row = mysql_fetch_array($result)) 361 { 362 $user = $row; 363 $user['groups'] = array(); 364 365 array_push($users, $user); 366 } 367 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 = ' 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); 384 while ($row = mysql_fetch_array($result)) 333 $users = array(); 334 335 /* search users depending on filters and order */ 336 //TODO:Adding condition in request [if user in USER_CONFIRM_MAIL_TABLE] 337 $query = ' 338 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 339 u.'.$conf['user_fields']['username'].' AS username, 340 u.'.$conf['user_fields']['email'].' AS email, 341 ui.status, 342 ui.adviser, 343 ui.enabled_high, 344 ui.level, 345 ui.registration_date 346 FROM '.USERS_TABLE.' AS u 347 INNER JOIN '.USER_INFOS_TABLE.' AS ui 348 ON u.'.$conf['user_fields']['id'].' = ui.user_id 349 LEFT JOIN '.USER_GROUP_TABLE.' AS ug 350 ON u.'.$conf['user_fields']['id'].' = ug.user_id 351 WHERE u.'.$conf['user_fields']['id'].' > 0 352 AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= '.$conf_nbc_UserAdvManager_ConfirmMail[1].' 353 ORDER BY id ASC 354 ;'; 355 356 $result = pwg_query($query); 357 358 while ($row = mysql_fetch_array($result)) 359 { 360 $user = $row; 361 $user['groups'] = array(); 362 363 array_push($users, $user); 364 } 365 366 /* add group lists */ 367 $user_ids = array(); 368 foreach ($users as $i => $user) 369 { 370 $user_ids[$i] = $user['id']; 371 } 372 $user_nums = array_flip($user_ids); 373 374 if (count($user_ids) > 0) 375 { 376 $query = ' 377 SELECT user_id, group_id 378 FROM '.USER_GROUP_TABLE.' 379 WHERE user_id IN ('.implode(',', $user_ids).') 380 ;'; 381 382 $result = pwg_query($query); 383 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 393 return $users; 394 } 395 396 // +-----------------------------------------------------------------------+ 397 // | initialization | 398 // +-----------------------------------------------------------------------+ 399 400 if (!defined('PHPWG_ROOT_PATH')) 401 { 402 die('Hacking attempt!'); 403 } 404 405 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 406 407 // +-----------------------------------------------------------------------+ 408 // | Check Access and exit when user status is not ok | 409 // +-----------------------------------------------------------------------+ 410 check_status(ACCESS_ADMINISTRATOR); 411 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 ); 418 419 // +-----------------------------------------------------------------------+ 420 // | user list | 421 // +-----------------------------------------------------------------------+ 422 423 $page['filtered_users'] = get_unvalid_user_list(); 424 425 // +-----------------------------------------------------------------------+ 426 // | selected users | 427 // +-----------------------------------------------------------------------+ 428 //TODO:Link deletion to all users selected or single user 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 498 foreach ($page['filtered_users'] as $filter_key => $filter_user) 499 { 500 if (in_array($filter_user['id'], $collection)) 501 { 502 unset($page['filtered_users'][$filter_key]); 503 } 504 } 505 } 506 else 507 { 508 array_push($page['errors'], l10n('You need to confirm deletion')); 509 } 510 } 511 } 512 // +-----------------------------------------------------------------------+ 513 // | Resend new validation key to users | 514 // +-----------------------------------------------------------------------+ 515 516 //TODO:Function to send a new validation key to all | single | selected users 517 518 // +-----------------------------------------------------------------------+ 519 // | groups list | 520 // +-----------------------------------------------------------------------+ 521 522 $groups[-1] = '------------'; 523 524 $query = ' 525 SELECT id, name 526 FROM '.GROUPS_TABLE.' 527 ORDER BY name ASC 528 ;'; 529 530 $result = pwg_query($query); 531 532 while ($row = mysql_fetch_array($result)) 533 { 534 $groups[$row['id']] = $row['name']; 535 } 536 537 // +-----------------------------------------------------------------------+ 538 // | Template Init | 539 // +-----------------------------------------------------------------------+ 540 $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list'; 541 542 if (isset($_GET['start']) and is_numeric($_GET['start'])) 543 { 544 $start = $_GET['start']; 545 } 546 else 547 { 548 $start = 0; 549 } 550 551 $template->assign( 552 array( 553 'F_ADD_ACTION' => $base_url, 554 'F_USERNAME' => @htmlentities($_GET['username']), 555 'F_FILTER_ACTION' => get_root_url().'admin.php' 556 ) 557 ); 558 559 /* Hide radio-button if not allow to assign adviser */ 560 if ($conf['allow_adviser']) 561 { 562 $template->assign('adviser', true); 563 } 564 565 // +-----------------------------------------------------------------------+ 566 // | user list | 567 // +-----------------------------------------------------------------------+ 568 569 $profile_url = get_root_url().'admin.php?page=profile&user_id='; 570 $perm_url = get_root_url().'admin.php?page=user_perm&user_id='; 571 572 $visible_user_list = array(); 573 foreach ($page['filtered_users'] as $num => $local_user) 574 { 575 /* simulate LIMIT $start, $conf['users_page'] */ 576 if ($num < $start) 577 { 578 continue; 579 } 580 if ($num >= $start + $conf['users_page']) 581 { 582 break; 583 } 584 585 $visible_user_list[] = $local_user; 586 } 587 588 foreach ($visible_user_list as $local_user) 589 { 590 $groups_string = preg_replace( 591 '/(\d+)/e', 592 "\$groups['$1']", 593 implode( 594 ', ', 595 $local_user['groups'] 596 ) 597 ); 598 599 if (isset($_POST['pref_submit']) 600 and isset($_POST['selection']) 601 and in_array($local_user['id'], $_POST['selection'])) 602 { 603 $checked = 'checked="checked"'; 604 } 605 else 606 { 607 $checked = ''; 608 } 609 610 $properties = array(); 611 if ( $local_user['level'] != 0 ) 612 { 613 $properties[] = l10n( sprintf('Level %d', $local_user['level']) ); 614 } 615 $properties[] = 616 (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true')) 617 ? l10n('is_high_enabled') : l10n('is_high_disabled'); 618 619 if (isset($conf_nbc_UserAdvManager_ConfirmMail[1]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ) 620 { 621 $template->append( 622 'users', 623 array( 624 'ID' => $local_user['id'], 625 'CHECKED' => $checked, 626 'U_PROFILE' => $profile_url.$local_user['id'], 627 'U_PERM' => $perm_url.$local_user['id'], 628 'USERNAME' => $local_user['username'] 629 .($local_user['id'] == $conf['guest_id'] 630 ? '<BR />['.l10n('is_the_guest').']' : '') 631 .($local_user['id'] == $conf['default_user_id'] 632 ? '<BR />['.l10n('is_the_default').']' : ''), 633 'STATUS' => l10n('user_status_'. 634 $local_user['status']).(($local_user['adviser'] == 'true') 635 ? '<BR />['.l10n('adviser').']' : ''), 636 'EMAIL' => get_email_address_as_display_text($local_user['email']), 637 'GROUPS' => $groups_string, 638 //TODO:Changing ACTION from $properties to Single_Deletion 639 //TODO:Addin new ACTION to Resend new validation key 640 'ACTION' => implode( ', ', $properties), 641 ) 642 ); 643 } 644 } 645 646 $template->assign( 647 array( 648 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ? 'checked="checked"' : '' , 649 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE' => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ? 'checked="checked"' : '' , 650 'UserAdvManager_CONFIRMMAIL_DELAY' => $conf_nbc_UserAdvManager_ConfirmMail[1], 651 //TODO:Adding new option [Auto Deletion : True | False] 652 //TODO:Adding new option [Resend_new_validation_key : True | False] 653 ) 654 ); 655 656 // +-----------------------------------------------------------------------+ 657 // | errors display | 658 // +-----------------------------------------------------------------------+ 659 if ( isset ($errors) and count($errors) != 0) 660 { 661 $template->assign('errors',array()); 662 foreach ($errors as $error) 663 { 664 array_push($page['errors'], $error); 665 } 666 } 667 668 // +-----------------------------------------------------------------------+ 669 // | templates display | 670 // +-----------------------------------------------------------------------+ 671 $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl'); 672 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); 673 } 674 else 385 675 { 386 array_push( 387 $users[$user_nums[$row['user_id']]]['groups'], 388 $row['group_id'] 389 ); 676 array_push($page['infos'], l10n('Err_ConfirmMail_Settings')); 390 677 } 391 } 392 393 return $users; 678 break; 394 679 } 395 396 // +-----------------------------------------------------------------------+397 // | initialization |398 // +-----------------------------------------------------------------------+399 400 if (!defined('PHPWG_ROOT_PATH'))401 {402 die('Hacking attempt!');403 }404 405 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');406 407 // +-----------------------------------------------------------------------+408 // | Check Access and exit when user status is not ok |409 // +-----------------------------------------------------------------------+410 check_status(ACCESS_ADMINISTRATOR);411 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 );418 419 // +-----------------------------------------------------------------------+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']) and469 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 else506 {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, name520 FROM '.GROUPS_TABLE.'521 ORDER BY name ASC522 ;';523 $result = pwg_query($query);524 525 while ($row = mysql_fetch_array($result))526 {527 $groups[$row['id']] = $row['name'];528 }529 530 // +-----------------------------------------------------------------------+531 // | Template Init |532 // +-----------------------------------------------------------------------+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 else540 {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 adviser552 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 else599 {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 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 )640 );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 else661 {662 array_push($page['infos'], l10n('Err_ConfirmMail_Settings'));663 664 }665 break;666 667 }668 669 680 ?> -
extensions/NBC_UserAdvManager-Trunk/admin/confirmmail.tpl
r3460 r3470 15 15 </li> 16 16 <br/> 17 <input type="text" name="UserAdvManager_ConfirmMail_Delay" value="{$UserAdvManager_CONFIRMMAIL_DELAY}" size="5" style="text-align: center;"/><br/> 17 <li><label>{'UserAdvManager_ConfirmMail_Delay_Info'|@translate}</label><input type="text" name="UserAdvManager_ConfirmMail_Delay" value="{$UserAdvManager_CONFIRMMAIL_DELAY}" size="5" style="text-align: center;"/><br/> 18 </li> 19 <!--TODO:Adding new option [Auto_Deletion : True | False]--> 20 <!--TODO:Adding new option [Resend_new_validation_key : True | False]--> 21 <br/> 22 </ul> 23 <div align="center"><input class="submit" type="submit" value="{'submit'|@translate}" name="submit" {$TAG_INPUT_ENABLED} /></div> 24 <ul> 18 25 <br/> 19 26 <table class="table2" width="97%"> … … 41 48 {/foreach} 42 49 <td style="text-align:center;"> 50 <!--TODO:Changing ACTION to Single_Deletion--> 43 51 <a href="{$user.U_ACTION}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/edit_s.png" class="button" style="border:none" alt="{'Profile'|@translate}" title="{'Profile'|@translate}" /></a> 44 52 </td> -
extensions/NBC_UserAdvManager-Trunk/language/fr_FR/plugin.lang.php
r3444 r3470 81 81 $lang['UserAdvManager_ConfirmMail_TimeOut_false'] = 'Désactiver la limitation du délai d\'inscription.'; 82 82 $lang['UserAdvManager_ConfirmMail_TimeOut'] = 'Délai d\activation :'; 83 $lang['UserAdvManager_ConfirmMail_Delay_Info'] = 'Saisissez ici le nombre de jours avant expiration de la validation d\'inscription : '; 84 85 $lang['UserAdvManager_Indiv_Suppr'] = 'Suppression individuelle'; 83 86 ?>
Note: See TracChangeset
for help on using the changeset viewer.