Example #1
0
 public function updatePerms($content_id, $groups = array())
 {
     $module_id = Page::getInstance()->getModule()->getVar('mid');
     $groups_exists = parent::getGroupIds('page_view_item', $content_id, $module_id);
     $groups_exists = array_values($groups_exists);
     $groups_delete = array_diff(array_values($groups_exists), $groups);
     $groups_add = array_diff($groups, array_values($groups_exists));
     // delete
     if (count($groups_delete) != 0) {
         $criteria = $criteria = new CriteriaCompo();
         $criteria->add(new Criteria('gperm_itemid', $content_id));
         $criteria->add(new Criteria('gperm_modid', $module_id));
         $criteria->add(new Criteria('gperm_name', 'page_view_item', '='));
         $criteria->add(new Criteria('gperm_groupid', '(' . implode(', ', $groups_delete) . ')', 'IN'));
         if (parent::deleteAll($criteria)) {
         }
     }
     // Add
     if (count($groups_add) != 0) {
         foreach ($groups_add as $group_id) {
             parent::addRight('page_view_item', $content_id, $group_id, $module_id);
         }
     }
 }
Example #2
0
 /**
  * Delete all permissions for a specific name and item
  *
  * @param string $gperm_name   name of the permission to test
  * @param int    $gperm_itemid id of the object to check
  *
  * @return bool   true if no errors
  */
 public function deletePermissionForItem($gperm_name, $gperm_itemid)
 {
     return $this->permissionHandler->deleteByModule($this->mid, $gperm_name, $gperm_itemid);
 }
Example #3
0
 /**
  * Check permission
  *
  * @param string    $gperm_name
  * @param int       $gperm_itemid
  * @param array|int $gperm_groupid
  * @param int       $gperm_modid
  * @param bool      $trueifadmin
  *
  * @return bool
  */
 public function checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid = 1, $trueifadmin = true)
 {
     $trueifadmin = false;
     return parent::checkRight($gperm_name, $gperm_itemid, $gperm_groupid, $gperm_modid, $trueifadmin);
 }