Changeset 5056 for extensions/NBC_UserAdvManager/trunk/main.inc.php
- Timestamp:
- Mar 5, 2010, 1:12:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/main.inc.php
r4957 r5056 2 2 /* 3 3 Plugin Name: NBC UserAdvManager 4 Version: 2.13. 44 Version: 2.13.5 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 … … 42 42 43 43 include_once (NBC_UAM_PATH.'include/constants.php'); 44 include_once (NBC_UAM_PATH.'include/functions _UserAdvManager.inc.php');44 include_once (NBC_UAM_PATH.'include/functions.inc.php'); 45 45 46 46 load_language('plugin.lang', NBC_UAM_PATH); … … 48 48 49 49 /* Plugin admin */ 50 add_event_handler('get_admin_plugin_menu_links', ' nbc_UserAdvManager_admin_menu');51 52 function nbc_UserAdvManager_admin_menu($menu)50 add_event_handler('get_admin_plugin_menu_links', 'UAM_admin_menu'); 51 52 function UAM_admin_menu($menu) 53 53 { 54 54 array_push($menu, 55 55 array( 56 56 'NAME' => 'UserAdvManager', 57 'URL' => get_admin_plugin_menu_link(NBC_UAM_PATH.'/admin/U serAdvManager_admin.php')57 'URL' => get_admin_plugin_menu_link(NBC_UAM_PATH.'/admin/UAM_admin.php') 58 58 ) 59 59 ); … … 63 63 64 64 /* Lastvisit table feed for Ghost Tracker */ 65 add_event_handler('loc_begin_index', 'U serAdvManager_GhostTracker');66 67 function U serAdvManager_GhostTracker()65 add_event_handler('loc_begin_index', 'UAM_GhostTracker'); 66 67 function UAM_GhostTracker() 68 68 { 69 69 global $conf, $user; 70 71 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();72 73 if (isset($conf_ nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17] == 'true' and !is_admin() and !is_a_guest())70 71 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 72 73 if (isset($conf_UAM[17]) and $conf_UAM[17] == 'true' and !is_admin() and !is_a_guest()) 74 74 { 75 75 … … 110 110 111 111 /* User creation */ 112 add_event_handler('register_user', 'U serAdvManager_Adduser');113 114 function U serAdvManager_Adduser($register_user)112 add_event_handler('register_user', 'UAM_Adduser'); 113 114 function UAM_Adduser($register_user) 115 115 { 116 116 global $conf; 117 118 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();117 118 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 119 119 120 120 /* Sending registration confirmation by email */ 121 if ((isset($conf_ nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true' and !is_admin()) or (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and !is_admin()))121 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' and !is_admin()) or (isset($conf_UAM[2]) and $conf_UAM[2] == 'true' and !is_admin())) 122 122 { 123 123 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; … … 129 129 130 130 /* User deletion */ 131 add_event_handler('delete_user', 'U serAdvManager_Deluser');132 133 function U serAdvManager_Deluser($user_id)131 add_event_handler('delete_user', 'UAM_Deluser'); 132 133 function UAM_Deluser($user_id) 134 134 { 135 135 /* Cleanup for ConfirmMail table */ … … 141 141 142 142 /* Check users registration */ 143 add_event_handler('register_user_check', 'U serAdvManager_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);144 145 function U serAdvManager_RegistrationCheck($err, $user)143 add_event_handler('register_user_check', 'UAM_RegistrationCheck', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 144 145 function UAM_RegistrationCheck($err, $user) 146 146 { 147 147 global $errors, $conf; … … 227 227 /* ****************************************** */ 228 228 $PasswordCheck = 0; 229 230 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();229 230 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 231 231 232 232 /* Password enforcement control */ 233 if (isset($conf_ nbc_UserAdvManager[14]) and $conf_nbc_UserAdvManager[14] == 'true' and !empty($conf_nbc_UserAdvManager[15]))233 if (isset($conf_UAM[14]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15])) 234 234 { 235 235 if (!empty($user['password']) and !is_admin()) … … 237 237 $PasswordCheck = testpassword($user['password']); 238 238 239 if ($PasswordCheck < $conf_ nbc_UserAdvManager[15])239 if ($PasswordCheck < $conf_UAM[15]) 240 240 { 241 241 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 242 return($lang['reg_err_pass'] = l10n_args($message).$conf_ nbc_UserAdvManager[15]);243 } 244 } 245 else if (!empty($user['password']) and is_admin() and isset($conf_ nbc_UserAdvManager[16]) and $conf_nbc_UserAdvManager[16] == 'true')242 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[15]); 243 } 244 } 245 else if (!empty($user['password']) and is_admin() and isset($conf_UAM[16]) and $conf_UAM[16] == 'true') 246 246 { 247 247 $PasswordCheck = testpassword($user['password']); 248 248 249 if ($PasswordCheck < $conf_ nbc_UserAdvManager[15])249 if ($PasswordCheck < $conf_UAM[15]) 250 250 { 251 251 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 252 return($lang['reg_err_pass'] = l10n_args($message).$conf_ nbc_UserAdvManager[15]);252 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[15]); 253 253 } 254 254 } … … 256 256 257 257 /* Username non case sensitive */ 258 if (isset($conf_ nbc_UserAdvManager[1]) and $conf_nbc_UserAdvManager[1] == 'true' and NotSensibleSearchUsername($_POST['login']))258 if (isset($conf_UAM[1]) and $conf_UAM[1] == 'true' and NotSensibleSearchUsername($_POST['login'])) 259 259 { 260 260 return($lang['reg_err_login5'] = l10n('reg_err_login5')); … … 262 262 263 263 /* Username without forbidden keys */ 264 if (isset($conf_ nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin())264 if (isset($conf_UAM[7]) and $conf_UAM[7] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin()) 265 265 { 266 266 $_POST['login'] = ''; 267 return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_ nbc_UserAdvManager[8]."'");267 return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[8]."'"); 268 268 } 269 269 270 270 /* Email without forbidden domains */ 271 if (isset($conf_ nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin())271 if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin()) 272 272 { 273 273 $_POST['mail_address'] = ''; 274 return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_ nbc_UserAdvManager[13]."'");274 return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[13]."'"); 275 275 } 276 276 } … … 279 279 if (script_basename() == 'profile') 280 280 { 281 add_event_handler('loc_begin_profile', 'U serAdvManager_Profile_Init');282 283 function U serAdvManager_Profile_Init()281 add_event_handler('loc_begin_profile', 'UAM_Profile_Init'); 282 283 function UAM_Profile_Init() 284 284 { 285 285 global $conf, $user, $template; 286 286 287 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();287 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 288 288 289 289 if (isset($_POST['validate']) and !is_admin()) 290 290 { 291 291 /* Email without forbidden domains */ 292 if (isset($conf_ nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['mail_address']))292 if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['mail_address'])) 293 293 { 294 294 if (ValidateEmailProvider($_POST['mail_address'])) 295 295 { 296 $template->append('errors', l10n('reg_err_login7')."'".$conf_ nbc_UserAdvManager[13]."'");296 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[13]."'"); 297 297 unset($_POST['validate']); 298 298 } … … 306 306 307 307 /* Password enforcement control */ 308 if (isset($conf_ nbc_UserAdvManager[14]) and $conf_nbc_UserAdvManager[14] == 'true' and !empty($conf_nbc_UserAdvManager[15]))308 if (isset($conf_UAM[14]) and $conf_UAM[14] == 'true' and !empty($conf_UAM[15])) 309 309 { 310 310 $PasswordCheck = testpassword($_POST['use_new_pwd']); 311 311 312 if ($PasswordCheck < $conf_ nbc_UserAdvManager[15])312 if ($PasswordCheck < $conf_UAM[15]) 313 313 { 314 314 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 315 $template->append('errors', l10n_args($message).$conf_ nbc_UserAdvManager[15]);315 $template->append('errors', l10n_args($message).$conf_UAM[15]); 316 316 unset($_POST['use_new_pwd']); 317 317 unset($_POST['validate']); … … 321 321 322 322 /* Sending registration confirmation by email */ 323 if ((isset($conf_ nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))323 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or (isset($conf_UAM[2]) and $conf_UAM[2] == 'true')) 324 324 { 325 325 $confirm_mail_need = false; … … 335 335 list($current_email) = mysql_fetch_row(pwg_query($query)); 336 336 337 if ($_POST['mail_address'] != $current_email and ( isset($conf_ nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true'))337 if ($_POST['mail_address'] != $current_email and ( isset($conf_UAM[2]) and $conf_UAM[2] == 'true')) 338 338 339 339 $confirm_mail_need = true; 340 340 } 341 341 342 if ((!empty($_POST['use_new_pwd']) and (isset($conf_ nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true') or $confirm_mail_need))342 if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need)) 343 343 { 344 344 $query = ' … … 358 358 359 359 360 add_event_handler('init', 'U serAdvManager_InitPage');360 add_event_handler('init', 'UAM_InitPage'); 361 361 /* *** Important ! This is necessary to make email exclusion work in admin's users management panel *** */ 362 function U serAdvManager_InitPage()362 function UAM_InitPage() 363 363 { 364 364 load_language('plugin.lang', NBC_UAM_PATH); 365 365 global $conf, $template, $page, $lang, $errors; 366 366 367 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();367 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 368 368 369 369 /* Admin user management */ … … 373 373 { 374 374 /* Email without forbidden domains */ 375 if (isset($conf_ nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email']))376 { 377 $template->append('errors', l10n('reg_err_login7')."'".$conf_ nbc_UserAdvManager[13]."'");375 if (isset($conf_UAM[12]) and $conf_UAM[12] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) 376 { 377 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[13]."'"); 378 378 unset($_POST['submit_add']); 379 379 } … … 383 383 384 384 385 add_event_handler('user_comment_check', 'U serAdvManager_CheckEmptyCommentAuthor', 50, 2);386 387 function U serAdvManager_CheckEmptyCommentAuthor($comment_action, $comm)385 add_event_handler('user_comment_check', 'UAM_CheckEmptyCommentAuthor', 50, 2); 386 387 function UAM_CheckEmptyCommentAuthor($comment_action, $comm) 388 388 { 389 389 load_language('plugin.lang', NBC_UAM_PATH); 390 390 global $infos, $conf, $template; 391 391 392 $conf_ nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();392 $conf_UAM = unserialize($conf['nbc_UserAdvManager']); 393 393 394 394 /* User creation OR update */ 395 if (isset($conf_ nbc_UserAdvManager[6]) and $conf_nbc_UserAdvManager[6] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest')395 if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest') 396 396 { 397 397 $comment_action = 'reject'; 398 398 399 array_push($infos, l10n('U serAdvManager_Empty Author'));399 array_push($infos, l10n('UAM_Empty Author')); 400 400 } 401 401
Note: See TracChangeset
for help on using the changeset viewer.