本文整理汇总了PHP中DiscussionModel::categoryPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::categoryPermissions方法的具体用法?PHP DiscussionModel::categoryPermissions怎么用?PHP DiscussionModel::categoryPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussionModel
的用法示例。
在下文中一共展示了DiscussionModel::categoryPermissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: categoryPermissions
/**
* Identify current user's category permissions and set as local array.
*
* @since 2.0.0
* @access public
*
* @param bool $Escape Prepends category IDs with @
* @return array Protected local _CategoryPermissions
*/
public static function categoryPermissions($Escape = false)
{
if (is_null(self::$categoryPermissions)) {
$Session = Gdn::session();
if (is_object($Session->User) && $Session->User->Admin) {
self::$categoryPermissions = true;
} elseif (c('Garden.Permissions.Disabled.Category')) {
if ($Session->checkPermission('Vanilla.Discussions.View')) {
self::$categoryPermissions = true;
} else {
self::$categoryPermissions = [];
// no permission
}
} else {
$Categories = CategoryModel::categories();
$IDs = [];
foreach ($Categories as $ID => $Category) {
if ($Category['PermsDiscussionsView']) {
$IDs[] = $ID;
}
}
// Check to see if the user has permission to all categories. This is for speed.
$CategoryCount = count($Categories);
if (count($IDs) == $CategoryCount) {
self::$categoryPermissions = true;
} else {
self::$categoryPermissions = [];
foreach ($IDs as $ID) {
self::$categoryPermissions[] = ($Escape ? '@' : '') . $ID;
}
}
}
}
return self::$categoryPermissions;
}