本文整理匯總了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;
}