| @@ 790-810 (lines=21) @@ | ||
| 787 | * @param int $sectionId |
|
| 788 | * @return bool |
|
| 789 | */ |
|
| 790 | public function addCategoryToSection($categoryId, $sectionId) |
|
| 791 | { |
|
| 792 | if (!is_numeric($categoryId) || $categoryId < 1 || !is_numeric($sectionId) || $sectionId < 1) { |
|
| 793 | return false; |
|
| 794 | } |
|
| 795 | $insert = sprintf(' |
|
| 796 | INSERT INTO |
|
| 797 | %sfaqsection_category |
|
| 798 | (category_id, section_id) |
|
| 799 | VALUES |
|
| 800 | (%s,%s)', |
|
| 801 | DB::getTablePrefix(), |
|
| 802 | $categoryId, |
|
| 803 | $sectionId |
|
| 804 | ); |
|
| 805 | $res = $this->config->getDb()->query($insert); |
|
| 806 | if (!$res) { |
|
| 807 | return false; |
|
| 808 | } |
|
| 809 | return true; |
|
| 810 | } |
|
| 811 | ||
| 812 | /** |
|
| 813 | * Removes a category $categoryId to the section $sectionId. |
|
| @@ 820-841 (lines=22) @@ | ||
| 817 | * @param int $sectionId |
|
| 818 | * @return bool |
|
| 819 | */ |
|
| 820 | public function removeCategoryFromSection($categoryId, $sectionId) |
|
| 821 | { |
|
| 822 | if (!is_numeric($categoryId) || $categoryId < 1 || !is_numeric($sectionId) || $sectionId < 1) { |
|
| 823 | return false; |
|
| 824 | } |
|
| 825 | $delete = sprintf(' |
|
| 826 | DELETE FROM |
|
| 827 | %sfaqsection_category |
|
| 828 | WHERE |
|
| 829 | category_id = %d |
|
| 830 | AND |
|
| 831 | section_id = %d', |
|
| 832 | DB::getTablePrefix(), |
|
| 833 | $categoryId, |
|
| 834 | $sectionId |
|
| 835 | ); |
|
| 836 | $res = $this->config->getDb()->query($delete); |
|
| 837 | if (!$res) { |
|
| 838 | return false; |
|
| 839 | } |
|
| 840 | return true; |
|
| 841 | } |
|
| 842 | ||
| 843 | /** |
|
| 844 | * Returns an array that contains the category IDs of all categories |
|
| @@ 908-928 (lines=21) @@ | ||
| 905 | * @param int $sectionId |
|
| 906 | * @return bool |
|
| 907 | */ |
|
| 908 | public function addNewsToSection($newsId, $sectionId) |
|
| 909 | { |
|
| 910 | if (!is_numeric($newsId) || $newsId < 1 || !is_numeric($sectionId) || $sectionId < 1) { |
|
| 911 | return false; |
|
| 912 | } |
|
| 913 | $insert = sprintf(' |
|
| 914 | INSERT INTO |
|
| 915 | %sfaqsection_news |
|
| 916 | (news_id, section_id) |
|
| 917 | VALUES |
|
| 918 | (%s,%s)', |
|
| 919 | DB::getTablePrefix(), |
|
| 920 | $newsId, |
|
| 921 | $sectionId |
|
| 922 | ); |
|
| 923 | $res = $this->config->getDb()->query($insert); |
|
| 924 | if (!$res) { |
|
| 925 | return false; |
|
| 926 | } |
|
| 927 | return true; |
|
| 928 | } |
|
| 929 | ||
| 930 | /** |
|
| 931 | * Removes a news $newsId from the section $sectionId. |
|
| @@ 938-959 (lines=22) @@ | ||
| 935 | * @param int $sectionId |
|
| 936 | * @return bool |
|
| 937 | */ |
|
| 938 | public function removeNewsFromSection($newsId, $sectionId) |
|
| 939 | { |
|
| 940 | if (!is_numeric($newsId) || $newsId < 1 || !is_numeric($sectionId) || $sectionId < 1) { |
|
| 941 | return false; |
|
| 942 | } |
|
| 943 | $delete = sprintf(' |
|
| 944 | DELETE FROM |
|
| 945 | %sfaqsection_news |
|
| 946 | WHERE |
|
| 947 | news_id = %d |
|
| 948 | AND |
|
| 949 | section_id = %d', |
|
| 950 | DB::getTablePrefix(), |
|
| 951 | $newsId, |
|
| 952 | $sectionId |
|
| 953 | ); |
|
| 954 | $res = $this->config->getDb()->query($delete); |
|
| 955 | if (!$res) { |
|
| 956 | return false; |
|
| 957 | } |
|
| 958 | return true; |
|
| 959 | } |
|
| 960 | ||
| 961 | /** |
|
| 962 | * Returns an array that contains the news IDs of all news |
|
| @@ 235-260 (lines=26) @@ | ||
| 232 | * |
|
| 233 | * @return bool |
|
| 234 | */ |
|
| 235 | public function refuseGroupRight($groupId, $rightId) |
|
| 236 | { |
|
| 237 | // check input |
|
| 238 | if ($rightId <= 0 || $groupId <= 0 || !is_numeric($rightId) || !is_numeric($groupId)) { |
|
| 239 | return false; |
|
| 240 | } |
|
| 241 | ||
| 242 | // grant right |
|
| 243 | $delete = sprintf(' |
|
| 244 | DELETE FROM |
|
| 245 | %sfaqgroup_right |
|
| 246 | WHERE |
|
| 247 | group_id = %d AND |
|
| 248 | right_id = %d', |
|
| 249 | Db::getTablePrefix(), |
|
| 250 | $groupId, |
|
| 251 | $rightId |
|
| 252 | ); |
|
| 253 | ||
| 254 | $res = $this->config->getDb()->query($delete); |
|
| 255 | if (!$res) { |
|
| 256 | return false; |
|
| 257 | } |
|
| 258 | ||
| 259 | return true; |
|
| 260 | } |
|
| 261 | ||
| 262 | /** |
|
| 263 | * Adds a new group to the database and returns the ID of the |
|
| @@ 530-552 (lines=23) @@ | ||
| 527 | * |
|
| 528 | * @return bool |
|
| 529 | */ |
|
| 530 | public function removeFromGroup($userId, $groupId) |
|
| 531 | { |
|
| 532 | if ($userId <= 0 || $groupId <= 0 || !is_numeric($userId) || !is_numeric($groupId)) { |
|
| 533 | return false; |
|
| 534 | } |
|
| 535 | ||
| 536 | $delete = sprintf(' |
|
| 537 | DELETE FROM |
|
| 538 | %sfaquser_group |
|
| 539 | WHERE |
|
| 540 | user_id = %d AND |
|
| 541 | group_id = %d', |
|
| 542 | Db::getTablePrefix(), |
|
| 543 | $userId, |
|
| 544 | $groupId); |
|
| 545 | ||
| 546 | $res = $this->config->getDb()->query($delete); |
|
| 547 | if (!$res) { |
|
| 548 | return false; |
|
| 549 | } |
|
| 550 | ||
| 551 | return true; |
|
| 552 | } |
|
| 553 | ||
| 554 | /** |
|
| 555 | * Returns the ID of the group that has the name $name. Returns |
|