source: extensions/NBC_UserAdvManager/branches/2.11/include/functions_UserAdvManager.inc.php @ 3859

Last change on this file since 3859 was 3859, checked in by Eric, 15 years ago

Release 2.11.0 - Merged from trunk

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