本文整理汇总了PHP中Publisher::getPermissionHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::getPermissionHandler方法的具体用法?PHP Publisher::getPermissionHandler怎么用?PHP Publisher::getPermissionHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::getPermissionHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CriteriaCompo
/**
* Get all subcats and put them in an array indexed by parent id
*
* @param array $categories
*
* @return array
*/
public function &getSubCats($categories)
{
$xoops = Xoops::getInstance();
$criteria = new CriteriaCompo(new Criteria('parentid', "(" . implode(',', array_keys($categories)) . ")", 'IN'));
$ret = array();
if (!PublisherUtils::IsUserAdmin()) {
$categoriesGranted = $this->publisher->getPermissionHandler()->getGrantedItems('category_read');
if (count($categoriesGranted) > 0) {
$criteria->add(new Criteria('categoryid', '(' . implode(',', $categoriesGranted) . ')', 'IN'));
} else {
return $ret;
}
if ($xoops->isUser()) {
$criteria->add(new Criteria('moderator', $xoops->user->getVar('uid')), 'OR');
}
}
$criteria->setSort('weight');
$criteria->setOrder('ASC');
$subcats = $this->getObjects($criteria, true);
/* @var $subcat PublisherCategory */
foreach ($subcats as $subcat) {
$ret[$subcat->getVar('parentid')][$subcat->getVar('categoryid')] = $subcat;
}
return $ret;
}
示例2: getItems
/**
* @param int $limit
* @param int $start
* @param string $status
* @param int $categoryid
* @param string $sort
* @param string $order
* @param string $notNullFields
* @param bool $asobject
* @param null $otherCriteria
* @param string $id_key
*
* @return array
*/
public function getItems($limit = 0, $start = 0, $status = '', $categoryid = -1, $sort = 'datesub', $order = 'DESC', $notNullFields = '', $asobject = true, $otherCriteria = null, $id_key = 'none')
{
global $publisher_isAdmin;
if (!$publisher_isAdmin) {
$criteriaPermissions = new CriteriaCompo();
// Categories for which user has access
$categoriesGranted = $this->publisher->getPermissionHandler()->getGrantedItems('category_read');
if (!empty($categoriesGranted)) {
$grantedCategories = new Criteria('categoryid', "(" . implode(',', $categoriesGranted) . ")", 'IN');
$criteriaPermissions->add($grantedCategories, 'AND');
} else {
return array();
}
}
if (isset($categoryid) && $categoryid != -1) {
$criteriaCategory = new criteria('categoryid', $categoryid);
}
if (!empty($status) && is_array($status)) {
$criteriaStatus = new CriteriaCompo();
foreach ($status as $v) {
$criteriaStatus->add(new Criteria('status', $v), 'OR');
}
} elseif (!empty($status) && $status != -1) {
$criteriaStatus = new CriteriaCompo();
$criteriaStatus->add(new Criteria('status', $status), 'OR');
}
$criteria = new CriteriaCompo();
if (!empty($criteriaCategory)) {
$criteria->add($criteriaCategory);
}
if (!empty($criteriaPermissions)) {
$criteria->add($criteriaPermissions);
}
if (!empty($criteriaStatus)) {
$criteria->add($criteriaStatus);
}
if (!empty($otherCriteria)) {
$criteria->add($otherCriteria);
}
$criteria->setLimit($limit);
$criteria->setStart($start);
$criteria->setSort($sort);
$criteria->setOrder($order);
$ret = $this->getItemObjects($criteria, $id_key, $notNullFields);
return $ret;
}