Ignore:
Timestamp:
Feb 4, 2014, 7:12:43 PM (10 years ago)
Author:
Eric
Message:

Piwigo 2.6 compatibility:
Users management (users display, password renewal and unlocking accounts) recoded in plugin's admin panel

Location:
extensions/Password_Policy
Files:
24 added
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/Password_Policy/admin/PP_admin.php

    r25089 r27179  
    1414//ini_set('display_errors', true);
    1515
     16include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    1617include_once (PHPWG_ROOT_PATH.'/include/constants.php');
    1718
     
    2526$error = array();
    2627
     28$my_base_url = get_admin_plugin_menu_link(__FILE__);
     29
    2730$PP_Password_Test_Score = 0;
    2831
     
    3336$version = $plugin['version'];
    3437
     38// ------------------------------------------
     39// Template initialization for forms and data
     40// ------------------------------------------
     41$themeconf = $template->get_template_vars('themeconf');
     42$PP_theme = $themeconf['id'];
    3543
    3644// +----------------------------------------------------------+
     
    5866}
    5967
     68
     69// +-----------------------------------------------------------------------+
     70// |                            Tabssheet                                  |
     71// +-----------------------------------------------------------------------+
     72if (!isset($_GET['tab']))
     73        $page['tab'] = 'config';
     74else
     75 $page['tab'] = $_GET['tab'];
     76
     77$tabsheet = new tabsheet();
     78$tabsheet->add('config',
     79               l10n('PP_config_tab'),
     80               $my_base_url.'&tab=config');
     81$tabsheet->add('userlist',
     82               l10n('PP_Users_List_Tab'),
     83               $my_base_url.'&tab=userlist');
     84$tabsheet->select($page['tab']);
     85$tabsheet->assign();
     86
     87
     88// +-----------------------------------------------------------------------+
     89// |                            Tabssheet select                           |
     90// +-----------------------------------------------------------------------+
     91
     92switch ($page['tab'])
     93{
     94// *************************************************************************
     95// +-----------------------------------------------------------------------+
     96// |                           Config tab                                  |
     97// +-----------------------------------------------------------------------+
     98// *************************************************************************
     99  case 'config':
    60100
    61101  if (isset($_POST['submit']) and isset($_POST['PP_Password_Enforced']) and isset($_POST['PP_AdminPassword_Enforced']) and isset($_POST['PP_PwdReset']) and isset($_POST['PP_LogFailedPassw']))
     
    92132
    93133  $conf_PP = unserialize($conf['PasswordPolicy']);
    94 
    95   // ------------------------------------------
    96   // Template initialization for forms and data
    97   // ------------------------------------------
    98   $themeconf=$template->get_template_vars('themeconf');
    99   $PP_theme=$themeconf['id'];
    100134
    101135  $template->assign(
     
    136170  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/PP_admin.tpl');
    137171  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     172
     173  break;
     174
     175
     176// *************************************************************************
     177// +-----------------------------------------------------------------------+
     178// |                           Users list page                             |
     179// +-----------------------------------------------------------------------+
     180// *************************************************************************
     181  case 'userlist':
     182
     183  $conf_PP = unserialize($conf['PasswordPolicy']);
     184
     185  if ((isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET']=='true') or (isset($conf_PP['LOGFAILBLOCK']) and $conf_PP['LOGFAILBLOCK']=='true'))
     186  {
     187// +-----------------------------------------------------------------------+
     188// |                           initialization                              |
     189// +-----------------------------------------------------------------------+
     190
     191    if (!defined('PHPWG_ROOT_PATH'))
     192    {
     193      die('Hacking attempt!');
     194    }
     195
     196    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     197
     198// +-----------------------------------------------------------------------+
     199// | Check Access and exit when user status is not ok                      |
     200// +-----------------------------------------------------------------------+
     201    check_status(ACCESS_ADMINISTRATOR);
     202
     203
     204// +-----------------------------------------------------------------------+
     205// |                               user list                               |
     206// +-----------------------------------------------------------------------+
     207
     208    $page['filtered_users'] = pp_get_user_list();
     209
     210// +-----------------------------------------------------------------------+
     211// |                            selected users                             |
     212// +-----------------------------------------------------------------------+
     213    if (isset($_POST['pwdreset']) or isset($_POST['unlock']))
     214    {
     215      $collection = array();
     216
     217      switch ($_POST['target'])
     218      {
     219        case 'all' :
     220        {
     221          foreach($page['filtered_users'] as $local_user)
     222          {
     223            array_push($collection, $local_user['id']);
     224          }
     225          break;
     226        }
     227        case 'selection' :
     228        {
     229          if (isset($_POST['selection']))
     230          {
     231            $collection = $_POST['selection'];
     232          }
     233          break;
     234        }
     235      }
     236
     237      if (count($collection) == 0)
     238      {
     239        array_push($page['errors'], l10n('Select at least one user'));
     240      }
     241    }
     242
     243// +-----------------------------------------------------------------------+
     244// |                               Reset pwd                               |
     245// +-----------------------------------------------------------------------+
     246    if (isset($_POST['pwdreset']) and count($collection) > 0)
     247    {
     248      if (in_array($conf['guest_id'], $collection))
     249      {
     250        array_push($page['errors'], l10n('PP_Guest cannot be pwdreset'));
     251      }
     252      if (($conf['guest_id'] != $conf['default_user_id']) and
     253        in_array($conf['default_user_id'], $collection))
     254      {
     255        array_push($page['errors'], l10n('PP_Default user cannot be pwdreset'));
     256      }
     257      if (in_array($conf['webmaster_id'], $collection))
     258      {
     259        array_push($page['errors'], l10n('PP_Webmaster cannot be pwdreset'));
     260      }
     261      if (in_array($user['id'], $collection))
     262      {
     263        array_push($page['errors'], l10n('PP_You cannot pwdreset your account'));
     264      }
     265
     266      // Generic accounts exclusion (including Adult_Content generic users)
     267      // ------------------------------------------------------------------
     268      $query ='
     269SELECT u.id
     270FROM '.USERS_TABLE.' AS u
     271INNER JOIN '.USER_INFOS_TABLE.' AS ui
     272  ON u.id = ui.user_id
     273WHERE ui.status = "generic"
     274;';
     275
     276            $result = pwg_query($query);
     277
     278      while ($row = pwg_db_fetch_assoc($result))
     279      {
     280        if (in_array($row['id'], $collection))
     281        {
     282          array_push($page['errors'], l10n('PP_Generic cannot be pwdreset'));
     283        }
     284      }
     285
     286      // Admins accounts exclusion
     287      // --------------------------
     288      $query ='
     289SELECT u.id
     290FROM '.USERS_TABLE.' AS u
     291INNER JOIN '.USER_INFOS_TABLE.' AS ui
     292  ON u.id = ui.user_id
     293WHERE ui.status = "admin"
     294;';
     295
     296            $result = pwg_query($query);
     297
     298      while ($row = pwg_db_fetch_assoc($result))
     299      {
     300        if (in_array($row['id'], $collection))
     301        {
     302          array_push($page['errors'], l10n('PP_Admins cannot be pwdreset'));
     303        }
     304      }
     305
     306
     307      if (count($page['errors']) == 0)
     308      {
     309        if (isset($_POST['confirm_pwdreset']) and 1 == $_POST['confirm_pwdreset'])
     310        {
     311          foreach ($collection as $user_id)
     312          {
     313            PP_Set_PwdReset($user_id);
     314          }
     315          array_push(
     316            $page['infos'],
     317            l10n_dec(
     318              'PP %d user pwdreseted', 'PP %d users pwdreseted',
     319              count($collection)
     320              )
     321            );
     322          $template->append('infos', l10n_dec(
     323              'PP %d user pwdreseted', 'PP %d users pwdreseted',
     324              count($collection)));
     325        }
     326        else
     327        {
     328          array_push($page['errors'], l10n('PP_You need to confirm pwdreset'));
     329        }
     330      }
     331    }
     332
     333
     334// +-----------------------------------------------------------------------+
     335// |                         Unlock accounts                               |
     336// +-----------------------------------------------------------------------+
     337    if (isset($_POST['unlock']) and count($collection) > 0)
     338    {
     339      if (in_array($conf['guest_id'], $collection))
     340      {
     341        array_push($page['errors'], l10n('PP_Guest is not unlockable'));
     342      }
     343      if (($conf['guest_id'] != $conf['default_user_id']) and
     344        in_array($conf['default_user_id'], $collection))
     345      {
     346        array_push($page['errors'], l10n('PP_Default user is not unlockable'));
     347      }
     348      if (in_array($conf['webmaster_id'], $collection))
     349      {
     350        array_push($page['errors'], l10n('PP_Webmaster is not unlockable'));
     351      }
     352      if (in_array($user['id'], $collection))
     353      {
     354        array_push($page['errors'], l10n('PP_You cannot unlock your account'));
     355      }
     356
     357      // Generic accounts exclusion (including Adult_Content generic users)
     358      // ------------------------------------------------------------------
     359      $query ='
     360SELECT u.id
     361FROM '.USERS_TABLE.' AS u
     362INNER JOIN '.USER_INFOS_TABLE.' AS ui
     363  ON u.id = ui.user_id
     364WHERE ui.status = "generic"
     365;';
     366
     367            $result = pwg_query($query);
     368
     369      while ($row = pwg_db_fetch_assoc($result))
     370      {
     371        if (in_array($row['id'], $collection))
     372        {
     373          array_push($page['errors'], l10n('PP_Generic is not unlockable'));
     374        }
     375      }
     376
     377      // Admins accounts exclusion
     378      // --------------------------
     379      $query ='
     380SELECT u.id
     381FROM '.USERS_TABLE.' AS u
     382INNER JOIN '.USER_INFOS_TABLE.' AS ui
     383  ON u.id = ui.user_id
     384WHERE ui.status = "admin"
     385;';
     386
     387            $result = pwg_query($query);
     388
     389      while ($row = pwg_db_fetch_assoc($result))
     390      {
     391        if (in_array($row['id'], $collection))
     392        {
     393          array_push($page['errors'], l10n('PP_Admins is not unlockable'));
     394        }
     395      }
     396
     397
     398      if (count($page['errors']) == 0)
     399      {
     400        if (isset($_POST['confirm_unlock']) and 1 == $_POST['confirm_unlock'])
     401        {
     402          foreach ($collection as $user_id)
     403          {
     404            PP_unlock_user($user_id);
     405          }
     406          array_push(
     407            $page['infos'],
     408            l10n_dec(
     409              'PP %d user unlocked', 'PP %d users unlocked',
     410              count($collection)
     411              )
     412            );
     413          $template->append('infos', l10n_dec(
     414              'PP %d user unlocked', 'PP %d users unlocked',
     415              count($collection)));
     416        }
     417        else
     418        {
     419          array_push($page['errors'], l10n('PP_You need to confirm unlock'));
     420        }
     421      }
     422    }
     423
     424
     425// +-----------------------------------------------------------------------+
     426// |                               user list                               |
     427// +-----------------------------------------------------------------------+
     428
     429    $visible_user_list = array();
     430        foreach ($page['filtered_users'] as $num => $local_user)
     431        {
     432      $visible_user_list[] = $local_user;
     433    }
     434
     435    foreach ($visible_user_list as $local_user)
     436    {
     437        if (!empty($local_user))
     438        {
     439          $query = '
     440SELECT DISTINCT id, PP_pwdreset
     441  FROM '.USERS_TABLE.'
     442  WHERE id IN ('.$local_user['id'].')
     443;';
     444          $result = pwg_query($query);
     445
     446          while ($row = pwg_db_fetch_assoc($result))
     447          {
     448            if ($row['PP_pwdreset'] == 'false')
     449            {
     450              $pwdreset = l10n('PP_PwdReset_Done');
     451            }
     452            else if ($row['PP_pwdreset'] == 'true')
     453            {
     454              $pwdreset = l10n('PP_PwdReset_Todo');
     455            }
     456            else $pwdreset = l10n('PP_PwdReset_NA');
     457          }
     458
     459
     460          $query = '
     461SELECT DISTINCT id, PP_lock
     462  FROM '.USERS_TABLE.'
     463  WHERE id IN ('.$local_user['id'].')
     464;';
     465          $result = pwg_query($query);
     466
     467          while ($row = pwg_db_fetch_assoc($result))
     468          {
     469            if ($row['PP_lock'] == 'false')
     470            {
     471              $LockedUser = '<img src="'.PP_PATH.'admin/template/icons/nolock.png" title="'.l10n('PP_User Not Locked').'" alt="'.l10n('PP_User Not Locked').'"/><div style="display: none">'.l10n('PP_User Not Locked').'</div>';
     472            }
     473            else if ($row['PP_lock'] == 'true')
     474            {
     475              $LockedUser = '<img src="'.PP_PATH.'admin/template/icons/lock.png" title="'.l10n('PP_User Locked').'" alt="'.l10n('PP_User Locked').'"/><div style="display: none">'.l10n('PP_User Locked').'</div>';
     476            }
     477            else $LockedUser = '<img src="'.PP_PATH.'admin/template/icons/nolock.png" title="'.l10n('PP_User Not Locked').'" alt="'.l10n('PP_User Not Locked').'"/><div style="display: none">'.l10n('PP_User Not Locked').'</div>';
     478          }
     479        }
     480
     481        // Template initialization
     482        // -----------------------
     483        $template->append(
     484          'users',
     485            array(
     486              'ID'            => $local_user['id'],
     487              'USERNAME'      => stripslashes($local_user['username'])
     488                                .($local_user['id'] == $conf['guest_id']
     489                                ? '<BR>['.l10n('guest').']' : '')
     490                                .($local_user['id'] == $conf['default_user_id']
     491                                ? '<BR>['.l10n('default values').']' : ''),
     492              'STATUS'        => l10n('user_status_'.$local_user['status']),
     493              'EMAIL'         => $local_user['email'],
     494              'PWD_LOCKED'    => $LockedUser,
     495              'PWDRESET'      => $pwdreset,
     496            )
     497        );
     498    }
     499
     500
     501    // Set extra template variables
     502    // ----------------------------
     503    $Conf_Pwreset = false;
     504    $Conf_Logfailblock = false;
     505
     506    if (isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET']=='true')
     507    {
     508      $Conf_Pwreset = true;
     509    }
     510
     511    if (isset($conf_PP['LOGFAILBLOCK']) and $conf_PP['LOGFAILBLOCK']=='true')
     512    {
     513      $Conf_Logfailblock = true;
     514    }
     515
     516// ----------------- Debugging code -----------------
     517//$converted_res1 = ($Conf_Pwreset) ? 'true' : 'false';
     518//$converted_res2 = ($Conf_Logfailblock) ? 'true' : 'false';
     519//PPLog($conf_PP['PWDRESET'],$converted_res1,$conf_PP['LOGFAILBLOCK'],$converted_res2);
     520
     521    // Template initialization - Extra variables
     522        // -----------------------------------------
     523        $template->assign(
     524           array(
     525        'PP_VERSION'    => $version,
     526        'PP_PATH'       => PP_PATH,
     527        'PP_THEME'      => $PP_theme,
     528        'PWRESET'       => $Conf_Pwreset,
     529        'LOGFAILBLOCK'  => $Conf_Logfailblock,
     530      )
     531    );
     532
     533// +-----------------------------------------------------------------------+
     534// |                             errors display                            |
     535// +-----------------------------------------------------------------------+
     536    if (isset($errors) and count($errors) != 0)
     537    {
     538      $template->assign('errors',array());
     539      foreach ($errors as $error)
     540      {
     541        array_push($page['errors'], $error);
     542      }
     543    } 
     544
     545// +-----------------------------------------------------------------------+
     546// |                           templates display                           |
     547// +-----------------------------------------------------------------------+
     548    $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/PP_userlist.tpl');
     549    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
     550  }
     551        else
     552        {
     553    array_push($page['errors'], l10n('PP_Err_Userlist_Settings'));
     554  }
     555
     556  break;
     557}
    138558?>
  • extensions/Password_Policy/admin/template/PP_admin.tpl

    r25089 r27179  
    2828</div>
    2929
    30 <form method="post" action="" class="general">
     30<form method="post" class="general">
    3131<fieldset>
    3232  <ul>
     
    4040      </label>
    4141      <label for="PP_Password_Enforced_true"><input id="PP_Password_Enforced_true" type="radio" value="true" {$PP_PASSWORDENF_TRUE} name="PP_Password_Enforced"/>
    42         {'PP_Password_Enforced_true'|@translate}&nbsp;
     42        {'PP_Password_Enforced_true'|@translate}&nbsp;</label>
    4343        <input type="text" name="PP_Password_Score" value="{$PP_PASSWORD_SCORE}" size="5" style="text-align: center;"/>
    44       </label>
    45       <br />
     44      <br /><br />
    4645        {'PP_PasswordTest'|@translate}
    4746        <input class="cluetip" title="{'PP_passwtestTitle'|translate}|{'PP_passwtestTitle_d'|translate}" type="text" name="PP_Password_Test" value="{$PP_PASSWORD_TEST}" size="50" style="text-align: left;"/>
     
    4948        <input class="submit" type="submit" value="{'PP_PasswordTest'|@translate}" name="PasswordTest"/>
    5049        &nbsp;&nbsp;&nbsp;{'PP_ScoreTest'|@translate}{$PP_PASSWORD_TEST_SCORE}
    51       </li>
     50    </li>
    5251
    5352      <ul>
     
    6665      </ul>
    6766
    68       <li>
    69         <label class="cluetip" title="{'PP_PwdReset'|translate}|{'PP_PwdResetTitle_d'|translate}">
    70           {'PP_PwdReset'|@translate}
     67    <li>
     68      <label class="cluetip" title="{'PP_PwdReset'|translate}|{'PP_PwdResetTitle_d'|translate}">
     69        {'PP_PwdReset'|@translate}
     70      </label>
     71
     72      <label for="PP_PwdReset_false"><input id="PP_PwdReset_false" value="false" {$PP_PWDRESET_FALSE} name="PP_PwdReset" type="radio"/>
     73        {'PP_Disable'|@translate}
     74      </label>
     75      <label for="PP_PwdReset_true"><input id="PP_PwdReset_true" value="true" {$PP_PWDRESET_TRUE} name="PP_PwdReset" type="radio"/>
     76        {'PP_Enable'|@translate}
     77      </label>
     78    </li>
     79
     80    <li>
     81      <label class="cluetip" title="{'PP_LoginAttempts'|translate}|{'PP_LoginAttempts_d'|translate}">
     82        {'PP_LoginAttempts'|@translate}
     83      </label>
     84
     85      <label for="PP_LoginAttempts_false"><input id="PP_LoginAttempts_false" value="false" {$PP_LOGFAILEDPASSW_FALSE} name="PP_LogFailedPassw" type="radio"/>
     86        {'PP_Disable'|@translate}
     87      </label>
     88      <label for="PP_LoginAttempts_true"><input id="PP_LoginAttempts_true" value="true" {$PP_LOGFAILEDPASSW_TRUE} name="PP_LogFailedPassw" type="radio"/>
     89        {'PP_Enable'|@translate}
     90      </label>
     91    </li>
     92
     93    <ul>
     94      <li id="PP_USRLOCKEDTXT" {if $PP_LOGFAILEDPASSW_FALSE} style="display: none"{/if}>
     95        <label class="cluetip" title="{'PP_Max number of failed attempts'|translate}|{'PP_Max number of failed attempts_d'|translate}">
     96          {'PP_Max number of failed attempts'|@translate}&nbsp;&nbsp;<input type="text" name="PP_NbFailedPassw" value="{$PP_NBLOGFAIL}" size="5" style="text-align: center;"/>
    7197        </label>
    72 
    73         <label for="PP_PwdReset_false"><input id="PP_PwdReset_false" value="false" {$PP_PWDRESET_FALSE} name="PP_PwdReset" type="radio"/>
    74           {'PP_Disable'|@translate}
     98<br />
     99        <label class="cluetip" title="{'PP_UserLocked_Custom_Txt'|translate}|{'PP_UserLocked_Custom_Txt_d'|translate}">
     100          {'PP_UserLocked_Custom_Txt'|@translate}
    75101        </label>
    76         <label for="PP_PwdReset_true"><input id="PP_PwdReset_true" value="true" {$PP_PWDRESET_TRUE} name="PP_PwdReset" type="radio"/>
    77           {'PP_Enable'|@translate}
    78         </label>
    79       </li>
    80 
    81       <li>
    82         <label class="cluetip" title="{'PP_LoginAttempts'|translate}|{'PP_LoginAttempts_d'|translate}">
    83           {'PP_LoginAttempts'|@translate}
    84         </label>
    85 
    86         <label for="PP_LoginAttempts_false"><input id="PP_LoginAttempts_false" value="false" {$PP_LOGFAILEDPASSW_FALSE} name="PP_LogFailedPassw" type="radio"/>
    87           {'PP_Disable'|@translate}
    88         </label>
    89         <label for="PP_LoginAttempts_true"><input id="PP_LoginAttempts_true" value="true" {$PP_LOGFAILEDPASSW_TRUE} name="PP_LogFailedPassw" type="radio"/>
    90           {'PP_Enable'|@translate}
    91         </label>
    92       </li>
    93 
    94       <ul>
    95         <li id="PP_USRLOCKEDTXT" {if $PP_LOGFAILEDPASSW_FALSE} style="display: none"{/if}>
    96           <label class="cluetip" title="{'PP_Max number of failed attempts'|translate}|{'PP_Max number of failed attempts_d'|translate}">
    97             {'PP_Max number of failed attempts'|@translate}&nbsp;&nbsp;<input type="text" name="PP_NbFailedPassw" value="{$PP_NBLOGFAIL}" size="5" style="text-align: center;"/>
    98           </label>
    99 <br />
    100           <label class="cluetip" title="{'PP_UserLocked_Custom_Txt'|translate}|{'PP_UserLocked_Custom_Txt_d'|translate}">
    101             {'PP_UserLocked_Custom_Txt'|@translate}
    102           </label>
    103           <textarea class="pp_textfields" name="PP_CustomLockMsg" id="PP_CustomLockMsg" rows="10" {$TAG_INPUT_ENABLED}>{$PP_USRLOCKEDTXT}</textarea>
     102        <textarea class="pp_textfields" name="PP_CustomLockMsg" id="PP_CustomLockMsg" rows="10" {$TAG_INPUT_ENABLED}>{$PP_USRLOCKEDTXT}</textarea>
    104103          {if 'FCK_PATH'|@defined}
    105104            <div style="text-align:right;">
     
    107106            </div>
    108107          {/if}
    109         </li>
    110       </ul>
     108      </li>
    111109    </ul>
     110  </ul>
    112111
    113112  <p>
  • extensions/Password_Policy/admin/template/pp.css

    r25089 r27179  
    2222  width: 70%;
    2323}
     24
     25table.table2 {
     26        border: 1px solid #111;
     27        margin: 1em auto;
     28        padding: 0;
     29  width: 97%;
     30}
     31
     32/* ******************************* */
     33/* jQuery tablesorter instructions */
     34/* ******************************* */
     35/* ******************************* */
     36/* jQuery tablesorter instructions */
     37/* ******************************* */
     38
     39/*table.tablesorter tbody tr.normal-row td {
     40  background: #111111; 
     41  color: #666666;
     42}
     43table.tablesorter tbody tr.alt-row td {
     44  background: #222222;
     45  color: #666666;
     46}*/
     47
     48tr.tablesorter-headerRow, throw
     49{
     50cursor:pointer;
     51text-align:center;
     52}
     53
     54th.tablesorter-header
     55{
     56background-image:url("./icons/bg.png");
     57background-position:right center;
     58background-repeat:no-repeat;
     59cursor:pointer;
     60}
     61
     62th.tablesorter-headerDesc
     63{
     64background-image:url("./icons/desc.png");
     65}
     66
     67th.tablesorter-headerAsc
     68{
     69background-image:url("./icons/asc.png");
     70}
     71
     72th.sorter-false {
     73        background-image: none;
     74}
     75
     76
     77
     78/* ************************************* */
     79/* jQuery tablesorter pager instructions */
     80/* ************************************* */
     81
     82.pager{
     83  text-align:center;
     84}
     85
     86/* pager wrapper, div */
     87.tablesorter-pager {
     88  padding: 5px;
     89}
     90/* pager wrapper, in thead/tfoot */
     91td.tablesorter-pager {
     92  background-color: #e6eeee;
     93  margin: 0; /* needed for bootstrap .pager gets a 18px bottom margin */
     94}
     95/* pager navigation arrows */
     96.tablesorter-pager img {
     97  vertical-align: middle;
     98  margin-right: 2px;
     99  cursor: pointer;
     100}
     101
     102#pager img {
     103  margin-bottom: -3px;
     104}
     105
     106/* pager output text */
     107.tablesorter-pager .pagedisplay {
     108  padding: 0 5px 0 5px;
     109  width: 50px;
     110  text-align: center;
     111}
     112
     113
     114/* pager element reset (needed for bootstrap) */
     115.tablesorter-pager select {
     116  margin: 0;
     117  padding: 0;
     118}
     119
     120/*** css used when "updateArrows" option is true ***/
     121/* the pager itself gets a disabled class when the number of rows is less than the size */
     122.tablesorter-pager.disabled {
     123  display: none;
     124}
     125/* hide or fade out pager arrows when the first or last row is visible */
     126.tablesorter-pager .disabled {
     127  /* visibility: hidden */
     128  opacity: 0.5;
     129  filter: alpha(opacity=50);
     130  cursor: default;
     131}
  • extensions/Password_Policy/include/functions.inc.php

    r25104 r27179  
    198198  load_language('plugin.lang', PP_PATH);
    199199
    200   $template->append('plugin_user_list_column_titles', l10n('PP_PwdReset'));
    201 
    202200  $user_ids = array();
    203201
     
    600598
    601599/**
     600 * Function called from PP_admin.php - Get all users to display the number of days since their last visit
     601 *
     602 * @return : List of users
     603 *
     604 */
     605function pp_get_user_list()
     606{
     607  global $conf, $page;
     608
     609  $users = array();
     610
     611  // Search users with exclusion of Adult_Content generic users and guest user
     612  // -------------------------------------------------------------------------
     613  $query = '
     614SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     615                u.'.$conf['user_fields']['username'].' AS username,
     616                u.'.$conf['user_fields']['email'].' AS email,
     617                ui.status
     618FROM '.USERS_TABLE.' AS u
     619  INNER JOIN '.USER_INFOS_TABLE.' AS ui
     620    ON u.'.$conf['user_fields']['id'].' = ui.user_id
     621WHERE u.username NOT LIKE "16"
     622  AND u.username NOT LIKE "18"
     623;';
     624
     625  $result = pwg_query($query);
     626     
     627  while ($row = pwg_db_fetch_assoc($result))
     628  {
     629    $user = $row;
     630    array_push($users, $user);
     631  }
     632
     633  $user_ids = array();
     634  foreach ($users as $i => $user)
     635  {
     636    $user_ids[$i] = $user['id'];
     637  }
     638
     639  return $users;
     640}
     641
     642
     643/**
    602644 * Function called from PP_admin.php to get the plugin version and name
    603645 *
  • extensions/Password_Policy/language/en_UK/plugin.lang.php

    r25104 r27179  
    7171$lang['PP %d user unlocked'] = '%d user unlocked';
    7272$lang['PP %d users unlocked'] = '%d users unlocked';
     73$lang['PP_config_tab'] = 'Configuration';
     74$lang['PP_Users_List_Tab'] = 'Management';
     75$lang['PP_Pwd_Actions'] = 'Users management';
     76$lang['PP_Pwd_Actions_d'] = 'Unlocking accounts and password renewal requests are set here.<br/><br/>
     77Select users before set an action. Confirmation checkbox is mandatory before applying any action.<br/><br/>
     78<b style=&quot;color: red;&quot;>Important :</b> Actions apply <u><b>ONLY</b> on visitor accounts</u> and not administrators, webmaster, default and guest.';
     79$lang['PP_Err_Userlist_Settings'] = 'This tab is available only if password renewal or unlocking accounts is enabled';
     80$lang['PP_No_Userlist'] = 'No users available to display';
     81$lang['PP_Select page number'] = 'Select page number to display';
     82$lang['PP_Select page size'] = 'Select page size';
    7383?>
  • extensions/Password_Policy/language/fr_FR/plugin.lang.php

    r25104 r27179  
    7171$lang['PP %d user unlocked'] = '%d utilisateur déverrouillé';
    7272$lang['PP %d users unlocked'] = '%d utilisateurs déverrouillés';
     73$lang['PP_config_tab'] = 'Configuration';
     74$lang['PP_Users_List_Tab'] = 'Gestion';
     75$lang['PP_Pwd_Actions'] = 'Gestion des utilisateurs';
     76$lang['PP_Pwd_Actions_d'] = 'Les actions de renouvellement forcée des mots de passe et de déverrouillages de comptes se font ici.<br/><br/>
     77Sélectionnez les utilisateurs avant d\'appliquer une action. De même, il est nécessaire de cocher la case de confirmation avant chaque action.<br/><br/>
     78<b style=&quot;color: red;&quot;>Important :</b> Les actions ne s\'appliquent <u><b>QUE</b> sur les comptes visiteurs</u> et pas administrateurs, webmestre, par défaut et invité (guest).';
     79$lang['PP_Err_Userlist_Settings'] = 'Cet onglet n\'est disponible que si le renouvellement du mots de passe ou la gestion des tentatives de connexion echouées est actif';
     80$lang['PP_No_Userlist'] = 'Pas d\'utilisateurs à afficher';
     81$lang['PP_Select page number'] = 'Sélectionnez le numéro de la page à afficher';
     82$lang['PP_Select page size'] = 'Sélectionnez le nombre de lignes par pages';
    7383?>
  • extensions/Password_Policy/main.inc.php

    r25104 r27179  
    4848add_event_handler('login_failure', 'PP_log_fail');
    4949
    50 // Add new feature in user_list - Password Reset
    51 // ---------------------------------------------
    52 if (isset($conf_PP['PWDRESET']) and $conf_PP['PWDRESET'] == 'true')
    53 {
    54   // Add new column on user_list
    55   // ---------------------------
    56   add_event_handler('loc_visible_user_list', 'PP_user_list_pwdreset');
    57 
    58   // Add prefilter on user_list
    59   // --------------------------
    60   add_event_handler('loc_begin_admin', 'PP_PwdReset_Action',60);
    61 
    62   /**
    63    * PP_PwdReset_Action - Triggered on PP_PwdReset_Action
    64    * Handle password reset action in user_list.php
    65    */
    66   function PP_PwdReset_Action()
    67   {
    68     global $conf, $user, $template, $lang, $errors;
    69 
    70     $page['errors'] = array();
    71     $page['infos'] = array();
    72     $page['filtered_users'] = array();
    73 
    74     load_language('plugin.lang', PP_PATH);
    75 
    76     if (isset($_POST['pwdreset']))
    77     {
    78       $collection = array();
    79 
    80       switch ($_POST['target'])
    81       {
    82         case 'all' :
    83         {
    84           foreach($page['filtered_users'] as $local_user)
    85           {
    86             array_push($collection, $local_user['id']);
    87           }
    88           break;
    89         }
    90         case 'selection' :
    91         {
    92           if (isset($_POST['selection']))
    93           {
    94             $collection = $_POST['selection'];
    95           }
    96           break;
    97         }
    98       }
    99 
    100       if (count($collection) == 0)
    101       {
    102         array_push($page['errors'], l10n('Select at least one user'));
    103       }
    104     }
    105 
    106     if (isset($_POST['pwdreset']) and count($collection) > 0)
    107     {
    108       if (in_array($conf['guest_id'], $collection))
    109       {
    110         array_push($page['errors'], l10n('PP_Guest cannot be pwdreset'));
    111         $template->append('errors', l10n('PP_Guest cannot be pwdreset'));
    112       }
    113       if (($conf['guest_id'] != $conf['default_user_id']) and
    114         in_array($conf['default_user_id'], $collection))
    115       {
    116         array_push($page['errors'], l10n('PP_Default user cannot be pwdreset'));
    117         $template->append('errors', l10n('PP_Default user cannot be pwdreset'));
    118       }
    119       if (in_array($conf['webmaster_id'], $collection))
    120       {
    121         array_push($page['errors'], l10n('PP_Webmaster cannot be pwdreset'));
    122         $template->append('errors', l10n('PP_Webmaster cannot be pwdreset'));
    123       }
    124       if (in_array($user['id'], $collection))
    125       {
    126         array_push($page['errors'], l10n('PP_You cannot pwdreset your account'));
    127         $template->append('errors', l10n('PP_You cannot pwdreset your account'));
    128       }
    129 
    130       // Generic accounts exclusion (including Adult_Content generic users)
    131       // ------------------------------------------------------------------
    132       $query ='
    133 SELECT u.id
    134 FROM '.USERS_TABLE.' AS u
    135 INNER JOIN '.USER_INFOS_TABLE.' AS ui
    136   ON u.id = ui.user_id
    137 WHERE ui.status = "generic"
    138 ;';
    139 
    140             $result = pwg_query($query);
    141 
    142       while ($row = pwg_db_fetch_assoc($result))
    143       {
    144         if (in_array($row['id'], $collection))
    145         {
    146           array_push($page['errors'], l10n('PP_Generic cannot be pwdreset'));
    147           $errors = l10n('PP_Generic cannot be pwdreset');
    148         }
    149       }
    150 
    151       // Admins accounts exclusion
    152       // --------------------------
    153       $query ='
    154 SELECT u.id
    155 FROM '.USERS_TABLE.' AS u
    156 INNER JOIN '.USER_INFOS_TABLE.' AS ui
    157   ON u.id = ui.user_id
    158 WHERE ui.status = "admin"
    159 ;';
    160 
    161             $result = pwg_query($query);
    162 
    163       while ($row = pwg_db_fetch_assoc($result))
    164       {
    165         if (in_array($row['id'], $collection))
    166         {
    167           array_push($page['errors'], l10n('PP_Admins cannot be pwdreset'));
    168           $errors = l10n('PP_Admins cannot be pwdreset');
    169         }
    170       }
    171 
    172       $template->append('errors', $errors);
    173 
    174       if (count($page['errors']) == 0)
    175       {
    176         if (isset($_POST['confirm_pwdreset']) and 1 == $_POST['confirm_pwdreset'])
    177         {
    178           foreach ($collection as $user_id)
    179           {
    180             PP_Set_PwdReset($user_id);
    181           }
    182           array_push(
    183             $page['infos'],
    184             l10n_dec(
    185               'PP %d user pwdreseted', 'PP %d users pwdreseted',
    186               count($collection)
    187               )
    188             );
    189           $template->append('infos', l10n_dec(
    190               'PP %d user pwdreseted', 'PP %d users pwdreseted',
    191               count($collection)));
    192           foreach ($page['filtered_users'] as $filter_key => $filter_user)
    193           {
    194             if (in_array($filter_user['id'], $collection))
    195             {
    196               unset($page['filtered_users'][$filter_key]);
    197             }
    198           }
    199         }
    200         else
    201         {
    202           array_push($page['errors'], l10n('PP_You need to confirm pwdreset'));
    203           $template->append('errors', l10n('PP_You need to confirm pwdreset'));
    204         }
    205       }
    206     }
    207     $template->set_prefilter('user_list', 'PP_PwdReset_Prefilter');
    208   }
    209 
    210   /**
    211    * PP_PwdReset_Prefilter
    212    * Adds action field for password reset in user_list.tpl
    213    */
    214   function PP_PwdReset_Prefilter($content, &$smarty)
    215   {
    216     $search = '
    217 <fieldset>
    218   <legend>{\'Deletions\'|@translate}</legend>
    219   <label><input type="checkbox" name="confirm_deletion" value="1"> {\'confirm\'|@translate}</label>
    220   <input class="submit" type="submit" value="{\'Delete selected users\'|@translate}" name="delete">
    221 </fieldset>
    222 ';
    223  
    224     $addon = '
    225 <fieldset>
    226   <legend>{\'PP_PwdReset\'|@translate}</legend>
    227   <label><input type="checkbox" name="confirm_pwdreset" value="1"> {\'confirm\'|@translate}</label>
    228   <input class="submit" type="submit" value="{\'PP_Password reset selected users\'|@translate}" name="pwdreset">
    229 </fieldset>
    230 ';
    231 
    232     $replacement = $addon.$search;
    233 
    234     return str_replace($search, $replacement, $content);
    235   }
    236 }
    237 
    238 
    239 // Add new feature in user_list - Show locked accounts and give unlock function
    240 // ----------------------------------------------------------------------------
    241 if (isset($conf_PP['LOGFAILBLOCK']) and $conf_PP['LOGFAILBLOCK']=='true')
    242 {
    243   // Add new column on user_list
    244   // ---------------------------
    245   add_event_handler('loc_visible_user_list', 'PP_user_list_locked');
    246 
    247   // Add prefilter on user_list
    248   // --------------------------
    249   add_event_handler('loc_begin_admin', 'PP_Unlock_Action',60);
    250 
    251   /**
    252    * PP_Unlock_Action - Triggered on PP_Unlock_Action
    253    * Handle unlocking action in user_list.php
    254    */
    255   function PP_Unlock_Action()
    256   {
    257     global $conf, $user, $template, $lang, $errors;
    258 
    259     $page['errors'] = array();
    260     $page['infos'] = array();
    261     $page['filtered_users'] = array();
    262 
    263     load_language('plugin.lang', PP_PATH);
    264 
    265     if (isset($_POST['unlock']))
    266     {
    267       $collection = array();
    268 
    269       switch ($_POST['target'])
    270       {
    271         case 'all' :
    272         {
    273           foreach($page['filtered_users'] as $local_user)
    274           {
    275             array_push($collection, $local_user['id']);
    276           }
    277           break;
    278         }
    279         case 'selection' :
    280         {
    281           if (isset($_POST['selection']))
    282           {
    283             $collection = $_POST['selection'];
    284           }
    285           break;
    286         }
    287       }
    288 
    289       if (count($collection) == 0)
    290       {
    291         array_push($page['errors'], l10n('Select at least one user'));
    292       }
    293     }
    294 
    295     if (isset($_POST['unlock']) and count($collection) > 0)
    296     {
    297       if (in_array($conf['guest_id'], $collection))
    298       {
    299         array_push($page['errors'], l10n('PP_Guest is not unlockable'));
    300         $template->append('errors', l10n('PP_Guest is not unlockable'));
    301       }
    302       if (($conf['guest_id'] != $conf['default_user_id']) and
    303         in_array($conf['default_user_id'], $collection))
    304       {
    305         array_push($page['errors'], l10n('PP_Default user is not unlockable'));
    306         $template->append('errors', l10n('PP_Default user is not unlockable'));
    307       }
    308       if (in_array($conf['webmaster_id'], $collection))
    309       {
    310         array_push($page['errors'], l10n('PP_Webmaster is not unlockable'));
    311         $template->append('errors', l10n('PP_Webmaster is not unlockable'));
    312       }
    313       if (in_array($user['id'], $collection))
    314       {
    315         array_push($page['errors'], l10n('PP_You cannot unlock your account'));
    316         $template->append('errors', l10n('PP_You cannot unlock your account'));
    317       }
    318 
    319       // Generic accounts exclusion (including Adult_Content generic users)
    320       // ------------------------------------------------------------------
    321       $query ='
    322 SELECT u.id
    323 FROM '.USERS_TABLE.' AS u
    324 INNER JOIN '.USER_INFOS_TABLE.' AS ui
    325   ON u.id = ui.user_id
    326 WHERE ui.status = "generic"
    327 ;';
    328 
    329             $result = pwg_query($query);
    330 
    331       while ($row = pwg_db_fetch_assoc($result))
    332       {
    333         if (in_array($row['id'], $collection))
    334         {
    335           array_push($page['errors'], l10n('PP_Generic is not unlockable'));
    336           $errors = l10n('PP_Generic is not unlockable');
    337         }
    338       }
    339 
    340       // Admins accounts exclusion
    341       // --------------------------
    342       $query ='
    343 SELECT u.id
    344 FROM '.USERS_TABLE.' AS u
    345 INNER JOIN '.USER_INFOS_TABLE.' AS ui
    346   ON u.id = ui.user_id
    347 WHERE ui.status = "admin"
    348 ;';
    349 
    350             $result = pwg_query($query);
    351 
    352       while ($row = pwg_db_fetch_assoc($result))
    353       {
    354         if (in_array($row['id'], $collection))
    355         {
    356           array_push($page['errors'], l10n('PP_Admins is not unlockable'));
    357           $errors = l10n('PP_Admins is not unlockable');
    358         }
    359       }
    360 
    361       $template->append('errors', $errors);
    362 
    363       if (count($page['errors']) == 0)
    364       {
    365         if (isset($_POST['confirm_unlock']) and 1 == $_POST['confirm_unlock'])
    366         {
    367           foreach ($collection as $user_id)
    368           {
    369             PP_unlock_user($user_id);
    370           }
    371           array_push(
    372             $page['infos'],
    373             l10n_dec(
    374               'PP %d user unlocked', 'PP %d users unlocked',
    375               count($collection)
    376               )
    377             );
    378           $template->append('infos', l10n_dec(
    379               'PP %d user unlocked', 'PP %d users unlocked',
    380               count($collection)));
    381           foreach ($page['filtered_users'] as $filter_key => $filter_user)
    382           {
    383             if (in_array($filter_user['id'], $collection))
    384             {
    385               unset($page['filtered_users'][$filter_key]);
    386             }
    387           }
    388         }
    389         else
    390         {
    391           array_push($page['errors'], l10n('PP_You need to confirm unlock'));
    392           $template->append('errors', l10n('PP_You need to confirm unlock'));
    393         }
    394       }
    395     }
    396     $template->set_prefilter('user_list', 'PP_Unlocking_Prefilter');
    397   }
    398 
    399   /**
    400    * PP_Unlocking_Prefilter
    401    * Adds action field for user unlocking in user_list.tpl
    402    */
    403   function PP_Unlocking_Prefilter($content, &$smarty)
    404   {
    405     $search = '
    406 <fieldset>
    407   <legend>{\'Deletions\'|@translate}</legend>
    408   <label><input type="checkbox" name="confirm_deletion" value="1"> {\'confirm\'|@translate}</label>
    409   <input class="submit" type="submit" value="{\'Delete selected users\'|@translate}" name="delete">
    410 </fieldset>
    411 ';
    412  
    413     $addon = '
    414 <fieldset>
    415   <legend>{\'PP_Unlock\'|@translate}</legend>
    416   <label><input type="checkbox" name="confirm_unlock" value="1"> {\'confirm\'|@translate}</label>
    417   <input class="submit" type="submit" value="{\'PP_Unlock selected users\'|@translate}" name="unlock">
    418 </fieldset>
    419 ';
    420 
    421     $replacement = $addon.$search;
    422 
    423     return str_replace($search, $replacement, $content);
    424   }
    425 }
    42650?>
Note: See TracChangeset for help on using the changeset viewer.