- Timestamp:
- Dec 1, 2010, 10:13:07 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions.inc.php
r7656 r7968 3 3 load_language('plugin.lang', UAM_PATH); 4 4 5 /* Function called from main.inc.php to send validation email */ 5 /** 6 * Triggered on get_admin_plugin_menu_links 7 * 8 * Plugin's administration menu 9 */ 10 function UAM_admin_menu($menu) 11 { 12 // +-----------------------------------------------------------------------+ 13 // | Getting plugin name | 14 // +-----------------------------------------------------------------------+ 15 $plugin = PluginInfos(UAM_PATH); 16 $name = $plugin['name']; 17 18 array_push($menu, 19 array( 20 'NAME' => $name, 21 'URL' => get_admin_plugin_menu_link(UAM_PATH.'/admin/UAM_admin.php') 22 ) 23 ); 24 25 return $menu; 26 } 27 28 /** 29 * Triggered on loc_begin_index 30 * 31 * Initiating GhostTracker 32 */ 33 function UAM_GhostTracker() 34 { 35 global $conf, $user; 36 37 $conf_UAM = unserialize($conf['UserAdvManager']); 38 39 // Admins, Guests and Adult_Content users are not tracked for Ghost Tracker or Users Tracker 40 if (!is_admin() and !is_a_guest() and $user['username'] != "16" and $user['username'] != "18") 41 { 42 if ((isset($conf_UAM[16]) and $conf_UAM[16] == 'true') or (isset($conf_UAM[19]) and $conf_UAM[19] == 'true')) 43 { 44 45 $userid = get_userid($user['username']); 46 47 // Looking for existing entry in last visit table 48 $query = ' 49 SELECT * 50 FROM '.USER_LASTVISIT_TABLE.' 51 WHERE user_id = '.$userid.' 52 ;'; 53 54 $count = pwg_db_num_rows(pwg_query($query)); 55 56 if ($count == 0) 57 { 58 // If not, data are inserted in table 59 $query = ' 60 INSERT INTO '.USER_LASTVISIT_TABLE.' (user_id, lastvisit, reminder) 61 VALUES ('.$userid.', now(), "false") 62 ;'; 63 pwg_query($query); 64 } 65 else if ($count > 0) 66 { 67 // If yes, data are updated in table 68 $query = ' 69 UPDATE '.USER_LASTVISIT_TABLE.' 70 SET lastvisit = now(), reminder = "false" 71 WHERE user_id = '.$userid.' 72 LIMIT 1 73 ;'; 74 pwg_query($query); 75 } 76 } 77 } 78 } 79 80 /** 81 * Triggered on register_user 82 * 83 * Additional controls on user registration 84 */ 85 function UAM_Adduser($register_user) 86 { 87 global $conf; 88 89 $conf_UAM = unserialize($conf['UserAdvManager']); 90 91 // Exclusion of Adult_Content users 92 if ($register_user['username'] != "16" and $register_user['username'] != "18") 93 { 94 if ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 95 { 96 // This is to send an information email and set user to "waiting" group or status until admin validation 97 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 98 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 99 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 100 } 101 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 102 { 103 // This is to set user to "waiting" group or status until admin validation 104 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 105 } 106 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'false')) 107 { 108 // This is to send an information email without validation key 109 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 110 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 111 } 112 // Sending registration confirmation by email 113 elseif ((isset($conf_UAM[0]) and $conf_UAM[0] == 'true' or $conf_UAM[0] == 'false') and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 114 { 115 if (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'true') 116 { 117 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 118 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 119 } 120 elseif (is_admin() and isset($conf_UAM[20]) and $conf_UAM[20] == 'false') 121 { 122 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 123 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 124 } 125 elseif (!is_admin()) 126 { 127 $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 128 SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 129 } 130 } 131 } 132 } 133 134 /** 135 * Triggered on delete_user 136 * 137 * Database cleanup on user deletion 138 */ 139 function UAM_Deluser($user_id) 140 { 141 // Cleanup for ConfirmMail table 142 DeleteConfirmMail($user_id); 143 // Cleanup for LastVisit table 144 DeleteLastVisit($user_id); 145 // Cleanup Redirection settings 146 DeleteRedir($user_id); 147 } 148 149 /** 150 * Triggered on register_user_check 151 * 152 * Additional controls on user registration check 153 */ 154 function UAM_RegistrationCheck($err, $user) 155 { 156 global $errors, $conf; 157 158 // Exclusion of Adult_Content users 159 if ($user['username'] != "16" and $user['username'] != "18") 160 { 161 162 // *********************************************************** 163 // We need to reset the standard Piwigo's register controls 164 // because the call of register_user_check trigger resets them 165 // *********************************************************** 166 167 // ********************************** 168 // Standard Piwigo's username control 169 // ********************************** 170 if ($_POST['login'] == '') 171 { 172 return l10n('reg_err_login1'); 173 } 174 if (preg_match('/^.* $/', $_POST['login'])) 175 { 176 return l10n('reg_err_login2'); 177 } 178 if (preg_match('/^ .*$/', $_POST['login'])) 179 { 180 return l10n('reg_err_login3'); 181 } 182 if (get_userid($_POST['login'])) 183 { 184 return l10n('reg_err_login5'); 185 } 186 187 if ($conf['insensitive_case_logon'] == true) 188 { 189 $login_error = validate_login_case($_POST['login']); 190 if ($login_error != '') 191 { 192 return l10n($login_error); 193 } 194 } 195 196 if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') // not the same email variable if we are on users registration page or on admin's user registration page 197 { 198 // Email doblons check 199 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase 200 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 201 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 202 203 if (!preg_match($regex, $_POST['email'])) 204 { 205 return l10n('reg_err_mail_address'); 206 } 207 208 $query = ' 209 SELECT count(*) 210 FROM '.USERS_TABLE.' 211 WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['email'].'\') 212 ;'; 213 list($count) = pwg_db_fetch_row(pwg_query($query)); 214 if ($count != 0) 215 { 216 return l10n('reg_err_mail_address_dbl'); 217 } 218 } 219 220 if (script_basename() == 'register') // not the same email variable if we are on users registration page or on admin's user registration page 221 { 222 // Email doblons check 223 $atom = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]'; // before arobase 224 $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name 225 $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i'; 226 227 if (!preg_match($regex, $_POST['mail_address'])) 228 { 229 return l10n('reg_err_mail_address'); 230 } 231 232 $query = ' 233 SELECT count(*) 234 FROM '.USERS_TABLE.' 235 WHERE upper('.$conf['user_fields']['email'].') = upper(\''.$_POST['mail_address'].'\') 236 ;'; 237 list($count) = pwg_db_fetch_row(pwg_query($query)); 238 if ($count != 0) 239 { 240 return l10n('reg_err_mail_address_dbl'); 241 } 242 } 243 // ****************************************** 244 // End of Piwigo's standard register controls 245 // ****************************************** 246 247 248 // ****************************************** 249 // Here begins the advanced register controls 250 // ****************************************** 251 $PasswordCheck = 0; 252 253 $conf_UAM = unserialize($conf['UserAdvManager']); 254 255 // Password enforcement control 256 if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 257 { 258 if (!empty($user['password']) and !is_admin()) 259 { 260 $PasswordCheck = testpassword($user['password']); 261 262 if ($PasswordCheck < $conf_UAM[14]) 263 { 264 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 265 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 266 } 267 } 268 else if (!empty($user['password']) and is_admin() and isset($conf_UAM[15]) and $conf_UAM[15] == 'true') 269 { 270 $PasswordCheck = testpassword($user['password']); 271 272 if ($PasswordCheck < $conf_UAM[14]) 273 { 274 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 275 return($lang['reg_err_pass'] = l10n_args($message).$conf_UAM[14]); 276 } 277 } 278 } 279 280 // Username without forbidden keys 281 if (isset($conf_UAM[6]) and $conf_UAM[6] == 'true' and !empty($_POST['login']) and ValidateUsername($_POST['login']) and !is_admin()) 282 { 283 $_POST['login'] = ''; 284 return($lang['reg_err_login1'] = l10n('reg_err_login6')."'".$conf_UAM[7]."'"); 285 } 286 287 // Email without forbidden domains 288 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address']) and ValidateEmailProvider($_POST['mail_address']) and !is_admin()) 289 { 290 $_POST['mail_address'] = ''; 291 return($lang['reg_err_login1'] = l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 292 } 293 } 294 } 295 296 /** 297 * Triggered on loc_begin_profile 298 */ 299 function UAM_Profile_Init() 300 { 301 global $conf, $user, $template; 302 303 $conf_UAM = unserialize($conf['UserAdvManager']); 304 305 if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 306 { 307 $user_idsOK = array(); 308 if (!check_consult($user['id'], $user_idsOK)) 309 { 310 $user_idsOK[] = $user['id']; 311 312 $query = " 313 UPDATE ".CONFIG_TABLE." 314 SET value = \"".implode(',', $user_idsOK)."\" 315 WHERE param = 'UserAdvManager_Redir';"; 316 317 pwg_query($query); 318 } 319 } 320 321 if (isset($_POST['validate']) and !is_admin()) 322 { 323 // Email without forbidden domains 324 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['mail_address'])) 325 { 326 if (ValidateEmailProvider($_POST['mail_address'])) 327 { 328 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 329 unset($_POST['validate']); 330 } 331 } 332 333 $typemail = 3; 334 335 if (!empty($_POST['use_new_pwd'])) 336 { 337 $typemail = 2; 338 339 // Password enforcement control 340 if (isset($conf_UAM[13]) and $conf_UAM[13] == 'true' and !empty($conf_UAM[14])) 341 { 342 $PasswordCheck = testpassword($_POST['use_new_pwd']); 343 344 if ($PasswordCheck < $conf_UAM[14]) 345 { 346 $message = get_l10n_args('reg_err_login4_%s', $PasswordCheck); 347 $template->append('errors', l10n_args($message).$conf_UAM[14]); 348 unset($_POST['use_new_pwd']); 349 unset($_POST['validate']); 350 } 351 } 352 } 353 354 // Sending registration confirmation by email 355 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')) 356 { 357 $confirm_mail_need = false; 358 359 if (!empty($_POST['mail_address'])) 360 { 361 $query = ' 362 SELECT '.$conf['user_fields']['email'].' AS email 363 FROM '.USERS_TABLE.' 364 WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' 365 ;'; 366 367 list($current_email) = pwg_db_fetch_row(pwg_query($query)); 368 369 // This is to send a new validation key 370 if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'true')) 371 372 $confirm_mail_need = true; 373 374 // This is to set the user to "waiting" group or status until admin validation 375 if ($_POST['mail_address'] != $current_email and (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')) 376 377 setgroup($register_user['id']);// Set to "waiting" group or status until admin validation 378 $confirm_mail_need = false; 379 } 380 381 if ((!empty($_POST['use_new_pwd']) and (isset($conf_UAM[0]) and $conf_UAM[0] == 'true') or $confirm_mail_need)) 382 { 383 $query = ' 384 SELECT '.$conf['user_fields']['username'].' 385 FROM '.USERS_TABLE.' 386 WHERE '.$conf['user_fields']['id'].' = \''.$user['id'].'\' 387 ;'; 388 389 list($username) = pwg_db_fetch_row(pwg_query($query)); 390 SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need); 391 } 392 } 393 } 394 } 395 396 /** 397 * Triggered on login_success 398 * 399 * redirects a visitor (except for admins, webmasters and generic statuses) to his profile.php page 400 * 401 * Thx to LucMorizur 402 */ 403 function UAM_RedirectToProfile() 404 { 405 global $conf, $user; 406 407 $conf_UAM = unserialize($conf['UserAdvManager']); 408 409 $query =' 410 SELECT user_id, status 411 FROM '.USER_INFOS_TABLE.' 412 WHERE user_id = '.$user['id'].' 413 ;'; 414 $data = pwg_db_fetch_assoc(pwg_query($query)); 415 416 if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") 417 { 418 if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true')) 419 { 420 $user_idsOK = array(); 421 if (!check_consult($user['id'], $user_idsOK)) 422 redirect(PHPWG_ROOT_PATH.'profile.php'); 423 } 424 } 425 } 426 427 /** 428 * Triggered on login_success 429 * 430 * Executes optional post-login tasks like GhostTracker auto tasks 431 * 432 */ 433 function UAM_Tasks() 434 { 435 global $conf, $user; 436 437 $conf_UAM = unserialize($conf['UserAdvManager']); 438 439 // Ghost accounts auto deletion 440 if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'true')) 441 { 442 443 } 444 445 // Ghost accounts auto group or status downgrade with or without information email sending 446 if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'false') and ((isset($conf_UAM[27]) and $conf_UAM[27] <> -1) or (isset($conf_UAM[28]) and $conf_UAM[28] <> -1))) 447 { 448 449 } 450 } 451 452 /** 453 * Triggered on init 454 * 455 * Check for forbidden email domains in admin's users management panel 456 */ 457 function UAM_InitPage() 458 { 459 load_language('plugin.lang', UAM_PATH); 460 global $conf, $template, $page, $lang, $errors; 461 462 $conf_UAM = unserialize($conf['UserAdvManager']); 463 464 // Admin user management 465 if (script_basename() == 'admin' and isset($_GET['page']) and $_GET['page'] == 'user_list') 466 { 467 if (isset($_POST['submit_add'])) 468 { 469 // Email without forbidden domains 470 if (isset($conf_UAM[11]) and $conf_UAM[11] == 'true' and !empty($_POST['email']) and ValidateEmailProvider($_POST['email'])) 471 { 472 $template->append('errors', l10n('reg_err_login7')."'".$conf_UAM[12]."'"); 473 unset($_POST['submit_add']); 474 } 475 } 476 } 477 } 478 479 /** 480 * Triggered on user_comment_check 481 * 482 * checks if author is mandatory and set on comments post 483 * 484 * @param : comment action, comment 485 * 486 * @return : comment action 487 * 488 */ 489 function UAM_CheckEmptyCommentAuthor($comment_action, $comm) 490 { 491 load_language('plugin.lang', UAM_PATH); 492 global $infos, $conf, $template; 493 494 $conf_UAM = unserialize($conf['UserAdvManager']); 495 496 // User creation OR update 497 if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $conf['comments_forall'] == 'true' and $comm['author'] == 'guest') 498 { 499 $comment_action = 'reject'; 500 501 array_push($infos, l10n('UAM_Empty Author')); 502 } 503 504 return $comment_action; 505 } 506 507 /** 508 * Function called from main.inc.php to send validation email 509 * 510 * @param : Type of email, user id, username, email address, confirmation (optional) 511 * 512 */ 6 513 function SendMail2User($typemail, $id, $username, $password, $email, $confirm) 7 514 { 515 // Only available for next Piwigo release (bug in switch_lang function) 8 516 global $conf; 9 517 … … 15 523 $infos2_perso = ""; 16 524 17 / * We have to get the user's language in database */525 // We have to get the user's language in database 18 526 $query =' 19 527 SELECT user_id, language … … 23 531 $data = pwg_db_fetch_assoc(pwg_query($query)); 24 532 25 / * Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language */533 // Check if user is already registered (profile changing) - If not (new registration), language is set to current gallery language 26 534 if (empty($data)) 27 535 { 28 / * And switch gallery to this language before using personalized and multilangual contents */536 // And switch gallery to this language before using personalized and multilangual contents 29 537 $language = pwg_get_session_var( 'lang_switch', $user['language'] ); 30 538 switch_lang_to($language); … … 32 540 else 33 541 { 34 / * And switch gallery to this language before using personalized and multilangual contents */35 $language = $data['language']; / * Usefull for debugging */542 // And switch gallery to this language before using personalized and multilangual contents 543 $language = $data['language']; // Usefull for debugging 36 544 switch_lang_to($data['language']); 37 545 load_language('plugin.lang', UAM_PATH); … … 98 606 } 99 607 100 / * ******************************************************** */101 / * **** Pending code since to find how to make it work **** */102 / * ******************************************************** */608 // ******************************************************** 609 // **** Pending code since to find how to make it work **** 610 // ******************************************************** 103 611 // Testing if FCK Editor is used. Then decoding htmlchars to avoid problems with pwg_mail() 104 612 /*$areas = array(); … … 123 631 124 632 125 / * Sending the email with subject and contents */633 // Sending the email with subject and contents 126 634 pwg_mail($email, array( 127 635 'subject' => $subject, … … 129 637 )); 130 638 131 / * ********************** */132 / * Email sending debugger */133 / * This is only to trace */134 / * the send of emails for */135 / * debugging */136 / * ********************** */639 // ********************** 640 // Email sending debugger 641 // This is only to trace 642 // the send of emails for 643 // debugging 644 // ********************** 137 645 //$content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); 138 646 //MailLog($email,$subject,$content,$language); 139 / * ********************** */140 141 / * Switching back to default language */647 // ********************** 648 649 // Switching back to default language 142 650 switch_lang_back(); 143 651 } 144 652 145 146 /* Function called from UAM_admin.php to resend validation email with or without new validation key */ 653 /** 654 * Function called from UAM_admin.php to resend validation email with or without new validation key 655 * 656 * @param : Type of email, user id, username, email address, confirmation (optional) 657 * 658 */ 147 659 function ResendMail2User($typemail, $user_id, $username, $email, $confirm) 148 660 { 149 / * Only available for next Piwigo release (bug in switch_lang function) */661 // Only available for next Piwigo release (bug in switch_lang function) 150 662 global $conf; 151 663 … … 159 671 $infos2_perso = ""; 160 672 161 / * We have to get the user's language in database */673 // We have to get the user's language in database 162 674 $query =' 163 675 SELECT user_id, language … … 168 680 $language = $data['language']; 169 681 170 / * And switch gallery to this language before using personalized and multilangual contents */682 // And switch gallery to this language before using personalized and multilangual contents 171 683 switch_lang_to($data['language']); 172 684 … … 193 705 } 194 706 195 / * Set reminder true */707 // Set reminder true 196 708 $query = " 197 709 UPDATE ".USER_CONFIRM_MAIL_TABLE." … … 215 727 } 216 728 217 / * Set reminder true */729 // Set reminder true 218 730 $query = " 219 731 UPDATE ".USER_CONFIRM_MAIL_TABLE." … … 231 743 )); 232 744 233 / * ********************** */234 / * Email sending debugger */235 / * This is only to trace */236 / * the send of emails for */237 / * debugging */238 / * ********************** */745 // ********************** 746 // Email sending debugger 747 // This is only to trace 748 // the send of emails for 749 // debugging 750 // ********************** 239 751 //$content = ($infos1."\n\n").(isset($infos2) ? l10n_args($infos2)."\n\n" : "").get_absolute_root_url(); 240 752 //MailLog($email,$subject,$content,$language); 241 / * ********************** */242 243 / * Switching back to default language */753 // ********************** 754 755 // Switching back to default language 244 756 switch_lang_back(); 245 757 } 246 758 247 248 /* Function called from UAM_admin.php to send a reminder mail for ghost users */ 759 /** 760 * Function called from UAM_admin.php to send a reminder mail for ghost users 761 * 762 * @param : User id, username, email address 763 * 764 */ 249 765 function ghostreminder($user_id, $username, $email) 250 766 { 251 / * Only available for next Piwigo release (bug in switch_lang function) */767 // Only available for next Piwigo release (bug in switch_lang function) 252 768 global $conf; 253 769 … … 258 774 $infos1_perso = ""; 259 775 260 / * We have to get the user's language in database */776 // We have to get the user's language in database 261 777 $query =' 262 778 SELECT user_id, language … … 267 783 $language = $data['language']; 268 784 269 / * And switch gallery to this language before using personalized and multilangual contents */785 // And switch gallery to this language before using personalized and multilangual contents 270 786 switch_lang_to($data['language']); 271 787 … … 293 809 )); 294 810 295 / * ********************** */296 / * Email sending debugger */297 / * This is only to trace */298 / * the send of emails for */299 / * debugging */300 / * ********************** */811 // ********************** 812 // Email sending debugger 813 // This is only to trace 814 // the send of emails for 815 // debugging 816 // ********************** 301 817 //$content = get_user_language_desc($conf_UAM[19])."\n\n"; 302 818 //MailLog($email,$subject,$content,$language); 303 / * ********************** */304 305 / * Switching back to default language */819 // ********************** 820 821 // Switching back to default language 306 822 switch_lang_back(); 307 823 } 308 824 309 310 /* Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation */ 825 /** 826 * Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation 827 * 828 * @return : validation key 829 * 830 */ 311 831 function FindAvailableConfirmMailID() 312 832 { … … 326 846 } 327 847 328 329 /* Function called from functions SendMail2User to process unvalidated users and generate validation key link */ 848 /** 849 * Function called from functions SendMail2User to process unvalidated users and generate validation key link 850 * 851 * @param : User id, email address 852 * 853 * @return : Build validation key in URL 854 * 855 */ 330 856 function AddConfirmMail($user_id, $email) 331 857 { … … 390 916 } 391 917 392 393 /* Function called from main.inc.php to set group to new users if manual validation is set */ 918 /** 919 * Function called from main.inc.php to set group to new users if manual validation is set 920 * 921 * @param : User id 922 * 923 * 924 */ 394 925 function setgroup($user_id) 395 926 { … … 431 962 } 432 963 433 434 /* Function called from UAM_admin.php to reset validation key */ 964 /** 965 * Function called from UAM_admin.php to reset validation key 966 * 967 * @param : User id 968 * 969 * @return : Build validation key in URL 970 * 971 */ 435 972 function ResetConfirmMail($user_id) 436 973 { … … 461 998 } 462 999 463 464 /* Function called from function_UserAdvManager.inc.php to reset last visit date after sending a reminder */ 1000 /** 1001 * Function called from functions.inc.php to reset last visit date after sending a reminder 1002 * 1003 * @param : User id 1004 * 1005 */ 465 1006 function resetlastvisit($user_id) 466 1007 { … … 478 1019 479 1020 480 /* Function called from main.inc.php - Triggered on user deletion */ 1021 /** 1022 * Function called from main.inc.php - Triggered on user deletion 1023 * 1024 */ 481 1025 function DeleteConfirmMail($user_id) 482 1026 { … … 488 1032 } 489 1033 490 /* Function called from main.inc.php - Triggered on user deletion */ 1034 /** 1035 * Function called from main.inc.php - Triggered on user deletion 1036 * 1037 */ 491 1038 function DeleteLastVisit($user_id) 492 1039 { … … 498 1045 } 499 1046 500 501 /* Function called from main.inc.php - Triggered on user deletion */ 1047 /** 1048 * Function called from main.inc.php - Triggered on user deletion 1049 * 1050 * @param : User id 1051 * 1052 */ 502 1053 function DeleteRedir($user_id) 503 1054 { … … 524 1075 } 525 1076 526 527 /* Function called from ConfirmMail.php to verify validation key used by user according time limit */ 528 /* Return true is key validation is OK else return false */ 1077 /** 1078 * Function called from ConfirmMail.php to verify validation key used by user according time limit 1079 * Return true is key validation is OK else return false 1080 * 1081 * @param : User id 1082 * 1083 * @return : Bool 1084 * 1085 */ 529 1086 function VerifyConfirmMail($id) 530 1087 { … … 562 1119 list($registration_date) = pwg_db_fetch_row(pwg_query($query)); 563 1120 564 / * Time limit process */565 / * ******************************************** */1121 // Time limit process 1122 // ******************************************** 566 1123 if (!empty($registration_date)) 567 1124 { … … 694 1251 } 695 1252 696 /* Function called from UAM_admin.php to force users validation by admin */ 1253 /** 1254 * Function called from UAM_admin.php to force users validation by admin 1255 * 1256 * @param : User id 1257 * 1258 * @return : Bool 1259 * 1260 */ 697 1261 function ForceValidation($id) 698 1262 { … … 774 1338 } 775 1339 776 777 /* Function called from main.inc.php - Check if username matches forbidden caracters */ 1340 /** 1341 * Function called from main.inc.php - Check if username matches forbidden caracters 1342 * 1343 * @param : User login 1344 * 1345 * @return : Bool 1346 * 1347 */ 778 1348 function ValidateUsername($login) 779 1349 { … … 800 1370 } 801 1371 802 803 /* Function called from main.inc.php - Check if user's email is in excluded email providers list */ 804 /* Doesn't work on call - Must be copied in main.inc.php to work */ 1372 /** 1373 * Function called from main.inc.php - Check if user's email is in excluded email providers list 1374 * Doesn't work on call - Must be copied in main.inc.php to work 1375 * 1376 * @param : Email address 1377 * 1378 * @return : Bool 1379 * 1380 */ 805 1381 function ValidateEmailProvider($email) 806 1382 { … … 828 1404 } 829 1405 830 831 /* Function called from UserAdvManager.php - Get unvalidated users according time limit */ 1406 /** 1407 * Function called from UAM_admin.php - Get unvalidated users according time limit 1408 * 1409 * @return : List of users 1410 * 1411 */ 832 1412 function get_unvalid_user_list() 833 1413 { 834 1414 global $conf, $page; 835 1415 836 / * Get ConfirmMail configuration */1416 // Get ConfirmMail configuration 837 1417 $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); 838 / * Get UAM configuration */1418 // Get UAM configuration 839 1419 $conf_UAM = unserialize($conf['UserAdvManager']); 840 1420 841 1421 $users = array(); 842 1422 843 / * search users depending expiration date */1423 // search users depending expiration date 844 1424 $query = ' 845 1425 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, … … 889 1469 } 890 1470 891 / * add group lists */1471 // add group lists 892 1472 $user_ids = array(); 893 1473 foreach ($users as $i => $user) … … 920 1500 } 921 1501 922 923 /* Function called from UserAdvManager.php - Get ghost users */ 1502 /** 1503 * Function called from UAM_admin.php - Get ghost users 1504 * 1505 * @return : List of users 1506 * 1507 */ 924 1508 function get_ghost_user_list() 925 1509 { … … 930 1514 $users = array(); 931 1515 932 / * search users depending expiration date */1516 // search users depending expiration date 933 1517 $query = ' 934 1518 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, … … 953 1537 } 954 1538 955 / * add group lists */1539 // add group lists 956 1540 $user_ids = array(); 957 1541 foreach ($users as $i => $user) … … 963 1547 } 964 1548 965 966 /* Function called from UserAdvManager.php - Get all users to display the number of days since their last visit */ 1549 /** 1550 * Function called from UAM_admin.php - Get all users to display the number of days since their last visit 1551 * 1552 * @return : List of users 1553 * 1554 */ 967 1555 function get_user_list() 968 1556 { … … 971 1559 $users = array(); 972 1560 973 / * search users depending expiration date */1561 // search users depending expiration date 974 1562 $query = ' 975 1563 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, … … 994 1582 } 995 1583 996 / * add group lists */1584 // add group lists 997 1585 $user_ids = array(); 998 1586 foreach ($users as $i => $user) … … 1004 1592 } 1005 1593 1006 1007 /* Function called from UserAdvManager.php - to determine who is expired or not and giving a different display color */ 1594 /** 1595 * Function called from UAM_admin.php - to determine who is expired or not and giving a different display color 1596 * 1597 * @param : user id 1598 * 1599 * @return : Bool 1600 * 1601 */ 1008 1602 function expiration($id) 1009 1603 { 1010 1604 global $conf, $page; 1011 1605 1012 / * Get ConfirmMail configuration */1606 // Get ConfirmMail configuration 1013 1607 $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']); 1014 1608 1015 / * Get UAM configuration */1609 // Get UAM configuration 1016 1610 $conf_UAM = unserialize($conf['UserAdvManager']); 1017 1611 … … 1023 1617 list($registration_date) = pwg_db_fetch_row(pwg_query($query)); 1024 1618 1025 / * Time limit process */1026 / * ******************************************** */1619 // Time limit process 1620 // ******************************************** 1027 1621 if (!empty($registration_date)) 1028 1622 { … … 1055 1649 * Returns a password's score for password complexity check 1056 1650 * 1057 * @param password filled by user 1651 * @param : password filled by user 1652 * 1653 * @return : Score calculation 1058 1654 * 1059 1655 * Thanx to MathieuGut from http://m-gut.developpez.com … … 1128 1724 } 1129 1725 1130 /* Function called from maintain.inc.php - to check if database upgrade is needed */ 1726 /** 1727 * Function called from maintain.inc.php - to check if database upgrade is needed 1728 * 1729 * @param : table name 1730 * 1731 * @return : boolean 1732 * 1733 */ 1131 1734 function table_exist($table) 1132 1735 { … … 1135 1738 } 1136 1739 1137 / * Email sending debugger function */1740 // Email sending debugger function 1138 1741 function MailLog($to, $subject, $content, $language) 1139 1742 { … … 1148 1751 } 1149 1752 1150 1151 /* Function called from UAM_admin.php and main.inc.php to get the plugin version and name */ 1753 /** 1754 * Function called from UAM_admin.php and main.inc.php to get the plugin version and name 1755 * 1756 * @param : plugin directory 1757 * 1758 * @return : plugin's version and name 1759 * 1760 */ 1152 1761 function PluginInfos($dir) 1153 1762 { … … 1213 1822 } 1214 1823 1215 1216 // check_consult - Thx to LucMorizur 1217 // checks if a user id is registered as having already 1218 // visited his profile.php page. 1219 // @uid : the user id 1220 // @user_idsOK : (returned) array of all users ids having already visited 1221 // their profile.php pages 1222 // 1223 // @returns : true or false whether the users has already visited his 1224 // profile.php page or not 1824 /** 1825 * check_consult - Thx to LucMorizur 1826 * checks if a user id is registered as having already 1827 * visited his profile.php page. 1828 * 1829 * @uid : the user id 1830 * 1831 * @user_idsOK : (returned) array of all users ids having already visited 1832 * their profile.php pages 1833 * 1834 * @returns : true or false whether the users has already visited his 1835 * profile.php page or not 1836 * 1837 */ 1225 1838 function check_consult($uid, &$user_idsOK) 1226 1839 {
Note: See TracChangeset
for help on using the changeset viewer.