/** * Returns permissions for a certain type * * @param string $gperm_name "global", "forum" or "topic" (should perhaps have "post" as well - but I don't know) * * @return array */ public function getGrantedItems($gperm_name) { static $items; if (isset($items[$gperm_name])) { return $items[$gperm_name]; } $ret = array(); //Instead of calling groupperm handler and get objects, we will save some memory and do it our way $criteria = new CriteriaCompo(new Criteria('gperm_name', $gperm_name)); $criteria->add(new Criteria('gperm_modid', $this->publisher->getModule()->getVar('mid'))); //Get user's groups $groups = \Xoops::getInstance()->getUserGroups(); $criteria2 = new CriteriaCompo(); foreach ($groups as $gid) { $criteria2->add(new Criteria('gperm_groupid', $gid), 'OR'); } $criteria->add($criteria2); $qb = $this->db2->createXoopsQueryBuilder(); $qb->select('gperm_itemid')->fromPrefix('group_permission', ''); $criteria->renderQb($qb); $result = $qb->execute(); while ($myrow = $result->fetch(\PDO::FETCH_ASSOC)) { $ret[$myrow['gperm_itemid']] = $myrow['gperm_itemid']; } $items[$gperm_name] = $ret; return $ret; }