Changeset 3460


Ignore:
Timestamp:
Jun 25, 2009, 11:18:36 PM (15 years ago)
Author:
Eric
Message:

Listing of expired users (when [NOW()- registration_date] <= [plugin_expiration_conf]) is near to be OK.
TODO :

  • Setting conf for auto-delete (true | false)
  • Adding auto-deletion functions and manual deletion functions
Location:
extensions/NBC_UserAdvManager-Trunk/admin
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/NBC_UserAdvManager-Trunk/admin/UserAdvManager_admin.php

    r3444 r3460  
    301301
    302302// +-----------------------------------------------------------------------+
    303 // |                           ConfirMail Config                           |
     303// |                           ConfirmMail Config                          |
    304304// +-----------------------------------------------------------------------+
    305305        case 'confirmmail':
     
    329329                $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
    330330
    331         /* List timed out users */             
    332         /* Get registration date  */
    333         /* Under construction ;-) */
    334331function get_unvalid_user_list()
    335332{
    336 /*  global $conf, $page;
    337 
     333  global $conf, $page;
     334 
     335  $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 
     336 
    338337  $users = array();
    339   $order_by = 'id';
    340   $direction = 'ASC';
     338
     339  // search users depending on filters and order
    341340  $query = '
    342                         SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     341SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
    343342                u.'.$conf['user_fields']['username'].' AS username,
    344343                u.'.$conf['user_fields']['email'].' AS email,
     
    346345                ui.adviser,
    347346                ui.enabled_high,
    348                 ui.level
    349                         FROM '.USERS_TABLE.' AS u
    350                         INNER JOIN '.USER_INFOS_TABLE.' AS ui
    351                 ON u.'.$conf['user_fields']['id'].' = ui.user_id
    352                 LEFT JOIN '.USER_GROUP_TABLE.' AS ug
    353                 ON u.'.$conf['user_fields']['id'].' = ug.user_id
    354                         WHERE u.'.$conf['user_fields']['id'].' > 0';
    355   $query.= '
    356                         ORDER BY '.$order_by.' '.$direction.'
    357                         ;';
     347                ui.level,
     348                ui.registration_date
     349  FROM '.USERS_TABLE.' AS u
     350    INNER JOIN '.USER_INFOS_TABLE.' AS ui
     351      ON u.'.$conf['user_fields']['id'].' = ui.user_id
     352    LEFT JOIN '.USER_GROUP_TABLE.' AS ug
     353      ON u.'.$conf['user_fields']['id'].' = ug.user_id
     354  WHERE u.'.$conf['user_fields']['id'].' > 0
     355  AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) <= '.$conf_nbc_UserAdvManager_ConfirmMail[1].'
     356  ORDER BY id ASC
     357;';
     358
    358359  $result = pwg_query($query);
    359360  while ($row = mysql_fetch_array($result))
    360361  {
    361         $user = $row;
    362         $user['groups'] = array();
     362    $user = $row;
     363    $user['groups'] = array();
     364
    363365    array_push($users, $user);
    364366  }
     367
    365368  // add group lists
    366369  $user_ids = array();
     
    374377  {
    375378    $query = '
    376                         SELECT user_id, group_id
    377                         FROM '.USER_GROUP_TABLE.'
    378                         WHERE user_id IN ('.implode(',', $user_ids).')
    379                         ;';
    380    
    381         $result = pwg_query($query);
    382    
     379SELECT user_id, group_id
     380  FROM '.USER_GROUP_TABLE.'
     381  WHERE user_id IN ('.implode(',', $user_ids).')
     382;';
     383    $result = pwg_query($query);
    383384    while ($row = mysql_fetch_array($result))
    384385    {
     
    390391  }
    391392
    392   return $users;*/
    393 }
    394  
    395 /*              $query = "
    396                   SELECT user.username, user.mail_address, info.registration_date
    397                   FROM ".USERS_TABLE." as user, ".USER_INFOS_TABLE." as info
    398                   WHERE user.id = info.user_id
    399                   ;";
    400                  
    401                 $result = pwg_query($query);
    402                  
    403                 while ($row = mysql_fetch_array($result))
    404                 {
    405 
    406                 }*/
     393  return $users;
     394}
    407395
    408396// +-----------------------------------------------------------------------+
     
    414402  die('Hacking attempt!');
    415403}
     404
    416405include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    417406
    418 $page['filtered_users'] = get_unvalid_user_list();     
    419 
     407// +-----------------------------------------------------------------------+
     408// | Check Access and exit when user status is not ok                      |
     409// +-----------------------------------------------------------------------+
     410check_status(ACCESS_ADMINISTRATOR);
     411
     412$page['order_by_items'] = array(
     413  'id' => l10n('registration_date'),
     414  'username' => l10n('Username'),
     415  'level' => l10n('Privacy level'),
     416  'language' => l10n('language'),
     417  );
     418
     419// +-----------------------------------------------------------------------+
     420// |                               user list                               |
     421// +-----------------------------------------------------------------------+
     422
     423$page['filtered_users'] = get_unvalid_user_list();
     424
     425// +-----------------------------------------------------------------------+
     426// |                            selected users                             |
     427// +-----------------------------------------------------------------------+
     428
     429if (isset($_POST['delete']))
     430{
     431  $collection = array();
     432
     433  switch ($_POST['target'])
     434  {
     435    case 'all' :
     436    {
     437      foreach($page['filtered_users'] as $local_user)
     438      {
     439        array_push($collection, $local_user['id']);
     440      }
     441      break;
     442    }
     443    case 'selection' :
     444    {
     445      if (isset($_POST['selection']))
     446      {
     447        $collection = $_POST['selection'];
     448      }
     449      break;
     450    }
     451  }
     452
     453  if (count($collection) == 0)
     454  {
     455    array_push($page['errors'], l10n('Select at least one user'));
     456  }
     457}
     458
     459// +-----------------------------------------------------------------------+
     460// |                             delete users                              |
     461// +-----------------------------------------------------------------------+
     462if (isset($_POST['delete']) and count($collection) > 0)
     463{
     464  if (in_array($conf['guest_id'], $collection))
     465  {
     466    array_push($page['errors'], l10n('Guest cannot be deleted'));
     467  }
     468  if (($conf['guest_id'] != $conf['default_user_id']) and
     469      in_array($conf['default_user_id'], $collection))
     470  {
     471    array_push($page['errors'], l10n('Default user cannot be deleted'));
     472  }
     473  if (in_array($conf['webmaster_id'], $collection))
     474  {
     475    array_push($page['errors'], l10n('Webmaster cannot be deleted'));
     476  }
     477  if (in_array($user['id'], $collection))
     478  {
     479    array_push($page['errors'], l10n('You cannot delete your account'));
     480  }
     481
     482  if (count($page['errors']) == 0)
     483  {
     484    if (isset($_POST['confirm_deletion']) and 1 == $_POST['confirm_deletion'])
     485    {
     486      foreach ($collection as $user_id)
     487      {
     488        delete_user($user_id);
     489      }
     490      array_push(
     491        $page['infos'],
     492        l10n_dec(
     493          '%d user deleted', '%d users deleted',
     494          count($collection)
     495          )
     496        );
     497      foreach ($page['filtered_users'] as $filter_key => $filter_user)
     498      {
     499        if (in_array($filter_user['id'], $collection))
     500        {
     501          unset($page['filtered_users'][$filter_key]);
     502        }
     503      }
     504    }
     505    else
     506    {
     507      array_push($page['errors'], l10n('You need to confirm deletion'));
     508    }
     509  }
     510}
     511
     512// +-----------------------------------------------------------------------+
     513// |                              groups list                              |
     514// +-----------------------------------------------------------------------+
     515
     516$groups[-1] = '------------';
     517
     518$query = '
     519SELECT id, name
     520  FROM '.GROUPS_TABLE.'
     521  ORDER BY name ASC
     522;';
     523$result = pwg_query($query);
     524
     525while ($row = mysql_fetch_array($result))
     526{
     527  $groups[$row['id']] = $row['name'];
     528}
    420529
    421530// +-----------------------------------------------------------------------+
    422531// |                           Template Init                               |
    423532// +-----------------------------------------------------------------------+
     533$base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
     534
     535if (isset($_GET['start']) and is_numeric($_GET['start']))
     536{
     537  $start = $_GET['start'];
     538}
     539else
     540{
     541  $start = 0;
     542}
     543
     544$template->assign(
     545  array(
     546    'F_ADD_ACTION' => $base_url,
     547    'F_USERNAME' => @htmlentities($_GET['username']),
     548    'F_FILTER_ACTION' => get_root_url().'admin.php'
     549    ));
     550
     551// Hide radio-button if not allow to assign adviser
     552if ($conf['allow_adviser'])
     553{
     554  $template->assign('adviser', true);
     555}
     556
     557       
     558// +-----------------------------------------------------------------------+
     559// |                               user list                               |
     560// +-----------------------------------------------------------------------+
     561
     562$profile_url = get_root_url().'admin.php?page=profile&amp;user_id=';
     563$perm_url = get_root_url().'admin.php?page=user_perm&amp;user_id=';
     564
     565$visible_user_list = array();
     566foreach ($page['filtered_users'] as $num => $local_user)
     567{
     568  // simulate LIMIT $start, $conf['users_page']
     569  if ($num < $start)
     570  {
     571    continue;
     572  }
     573  if ($num >= $start + $conf['users_page'])
     574  {
     575    break;
     576  }
     577
     578  $visible_user_list[] = $local_user;
     579}
     580
     581foreach ($visible_user_list as $local_user)
     582{
     583  $groups_string = preg_replace(
     584    '/(\d+)/e',
     585    "\$groups['$1']",
     586    implode(
     587      ', ',
     588      $local_user['groups']
     589      )
     590    );
     591
     592  if (isset($_POST['pref_submit'])
     593      and isset($_POST['selection'])
     594      and in_array($local_user['id'], $_POST['selection']))
     595  {
     596    $checked = 'checked="checked"';
     597  }
     598  else
     599  {
     600    $checked = '';
     601  }
     602
     603  $properties = array();
     604  if ( $local_user['level'] != 0 )
     605  {
     606    $properties[] = l10n( sprintf('Level %d', $local_user['level']) );
     607  }
     608  $properties[] =
     609    (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true'))
     610        ? l10n('is_high_enabled') : l10n('is_high_disabled');
     611
     612  $template->append(
     613    'users',
     614    array(
     615      'ID' => $local_user['id'],
     616      'CHECKED' => $checked,
     617      'U_PROFILE' => $profile_url.$local_user['id'],
     618      'U_PERM' => $perm_url.$local_user['id'],
     619      'USERNAME' => $local_user['username']
     620        .($local_user['id'] == $conf['guest_id']
     621          ? '<BR />['.l10n('is_the_guest').']' : '')
     622        .($local_user['id'] == $conf['default_user_id']
     623          ? '<BR />['.l10n('is_the_default').']' : ''),
     624      'STATUS' => l10n('user_status_'.
     625        $local_user['status']).(($local_user['adviser'] == 'true')
     626        ? '<BR />['.l10n('adviser').']' : ''),
     627      'EMAIL' => get_email_address_as_display_text($local_user['email']),
     628      'GROUPS' => $groups_string,
     629      'ACTION' => implode( ', ', $properties),
     630      )
     631    );
     632}               
     633
    424634        $template->assign(
    425635        array(
     
    428638                'UserAdvManager_CONFIRMMAIL_DELAY'                  => $conf_nbc_UserAdvManager_ConfirmMail[1],
    429639                )
    430         );
    431                
    432                
     640        );             
    433641
    434642// +-----------------------------------------------------------------------+
  • extensions/NBC_UserAdvManager-Trunk/admin/confirmmail.tpl

    r3444 r3460  
    1111    <ul>
    1212        <li><label>{'UserAdvManager_ConfirmMail_Info'|@translate}</label><br/>
    13         <input type="radio" value="true" {$UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE} name="UserAdvManager_ConfirmMail_TimeOut"/>{'UserAdvManager_ConfirmMail_TimeOut_true'|@translate}<br/>
    14         <input type="radio" value="false" {$UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE} name="UserAdvManager_ConfirmMail_TimeOut"/>{'UserAdvManager_ConfirmMail_TimeOut_false'|@translate}<br/>
     13        <input type="radio" value="true" {$UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE} name="UserAdvManager_ConfirmMail_TimeOut"/> {'UserAdvManager_ConfirmMail_TimeOut_true'|@translate}<br/>
     14        <input type="radio" value="false" {$UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE} name="UserAdvManager_ConfirmMail_TimeOut"/> {'UserAdvManager_ConfirmMail_TimeOut_false'|@translate}<br/>
    1515        </li>
    1616      <br/>
     
    2525                        <td>{'Email address'|@translate}</td>
    2626                        <td>{'Groups'|@translate}</td>
    27                         <td>{'Actions'|@translate}</td>
     27                        <td>{'UserAdvManager_Indiv_Suppr'|@translate}</td>
    2828                        </tr>
    2929                        </thead>
     
    4141                {/foreach}
    4242                        <td style="text-align:center;">
    43                         <a href="{$user.U_PROFILE}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/edit_s.png" class="button" style="border:none" alt="{'Profile'|@translate}" title="{'Profile'|@translate}" /></a>
    44                 {foreach from=$user.plugin_actions item=data}
    45                         {$data}
    46                 {/foreach}
     43                        <a href="{$user.U_ACTION}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/edit_s.png" class="button" style="border:none" alt="{'Profile'|@translate}" title="{'Profile'|@translate}" /></a>
    4744                        </td>
    4845                        </tr>
Note: See TracChangeset for help on using the changeset viewer.