source: extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php @ 3841

Last change on this file since 3841 was 3841, checked in by Eric, 15 years ago
  • Adding management of unvalidated users according time limit
  • Adding actions : Resend validation email with new key generation (reset of time limit), send reminder mail for validation (no new key generation), delete expired unvalidated users.

Note : There is still a problem with the display of a new validation link when using function "Resend validation email with new key generation"

  • Property svn:eol-style set to LF
File size: 18.8 KB
Line 
1<?php
2include_once (NBC_UserAdvManager_PATH.'include/constants.php');
3load_language('plugin.lang', NBC_UserAdvManager_PATH);
4
5function SendMail2User($typemail, $id, $username, $password, $email, $confirm)
6{
7  global $conf;
8  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
9 
10        include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
11 
12        $infos1_perso = "";
13  $infos2_perso = "";
14
15  switch($typemail)
16  {
17    case 1:
18      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Add of %s', $username));
19      $password = $password <> '' ? $password : l10n('UserAdvManager_empty_pwd');
20     
21      if ( function_exists('get_user_language_desc') and isset($conf_nbc_UserAdvManager[10]) and $conf_nbc_UserAdvManager[10] <> '' )
22        $infos1_perso = get_user_language_desc($conf_nbc_UserAdvManager[10])."\n\n";
23     
24      break;
25     
26    case 2:
27      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', $username));
28      $password = $password <> '' ? $password : l10n('UserAdvManager_empty_pwd');
29
30      break;
31       
32    case 3:
33      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Update of %s', $username));
34      $password = $password <> '' ? $password : l10n('UserAdvManager_no_update_pwd');
35
36      break;
37  }
38
39  if ( isset($conf_nbc_UserAdvManager[0]) and $conf_nbc_UserAdvManager[0] == 'true' )
40  {
41    $infos1 = array(
42      get_l10n_args('infos_mail %s', $username),
43      get_l10n_args('User: %s', $username),
44      get_l10n_args('Password: %s', $password),
45      get_l10n_args('Email: %s', $email),
46      get_l10n_args('', ''),
47    );
48  }
49
50
51  if ( isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm)
52  {
53    $infos2 = array
54    (
55      get_l10n_args('Link: %s', AddConfirmMail($id, $email)),
56      get_l10n_args('', ''),
57    );
58
59    if ( function_exists('get_user_language_desc') and isset($conf_nbc_UserAdvManager[11]) and $conf_nbc_UserAdvManager[11] <> '' )
60      $infos2_perso = get_user_language_desc($conf_nbc_UserAdvManager[11])."\n\n";
61  }
62
63  pwg_mail($email, array(
64    'subject' => $subject,
65    'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(),
66  ));
67
68/* ********************** */
69/* Email sending debugger */
70/* This is only to trace  */
71/* the send of emails for */
72/* debugging              */
73/* ********************** */ 
74  MailLog($email,$subject);
75/* ********************** */
76
77}
78
79/* Email sending debugger function */
80function MailLog  ($to, $subject)
81{
82   $fo=fopen (NBC_UserAdvManager_PATH.'admin/maillog.txt','a') ;
83   fwrite($fo,"======================\n") ;
84   fwrite($fo,'le ' . date('D, d M Y H:i:s') . "\r\n");
85   fwrite($fo,$to . "\n" . $subject . "\r\n") ;
86   fclose($fo) ;
87   //return mail ($to,$subject) ;
88}
89
90
91function ResendMail2User($typemail, $user_id, $username, $email, $confirm)
92{
93  global $conf;
94  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
95        $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
96 
97        include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
98 
99        $infos1_perso = "";
100  $infos2_perso = "";
101
102  switch($typemail)
103  {
104    case 1:
105      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_with_key_of_%s', $username));
106     
107      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '')
108      {
109        if (function_exists('get_user_language_desc'))
110        {
111                                        $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
112                               
113                                        if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm)
114                                        {
115                                                $infos2 = array
116                                                (
117                                                        get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
118                                                        get_l10n_args('', ''),
119                                                );
120                                        }
121        }
122        else
123        {
124                                        $infos1 = $conf_nbc_UserAdvManager_ConfirmMail[2]."\n\n";
125
126                                        if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm)
127                                        {       
128                                                $infos2 = array
129                                                (
130                                                        get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
131                                                        get_l10n_args('', ''),
132                                                );
133                                        }
134        }
135          pwg_mail($email, array(
136                        'subject' => $subject,
137                            'content' => (isset($infos1) ? $infos1."\n\n" : "").(isset($infos2) ? $infos2."\n\n" : "").get_absolute_root_url(),
138                                ));
139      }
140                        elseif (isset($conf_nbc_UserAdvManager[11]) and $conf_nbc_UserAdvManager[11] <> '' and !isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] == '')
141                        {
142        if (function_exists('get_user_language_desc'))
143        {
144                                        $infos1 = get_user_language_desc($conf_nbc_UserAdvManager[11])."\n\n";
145                               
146                                        if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm)
147                                        {
148                                                $infos2 = array
149                                                (
150                                                        get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
151                                                        get_l10n_args('', ''),
152                                                );
153                                        }
154        }
155        else
156        {
157                                        $infos1 = $conf_nbc_UserAdvManager[11]."\n\n";
158
159                                        if (isset($conf_nbc_UserAdvManager[2]) and $conf_nbc_UserAdvManager[2] == 'true' and $confirm)
160                                        {       
161                                                $infos2 = array
162                                                (
163                                                        get_l10n_args('Link: %s', ResetConfirmMail($user_id)),
164                                                        get_l10n_args('', ''),
165                                                );
166                                        }
167        }
168                                pwg_mail($email, array(
169                        'subject' => $subject,
170                        'content' => (isset($infos1) ? $infos1."\n\n" : "").(isset($infos2) ? $infos2."\n\n" : "").get_absolute_root_url(),
171                        ));
172                        }
173     
174      break;
175     
176    case 2:
177      $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Reminder_without_key_of_%s', $username));
178     
179      if (isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] <> '' and isset($conf_nbc_UserAdvManager[11]) and $conf_nbc_UserAdvManager[11] <> '')
180      {
181        if (function_exists('get_user_language_desc'))
182        {
183                                        $infos1 = get_user_language_desc($conf_nbc_UserAdvManager_ConfirmMail[2])."\n\n";
184        }
185        else
186        {
187                                        $infos1 = $conf_nbc_UserAdvManager_ConfirmMail[2]."\n\n";
188        }
189                                pwg_mail($email, array(
190                        'subject' => $subject,
191                        'content' => (isset($infos1) ? $infos1."\n\n" : "").(isset($infos2) ? $infos2."\n\n" : "").get_absolute_root_url(),
192                        ));
193                        }
194                        elseif ((function_exists('get_user_language_desc') and isset($conf_nbc_UserAdvManager[11]) and $conf_nbc_UserAdvManager[11] <> '' and !isset($conf_nbc_UserAdvManager_ConfirmMail[2]) and $conf_nbc_UserAdvManager_ConfirmMail[2] == ''))
195                        {
196        if (function_exists('get_user_language_desc'))
197        {
198                                        $infos1 = get_user_language_desc($conf_nbc_UserAdvManager[11])."\n\n";
199        }
200        else
201        {
202                                        $infos1 = $conf_nbc_UserAdvManager[11]."\n\n";
203        }
204                                pwg_mail($email, array(
205                        'subject' => $subject,
206                        'content' => (isset($infos1) ? $infos1."\n\n" : "").(isset($infos2) ? $infos2."\n\n" : "").get_absolute_root_url(),
207                        ));
208                        }
209                       
210      break;
211  }
212
213/* ********************** */
214/* Email sending debugger */
215/* This is only to trace  */
216/* the send of emails for */
217/* debugging              */
218/* ********************** */ 
219  MailLog($email,$subject);
220/* ********************** */
221
222}
223
224
225function FindAvailableConfirmMailID()
226{
227  while (true)
228  {
229    $id = generate_key(16);
230    $query = "
231      SELECT COUNT(*)
232      FROM ".USER_CONFIRM_MAIL_TABLE."
233      WHERE id = '".$id."'
234    ;";
235    list($count) = mysql_fetch_row(pwg_query($query));
236
237    if ($count == 0)
238      return $id;
239  }
240}
241
242
243
244function AddConfirmMail($user_id, $email)
245{
246  global $conf;
247  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
248  $Confirm_Mail_ID = FindAvailableConfirmMailID();
249
250  list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
251 
252  if ( isset($Confirm_Mail_ID) )
253  {
254    $query = "
255      SELECT status
256      FROM ".USER_INFOS_TABLE."
257      WHERE user_id = '".$user_id."'
258    ;";
259    list($status) = mysql_fetch_row(pwg_query($query));
260   
261    $query = "
262      INSERT INTO ".USER_CONFIRM_MAIL_TABLE."
263      (id, user_id, mail_address, status, date_check)
264      VALUES
265      ('".$Confirm_Mail_ID."', '".$user_id."', '".$email."', '".$status."', null)
266    ;";
267    pwg_query($query);
268
269    $query = "
270      DELETE FROM ".USER_GROUP_TABLE."
271      WHERE user_id = '".$user_id."'
272      AND (
273        group_id = '".$conf_nbc_UserAdvManager[3]."'
274        OR
275        group_id = '".$conf_nbc_UserAdvManager[4]."'
276      )
277    ;";
278    pwg_query($query);
279
280    if ( !is_admin() and $conf_nbc_UserAdvManager[9] <> -1 )
281    {
282      $query = "
283        UPDATE ".USER_INFOS_TABLE."
284        SET status = '".$conf_nbc_UserAdvManager[9]."'
285        WHERE user_id = '".$user_id."'
286      ;";
287      pwg_query($query);
288    }
289
290    if ( $conf_nbc_UserAdvManager[3] <> -1 )
291    {
292      $query = "
293        INSERT INTO ".USER_GROUP_TABLE."
294        (user_id, group_id)
295        VALUES
296        ('".$user_id."', '".$conf_nbc_UserAdvManager[3]."')
297      ;";
298      pwg_query($query);
299    }
300   
301    return get_absolute_root_url().NBC_UserAdvManager_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
302  }
303}
304
305
306function ResetConfirmMail($user_id)
307{
308  global $conf;
309 
310  $Confirm_Mail_ID = FindAvailableConfirmMailID();
311
312  list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
313 
314  if ( isset($Confirm_Mail_ID) )
315  { 
316    $query = "
317                        UPDATE ".USER_CONFIRM_MAIL_TABLE."
318                        SET id = '".$Confirm_Mail_ID."'
319                        WHERE user_id = '".$user_id."'
320    ;";
321    pwg_query($query);
322
323                $query = "
324        UPDATE ".USER_INFOS_TABLE."
325      SET registration_date = '".$dbnow."'
326      WHERE user_id = '".$user_id."'
327      ;";
328                pwg_query($query);
329   
330    return get_absolute_root_url().NBC_UserAdvManager_PATH.'ConfirmMail.php?key='.$Confirm_Mail_ID;
331  }
332}
333
334
335function DeleteConfirmMail($user_id)
336{
337  $query = "
338    DELETE FROM ".USER_CONFIRM_MAIL_TABLE."
339    WHERE user_id = '".$user_id."'
340  ;";
341  pwg_query($query);
342}
343
344
345
346function VerifyConfirmMail($id)
347{
348  global $conf;
349
350  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
351 
352  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
353  $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
354
355  $query = "
356    SELECT COUNT(*)
357    FROM ".USER_CONFIRM_MAIL_TABLE."
358    WHERE id = '".$id."'
359  ;";
360  list($count) = mysql_fetch_row(pwg_query($query));
361
362  if ($count == 1)
363  {
364    $query = "
365      SELECT user_id, status, date_check
366      FROM ".USER_CONFIRM_MAIL_TABLE."
367      WHERE id = '".$id."'
368    ;";
369    $data = mysql_fetch_array(pwg_query($query));
370       
371    if (!empty($data) and isset($data['user_id']) and !isset($data['date_check']))
372    {
373      $query = "
374        SELECT registration_date
375        FROM ".USER_INFOS_TABLE."
376        WHERE user_id = '".$data['user_id']."'
377      ;";
378      list($registration_date) = mysql_fetch_row(pwg_query($query));
379
380/*              Time limit process              */
381/* ****************** begin ******************* */ 
382      if (!empty($registration_date))
383      {
384                // Verify Confirmmail with time limit ON
385                if (isset ($conf_nbc_UserAdvManager_ConfirmMail[1]))
386                {
387                        // dates formating and compare
388                        $today = date("d-m-Y"); // Get today's date
389                        list($day, $month, $year) = explode('-', $today); // explode date of today                                               
390                        $daytimestamp = mktime(0, 0, 0, $month, $day, $year);// Generate UNIX timestamp
391                       
392                        list($regdate, $regtime) = explode(' ', $registration_date); // Explode date and time from registration date
393                        list($regyear, $regmonth, $regday) = explode('-', $regdate); // Explode date from registration date
394                        $regtimestamp = mktime(0, 0, 0, $regmonth, $regday, $regyear);// Generate UNIX timestamp
395                       
396                        $deltasecs = $daytimestamp - $regtimestamp;// Compare the 2 UNIX timestamps     
397                        $deltadays = floor($deltasecs / 86400);// Convert result from seconds to days
398
399                        // Condition with the value set for time limit
400                        if ($deltadays <= $conf_nbc_UserAdvManager_ConfirmMail[1]) // If Nb of days is less than the set limit
401                        {
402                                list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
403
404                                $query = '
405                                        UPDATE '.USER_CONFIRM_MAIL_TABLE.'
406                                        SET date_check="'.$dbnow.'"
407                                        WHERE id = "'.$id.'"
408                                        ;';
409                                pwg_query($query);
410     
411                                if ( $conf_nbc_UserAdvManager[3] <> -1 )
412                                {
413                                        $query = "
414                                                DELETE FROM ".USER_GROUP_TABLE."
415                                                WHERE user_id = '".$data['user_id']."'
416                                                AND group_id = '".$conf_nbc_UserAdvManager[3]."'
417                                                ;";
418                                        pwg_query($query);
419                                }
420           
421                                if ( $conf_nbc_UserAdvManager[4] <> -1 ) // Change user's group
422                                {
423                                        $query = "
424                                                DELETE FROM ".USER_GROUP_TABLE."
425                                                WHERE user_id = '".$data['user_id']."'
426                                                AND group_id = '".$conf_nbc_UserAdvManager[4]."'
427                                                ;";
428                                        pwg_query($query);
429       
430                                        $query = "
431                                                INSERT INTO ".USER_GROUP_TABLE."
432                                                        (user_id, group_id)
433                                                VALUES
434                                                        ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."')
435                                                ;";
436                                        pwg_query($query);
437                                }
438
439                                if (($conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']))) // Change user's status
440                                {
441                                        $query = "
442                                                UPDATE ".USER_INFOS_TABLE."
443                                                SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."'
444                                                WHERE user_id = '".$data['user_id']."'
445                                                ;";
446                                        pwg_query($query);
447                                }
448                        // Refresh user's category cache
449                                invalidate_user_cache();
450 
451                                return true;
452                        }
453                        elseif ($deltadays > $conf_nbc_UserAdvManager_ConfirmMail[1]) // If timelimit exeeds
454                        {
455                                return false;
456                        }
457                }
458                // Verify Confirmmail with time limit OFF
459                else
460                {
461                        list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));
462
463                        $query = '
464                                UPDATE '.USER_CONFIRM_MAIL_TABLE.'
465                                SET date_check="'.$dbnow.'"
466                                WHERE id = "'.$id.'"
467                                ;';
468                        pwg_query($query);
469     
470                        if ( $conf_nbc_UserAdvManager[3] <> -1 )
471                        {
472                                $query = "
473                                        DELETE FROM ".USER_GROUP_TABLE."
474                                        WHERE user_id = '".$data['user_id']."'
475                                        AND group_id = '".$conf_nbc_UserAdvManager[3]."'
476                                        ;";
477                                pwg_query($query);
478                        }
479   
480                        if ( $conf_nbc_UserAdvManager[4] <> -1 )
481                        {
482                                $query = "
483                                        DELETE FROM ".USER_GROUP_TABLE."
484                                        WHERE user_id = '".$data['user_id']."'
485                                        AND group_id = '".$conf_nbc_UserAdvManager[4]."'
486                                        ;";
487                                pwg_query($query);
488
489                                $query = "
490                                        INSERT INTO ".USER_GROUP_TABLE."
491                                                (user_id, group_id)
492                                        VALUES
493                                                ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."')
494                                        ;";
495                                pwg_query($query);
496                        }
497
498                        if ( ( $conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']) ) )
499                        {
500                                $query = "
501                                        UPDATE ".USER_INFOS_TABLE."
502                                        SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."'
503                                        WHERE user_id = '".$data['user_id']."'
504                                        ;";
505                                pwg_query($query);
506                        }
507// Refresh user's category cache
508                        invalidate_user_cache();
509 
510                        return true;
511                }
512      }
513    }
514  }
515  else
516    return false;
517}
518
519
520function NotSensibleSearchUsername($username)
521{
522  global $conf;
523 
524  if ( isset($username) )
525  {
526    $query = "
527      SELECT ".$conf['user_fields']['username']."
528      FROM ".USERS_TABLE."
529      WHERE LOWER(".$conf['user_fields']['username'].") = '".strtolower($username)."'
530    ;";
531    list($username) = mysql_fetch_row(pwg_query($query));
532
533    return isset($username) ? $username : '';
534  }
535}
536
537
538function SearchMail($email)
539{
540  global $conf, $lang;
541 
542  if ( isset($email) )
543  {
544    $query = "
545      SELECT COUNT(*)
546      FROM ".USERS_TABLE."
547      WHERE ".$conf['user_fields']['email']." = '".$email."'
548    ;";
549    list($nbr_mail) = mysql_fetch_row(pwg_query($query));
550 
551    return isset($nbr_mail) ? $nbr_mail : 0;
552  }
553}
554
555function ValidateUsername($login)
556{
557  global $conf;
558
559  $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
560
561  if ( isset($login) and isset($conf_nbc_UserAdvManager[8]) and $conf_nbc_UserAdvManager[8] <> '' )
562  {
563        $pattern = '/'.$conf_nbc_UserAdvManager[8].'/';
564    if ( preg_match($pattern, $login) )
565      return false;
566    else
567      return true;
568  }
569  else
570  {
571    return true;
572  }
573}
574
575
576function ValidateEmailProvider($email)
577{
578  global $conf;
579
580        $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array();
581        if (isset($conf_nbc_UserAdvManager[12]))
582        {
583                $ncsemail = strtolower($email);
584                $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]);
585                for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++)
586                {
587                        $pattern = '/'.$conf_nbc_MailExclusion[$i].'/';
588                        if (preg_match($pattern, $ncsemail))
589                        return false;
590                else
591                        return true;
592                }
593        }
594}
595
596
597function get_unvalid_user_list()
598{
599        global $conf, $page;
600         
601        /* Get ConfirmMail configuration */
602    $conf_nbc_UserAdvManager_ConfirmMail = isset($conf['nbc_UserAdvManager_ConfirmMail']) ? explode(";" , $conf['nbc_UserAdvManager_ConfirmMail']) : array();
603         
604        /* Get UserAdvManager configuration */
605        $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 
606 
607    $users = array();
608   
609        /* search users depending expiration date */
610    $query = '
611        SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
612                                                                                        u.'.$conf['user_fields']['username'].' AS username,
613                      u.'.$conf['user_fields']['email'].' AS email,
614                      ui.status,
615                      ui.adviser,
616                      ui.enabled_high,
617                      ui.level,
618                      ui.registration_date,
619                      ug.group_id
620                        FROM '.USERS_TABLE.' AS u
621                        INNER JOIN '.USER_INFOS_TABLE.' AS ui
622                                ON u.'.$conf['user_fields']['id'].' = ui.user_id
623                INNER JOIN '.USER_GROUP_TABLE.' AS ug
624        ON u.'.$conf['user_fields']['id'].' = ug.user_id
625        WHERE u.'.$conf['user_fields']['id'].' >= 0
626        AND ug.group_id = "'.$conf_nbc_UserAdvManager[3].'"
627        AND TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'"
628        ORDER BY id ASC
629                ;';
630
631        $result = pwg_query($query);
632     
633    while ($row = mysql_fetch_array($result))
634        {
635        $user = $row;
636        $user['groups'] = array();
637
638        array_push($users, $user);
639        }
640
641        /* add group lists */
642    $user_ids = array();
643    foreach ($users as $i => $user)
644    {
645        $user_ids[$i] = $user['id'];
646        }
647       
648        $user_nums = array_flip($user_ids);
649
650    if (count($user_ids) > 0)
651    {
652        $query = '
653                SELECT user_id, group_id
654                        FROM '.USER_GROUP_TABLE.'
655            WHERE user_id IN ('.implode(',', $user_ids).')
656            ;';
657       
658                $result = pwg_query($query);
659       
660        while ($row = mysql_fetch_array($result))
661        {
662                array_push(
663                $users[$user_nums[$row['user_id']]]['groups'],
664                $row['group_id']
665                );
666         }
667        }
668
669return $users;
670}
671?>
Note: See TracBrowser for help on using the repository browser.