Changeset 3841 for extensions/NBC_UserAdvManager/trunk/include
- Timestamp:
- Sep 12, 2009, 6:57:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
r3836 r3841 7 7 global $conf; 8 8 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 9 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 10 $infos1_perso = ""; 9 10 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 11 12 $infos1_perso = ""; 11 13 $infos2_perso = ""; 12 14 … … 84 86 fclose($fo) ; 85 87 //return mail ($to,$subject) ; 88 } 89 90 91 function 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 86 222 } 87 223 … … 167 303 } 168 304 305 306 function 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 } 169 333 170 334 … … 347 511 } 348 512 } 349 /* ****************** end ******************* */350 // Original code without time limit351 /* list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();'));352 353 $query = '354 UPDATE '.USER_CONFIRM_MAIL_TABLE.'355 SET date_check="'.$dbnow.'"356 WHERE id = "'.$id.'"357 ;';358 pwg_query($query);359 360 if ( $conf_nbc_UserAdvManager[3] <> -1 )361 {362 $query = "363 DELETE FROM ".USER_GROUP_TABLE."364 WHERE user_id = '".$data['user_id']."'365 AND group_id = '".$conf_nbc_UserAdvManager[3]."'366 ;";367 pwg_query($query);368 }369 370 if ( $conf_nbc_UserAdvManager[4] <> -1 )371 {372 $query = "373 DELETE FROM ".USER_GROUP_TABLE."374 WHERE user_id = '".$data['user_id']."'375 AND group_id = '".$conf_nbc_UserAdvManager[4]."'376 ;";377 pwg_query($query);378 379 $query = "380 INSERT INTO ".USER_GROUP_TABLE."381 (user_id, group_id)382 VALUES383 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."')384 ;";385 pwg_query($query);386 }387 388 if ( ( $conf_nbc_UserAdvManager[5] <> -1 or isset($data['status']) ) )389 {390 $query = "391 UPDATE ".USER_INFOS_TABLE."392 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."'393 WHERE user_id = '".$data['user_id']."'394 ;";395 pwg_query($query);396 }397 // Refresh user's category cache398 invalidate_user_cache();399 400 return true;*/401 513 } 402 514 } … … 404 516 return false; 405 517 } 518 406 519 407 520 function NotSensibleSearchUsername($username) … … 421 534 } 422 535 } 536 423 537 424 538 function SearchMail($email) … … 470 584 $conf_nbc_MailExclusion = preg_split('/,/',$conf_nbc_UserAdvManager[13]); 471 585 for ($i = 0 ; $i < count($conf_nbc_MailExclusion) ; $i++) 472 473 474 475 476 477 478 586 { 587 $pattern = '/'.$conf_nbc_MailExclusion[$i].'/'; 588 if (preg_match($pattern, $ncsemail)) 589 return false; 590 else 591 return true; 592 } 479 593 } 480 594 } 595 596 597 function 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 669 return $users; 670 } 481 671 ?>
Note: See TracChangeset
for help on using the changeset viewer.