@@ 217-241 (lines=25) @@ | ||
214 | * @param integer $rightId Right ID |
|
215 | * @return boolean |
|
216 | */ |
|
217 | public function refuseGroupRight($groupId, $rightId) |
|
218 | { |
|
219 | // check input |
|
220 | if ($rightId <= 0 || $groupId <= 0 || !is_numeric($rightId) || !is_numeric($groupId)) { |
|
221 | return false; |
|
222 | } |
|
223 | ||
224 | // grant right |
|
225 | $delete = sprintf(" |
|
226 | DELETE FROM |
|
227 | %sfaqgroup_right |
|
228 | WHERE |
|
229 | group_id = %d AND |
|
230 | right_id = %d", |
|
231 | PMF_Db::getTablePrefix(), |
|
232 | $groupId, |
|
233 | $rightId |
|
234 | ); |
|
235 | ||
236 | $res = $this->config->getDb()->query($delete); |
|
237 | if (!$res) { |
|
238 | return false; |
|
239 | } |
|
240 | return true; |
|
241 | } |
|
242 | ||
243 | /** |
|
244 | * Adds a new group to the database and returns the ID of the |
|
@@ 468-495 (lines=28) @@ | ||
465 | * |
|
466 | * @return boolean |
|
467 | */ |
|
468 | function addToGroup($userId, $groupId) |
|
469 | { |
|
470 | if ($userId <= 0 || $groupId <= 0 || !is_numeric($userId) || !is_numeric($groupId)) { |
|
471 | return false; |
|
472 | } |
|
473 | ||
474 | if (!$this->getGroupData($groupId)) { |
|
475 | return false; |
|
476 | } |
|
477 | ||
478 | // add user to group |
|
479 | $insert = sprintf(" |
|
480 | INSERT INTO |
|
481 | %sfaquser_group |
|
482 | (user_id, group_id) |
|
483 | VALUES |
|
484 | (%d, %d)", |
|
485 | PMF_Db::getTablePrefix(), |
|
486 | $userId, |
|
487 | $groupId |
|
488 | ); |
|
489 | ||
490 | $res = $this->config->getDb()->query($insert); |
|
491 | if (!$res) { |
|
492 | return false; |
|
493 | } |
|
494 | return true; |
|
495 | } |
|
496 | ||
497 | /** |
|
498 | * Removes a user $userId from the group $groupId. |
|
@@ 506-527 (lines=22) @@ | ||
503 | * |
|
504 | * @return boolean |
|
505 | */ |
|
506 | public function removeFromGroup($userId, $groupId) |
|
507 | { |
|
508 | if ($userId <= 0 || $groupId <= 0 || !is_numeric($userId) || !is_numeric($groupId)) { |
|
509 | return false; |
|
510 | } |
|
511 | ||
512 | $delete = sprintf(" |
|
513 | DELETE FROM |
|
514 | %sfaquser_group |
|
515 | WHERE |
|
516 | user_id = %d AND |
|
517 | group_id = %d", |
|
518 | PMF_Db::getTablePrefix(), |
|
519 | $userId, |
|
520 | $groupId); |
|
521 | ||
522 | $res = $this->config->getDb()->query($delete); |
|
523 | if (!$res) { |
|
524 | return false; |
|
525 | } |
|
526 | return true; |
|
527 | } |
|
528 | ||
529 | /** |
|
530 | * Returns the ID of the group that has the name $name. Returns |