Changeset 12239 for extensions/UserAdvManager/trunk/include
- Timestamp:
- Sep 26, 2011, 10:26:09 PM (13 years ago)
- Location:
- extensions/UserAdvManager/trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserAdvManager/trunk/include/functions.inc.php
r12227 r12239 223 223 224 224 $conf_UAM = unserialize($conf['UserAdvManager']); 225 225 226 // Update first redirection parameter 226 227 if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true')) 227 228 { … … 240 241 } 241 242 243 // Special message display for password reset 244 if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true')) 245 { 246 if (UAM_check_pwgreset($user['id'])) 247 { 248 $template->append('errors', l10n('UAM_Password_Reset_Msg')); 249 } 250 } 251 252 // Controls on profile page submission 242 253 if (isset($_POST['validate']) and !is_admin()) 243 254 { … … 249 260 $template->append('errors', l10n('UAM_reg_err_login5')."'".$conf_UAM[11]."'"); 250 261 unset($_POST['validate']); 262 } 263 } 264 265 // Password reset control 266 if (isset($conf_UAM[38]) and $conf_UAM[38] == 'true' and UAM_check_pwgreset($user['id'])) 267 { 268 // if password not changed then pwdreset filed = true else pwdreset field = false 269 if (!empty($_POST['use_new_pwd'])) 270 { 271 $query = ' 272 UPDATE '.USERS_TABLE.' 273 SET UAM_pwdreset = "false" 274 WHERE id = '.$user['id'].' 275 LIMIT 1 276 ;'; 277 pwg_query($query); 251 278 } 252 279 } … … 341 368 } 342 369 370 // Performing redirection to profile page on first login 343 371 if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true')) 344 { 345 // Performing redirection 372 { 346 373 $query =' 347 374 SELECT user_id, status … … 351 378 $data = pwg_db_fetch_assoc(pwg_query($query)); 352 379 353 if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") 380 if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") // Exclusion of specific accounts 354 381 { 355 382 $user_idsOK = array(); 356 383 if (!UAM_check_profile($user['id'], $user_idsOK)) 357 384 redirect(PHPWG_ROOT_PATH.'profile.php'); 385 } 386 } 387 388 // Performing redirection to profile page for password reset 389 if ((isset($conf_UAM[38]) and $conf_UAM[38] == 'true')) 390 { 391 $query =' 392 SELECT user_id, status 393 FROM '.USER_INFOS_TABLE.' 394 WHERE user_id = '.$user['id'].' 395 ;'; 396 $data = pwg_db_fetch_assoc(pwg_query($query)); 397 398 if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic") // Exclusion of specific accounts 399 { 400 if (UAM_check_pwgreset($user['id'])) 401 { 402 redirect(PHPWG_ROOT_PATH.'profile.php'); 403 } 358 404 } 359 405 } … … 2465 2511 @unlink($path); 2466 2512 } 2513 elseif (is_dir($path)) 2514 { 2515 @rmdir($path); 2516 } 2467 2517 } 2468 2518 } … … 2489 2539 $v = false; 2490 2540 2491 $query = "2541 $query = ' 2492 2542 SELECT value 2493 FROM ".CONFIG_TABLE."2494 WHERE param = 'UserAdvManager_Redir'2495 ; ";2543 FROM '.CONFIG_TABLE.' 2544 WHERE param = "UserAdvManager_Redir" 2545 ;'; 2496 2546 2497 2547 if ($v = (($t = pwg_db_fetch_row(pwg_query($query))) !== false)) … … 2505 2555 2506 2556 /** 2557 * UAM_check_pwdreset 2558 * checks if a user id is registered as having already 2559 * changed their password. 2560 * 2561 * @uid : the user id 2562 * 2563 * @returns : true or false whether the users has already changed his password 2564 * 2565 */ 2566 function UAM_check_pwgreset($uid) 2567 { 2568 $query = ' 2569 SELECT UAM_pwdreset 2570 FROM '.USERS_TABLE.' 2571 WHERE id='.$uid.' 2572 ;'; 2573 2574 $result = pwg_db_fetch_assoc(pwg_query($query)); 2575 2576 if($result['UAM_pwdreset'] == 'true') 2577 { 2578 return true; 2579 } 2580 else return false; 2581 } 2582 2583 /** 2584 * UAM_Set_PwdReset 2585 * Action in user_list to set a password reset for a user 2586 */ 2587 function UAM_Set_PwdReset($uid) 2588 { 2589 $query =' 2590 UPDATE '.USERS_TABLE.' 2591 SET UAM_pwdreset = "true" 2592 WHERE id = '.$uid.' 2593 LIMIT 1 2594 ;'; 2595 2596 pwg_query($query); 2597 } 2598 2599 2600 /** 2601 * UAM_loc_visible_user_list 2602 * Adds a new feature in user_list to allow password reset for selected users by admin 2603 * 2604 */ 2605 function UAM_loc_visible_user_list($visible_user_list) 2606 { 2607 global $template; 2608 2609 $template->append('plugin_user_list_column_titles', l10n('UAM_PwdReset')); 2610 2611 $user_ids = array(); 2612 2613 foreach ($visible_user_list as $i => $user) 2614 { 2615 $user_ids[$i] = $user['id']; 2616 } 2617 2618 $user_nums = array_flip($user_ids); 2619 2620 // Query to get informations in database 2621 if (!empty($user_ids)) 2622 { 2623 $query = ' 2624 SELECT DISTINCT id, UAM_pwdreset 2625 FROM '.USERS_TABLE.' 2626 WHERE id IN ('.implode(',', $user_ids).') 2627 ;'; 2628 $result = pwg_query($query); 2629 2630 while ($row = mysql_fetch_array($result)) 2631 { 2632 if ($row['UAM_pwdreset'] == 'false') 2633 { 2634 $pwdreset = l10n('UAM_PwdReset_Done'); 2635 } 2636 else if ($row['UAM_pwdreset'] == 'true') 2637 { 2638 $pwdreset = l10n('UAM_PwdReset_Todo'); 2639 } 2640 else $pwdreset = l10n('UAM_PwdReset_NA'); 2641 2642 $visible_user_list[$user_nums[$row['id']]]['plugin_columns'][] = $pwdreset; // Shows users password state in user_list 2643 } 2644 } 2645 return $visible_user_list; 2646 } 2647 2648 2649 /** 2507 2650 * UAM specific database dump (only for MySql !) 2508 2651 * Creates an SQL dump of UAM specific tables and configuration settings … … 2511 2654 * 2512 2655 */ 2513 function uam_dump($download)2656 function UAM_dump($download) 2514 2657 { 2515 2658 global $conf; -
extensions/UserAdvManager/trunk/include/upgradedb.inc.php
r12189 r12239 515 515 $Newconf_UAM[36] = '-1'; 516 516 $Newconf_UAM[37] = '-1'; 517 518 $update_conf = serialize($Newconf_UAM); 519 520 conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf)); 517 $Newconf_UAM[38] = 'false'; 518 519 $update_conf = serialize($Newconf_UAM); 520 521 conf_update_param('UserAdvManager', pwg_db_real_escape_string($update_conf)); 522 523 // Piwigo's native tables modifications for password reset function - Add pwdreset column 524 $q = ' 525 ALTER TABLE '.USERS_TABLE.' 526 ADD UAM_pwdreset enum("true","false") 527 ;'; 528 pwg_query($q); 521 529 } 522 530 ?>
Note: See TracChangeset
for help on using the changeset viewer.