Changeset 4143 for extensions/NBC_UserAdvManager/trunk/include
- Timestamp:
- Oct 29, 2009, 2:25:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/NBC_UserAdvManager/trunk/include/functions_UserAdvManager.inc.php
r4135 r4143 145 145 146 146 147 /* Function called from UserAdvManager_admin.php to send a reminder mail for ghost users */ 148 function ghostreminder($user_id, $username, $email) 149 { 150 global $conf; 151 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 152 153 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 154 155 $infos1_perso = ""; 156 157 $subject = '['.$conf['gallery_title'].'] '.l10n_args(get_l10n_args('Ghost_remainder_of_%s', $username)); 158 159 if (function_exists('get_user_language_desc') and isset($conf_nbc_UserAdvManager[19]) and $conf_nbc_UserAdvManager[19] <> '' and isset($conf_nbc_UserAdvManager[17]) and $conf_nbc_UserAdvManager[17] == 'true') 160 { 161 $infos1 = get_user_language_desc($conf_nbc_UserAdvManager[19])."\n\n"; 162 resetlastvisit($user_id); 163 } 164 165 pwg_mail($email, array( 166 'subject' => $subject, 167 'content' => $infos1.get_absolute_root_url(), 168 )); 169 170 /* ********************** */ 171 /* Email sending debugger */ 172 /* This is only to trace */ 173 /* the send of emails for */ 174 /* debugging */ 175 /* ********************** */ 176 // MailLog($email,$subject); 177 /* ********************** */ 178 } 179 180 147 181 /* Function called from functions AddConfirmMail and ResetConfirmMail for validation key generation */ 148 182 function FindAvailableConfirmMailID() … … 152 186 $id = generate_key(16); 153 187 $query = " 154 155 156 157 188 SELECT COUNT(*) 189 FROM ".USER_CONFIRM_MAIL_TABLE." 190 WHERE id = '".$id."' 191 ;"; 158 192 list($count) = mysql_fetch_row(pwg_query($query)); 159 193 … … 176 210 { 177 211 $query = " 178 179 180 181 212 SELECT status 213 FROM ".USER_INFOS_TABLE." 214 WHERE user_id = '".$user_id."' 215 ;"; 182 216 list($status) = mysql_fetch_row(pwg_query($query)); 183 217 184 218 $query = " 185 186 187 188 189 219 INSERT INTO ".USER_CONFIRM_MAIL_TABLE." 220 (id, user_id, mail_address, status, date_check) 221 VALUES 222 ('".$Confirm_Mail_ID."', '".$user_id."', '".$email."', '".$status."', null) 223 ;"; 190 224 pwg_query($query); 191 225 192 226 $query = " 193 194 195 196 197 198 199 200 227 DELETE FROM ".USER_GROUP_TABLE." 228 WHERE user_id = '".$user_id."' 229 AND ( 230 group_id = '".$conf_nbc_UserAdvManager[3]."' 231 OR 232 group_id = '".$conf_nbc_UserAdvManager[4]."' 233 ) 234 ;"; 201 235 pwg_query($query); 202 236 … … 204 238 { 205 239 $query = " 206 207 208 209 240 UPDATE ".USER_INFOS_TABLE." 241 SET status = '".$conf_nbc_UserAdvManager[9]."' 242 WHERE user_id = '".$user_id."' 243 ;"; 210 244 pwg_query($query); 211 245 } … … 214 248 { 215 249 $query = " 216 217 218 219 220 250 INSERT INTO ".USER_GROUP_TABLE." 251 (user_id, group_id) 252 VALUES 253 ('".$user_id."', '".$conf_nbc_UserAdvManager[3]."') 254 ;"; 221 255 pwg_query($query); 222 256 } … … 239 273 { 240 274 $query = " 241 242 243 244 275 UPDATE ".USER_CONFIRM_MAIL_TABLE." 276 SET id = '".$Confirm_Mail_ID."' 277 WHERE user_id = '".$user_id."' 278 ;"; 245 279 pwg_query($query); 246 280 247 281 $query = " 248 249 250 251 282 UPDATE ".USER_INFOS_TABLE." 283 SET registration_date = '".$dbnow."' 284 WHERE user_id = '".$user_id."' 285 ;"; 252 286 pwg_query($query); 253 287 … … 257 291 258 292 293 /* Function called from function_UserAdvManager.inc.php to reset last visit date after sending a reminder */ 294 function resetlastvisit($user_id) 295 { 296 global $conf; 297 298 list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); 299 300 $query = " 301 UPDATE ".USER_LASTVISIT_TABLE." 302 SET lastvisit = '".$dbnow."' 303 WHERE user_id = '".$user_id."' 304 ;"; 305 pwg_query($query); 306 } 307 308 259 309 /* Function called from main.inc.php - Triggered on user deletion */ 260 310 function DeleteConfirmMail($user_id) 261 311 { 262 312 $query = " 263 264 265 313 DELETE FROM ".USER_CONFIRM_MAIL_TABLE." 314 WHERE user_id = '".$user_id."' 315 ;"; 266 316 pwg_query($query); 267 317 } … … 279 329 280 330 $query = " 281 282 283 284 331 SELECT COUNT(*) 332 FROM ".USER_CONFIRM_MAIL_TABLE." 333 WHERE id = '".$id."' 334 ;"; 285 335 list($count) = mysql_fetch_row(pwg_query($query)); 286 336 … … 288 338 { 289 339 $query = " 290 291 292 293 340 SELECT user_id, status, date_check 341 FROM ".USER_CONFIRM_MAIL_TABLE." 342 WHERE id = '".$id."' 343 ;"; 294 344 $data = mysql_fetch_array(pwg_query($query)); 295 345 … … 297 347 { 298 348 $query = " 299 300 301 302 349 SELECT registration_date 350 FROM ".USER_INFOS_TABLE." 351 WHERE user_id = '".$data['user_id']."' 352 ;"; 303 353 list($registration_date) = mysql_fetch_row(pwg_query($query)); 304 354 … … 328 378 329 379 $query = ' 330 331 332 333 380 UPDATE '.USER_CONFIRM_MAIL_TABLE.' 381 SET date_check="'.$dbnow.'" 382 WHERE id = "'.$id.'" 383 ;'; 334 384 pwg_query($query); 335 385 … … 337 387 { 338 388 $query = " 339 340 341 342 389 DELETE FROM ".USER_GROUP_TABLE." 390 WHERE user_id = '".$data['user_id']."' 391 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 392 ;"; 343 393 pwg_query($query); 344 394 } … … 347 397 { 348 398 $query = " 349 350 351 352 353 399 INSERT INTO ".USER_GROUP_TABLE." 400 (user_id, group_id) 401 VALUES 402 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 403 ;"; 354 404 pwg_query($query); 355 405 } … … 358 408 { 359 409 $query = " 360 361 362 363 410 UPDATE ".USER_INFOS_TABLE." 411 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 412 WHERE user_id = '".$data['user_id']."' 413 ;"; 364 414 pwg_query($query); 365 415 } … … 380 430 381 431 $query = ' 382 383 384 385 432 UPDATE '.USER_CONFIRM_MAIL_TABLE.' 433 SET date_check="'.$dbnow.'" 434 WHERE id = "'.$id.'" 435 ;'; 386 436 pwg_query($query); 387 437 … … 389 439 { 390 440 $query = " 391 392 393 394 441 DELETE FROM ".USER_GROUP_TABLE." 442 WHERE user_id = '".$data['user_id']."' 443 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 444 ;"; 395 445 pwg_query($query); 396 446 } … … 399 449 { 400 450 $query = " 401 402 403 404 451 DELETE FROM ".USER_GROUP_TABLE." 452 WHERE user_id = '".$data['user_id']."' 453 AND group_id = '".$conf_nbc_UserAdvManager[4]."' 454 ;"; 405 455 pwg_query($query); 406 456 407 457 $query = " 408 409 410 411 412 458 INSERT INTO ".USER_GROUP_TABLE." 459 (user_id, group_id) 460 VALUES 461 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 462 ;"; 413 463 pwg_query($query); 414 464 } … … 417 467 { 418 468 $query = " 419 420 421 422 469 UPDATE ".USER_INFOS_TABLE." 470 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 471 WHERE user_id = '".$data['user_id']."' 472 ;"; 423 473 pwg_query($query); 424 474 } … … 445 495 446 496 $query = " 447 448 449 450 497 SELECT COUNT(*) 498 FROM ".USER_CONFIRM_MAIL_TABLE." 499 WHERE user_id = '".$id."' 500 ;"; 451 501 list($count) = mysql_fetch_row(pwg_query($query)); 452 502 … … 454 504 { 455 505 $query = " 456 457 458 459 506 SELECT user_id, status, date_check 507 FROM ".USER_CONFIRM_MAIL_TABLE." 508 WHERE user_id = '".$id."' 509 ;"; 460 510 $data = mysql_fetch_array(pwg_query($query)); 461 511 … … 465 515 466 516 $query = " 467 468 469 470 517 UPDATE ".USER_CONFIRM_MAIL_TABLE." 518 SET date_check='".$dbnow."' 519 WHERE user_id = '".$data['user_id']."' 520 ;"; 471 521 pwg_query($query); 472 522 … … 474 524 { 475 525 $query = " 476 477 478 479 526 DELETE FROM ".USER_GROUP_TABLE." 527 WHERE user_id = '".$data['user_id']."' 528 AND group_id = '".$conf_nbc_UserAdvManager[3]."' 529 ;"; 480 530 pwg_query($query); 481 531 } … … 484 534 { 485 535 $query = " 486 487 488 536 DELETE FROM ".USER_GROUP_TABLE." 537 WHERE user_id = '".$data['user_id']."' 538 AND group_id = '".$conf_nbc_UserAdvManager[4]."' 489 539 ;"; 490 540 pwg_query($query); 491 541 492 542 $query = " 493 494 495 496 497 543 INSERT INTO ".USER_GROUP_TABLE." 544 (user_id, group_id) 545 VALUES 546 ('".$data['user_id']."', '".$conf_nbc_UserAdvManager[4]."') 547 ;"; 498 548 pwg_query($query); 499 549 } … … 502 552 { 503 553 $query = " 504 505 506 507 554 UPDATE ".USER_INFOS_TABLE." 555 SET status = '".(isset($data['status']) ? $data['status'] : $conf_nbc_UserAdvManager[5])."' 556 WHERE user_id = '".$data['user_id']."' 557 ;"; 508 558 pwg_query($query); 509 559 } … … 523 573 { 524 574 $query = " 525 526 527 528 575 SELECT ".$conf['user_fields']['username']." 576 FROM ".USERS_TABLE." 577 WHERE LOWER(".$conf['user_fields']['username'].") = '".strtolower($username)."' 578 ;"; 529 579 list($username) = mysql_fetch_row(pwg_query($query)); 530 580 … … 532 582 } 533 583 } 534 535 536 /* Obsolete function - Check for single email in database */537 //function SearchMail($email)538 //{539 // global $conf, $lang;540 //541 // if (isset($email))542 // {543 // $query = "544 // SELECT COUNT(*)545 // FROM ".USERS_TABLE."546 // WHERE ".$conf['user_fields']['email']." = '".$email."'547 // ;";548 // list($nbr_mail) = mysql_fetch_row(pwg_query($query));549 //550 // return isset($nbr_mail) ? $nbr_mail : 0;551 // }552 //}553 584 554 585 … … 612 643 /* search users depending expiration date */ 613 644 $query = ' 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 645 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 646 u.'.$conf['user_fields']['username'].' AS username, 647 u.'.$conf['user_fields']['email'].' AS email, 648 ui.status, 649 ui.adviser, 650 ui.enabled_high, 651 ui.level, 652 ui.registration_date 653 FROM '.USERS_TABLE.' AS u 654 INNER JOIN '.USER_INFOS_TABLE.' AS ui 655 ON u.'.$conf['user_fields']['id'].' = ui.user_id 656 LEFT JOIN '.USER_GROUP_TABLE.' AS ug 657 ON u.'.$conf['user_fields']['id'].' = ug.user_id 658 WHERE u.'.$conf['user_fields']['id'].' >= 3 659 AND (TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) >= "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'" 660 OR TO_DAYS(NOW()) - TO_DAYS(ui.registration_date) < "'.$conf_nbc_UserAdvManager_ConfirmMail[1].'")'; 630 661 631 662 if ($conf_nbc_UserAdvManager[3] <> '-1' and $conf_nbc_UserAdvManager[9] == '-1') 632 663 { 633 664 $query.= ' 634 665 AND ug.group_id = '.$conf_nbc_UserAdvManager[3]; 635 666 } 636 667 if ($conf_nbc_UserAdvManager[3] == '-1' and $conf_nbc_UserAdvManager[9] <> '-1') 637 668 { 638 669 $query.= ' 639 670 AND ui.status = \''.$conf_nbc_UserAdvManager[9]."'"; 640 671 } 641 672 if ($conf_nbc_UserAdvManager[3] <> '-1' and $conf_nbc_UserAdvManager[9] <> '-1') 642 673 { 643 674 $query.= ' 644 675 AND ug.group_id = \''.$conf_nbc_UserAdvManager[3]."'"; 645 676 } 646 677 $query.= ' 647 678 ORDER BY id ASC 648 679 ;'; 649 680 … … 670 701 { 671 702 $query = ' 672 673 674 675 703 SELECT user_id, group_id 704 FROM '.USER_GROUP_TABLE.' 705 WHERE user_id IN ('.implode(',', $user_ids).') 706 ;'; 676 707 677 708 $result = pwg_query($query); … … 689 720 } 690 721 722 723 /* Function called from UserAdvManager.php - Get ghost users */ 724 function get_ghost_user_list() 725 { 726 global $conf, $page; 727 728 /* Get UserAdvManager configuration */ 729 $conf_nbc_UserAdvManager = isset($conf['nbc_UserAdvManager']) ? explode(";" , $conf['nbc_UserAdvManager']) : array(); 730 731 $users = array(); 732 733 /* search users depending expiration date */ 734 $query = ' 735 SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id, 736 u.'.$conf['user_fields']['username'].' AS username, 737 u.'.$conf['user_fields']['email'].' AS email, 738 lv.lastvisit, 739 lv.reminder 740 FROM '.USERS_TABLE.' AS u 741 INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv 742 ON u.'.$conf['user_fields']['id'].' = lv.user_id 743 WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_nbc_UserAdvManager[18].'") 744 ORDER BY id ASC;'; 745 746 $result = pwg_query($query); 747 748 while ($row = mysql_fetch_array($result)) 749 { 750 $user = $row; 751 $user['groups'] = array(); 752 753 array_push($users, $user); 754 } 755 756 /* add group lists */ 757 $user_ids = array(); 758 foreach ($users as $i => $user) 759 { 760 $user_ids[$i] = $user['id']; 761 } 762 763 return $users; 764 } 765 766 691 767 /* Function called from UserAdvManager.php - to determine who is expired or not and giving a different display color */ 692 768 function expiration($id) … … 701 777 702 778 $query = " 703 704 705 706 779 SELECT registration_date 780 FROM ".USER_INFOS_TABLE." 781 WHERE user_id = '".$id."' 782 ;"; 707 783 list($registration_date) = mysql_fetch_row(pwg_query($query)); 708 784 … … 734 810 } 735 811 } 812 736 813 737 814 /** … … 811 888 } 812 889 813 /* Function called from maintain.inc.php - to determineif database upgrade is needed */890 /* Function called from maintain.inc.php - to check if database upgrade is needed */ 814 891 function table_exist($table) 815 892 {
Note: See TracChangeset
for help on using the changeset viewer.