Ignore:
Timestamp:
Sep 26, 2011, 10:26:09 PM (13 years ago)
Author:
Eric
Message:
  • Bug 2437 fixed - New feature : Request password renewal for selected users in Piwigo's users management panel.
  • Language files updates.
  • obsolete.list file creation to clean old help directories in languages.
  • Perform database upgrade.
Location:
extensions/UserAdvManager/trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r12227 r12239  
    223223
    224224  $conf_UAM = unserialize($conf['UserAdvManager']);
    225    
     225
     226  // Update first redirection parameter
    226227  if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true'))
    227228  {
     
    240241  }
    241242
     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
    242253  if (isset($_POST['validate']) and !is_admin())
    243254  {
     
    249260        $template->append('errors', l10n('UAM_reg_err_login5')."'".$conf_UAM[11]."'");
    250261        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 = '
     272UPDATE '.USERS_TABLE.'
     273SET UAM_pwdreset = "false"
     274WHERE id = '.$user['id'].'
     275LIMIT 1
     276;';
     277        pwg_query($query);
    251278      }
    252279    }
     
    341368  }
    342369
     370  // Performing redirection to profile page on first login
    343371  if ((isset($conf_UAM[20]) and $conf_UAM[20] == 'true'))
    344   {
    345     // Performing redirection 
     372  { 
    346373    $query ='
    347374SELECT user_id, status
     
    351378    $data = pwg_db_fetch_assoc(pwg_query($query));
    352379
    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
    354381    {
    355382      $user_idsOK = array();
    356383      if (!UAM_check_profile($user['id'], $user_idsOK))
    357384        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 ='
     392SELECT user_id, status
     393FROM '.USER_INFOS_TABLE.'
     394WHERE 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      }
    358404    }
    359405  }
     
    24652511        @unlink($path);
    24662512      }
     2513      elseif (is_dir($path))
     2514      {
     2515        @rmdir($path);
     2516      }
    24672517    }
    24682518  }
     
    24892539  $v = false;
    24902540 
    2491   $query = "
     2541  $query = '
    24922542SELECT value
    2493 FROM ".CONFIG_TABLE."
    2494 WHERE param = 'UserAdvManager_Redir'
    2495 ;";
     2543FROM '.CONFIG_TABLE.'
     2544WHERE param = "UserAdvManager_Redir"
     2545;';
    24962546 
    24972547  if ($v = (($t = pwg_db_fetch_row(pwg_query($query))) !== false))
     
    25052555
    25062556/**
     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 */
     2566function UAM_check_pwgreset($uid)
     2567{
     2568  $query = '
     2569SELECT UAM_pwdreset
     2570FROM '.USERS_TABLE.'
     2571WHERE 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 */
     2587function UAM_Set_PwdReset($uid)
     2588{
     2589  $query ='
     2590UPDATE '.USERS_TABLE.'
     2591SET UAM_pwdreset = "true"
     2592WHERE id = '.$uid.'
     2593LIMIT 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 */
     2605function 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 = '
     2624SELECT 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/**
    25072650 * UAM specific database dump (only for MySql !)
    25082651 * Creates an SQL dump of UAM specific tables and configuration settings
     
    25112654 *
    25122655 */
    2513 function uam_dump($download)
     2656function UAM_dump($download)
    25142657{
    25152658  global $conf;
  • extensions/UserAdvManager/trunk/include/upgradedb.inc.php

    r12189 r12239  
    515515  $Newconf_UAM[36] = '-1';
    516516  $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 = '
     525ALTER TABLE '.USERS_TABLE.'
     526ADD UAM_pwdreset enum("true","false")
     527;';
     528  pwg_query($q);
    521529}
    522530?>
Note: See TracChangeset for help on using the changeset viewer.