source: extensions/NBC_UserAdvManager/trunk/admin/UserAdvManager_admin.php @ 3845

Last change on this file since 3845 was 3845, checked in by Eric, 15 years ago
  • Finalization and improvement of resending validation mail with and without new key regeneration. That works fine now.
  • Adding of a new plugin tab to display users management table

-> Left to do :

  • Adding "force validation" function
  • Beta testing
  • Property svn:eol-style set to LF
File size: 28.3 KB
Line 
1<?php
2
3global $user, $lang, $conf, $errors;
4
5if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
6// +-----------------------------------------------------------------------+
7// | Check Access and exit when user status is not ok                      |
8// +-----------------------------------------------------------------------+
9check_status(ACCESS_ADMINISTRATOR);
10
11//ini_set('error_reporting', E_ALL);
12//ini_set('display_errors', true);
13
14include_once (PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
15include_once (PHPWG_ROOT_PATH.'/include/constants.php');
16$my_base_url = get_admin_plugin_menu_link(__FILE__);
17
18load_language('plugin.lang', NBC_UserAdvManager_PATH);
19
20// +-----------------------------------------------------------------------+
21// |                            Tabssheet                                  |
22// +-----------------------------------------------------------------------+
23if (!isset($_GET['tab']))
24        $page['tab'] = 'global';
25else
26  $page['tab'] = $_GET['tab'];
27
28$tabsheet = new tabsheet();
29$tabsheet->add('global',
30               l10n('Tab_Global'),
31               $my_base_url.'&amp;tab=global');
32$tabsheet->add('confirmmail',
33               l10n('Tab_ConfirmMail'),
34               $my_base_url.'&amp;tab=confirmmail');
35$tabsheet->add('usermanager',
36               l10n('Tab_UserManager'),
37               $my_base_url.'&amp;tab=usermanager');
38$tabsheet->select($page['tab']);
39$tabsheet->assign();
40
41$page['global'] = array();
42$error = array();
43
44// +-----------------------------------------------------------------------+
45// |                            Tabssheet select                           |
46// +-----------------------------------------------------------------------+
47
48switch ($page['tab'])
49{
50// +-----------------------------------------------------------------------+
51// |                           Global Config                               |
52// +-----------------------------------------------------------------------+
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'])
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
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;
153                }
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
160                    )
161            );
162        }
163       
164  $template->assign(
165    array(
166                'UserAdvManager_MAIL_INFO_TRUE'       => $conf_nbc_UserAdvManager[0]=='true' ?  'checked="checked"' : '' ,
167                'UserAdvManager_MAIL_INFO_FALSE'      => $conf_nbc_UserAdvManager[0]=='false' ?  'checked="checked"' : '' ,
168                'UserAdvManager_MAILINFO_TEXT'        => $conf_nbc_UserAdvManager[10],
169                'UserAdvManager_NO_CASSE_TRUE'        => $conf_nbc_UserAdvManager[1]=='true' ?  'checked="checked"' : '' ,
170                'UserAdvManager_NO_CASSE_FALSE'       => $conf_nbc_UserAdvManager[1]=='false' ?  'checked="checked"' : '' ,
171                'UserAdvManager_USERNAME_CHAR_TRUE'   => $conf_nbc_UserAdvManager[7]=='true' ?  'checked="checked"' : '' ,
172                'UserAdvManager_USERNAME_CHAR_FALSE'  => $conf_nbc_UserAdvManager[7]=='false' ?  'checked="checked"' : '' ,
173                'UserAdvManager_USERNAME_CHAR_LIST'   => $conf_nbc_UserAdvManager[8],
174                'UserAdvManager_CONFIRM_MAIL_TRUE'    => $conf_nbc_UserAdvManager[2]=='true' ?  'checked="checked"' : '' ,
175                'UserAdvManager_CONFIRM_MAIL_FALSE'   => $conf_nbc_UserAdvManager[2]=='false' ?  'checked="checked"' : '' ,
176                'UserAdvManager_CONFIRMMAIL_TEXT'     => $conf_nbc_UserAdvManager[11],
177                'UserAdvManager_No_Confirm_Group'     => $conf_nbc_UserAdvManager[3],
178                'UserAdvManager_Validated_Group'      => $conf_nbc_UserAdvManager[4],
179                'UserAdvManager_No_Confirm_Status'    => $conf_nbc_UserAdvManager[9],
180                'UserAdvManager_Validated_Status'     => $conf_nbc_UserAdvManager[5],
181                'UserAdvManager_NO_COMMENT_ANO_TRUE'  => $conf_nbc_UserAdvManager[6]=='true' ?  'checked="checked"' : '' ,
182                'UserAdvManager_NO_COMMENT_ANO_FALSE' => $conf_nbc_UserAdvManager[6]=='false' ?  'checked="checked"' : '' ,
183                'UserAdvManager_MAILEXCLUSION_TRUE'   => $conf_nbc_UserAdvManager[12]=='true' ?  'checked="checked"' : '' ,
184                'UserAdvManager_MAILEXCLUSION_FALSE'  => $conf_nbc_UserAdvManager[12]=='false' ?  'checked="checked"' : '' ,
185                'UserAdvManager_MAILEXCLUSION_LIST'   => $conf_nbc_UserAdvManager[13],
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                        ;";
207                         
208                  $result = pwg_query($query);
209                       
210                  while($row = mysql_fetch_array($result))
211                {
212                                $msg_error1 .= (($msg_error1 <> '') ? '<br/>' : '') . l10n('Err_audit_no_casse').$row['username'];
213                        }
214                }
215
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                                ;";
225                         
226                          $result = pwg_query($query);
227                       
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'];
232                                }
233                        }
234
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                                ;";
244                         
245                        $result = pwg_query($query);
246                       
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 = preg_split('/,/',$conf_nbc_UserAdvManager[13]);
251                                for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
252                            {
253                                                $pattern = '/'.$conf_nbc_MailExclusion[$i].'/';
254                                        if (preg_match($pattern, $row['mail_address']))
255                                    {
256                                                $msg_error3 .=  (($msg_error3 <> '') ? '<br/>' : '') . l10n('Err_audit_email_forbidden').$row['username'].' ('.$row['mail_address'].')';
257                                                }
258                                        }
259                                }
260                        }
261               
262      if ($msg_error1 <> '')
263                    $errors[] = $msg_error1.'<br/><br/>';
264               
265      if ($msg_error2 <> '')
266                    $errors[] = $msg_error2.'<br/><br/>';
267               
268                if ($msg_error3 <> '')
269                $errors[] = $msg_error3.'<br/><br/>';
270               
271                if ($msg_error1 <> '' or $msg_error2 <> '' or $msg_error3 <> '')
272                array_push($page['errors'], l10n('Err_audit_advise'));
273                else
274        array_push($page['infos'], l10n('UserAdvManager_audit_ok'));
275        }
276
277
278// +-----------------------------------------------------------------------+
279// |                             errors display                            |
280// +-----------------------------------------------------------------------+
281  if ( isset ($errors) and count($errors) != 0)
282  {
283          $template->assign('errors',array());
284          foreach ($errors as $error)
285          {
286                  array_push($page['errors'], $error);
287                }
288        } 
289
290// +-----------------------------------------------------------------------+
291// |                           templates display                           |
292// +-----------------------------------------------------------------------+
293  $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/global.tpl');
294  $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
295
296  break;
297
298// +-----------------------------------------------------------------------+
299// |                           ConfirmMail Config                          |
300// +-----------------------------------------------------------------------+
301  case 'confirmmail':
302       
303  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
304       
305  if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true')
306  {
307    if ( isset($_POST['submit']) and !is_adviser() and isset($_POST['UserAdvManager_ConfirmMail_TimeOut']) )
308                {
309                $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt1']));
310                $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'] = str_replace("\'", "'", str_replace("\\\\", "\\", $_POST['UserAdvManager_ConfirmMail_ReMail_Txt2']));
311                 
312                $newconf_nbc_UserAdvManager_ConfirmMail = $_POST['UserAdvManager_ConfirmMail_TimeOut'].';'.$_POST['UserAdvManager_ConfirmMail_Delay'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt1'].';'.$_POST['UserAdvManager_ConfirmMail_Remail'].';'.$_POST['UserAdvManager_ConfirmMail_ReMail_Txt2'];
313                 
314//NODO:Adding new option [Auto deletion : True | False] - No access to cron functionnalities
315
316                $conf['nbc_UserAdvManager_ConfirmMail'] = $newconf_nbc_UserAdvManager_ConfirmMail;
317               
318                $query = '
319                UPDATE '.CONFIG_TABLE.'
320                                SET value="'.$newconf_nbc_UserAdvManager_ConfirmMail.'"
321                                WHERE param="nbc_UserAdvManager_ConfirmMail"
322                                LIMIT 1
323                        ;';
324               
325                        pwg_query($query);
326               
327                        array_push($page['infos'], l10n('UserAdvManager_save_config'));
328                }
329       
330                $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();               
331
332          $template->assign(
333          array(
334                'UserAdvManager_CONFIRMMAIL_TIMEOUT_TRUE'               => $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' ?  'checked="checked"' : '' ,
335                'UserAdvManager_CONFIRMMAIL_TIMEOUT_FALSE'      => $conf_nbc_UserAdvManager_ConfirmMail[0]=='false' ?  'checked="checked"' : '' ,
336                'UserAdvManager_CONFIRMMAIL_DELAY'                                      => $conf_nbc_UserAdvManager_ConfirmMail[1],
337    'UserAdvManager_CONFIRMMAIL_REMAIL_TXT1'            => $conf_nbc_UserAdvManager_ConfirmMail[2],
338    'UserAdvManager_CONFIRMMAIL_REMAIL_TXT2'            => $conf_nbc_UserAdvManager_ConfirmMail[4],
339    'UserAdvManager_CONFIRMMAIL_REMAIL_TRUE'            => $conf_nbc_UserAdvManager_ConfirmMail[3]=='true' ? 'checked="checked"' : '',
340    'UserAdvManager_CONFIRMMAIL_REMAIL_FALSE'           => $conf_nbc_UserAdvManager_ConfirmMail[3]=='false' ? 'checked="checked"' : '',
341        )
342          );           
343
344// +-----------------------------------------------------------------------+
345// |                             errors display                            |
346// +-----------------------------------------------------------------------+
347        if ( isset ($errors) and count($errors) != 0)
348        {
349          $template->assign('errors',array());
350                foreach ($errors as $error)
351          {
352                        array_push($page['errors'], $error);
353          }
354        } 
355
356// +-----------------------------------------------------------------------+
357// |                           templates display                           |
358// +-----------------------------------------------------------------------+
359                $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/confirmmail.tpl');
360    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
361  }
362  else
363  {
364                array_push($page['infos'], l10n('Err_ConfirmMail_Settings'));
365  }
366  break;
367
368
369// +-----------------------------------------------------------------------+
370// |                           Users manager page                          |
371// +-----------------------------------------------------------------------+
372  case 'usermanager':
373  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
374  $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
375       
376  if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2]=='true' and isset($conf_nbc_UserAdvManager_ConfirmMail[0]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' )
377  {
378// +-----------------------------------------------------------------------+
379// |                           initialization                              |
380// +-----------------------------------------------------------------------+
381
382        if (!defined('PHPWG_ROOT_PATH'))
383    {
384        die('Hacking attempt!');
385    }
386         
387    include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
388
389// +-----------------------------------------------------------------------+
390// | Check Access and exit when user status is not ok                      |
391// +-----------------------------------------------------------------------+
392        check_status(ACCESS_ADMINISTRATOR);
393
394    $page['order_by_items'] = array(
395      'id' => l10n('registration_date'),
396      'username' => l10n('Username'),
397      'level' => l10n('Privacy level'),
398      'language' => l10n('language'),
399    );
400
401// +-----------------------------------------------------------------------+
402// |                               user list                               |
403// +-----------------------------------------------------------------------+
404
405        $page['filtered_users'] = get_unvalid_user_list();
406
407// +-----------------------------------------------------------------------+
408// |                            selected users                             |
409// +-----------------------------------------------------------------------+
410        if (isset($_POST['Del_Selected']))
411        {
412        $collection = array();
413
414                switch ($_POST['target'])
415    {
416        case 'all' :
417      {
418        foreach($page['filtered_users'] as $local_user)
419        {
420                array_push($collection, $local_user['id']);
421        }
422        break;
423                        }
424      case 'selection' :
425      {
426        if (isset($_POST['selection']))
427        {
428                $collection = $_POST['selection'];
429        }
430        break;
431      }
432                }
433
434    if (count($collection) == 0)
435    {
436        array_push($page['errors'], l10n('Select at least one user'));
437    }
438        }
439
440// +-----------------------------------------------------------------------+
441// |                             delete users                              |
442// +-----------------------------------------------------------------------+
443        if (isset($_POST['Del_Selected']) and count($collection) > 0)
444  {
445        if (in_array($conf['guest_id'], $collection))
446        {
447        array_push($page['errors'], l10n('Guest cannot be deleted'));
448    }
449    if (($conf['guest_id'] != $conf['default_user_id']) and
450        in_array($conf['default_user_id'], $collection))
451    {
452        array_push($page['errors'], l10n('Default user cannot be deleted'));
453    }
454    if (in_array($conf['webmaster_id'], $collection))
455    {
456        array_push($page['errors'], l10n('Webmaster cannot be deleted'));
457    }
458    if (in_array($user['id'], $collection))
459    {
460        array_push($page['errors'], l10n('You cannot delete your account'));
461    }
462
463    if (count($page['errors']) == 0)
464    {
465        foreach ($collection as $user_id)
466      {
467        delete_user($user_id);
468      }
469        array_push(
470        $page['infos'],
471        l10n_dec(
472        '%d user deleted', '%d users deleted',
473        count($collection)
474        )
475      );
476
477      foreach ($page['filtered_users'] as $filter_key => $filter_user)
478      {
479        if (in_array($filter_user['id'], $collection))
480        {
481                unset($page['filtered_users'][$filter_key]);
482        }
483      }
484                }
485        }
486
487// +-----------------------------------------------------------------------+
488// |                            selected users                             |
489// +-----------------------------------------------------------------------+
490        if (isset($_POST['Mail_With_Key']))
491        {
492        $collection = array();
493
494                switch ($_POST['target'])
495    {
496        case 'all' :
497      {
498        foreach($page['filtered_users'] as $local_user)
499        {
500                array_push($collection, $local_user['id']);
501        }
502        break;
503                        }
504      case 'selection' :
505      {
506        if (isset($_POST['selection']))
507        {
508                $collection = $_POST['selection'];
509        }
510        break;
511      }
512                }
513
514    if (count($collection) == 0)
515    {
516        array_push($page['errors'], l10n('Select at least one user'));
517    }
518        }
519// +-----------------------------------------------------------------------+
520// |                 Resend new validation key to users                    |
521// +-----------------------------------------------------------------------+
522        if (isset($_POST['Mail_With_Key']) and count($collection) > 0)
523        {
524                if (in_array($conf['guest_id'], $collection))
525        {
526        array_push($page['errors'], l10n('No_validation_for_Guest'));
527    }
528    if (($conf['guest_id'] != $conf['default_user_id']) and
529        in_array($conf['default_user_id'], $collection))
530    {
531        array_push($page['errors'], l10n('No_validation_for_default_user'));
532    }
533        if (in_array($conf['webmaster_id'], $collection))
534    {
535        array_push($page['errors'], l10n('No_validation_for_Webmaster'));
536    }
537    if (in_array($user['id'], $collection))
538    {
539        array_push($page['errors'], l10n('No_validation_for_your_account'));
540    }
541
542    if (count($page['errors']) == 0)
543    {
544        foreach ($collection as $user_id)
545      {         
546        $typemail = 1;
547                                    $query = "
548                                                        SELECT id, username, mail_address
549                                                        FROM ".USERS_TABLE."
550                                                        WHERE id = '".$user_id."'
551                                                ;";
552                                $data = mysql_fetch_array(pwg_query($query));
553                               
554        ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],true);
555      }
556      array_push(
557        $page['infos'],
558        l10n_dec(
559        '%d_Mail_With_Key', '%d_Mails_With_Key',
560        count($collection)
561        )
562      );
563
564      foreach ($page['filtered_users'] as $filter_key => $filter_user)
565      {
566        if (in_array($filter_user['id'], $collection))
567        {
568                unset($page['filtered_users'][$filter_key]);
569        }
570                        }
571                }
572        }
573
574// +-----------------------------------------------------------------------+
575// |                            selected users                             |
576// +-----------------------------------------------------------------------+
577        if (isset($_POST['Mail_Without_Key']))
578        {
579        $collection = array();
580
581                switch ($_POST['target'])
582    {
583        case 'all' :
584      {
585        foreach($page['filtered_users'] as $local_user)
586        {
587                array_push($collection, $local_user['id']);
588        }
589        break;
590                        }
591      case 'selection' :
592      {
593        if (isset($_POST['selection']))
594        {
595                $collection = $_POST['selection'];
596        }
597        break;
598      }
599                }
600
601    if (count($collection) == 0)
602    {
603        array_push($page['errors'], l10n('Select at least one user'));
604    }
605        }
606// +-----------------------------------------------------------------------+
607// |             Send reminder without new key to users                    |
608// +-----------------------------------------------------------------------+
609        if (isset($_POST['Mail_Without_Key']) and count($collection) > 0)
610        {
611                if (in_array($conf['guest_id'], $collection))
612        {
613        array_push($page['errors'], l10n('No_validation_for_Guest'));
614    }
615    if (($conf['guest_id'] != $conf['default_user_id']) and
616        in_array($conf['default_user_id'], $collection))
617    {
618        array_push($page['errors'], l10n('No_validation_for_default_user'));
619    }
620        if (in_array($conf['webmaster_id'], $collection))
621    {
622        array_push($page['errors'], l10n('No_validation_for_Webmaster'));
623    }
624    if (in_array($user['id'], $collection))
625    {
626        array_push($page['errors'], l10n('No_validation_for_your_account'));
627    }
628
629    if (count($page['errors']) == 0)
630    {
631        foreach ($collection as $user_id)
632      {
633        $typemail = 2;
634                                    $query = "
635                                                        SELECT id, username, mail_address
636                                                        FROM ".USERS_TABLE."
637                                                        WHERE id = '".$user_id."'
638                                                ;";
639                                $data = mysql_fetch_array(pwg_query($query));
640                               
641        ResendMail2User($typemail,$user_id,$data['username'],$data['mail_address'],false);                             
642      }
643      array_push(
644        $page['infos'],
645        l10n_dec(
646        '%d_Reminder_Sent', '%d_Reminders_Sent',
647        count($collection)
648        )
649      );
650
651      foreach ($page['filtered_users'] as $filter_key => $filter_user)
652      {
653        if (in_array($filter_user['id'], $collection))
654        {
655                unset($page['filtered_users'][$filter_key]);
656        }
657                        }
658                }
659        }
660
661// +-----------------------------------------------------------------------+
662// |                              groups list                              |
663// +-----------------------------------------------------------------------+
664
665        $groups[-1] = '------------';
666
667    $query = '
668      SELECT id, name
669      FROM '.GROUPS_TABLE.'
670      ORDER BY name ASC
671      ;';
672
673        $result = pwg_query($query);
674         
675    while ($row = mysql_fetch_array($result))
676    {
677      $groups[$row['id']] = $row['name'];
678    }
679
680// +-----------------------------------------------------------------------+
681// |                           Template Init                               |
682// +-----------------------------------------------------------------------+
683        $base_url = PHPWG_ROOT_PATH.'admin.php?page=user_list';
684
685    if (isset($_GET['start']) and is_numeric($_GET['start']))
686    {
687      $start = $_GET['start'];
688    }
689    else
690    {
691      $start = 0;
692    }
693
694    $template->assign(
695      array(
696        'F_ADD_ACTION' => $base_url,
697        'F_USERNAME' => @htmlentities($_GET['username']),
698        'F_FILTER_ACTION' => get_root_url().'admin.php'
699        )
700          );
701
702/* Hide radio-button if not allow to assign adviser */
703        if ($conf['allow_adviser'])
704    {
705      $template->assign('adviser', true);
706    }
707       
708// +-----------------------------------------------------------------------+
709// |                               user list                               |
710// +-----------------------------------------------------------------------+
711
712        $profile_url = get_root_url().'admin.php?page=profile&amp;user_id=';
713    $perm_url = get_root_url().'admin.php?page=user_perm&amp;user_id=';
714
715    $visible_user_list = array();
716    foreach ($page['filtered_users'] as $num => $local_user)
717    {
718/* simulate LIMIT $start, $conf['users_page'] */
719      if ($num < $start)
720      {
721        continue;
722      }
723      if ($num >= $start + $conf['users_page'])
724      {
725        break;
726      }
727
728      $visible_user_list[] = $local_user;
729        }
730
731        foreach ($visible_user_list as $local_user)
732    {
733      $groups_string = preg_replace(
734        '/(\d+)/e',
735        "\$groups['$1']",
736        implode(
737                ', ',
738            $local_user['groups']
739         )
740        );
741
742          if (isset($_POST['pref_submit'])
743        and isset($_POST['selection'])
744        and in_array($local_user['id'], $_POST['selection']))
745          {
746        $checked = 'checked="checked"';
747          }
748      else
749      {
750        $checked = '';
751      }
752
753      $properties = array();
754      if ( $local_user['level'] != 0 )
755      {
756        $properties[] = l10n( sprintf('Level %d', $local_user['level']) );
757      }
758      $properties[] =
759        (isset($local_user['enabled_high']) and ($local_user['enabled_high'] == 'true'))
760          ? l10n('is_high_enabled') : l10n('is_high_disabled');
761             
762      if (isset($conf_nbc_UserAdvManager_ConfirmMail[1]) and $conf_nbc_UserAdvManager_ConfirmMail[0]=='true' )
763      {
764        $template->append(
765                'users',
766              array(
767                'ID' => $local_user['id'],
768                'CHECKED' => $checked,
769                'U_PROFILE' => $profile_url.$local_user['id'],
770                'U_PERM' => $perm_url.$local_user['id'],
771                'USERNAME' => $local_user['username']
772                  .($local_user['id'] == $conf['guest_id']
773                    ? '<BR />['.l10n('is_the_guest').']' : '')
774                  .($local_user['id'] == $conf['default_user_id']
775                    ? '<BR />['.l10n('is_the_default').']' : ''),
776                'STATUS' => l10n('user_status_'.
777                  $local_user['status']).(($local_user['adviser'] == 'true')
778                    ? '<BR />['.l10n('adviser').']' : ''),
779                'EMAIL' => get_email_address_as_display_text($local_user['email']),
780                'GROUPS' => $groups_string,
781                'REGISTRATION' => $local_user['registration_date'],
782                )
783              );
784        }
785          }
786
787
788
789
790
791// +-----------------------------------------------------------------------+
792// |                             errors display                            |
793// +-----------------------------------------------------------------------+
794        if ( isset ($errors) and count($errors) != 0)
795        {
796          $template->assign('errors',array());
797      foreach ($errors as $error)
798          {
799                array_push($page['errors'], $error);
800          }
801        } 
802
803// +-----------------------------------------------------------------------+
804// |                           templates display                           |
805// +-----------------------------------------------------------------------+
806        $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/usermanager.tpl');
807    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');         
808  }
809  else
810  {
811        array_push($page['infos'], l10n('Err_UserManager_Settings'));
812  }
813  break; 
814 
815}
816?>
Note: See TracBrowser for help on using the repository browser.