当前位置: 首页>>代码示例>>PHP>>正文


PHP DiscussionModel::_CategoryPermissions方法代码示例

本文整理汇总了PHP中DiscussionModel::_CategoryPermissions方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionModel::_CategoryPermissions方法的具体用法?PHP DiscussionModel::_CategoryPermissions怎么用?PHP DiscussionModel::_CategoryPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DiscussionModel的用法示例。


在下文中一共展示了DiscussionModel::_CategoryPermissions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = array();
                 // no permission
             }
         } else {
             $Categories = CategoryModel::categories();
             $IDs = array();
             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 = array();
                 foreach ($IDs as $ID) {
                     self::$_CategoryPermissions[] = ($Escape ? '@' : '') . $ID;
                 }
             }
         }
     }
     return self::$_CategoryPermissions;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:44,代码来源:class.discussionmodel.php

示例2: 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 == '1')) {
            self::$_CategoryPermissions = TRUE;
			} elseif(C('Garden.Permissions.Disabled.Category')) {
				if($Session->CheckPermission('Vanilla.Discussions.View'))
					self::$_CategoryPermissions = TRUE;
				else
					self::$_CategoryPermissions = array(); // no permission
         } else {
            $SQL = Gdn::SQL();
            
            $Data = $SQL
               ->Select('c.CategoryID')
               ->From('Category c')
               ->Permission('Vanilla.Discussions.View', 'c', 'PermissionCategoryID', 'Category')
               ->Get();
            
            $Data = $Data->ResultArray();

            // Check to see if the user has permission to all categories. This is for speed.
            $CategoryCount = $SQL
               ->Select('c.CategoryID', 'count', 'CategoryCount')
               ->From('Category c')
               ->Get()->Value('CategoryCount', 0);
            if (count($Data) == $CategoryCount)
               self::$_CategoryPermissions = TRUE;
            else {
               self::$_CategoryPermissions = array();
               foreach($Data as $Row) {
                  self::$_CategoryPermissions[] = ($Escape ? '@' : '').$Row['CategoryID'];
               }
            }
         }
      }
      
      return self::$_CategoryPermissions;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:49,代码来源:class.discussionmodel.php


注:本文中的DiscussionModel::_CategoryPermissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。