- Timestamp:
- May 20, 2011, 10:22:18 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/UserAdvManager/branches/2.20/include/functions.inc.php
r10707 r10958 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
Note: See TracChangeset
for help on using the changeset viewer.