Changeset 6776 for extensions/NBC_UserAdvManager/branches/2.15/main.inc.php
- Timestamp:
- Aug 18, 2010, 10:56:53 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/branches/2.15/main.inc.php
r6256 r6776 2 2 /* 3 3 Plugin Name: UserAdvManager 4 Version: 2.15. 34 Version: 2.15.4 5 5 Description: Renforcer la gestion des utilisateurs - Enforce users management 6 6 Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=216 … … 13 13 /* 14 14 ***** TODO List ***** 15 ++ Adding ASC and DESC ordering for user's lists tables (Ghost Tracker, UserList and Unvalidated) ?16 17 15 ++ No validation needed for admins users comments (new trigger needed in comments.php ?) 18 16 … … 80 78 if (!is_admin() and !is_a_guest()) 81 79 { 82 if ((isset($conf_UAM[1 7]) and $conf_UAM[17] == 'true') or (isset($conf_UAM[20]) and $conf_UAM[20] == 'true'))80 if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true')) 83 81 { 84 82 … … 128 126 $conf_UAM = unserialize($conf['UserAdvManager']); 129 127 130 /* Sending registration confirmation by email */ 131 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[2]) and $conf_UAM[2] == 'true')) 132 { 133 if (is_admin() and isset($conf_UAM[21]) and $conf_UAM[21] == 'true') 134 { 135 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 136 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 137 } 138 elseif (is_admin() and isset($conf_UAM[21]) and $conf_UAM[21] == 'false') 139 { 128 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 129 { 130 /* This is to send an information email and set user to "waiting" group or status until admin validation */ 140 131 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 141 132 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 133 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 134 } 135 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 136 { 137 /* This is to set user to "wainting" group or status until admin validation */ 138 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 139 } 140 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false')) 141 { 142 /* This is to send an information email without validation key */ 143 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 144 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 145 } 146 /* Sending registration confirmation by email */ 147 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 148 { 149 if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true') 150 { 151 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 152 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 153 } 154 elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false') 155 { 156 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 157 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 142 158 } 143 159 elseif (!is_admin()) 144 160 { 145 $passwd = (isset($_POST['password'])) ? $_POST['password'] : '';146 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);161 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 162 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 147 163 } 148 164 } … … 159 175 /* Cleanup for LastVisit table */ 160 176 DeleteLastVisit($user_id); 177 /* Cleanup Redirection settings */ 178 DeleteRedir($user_id); 161 179 } 162 180 … … 253 271 254 272 /* Password enforcement control */ 255 if (isset($conf_UAM[1 4]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15]))273 if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 256 274 { 257 275 if (!empty($user['password']) and !is_admin()) … … 259 277 $PasswordCheck = testpassword($user['password']); 260 278 261 if ($PasswordCheck < $conf_UAM[1 5])279 if ($PasswordCheck < $conf_UAM[14]) 262 280 { 263 281 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 264 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[1 5]);265 } 266 } 267 else if (!empty($user['password']) and is_admin() and isset($conf_UAM[1 6]) and $conf_UAM[16] == 'true')282 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 283 } 284 } 285 else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true') 268 286 { 269 287 $PasswordCheck = testpassword($user['password']); 270 288 271 if ($PasswordCheck < $conf_UAM[1 5])289 if ($PasswordCheck < $conf_UAM[14]) 272 290 { 273 291 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 274 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[15]); 275 } 276 } 277 } 278 279 /* Username non case sensitive */ 280 if (isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and NotSensibleSearchUsername($_POST['login'])) 281 { 282 return($lang['reg_err_login5'] = l10n('reg_err_login5')); 292 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 293 } 294 } 283 295 } 284 296 285 297 /* Username without forbidden keys */ 286 if (isset($conf_UAM[ 7]) and $conf_UAM[7] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())298 if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin()) 287 299 { 288 300 $_POST['login'] = ''; 289 return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[ 8]."'");301 return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'"); 290 302 } 291 303 292 304 /* Email without forbidden domains */ 293 if (isset($conf_UAM[1 2]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())305 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin()) 294 306 { 295 307 $_POST['mail_address'] = ''; 296 return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[1 3]."'");308 return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 297 309 } 298 310 } … … 309 321 $conf_UAM = unserialize($conf['UserAdvManager']); 310 322 323 if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 324 { 325 $user_idsOK = array(); 326 if (!check_consult($user['id'], $user_idsOK)) 327 { 328 $user_idsOK[] = $user['id']; 329 330 $query = " 331 UPDATE ".CONFIG_TABLE." 332 SET value = \"".implode(',', $user_idsOK)."\" 333 WHERE param = 'UserAdvManager_Redir';"; 334 335 pwg_query($query); 336 } 337 } 338 311 339 if (isset($_POST['validate']) and !is_admin()) 312 340 { 313 341 /* Email without forbidden domains */ 314 if (isset($conf_UAM[1 2]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address']))342 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address'])) 315 343 { 316 344 if (ValidateEmailProvider($_POST['mail_address'])) 317 345 { 318 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[1 3]."'");346 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 319 347 unset($_POST['validate']); 320 348 } … … 328 356 329 357 /* Password enforcement control */ 330 if (isset($conf_UAM[1 4]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15]))358 if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 331 359 { 332 360 $PasswordCheck = testpassword($_POST['use_new_pwd']); 333 361 334 if ($PasswordCheck < $conf_UAM[1 5])362 if ($PasswordCheck < $conf_UAM[14]) 335 363 { 336 364 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 337 $template->append('errors', l10n_args($message).$conf_UAM[1 5]);365 $template->append('errors', l10n_args($message).$conf_UAM[14]); 338 366 unset($_POST['use_new_pwd']); 339 367 unset($_POST['validate']); … … 343 371 344 372 /* Sending registration confirmation by email */ 345 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[ 2]) and $conf_UAM[2] == 'true'))373 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'true') or (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 346 374 { 347 375 $confirm_mail_need = false; … … 356 384 357 385 list($current_email) = pwg_db_fetch_row(pwg_query($query)); 358 359 if ($_POST['mail_address'] != $current_email and ( isset($conf_UAM[2]) and $conf_UAM[2] == 'true')) 386 387 /* This is to send a new validation key */ 388 if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 360 389 361 390 $confirm_mail_need = true; 391 392 /* This is to set the user to "waiting" group or status until admin validation */ 393 if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 394 395 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 396 $confirm_mail_need = false; 362 397 } 363 398 … … 380 415 381 416 417 // RedirectToProfile - Thx to LucMorizur 418 // redirects a visitor (not generic (forbidden) neither admin) to his 419 // profile.php page 420 // 421 // no variable, no return 422 add_event_handler('login_success', 'RedirectToProfile'); 423 424 function RedirectToProfile() 425 { 426 global $conf, $user; 427 428 $conf_UAM = unserialize($conf['UserAdvManager']); 429 430 if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 431 { 432 $user_idsOK = array(); 433 if (!check_consult($user['id'], $user_idsOK)) 434 redirect(PHPWG_ROOT_PATH.'profile.php'); 435 } 436 } 437 438 382 439 add_event_handler('init', 'UAM_InitPage'); 383 440 /* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */ … … 395 452 { 396 453 /* Email without forbidden domains */ 397 if (isset($conf_UAM[1 2]) and $conf_UAM[12] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))398 { 399 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[1 3]."'");454 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) 455 { 456 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 400 457 unset($_POST['submit_add']); 401 458 } … … 415 472 416 473 /* User creation OR update */ 417 if (isset($conf_UAM[ 6]) and $conf_UAM[6] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')474 if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest') 418 475 { 419 476 $comment_action = 'reject';
Note: See TracChangeset
for help on using the changeset viewer.