Changeset 10957 for extensions/UserAdvManager/trunk/include
- Timestamp:
- May 20, 2011, 10:21:46 PM (13 years ago)
- Location:
- extensions/UserAdvManager/trunk/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserAdvManager/trunk/include/functions.inc.php
r10706 r10957 752 752 * Triggered on user_comment_check 753 753 * 754 * checks if author is mandatory and set on comments post 754 * checks if author is mandatory and set on comments post when comments for all is set 755 * 756 * cheks if author is in an allowed group to post comment when comments for all is not set 755 757 * 756 758 * @param : comment action, comment … … 762 764 { 763 765 load_language('plugin.lang', UAM_PATH); 764 global $infos, $conf, $ template;766 global $infos, $conf, $user; 765 767 766 768 $conf_UAM = unserialize($conf['UserAdvManager']); 767 769 768 // User creation OR update769 if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $co nf['comments_forall'] == 'true' and $comm['author'] == 'guest')770 // Does not allow empty author name on comments for all 771 if (isset($conf_UAM[5]) and $conf_UAM[5] == 'true' and $comm['author'] == 'guest' and $conf['comments_forall']) 770 772 { 771 773 $comment_action = 'reject'; 772 774 773 775 array_push($infos, l10n('UAM_Empty Author')); 776 } 777 778 779 // Do not allow comments if user is not in an allowed group 780 if (isset($conf_UAM[36]) and $conf_UAM[36] == 'true' and !$conf['comments_forall']) 781 { 782 if (!UAM_CheckAuthor($comm['author'])) 783 { 784 $comment_action = 'reject'; 785 786 array_push($infos, l10n('UAM_Not_Allowed_Author')); 787 } 774 788 } 775 789 … … 2526 2540 2527 2541 /** 2542 * Called from UAM_CheckEmptyCommentAuthor() 2543 * Checks if comment's author name is in the allowed group 2544 * 2545 * @author : author's name 2546 * 2547 * @returns : Boolean (true is user is allowed to post / false if not allowed) 2548 * 2549 */ 2550 function UAM_CheckAuthor($author) 2551 { 2552 global $conf; 2553 2554 // Get UAM configuration 2555 $conf_UAM = unserialize($conf['UserAdvManager']); 2556 2557 if (isset($conf_UAM[37]) and $conf_UAM[37] <> -1) 2558 { 2559 $query = ' 2560 SELECT u.id, 2561 u.username, 2562 ug.user_id, 2563 ug.group_id 2564 FROM '.USERS_TABLE.' AS u 2565 INNER JOIN '.USER_GROUP_TABLE.' AS ug 2566 ON u.id = ug.user_id 2567 WHERE u.username LIKE "'.$author.'" 2568 AND ug.group_id = '.$conf_UAM[37].' 2569 ;'; 2570 2571 $count = pwg_db_num_rows(pwg_query($query)); 2572 2573 if (is_null($count) or $count == 0) 2574 { 2575 return false; 2576 } 2577 else 2578 return true; 2579 } 2580 } 2581 2582 2583 /** 2528 2584 * Useful for debugging - 4 vars can be set 2529 2585 * Output result to log.txt file -
extensions/UserAdvManager/trunk/include/upgradedb.inc.php
r10942 r10957 453 453 pwg_query($query); 454 454 } 455 456 /* upgrade from 2.20.4 to 2.20.7 */ 457 /* ***************************** */ 458 function upgrade_2204_2207() 459 { 460 global $conf; 461 462 // Upgrading options 463 $query = ' 464 SELECT value 465 FROM '.CONFIG_TABLE.' 466 WHERE param = "UserAdvManager" 467 ;'; 468 469 $result = pwg_query($query); 470 $conf_UAM = pwg_db_fetch_assoc($result); 471 472 $Newconf_UAM = unserialize($conf_UAM['value']); 473 474 $Newconf_UAM[36] = 'false'; 475 $Newconf_UAM[37] = '-1'; 476 477 $update_conf = serialize($Newconf_UAM); 478 479 $query = ' 480 UPDATE '.CONFIG_TABLE.' 481 SET value="'.pwg_db_real_escape_string($update_conf).'" 482 WHERE param="UserAdvManager" 483 LIMIT 1 484 ;'; 485 486 pwg_query($query); 487 } 455 488 ?>
Note: See TracChangeset
for help on using the changeset viewer.