Ignore:
Timestamp:
Jun 27, 2009, 12:00:31 AM (15 years ago)
Author:
Eric
Message:

List of users who have registered since x days is working.

TODO:Adding new option [Auto deletion : True | False]

Adding new option [Resend_new_validation_key : True | False]
Adding condition in user list request [if user in USER_CONFIRM_MAIL_TABLE]

Link deletion to all users selected or single user
Function to send a new validation key to all | single | selected users
Changing ACTION from $properties to Single_Deletion
Adding new ACTION to Resend new validation key

File:
1 edited

Legend:

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

    r3460 r3470  
    2222// +-----------------------------------------------------------------------+
    2323if (!isset($_GET['tab']))
    24     $page['tab'] = 'global';
     24  $page['tab'] = 'global';
    2525else
    26     $page['tab'] = $_GET['tab'];
     26  $page['tab'] = $_GET['tab'];
    2727
    2828$tabsheet = new tabsheet();
     
    5151// |                           Global Config                               |
    5252// +-----------------------------------------------------------------------+
    53         case 'global':
    54        
    55         if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_Mail_Info']) and isset($_POST['UserAdvManager_No_Casse']) and isset($_POST['UserAdvManager_Username_Char']) and isset($_POST['UserAdvManager_Confirm_Mail']) and isset($_POST['UserAdvManager_No_Comment_Anonymous']) )
     53  case 'global':
     54       
     55  if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_Mail_Info']) and isset($_POST['UserAdvManager_No_Casse']) and isset($_POST['UserAdvManager_Username_Char']) and isset($_POST['UserAdvManager_Confirm_Mail']) and isset($_POST['UserAdvManager_No_Comment_Anonymous']) )
     56  {
     57    $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text']));
     58        $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text']));
     59               
     60        $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List'];
     61               
     62        $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager;
     63               
     64        $query = '
     65          UPDATE '.CONFIG_TABLE.'
     66          SET value="'.$newconf_nbc_UserAdvManager.'"
     67          WHERE param="nbc_UserAdvManager"
     68          LIMIT 1
     69          ;';
     70               
     71        pwg_query($query);
     72               
     73        array_push($page['infos'], l10n('UserAdvManager_save_config'));
     74  }
     75       
     76  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     77       
     78/* Group setting for unvalidated and validated users */
     79  $groups[-1] = '---------';
     80  $No_Valid = -1;
     81  $Valid = -1;
     82       
     83/* Check groups list in database  */
     84  $query = '
     85    SELECT id, name
     86        FROM '.GROUPS_TABLE.'
     87        ORDER BY name ASC
     88        ;';
     89       
     90  $result = pwg_query($query);
     91       
     92  while ($row = mysql_fetch_array($result))
     93  {
     94    $groups[$row['id']] = $row['name'];
     95/* configuration value for unvalidated users */
     96    if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id'])
     97    {
     98          $No_Valid = $row['id'];
     99        }
     100/* configuration value for validated users */
     101    if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id'])
    56102        {
    57                 $_POST['UserAdvManager_MailInfo_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_MailInfo_Text']));
    58                 $_POST['UserAdvManager_ConfirmMail_Text'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_Text']));
    59                
    60                 $newconf_nbc_UserAdvManager = $_POST['UserAdvManager_Mail_Info'].';'.$_POST['UserAdvManager_No_Casse'].';'.$_POST['UserAdvManager_Confirm_Mail'].';'.(isset($_POST['UserAdvManager_No_Confirm_Group'])?$_POST['UserAdvManager_No_Confirm_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Group'])?$_POST['UserAdvManager_Validated_Group']:'').';'.(isset($_POST['UserAdvManager_Validated_Status'])?$_POST['UserAdvManager_Validated_Status']:'').';'.$_POST['UserAdvManager_No_Comment_Anonymous'].';'.$_POST['UserAdvManager_Username_Char'].';'.$_POST['UserAdvManager_Username_List'].';'.(isset($_POST['UserAdvManager_No_Confirm_Status'])?$_POST['UserAdvManager_No_Confirm_Status']:'').';'.$_POST['UserAdvManager_MailInfo_Text'].';'.$_POST['UserAdvManager_ConfirmMail_Text'].';'.$_POST['UserAdvManager_MailExclusion'].';'.$_POST['UserAdvManager_MailExclusion_List'];
    61                
    62                 $conf['nbc_UserAdvManager'] = $newconf_nbc_UserAdvManager;
    63                
    64                 $query = '
    65                   UPDATE '.CONFIG_TABLE.'
    66                   SET value="'.$newconf_nbc_UserAdvManager.'"
    67                   WHERE param="nbc_UserAdvManager"
    68                   LIMIT 1
    69                   ;';
    70                
    71                 pwg_query($query);
    72                
    73                 array_push($page['infos'], l10n('UserAdvManager_save_config'));
     103          $Valid = $row['id'];
    74104        }
    75        
    76         $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    77        
    78         /* Group setting for unvalidated and validated users */
    79         $groups[-1] = '---------';
    80         $No_Valid = -1;
    81         $Valid = -1;
    82        
    83         /* Check groups list in database  */
    84         $query = '
    85           SELECT id, name
    86           FROM '.GROUPS_TABLE.'
    87           ORDER BY name ASC
    88           ;';
    89        
    90         $result = pwg_query($query);
    91        
    92         while ($row = mysql_fetch_array($result))
    93         {
    94                 $groups[$row['id']] = $row['name'];
    95                 /* configuration value for unvalidated users */
    96                 if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == $row['id'])
    97                 {
    98                         $No_Valid = $row['id'];
     105  }
     106       
     107/* Template initialization for unvalidated users group */
     108  $template->assign(
     109    'No_Confirm_Group',
     110    array(
     111          'group_options'=> $groups,
     112          'group_selected' => $No_Valid
     113        )
     114  );
     115/* Template initialization for validated users group */
     116  $template->assign(
     117    'Validated_Group',
     118        array(
     119      'group_options'=> $groups,
     120      'group_selected' => $Valid
     121        )
     122  );
     123       
     124/* Status setting for unvalidated and validated users */
     125  $status_options[-1] = '------------';
     126  $No_Valid_Status = -1;
     127  $Valid_Status = -1;
     128       
     129/* Get status values */
     130  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
     131    {
     132          $status_options[$status] = l10n('user_status_'.$status);
     133          if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status)
     134          {
     135            $No_Valid_Status = $status;
     136          }
     137/* Template initialization for unvalidated users group */
     138      $template->assign(
     139        'No_Confirm_Status',
     140        array(
     141                  'Status_options' => $status_options,
     142                  'Status_selected' => $No_Valid_Status
     143                )
     144          );
     145    }
     146/* Get status values */
     147  foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
     148    {
     149          $status_options[$status] = l10n('user_status_'.$status);
     150          if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status)
     151            {
     152                  $Valid_Status = $status;
    99153                }
    100                 /* configuration value for validated users */
    101                 if (isset($conf_nbc_UserAdvManager[4]) and $conf_nbc_UserAdvManager[4] == $row['id'])
    102                 {
    103                         $Valid = $row['id'];
    104                 }
    105         }
    106        
    107         /* Template initialization for unvalidated users group */
    108         $template->assign(
    109         'No_Confirm_Group',
    110         array(
    111                 'group_options'=> $groups,
    112                 'group_selected' => $No_Valid
     154/* Template initialization for unvalidated users group */
     155      $template->assign(
     156            'Confirm_Status',
     157            array(
     158                  'Status_options' => $status_options,
     159                  'Status_selected' => $Valid_Status
    113160                )
    114         );
    115         /* Template initialization for validated users group */
    116         $template->assign(
    117         'Validated_Group',
    118         array(
    119         'group_options'=> $groups,
    120         'group_selected' => $Valid
    121                 )
    122         );
    123        
    124         /* Status setting for unvalidated and validated users */
    125         $status_options[-1] = '------------';
    126         $No_Valid_Status = -1;
    127         $Valid_Status = -1;
    128        
    129         /* Get status values */
    130         foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    131         {
    132                 $status_options[$status] = l10n('user_status_'.$status);
    133                 if (isset($conf_nbc_UserAdvManager[9]) and $conf_nbc_UserAdvManager[9] == $status)
    134                 {
    135                         $No_Valid_Status = $status;
    136                 }
    137         /* Template initialization for unvalidated users group */
    138         $template->assign(
    139     'No_Confirm_Status',
    140         array(
    141                 'Status_options' => $status_options,
    142                 'Status_selected' => $No_Valid_Status
    143                 )
    144         );
    145        
    146         }
    147         /* Get status values */
    148         foreach (get_enums(USER_INFOS_TABLE, 'status') as $status)
    149         {
    150                 $status_options[$status] = l10n('user_status_'.$status);
    151                 if (isset($conf_nbc_UserAdvManager[5]) and $conf_nbc_UserAdvManager[5] == $status)
    152                 {
    153                         $Valid_Status = $status;
    154                 }
    155         /* Template initialization for unvalidated users group */
    156         $template->assign(
    157         'Confirm_Status',
    158         array(
    159                 'Status_options' => $status_options,
    160                 'Status_selected' => $Valid_Status
    161                 )
    162         );
    163        
    164         }
    165        
    166        
    167         $template->assign(
    168         array(
     161          );
     162    }
     163       
     164  $template->assign(
     165    array(
    169166                'UserAdvManager_MAIL_INFO_TRUE'       => $conf_nbc_UserAdvManager[0]=='true' ?  'checked="checked"' : '' ,
    170167                'UserAdvManager_MAIL_INFO_FALSE'      => $conf_nbc_UserAdvManager[0]=='false' ?  'checked="checked"' : '' ,
     
    187184                'UserAdvManager_MAILEXCLUSION_FALSE'  => $conf_nbc_UserAdvManager[12]=='false' ?  'checked="checked"' : '' ,
    188185                'UserAdvManager_MAILEXCLUSION_LIST'   => $conf_nbc_UserAdvManager[13],
    189                 )
    190         );
    191        
    192 
    193         if ( isset($_POST['audit']) or isset($_POST['submit']) )
    194         {
    195                 $msg_error1 = '';
    196                
    197                 /* username insensible a la casse */
    198                 if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true')
    199                 {
    200                         $query = "
    201                           SELECT ".$conf['user_fields']['username']."
    202                           FROM ".USERS_TABLE." p1
    203                           WHERE EXISTS(
    204                           SELECT ".$conf['user_fields']['username']."
    205                           FROM ".USERS_TABLE." p2
    206                           WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']."
    207                           AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].")
    208                           )
    209                           ;";
     186    )
     187  );
     188       
     189
     190  if ( isset($_POST['audit']) or isset($_POST['submit']) )
     191    {
     192          $msg_error1 = '';
     193               
     194/* username insensible a la casse */
     195      if (isset($conf_nbc_UserAdvManager[3]) and $conf_nbc_UserAdvManager[3] == 'true')
     196            {
     197                  $query = "
     198                    SELECT ".$conf['user_fields']['username']."
     199                        FROM ".USERS_TABLE." p1
     200                        WHERE EXISTS(
     201                        SELECT ".$conf['user_fields']['username']."
     202                        FROM ".USERS_TABLE." p2
     203                        WHERE p1.".$conf['user_fields']['id']." <> p2.".$conf['user_fields']['id']."
     204                        AND LOWER(p1.".$conf['user_fields']['username'].") = LOWER(p2.".$conf['user_fields']['username'].")
     205                        )
     206                        ;";
    210207                         
    211                         $result = pwg_query($query);
     208                  $result = pwg_query($query);
    212209                       
    213                         while($row = mysql_fetch_array($result))
    214                         {
    215                                 $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username'];
     210                  while($row = mysql_fetch_array($result))
     211                    {
     212                          $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username'];
    216213                        }
    217214                }
    218215
    219 
    220                 $msg_error2 = '';
    221                
    222                 /* Username without forbidden keys */
    223                 if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' )
    224                 {
    225                         $query = "
    226                           SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']."
    227                           FROM ".USERS_TABLE."
    228                           ;";
     216      $msg_error2 = '';
     217               
     218/* Username without forbidden keys */
     219      if ( isset($conf_nbc_UserAdvManager[7]) and $conf_nbc_UserAdvManager[7] == 'true' )
     220            {
     221                  $query = "
     222                    SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']."
     223                        FROM ".USERS_TABLE."
     224                        ;";
    229225                         
    230                         $result = pwg_query($query);
     226                  $result = pwg_query($query);
    231227                       
    232                         while($row = mysql_fetch_array($result))
    233                         {
    234                                 if ( !ValidateUsername($row['username']) )
    235                                 $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username'];
     228                  while($row = mysql_fetch_array($result))
     229                    {
     230                          if ( !ValidateUsername($row['username']) )
     231                            $msg_error2 .= (($msg_error2 <> '') ? '<br/>' : '') . l10n('Err_audit_username_char').$row['username'];
    236232                        }
    237233                }
    238234
    239                
    240                 $msg_error3 = '';
    241                
    242                 /* Email without forbidden domain */
    243                 if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' )
    244                 {
    245                         $query = "
    246                           SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']."
    247                           FROM ".USERS_TABLE."
    248                           ;";
     235      $msg_error3 = '';
     236               
     237/* Email without forbidden domain */
     238      if ( isset($conf_nbc_UserAdvManager[12]) and $conf_nbc_UserAdvManager[12] == 'true' )
     239            {
     240                  $query = "
     241                    SELECT ".$conf['user_fields']['username'].", ".$conf['user_fields']['email']."
     242                        FROM ".USERS_TABLE."
     243                        ;";
    249244                         
    250                         $result = pwg_query($query);
     245                  $result = pwg_query($query);
    251246                       
    252                         while($row = mysql_fetch_array($result))
    253                         {
    254                                 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    255                                 $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]);
    256                                 for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
    257                                 {
    258                                         if (ereg($conf_nbc_MailExclusion[$i], $row['mail_address']))
    259                                         {
    260                                                 $msg_error3 .=  (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')';
     247                  while($row = mysql_fetch_array($result))
     248                    {
     249                          $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     250                          $conf_nbc_MailExclusion = split (",",$conf_nbc_UserAdvManager[13]);
     251                          for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
     252                            {
     253                                  if (ereg($conf_nbc_MailExclusion[$i], $row['mail_address']))
     254                                    {
     255                                          $msg_error3 .=  (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')';
    261256                                        }
    262257                                }
     
    264259                }
    265260               
    266                 if ($msg_error1 <> '')
    267                 $errors[] = $msg_error1.'<br/><br/>';
    268                
    269                 if ($msg_error2 <> '')
    270                 $errors[] = $msg_error2.'<br/><br/>';
    271                
    272                 if ($msg_error3 <> '')
    273                 $errors[] = $msg_error3.'<br/><br/>';
    274                
    275                 if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '')
    276                         array_push($page['errors'], l10n('Err_audit_advise'));
    277                 else
    278                         array_push($page['infos'], l10n('UserAdvManager_audit_ok'));
    279         }
     261      if ($msg_error1 <> '')
     262            $errors[] = $msg_error1.'<br/><br/>';
     263               
     264      if ($msg_error2 <> '')
     265            $errors[] = $msg_error2.'<br/><br/>';
     266               
     267          if ($msg_error3 <> '')
     268            $errors[] = $msg_error3.'<br/><br/>';
     269               
     270          if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '')
     271            array_push($page['errors'], l10n('Err_audit_advise'));
     272          else
     273        array_push($page['infos'], l10n('UserAdvManager_audit_ok'));
     274    }
    280275
    281276
     
    283278// |                             errors display                            |
    284279// +-----------------------------------------------------------------------+
    285         if ( isset ($errors) and count($errors) != 0)
    286         {
    287                 $template->assign('errors',array());
    288                 foreach ($errors as $error)
    289                 {
    290                         array_push($page['errors'], $error);
     280  if ( isset ($errors) and count($errors) != 0)
     281    {
     282          $template->assign('errors',array());
     283          foreach ($errors as $error)
     284            {
     285                  array_push($page['errors'], $error);
    291286                }
    292287        } 
     
    295290// |                           templates display                           |
    296291// +-----------------------------------------------------------------------+
    297         $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl');
    298         $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    299 
    300         break;
     292  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl');
     293  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
     294
     295  break;
    301296
    302297// +-----------------------------------------------------------------------+
    303298// |                           ConfirmMail Config                          |
    304299// +-----------------------------------------------------------------------+
    305         case 'confirmmail':
    306        
    307         $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
    308        
    309         if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' )
    310         {
    311                 if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) )
    312                 {               
    313                         $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay'];
    314                        
    315                         $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail;
    316                
    317                         $query = '
    318                           UPDATE '.CONFIG_TABLE.'
    319                           SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'"
    320                           WHERE param="nbc_UserAdvManager_ConfirmMail"
    321                           LIMIT 1
    322                           ;';
    323                
    324                         pwg_query($query);
    325                
    326                         array_push($page['infos'], l10n('UserAdvManager_save_config'));
     300  case 'confirmmail':
     301       
     302  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
     303       
     304  if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' )
     305    {
     306      if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) )
     307            {           
     308                  $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay'];
     309        //TODO:Adding new option [Auto deletion : True | False]
     310        //TODO:Adding new option [Resend_new_validation_key : True | False]
     311                  $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail;
     312               
     313                  $query = '
     314                    UPDATE '.CONFIG_TABLE.'
     315                        SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'"
     316                        WHERE param="nbc_UserAdvManager_ConfirmMail"
     317                        LIMIT 1
     318                        ;';
     319               
     320                  pwg_query($query);
     321               
     322                  array_push($page['infos'], l10n('UserAdvManager_save_config'));
    327323                }
    328324       
    329                 $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
    330 
    331 function get_unvalid_user_list()
    332 {
    333   global $conf, $page;
     325      $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
     326
     327      function get_unvalid_user_list()
     328        {
     329          global $conf, $page;
    334330 
    335   $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 
     331          $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array(); 
    336332 
    337   $users = array();
    338 
    339   // search users depending on filters and order
    340   $query = '
    341 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
    342                 u.'.$conf['user_fields']['username'].' AS username,
    343                 u.'.$conf['user_fields']['email'].' AS email,
    344                 ui.status,
    345                 ui.adviser,
    346                 ui.enabled_high,
    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 
    359   $result = pwg_query($query);
    360   while ($row = mysql_fetch_array($result))
    361   {
    362     $user = $row;
    363     $user['groups'] = array();
    364 
    365     array_push($users, $user);
    366   }
    367 
    368   // add group lists
    369   $user_ids = array();
    370   foreach ($users as $i => $user)
    371   {
    372     $user_ids[$i] = $user['id'];
    373   }
    374   $user_nums = array_flip($user_ids);
    375 
    376   if (count($user_ids) > 0)
    377   {
    378     $query = '
    379 SELECT user_id, group_id
    380   FROM '.USER_GROUP_TABLE.'
    381   WHERE user_id IN ('.implode(',', $user_ids).')
    382 ;';
    383     $result = pwg_query($query);
    384     while ($row = mysql_fetch_array($result))
     333          $users = array();
     334   
     335/* search users depending on filters and order */
     336//TODO:Adding condition in request [if user in USER_CONFIRM_MAIL_TABLE]
     337          $query = '
     338            SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
     339                            u.'.$conf['user_fields']['username'].' AS username,
     340                            u.'.$conf['user_fields']['email'].' AS email,
     341                            ui.status,
     342                            ui.adviser,
     343                            ui.enabled_high,
     344                            ui.level,
     345                            ui.registration_date
     346            FROM '.USERS_TABLE.' AS u
     347            INNER JOIN '.USER_INFOS_TABLE.' AS ui
     348              ON u.'.$conf['user_fields']['id'].' = ui.user_id
     349            LEFT JOIN '.USER_GROUP_TABLE.' AS ug
     350              ON u.'.$conf['user_fields']['id'].' = ug.user_id
     351            WHERE u.'.$conf['user_fields']['id'].' > 0
     352            AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= '.$conf_nbc_UserAdvManager_ConfirmMail[1].'
     353            ORDER BY id ASC
     354          ;';
     355
     356          $result = pwg_query($query);
     357     
     358          while ($row = mysql_fetch_array($result))
     359            {
     360              $user = $row;
     361              $user['groups'] = array();
     362
     363              array_push($users, $user);
     364            }
     365
     366/* add group lists */
     367          $user_ids = array();
     368          foreach ($users as $i => $user)
     369            {
     370              $user_ids[$i] = $user['id'];
     371            }
     372          $user_nums = array_flip($user_ids);
     373
     374          if (count($user_ids) > 0)
     375            {
     376              $query = '
     377                SELECT user_id, group_id
     378                FROM '.USER_GROUP_TABLE.'
     379                WHERE user_id IN ('.implode(',', $user_ids).')
     380              ;';
     381       
     382              $result = pwg_query($query);
     383       
     384                  while ($row = mysql_fetch_array($result))
     385                {
     386                  array_push(
     387                    $users[$user_nums[$row['user_id']]]['groups'],
     388                    $row['group_id']
     389                  );
     390                }
     391              }
     392
     393          return $users;
     394        }
     395
     396// +-----------------------------------------------------------------------+
     397// |                           initialization                              |
     398// +-----------------------------------------------------------------------+
     399
     400        if (!defined('PHPWG_ROOT_PATH'))
     401          {
     402            die('Hacking attempt!');
     403          }
     404         
     405        include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     406
     407// +-----------------------------------------------------------------------+
     408// | Check Access and exit when user status is not ok                      |
     409// +-----------------------------------------------------------------------+
     410        check_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//TODO:Link deletion to all users selected or single user
     429        if (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// +-----------------------------------------------------------------------+
     462        if (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
     498                    foreach ($page['filtered_users'] as $filter_key => $filter_user)
     499                      {
     500                        if (in_array($filter_user['id'], $collection))
     501                          {
     502                            unset($page['filtered_users'][$filter_key]);
     503                          }
     504                      }
     505                  }
     506                else
     507                  {
     508                    array_push($page['errors'], l10n('You need to confirm deletion'));
     509                  }
     510               }
     511          }
     512// +-----------------------------------------------------------------------+
     513// |                 Resend new validation key to users                    |
     514// +-----------------------------------------------------------------------+
     515
     516//TODO:Function to send a new validation key to all | single | selected users
     517
     518// +-----------------------------------------------------------------------+
     519// |                              groups list                              |
     520// +-----------------------------------------------------------------------+
     521
     522          $groups[-1] = '------------';
     523
     524          $query = '
     525            SELECT id, name
     526            FROM '.GROUPS_TABLE.'
     527            ORDER BY name ASC
     528            ;';
     529
     530          $result = pwg_query($query);
     531         
     532          while ($row = mysql_fetch_array($result))
     533            {
     534              $groups[$row['id']] = $row['name'];
     535            }
     536
     537// +-----------------------------------------------------------------------+
     538// |                           Template Init                               |
     539// +-----------------------------------------------------------------------+
     540        $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
     541
     542        if (isset($_GET['start']) and is_numeric($_GET['start']))
     543          {
     544            $start = $_GET['start'];
     545          }
     546        else
     547          {
     548            $start = 0;
     549          }
     550
     551        $template->assign(
     552          array(
     553            'F_ADD_ACTION' => $base_url,
     554            'F_USERNAME' => @htmlentities($_GET['username']),
     555            'F_FILTER_ACTION' => get_root_url().'admin.php'
     556            )
     557          );
     558
     559/* Hide radio-button if not allow to assign adviser */
     560        if ($conf['allow_adviser'])
     561          {
     562            $template->assign('adviser', true);
     563          }
     564       
     565// +-----------------------------------------------------------------------+
     566// |                               user list                               |
     567// +-----------------------------------------------------------------------+
     568
     569        $profile_url = get_root_url().'admin.php?page=profile&amp;user_id=';
     570        $perm_url = get_root_url().'admin.php?page=user_perm&amp;user_id=';
     571
     572        $visible_user_list = array();
     573        foreach ($page['filtered_users'] as $num => $local_user)
     574          {
     575/* simulate LIMIT $start, $conf['users_page'] */
     576            if ($num < $start)
     577              {
     578                continue;
     579              }
     580            if ($num >= $start + $conf['users_page'])
     581              {
     582                break;
     583              }
     584
     585            $visible_user_list[] = $local_user;
     586          }
     587
     588        foreach ($visible_user_list as $local_user)
     589          {
     590            $groups_string = preg_replace(
     591              '/(\d+)/e',
     592              "\$groups['$1']",
     593              implode(
     594                ', ',
     595                $local_user['groups']
     596              )
     597            );
     598
     599            if (isset($_POST['pref_submit'])
     600              and isset($_POST['selection'])
     601              and in_array($local_user['id'], $_POST['selection']))
     602              {
     603                $checked = 'checked="checked"';
     604              }
     605            else
     606              {
     607                $checked = '';
     608              }
     609
     610            $properties = array();
     611            if ( $local_user['level'] != 0 )
     612              {
     613                $properties[] = l10n( sprintf('Level %d', $local_user['level']) );
     614              }
     615            $properties[] =
     616            (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true'))
     617              ? l10n('is_high_enabled') : l10n('is_high_disabled');
     618             
     619            if (isset($conf_nbc_UserAdvManager_ConfirmMail[1]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' )
     620              {
     621                $template->append(
     622                  'users',
     623                  array(
     624                    'ID' => $local_user['id'],
     625                    'CHECKED' => $checked,
     626                    'U_PROFILE' => $profile_url.$local_user['id'],
     627                    'U_PERM' => $perm_url.$local_user['id'],
     628                    'USERNAME' => $local_user['username']
     629                      .($local_user['id'] == $conf['guest_id']
     630                        ? '<BR />['.l10n('is_the_guest').']' : '')
     631                      .($local_user['id'] == $conf['default_user_id']
     632                        ? '<BR />['.l10n('is_the_default').']' : ''),
     633                    'STATUS' => l10n('user_status_'.
     634                      $local_user['status']).(($local_user['adviser'] == 'true')
     635                      ? '<BR />['.l10n('adviser').']' : ''),
     636                    'EMAIL' => get_email_address_as_display_text($local_user['email']),
     637                    'GROUPS' => $groups_string,
     638                    //TODO:Changing ACTION from $properties to Single_Deletion
     639                    //TODO:Addin new ACTION to Resend new validation key
     640                    'ACTION' => implode( ', ', $properties),
     641                  )
     642                );
     643              }
     644          }             
     645
     646          $template->assign(
     647            array(
     648                  'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE'             => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ?  'checked="checked"' : '' ,
     649                  'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE'    => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ?  'checked="checked"' : '' ,
     650                  'UserAdvManager_CONFIRMMAIL_DELAY'                    => $conf_nbc_UserAdvManager_ConfirmMail[1],
     651                  //TODO:Adding new option [Auto Deletion : True | False]
     652                  //TODO:Adding new option [Resend_new_validation_key : True | False]
     653            )
     654          );           
     655
     656// +-----------------------------------------------------------------------+
     657// |                             errors display                            |
     658// +-----------------------------------------------------------------------+
     659          if ( isset ($errors) and count($errors) != 0)
     660            {
     661              $template->assign('errors',array());
     662              foreach ($errors as $error)
     663                        {
     664                          array_push($page['errors'], $error);
     665                        }
     666                } 
     667
     668// +-----------------------------------------------------------------------+
     669// |                           templates display                           |
     670// +-----------------------------------------------------------------------+
     671      $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl');
     672      $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');               
     673    }
     674  else
    385675    {
    386       array_push(
    387         $users[$user_nums[$row['user_id']]]['groups'],
    388         $row['group_id']
    389         );
     676          array_push($page['infos'], l10n('Err_ConfirmMail_Settings'));
    390677    }
    391   }
    392 
    393   return $users;
     678  break;
    394679}
    395 
    396 // +-----------------------------------------------------------------------+
    397 // |                           initialization                              |
    398 // +-----------------------------------------------------------------------+
    399 
    400 if (!defined('PHPWG_ROOT_PATH'))
    401 {
    402   die('Hacking attempt!');
    403 }
    404 
    405 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    406 
    407 // +-----------------------------------------------------------------------+
    408 // | Check Access and exit when user status is not ok                      |
    409 // +-----------------------------------------------------------------------+
    410 check_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 
    429 if (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 // +-----------------------------------------------------------------------+
    462 if (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 = '
    519 SELECT id, name
    520   FROM '.GROUPS_TABLE.'
    521   ORDER BY name ASC
    522 ;';
    523 $result = pwg_query($query);
    524 
    525 while ($row = mysql_fetch_array($result))
    526 {
    527   $groups[$row['id']] = $row['name'];
    528 }
    529 
    530 // +-----------------------------------------------------------------------+
    531 // |                           Template Init                               |
    532 // +-----------------------------------------------------------------------+
    533 $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
    534 
    535 if (isset($_GET['start']) and is_numeric($_GET['start']))
    536 {
    537   $start = $_GET['start'];
    538 }
    539 else
    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
    552 if ($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();
    566 foreach ($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 
    581 foreach ($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 
    634         $template->assign(
    635         array(
    636                 'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE'       => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ?  'checked="checked"' : '' ,
    637                 'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE'      => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ?  'checked="checked"' : '' ,
    638                 'UserAdvManager_CONFIRMMAIL_DELAY'                  => $conf_nbc_UserAdvManager_ConfirmMail[1],
    639                 )
    640         );             
    641 
    642 // +-----------------------------------------------------------------------+
    643 // |                             errors display                            |
    644 // +-----------------------------------------------------------------------+
    645         if ( isset ($errors) and count($errors) != 0)
    646         {
    647                 $template->assign('errors',array());
    648                 foreach ($errors as $error)
    649                 {
    650                         array_push($page['errors'], $error);
    651                 }
    652         } 
    653 
    654 // +-----------------------------------------------------------------------+
    655 // |                           templates display                           |
    656 // +-----------------------------------------------------------------------+
    657         $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl');
    658         $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');             
    659         }
    660         else
    661         {
    662                 array_push($page['infos'], l10n('Err_ConfirmMail_Settings'));
    663 
    664         }
    665         break;
    666 
    667 }
    668 
    669680?>
Note: See TracChangeset for help on using the changeset viewer.