當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。