當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DiscussHelper::getAclCategories方法代碼示例

本文整理匯總了PHP中DiscussHelper::getAclCategories方法的典型用法代碼示例。如果您正苦於以下問題:PHP DiscussHelper::getAclCategories方法的具體用法?PHP DiscussHelper::getAclCategories怎麽用?PHP DiscussHelper::getAclCategories使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DiscussHelper的用法示例。


在下文中一共展示了DiscussHelper::getAclCategories方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getChildCategories

 public static function getChildCategories($parentId, $isPublishedOnly = false, $includePrivate = true)
 {
     static $categories = array();
     $sig = $parentId . '-' . (int) $isPublishedOnly . '-' . (int) $includePrivate;
     if (!array_key_exists($sig, $categories)) {
         $db = DiscussHelper::getDBO();
         $my = JFactory::getUser();
         $config = DiscussHelper::getConfig();
         $mainframe = JFactory::getApplication();
         $sortConfig = $config->get('layout_ordering_category', 'latest');
         $query = 'SELECT a.`id`, a.`title`, a.`alias`, a.`private`,a.`default`, a.`container`';
         $query .= ' FROM `#__discuss_category` as a';
         $query .= ' WHERE a.parent_id = ' . $db->Quote($parentId);
         if ($isPublishedOnly) {
             $query .= ' AND a.`published` = ' . $db->Quote('1');
         }
         if (!$mainframe->isAdmin()) {
             if (!$includePrivate) {
                 //check categories acl here.
                 $catIds = DiscussHelper::getAclCategories(DISCUSS_CATEGORY_ACL_ACTION_VIEW, $my->id, $parentId);
                 if (count($catIds) > 0) {
                     $strIds = '';
                     foreach ($catIds as $cat) {
                         $strIds = empty($strIds) ? $cat->id : $strIds . ', ' . $cat->id;
                     }
                     $query .= ' AND a.id NOT IN (';
                     $query .= $strIds;
                     $query .= ')';
                 }
             }
         }
         switch ($sortConfig) {
             case 'alphabet':
                 $orderBy = ' ORDER BY a.`title` ';
                 break;
             case 'ordering':
                 $orderBy = ' ORDER BY a.`lft` ';
                 break;
             case 'latest':
                 $orderBy = ' ORDER BY a.`created` ';
                 break;
             default:
                 $orderBy = ' ORDER BY a.`lft` ';
                 break;
         }
         $sort = $config->get('layout_sort_category', 'asc');
         $query .= $orderBy . $sort;
         $db->setQuery($query);
         $result = $db->loadObjectList();
         $categories[$sig] = $result;
     }
     return $categories[$sig];
 }
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:53,代碼來源:category.php

示例2: getCategories

 /**
  * Retrieves a list of categories from the site.
  *
  * @since	3.0
  * @access	public
  * @param	int 	If there's a parent id provided, it would load sub categories.
  */
 public function getCategories($options = array())
 {
     // Legacy
     if (!is_array($options)) {
         $parent_id = $options;
         $options = array('parent_id' => $parent_id);
     }
     $default = array('acl_type' => DISCUSS_CATEGORY_ACL_ACTION_VIEW, 'bind_table' => true, 'parent_id' => 0);
     $options += $default;
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $query = 'SELECT * FROM ' . $db->nameQuote('#__discuss_category');
     $query .= ' WHERE ' . $db->nameQuote('parent_id') . '=' . $db->Quote($options['parent_id']);
     $query .= ' AND ' . $db->nameQuote('published') . '=' . $db->Quote(1);
     if ($my->id == 0) {
         $query .= ' AND ' . $db->nameQuote('private') . '!=' . $db->Quote('1');
     }
     //check categories acl here.
     $catIds = DiscussHelper::getAclCategories($options['acl_type'], $my->id, $options['parent_id']);
     if (count($catIds) > 0) {
         $strIds = '';
         foreach ($catIds as $cat) {
             $strIds = empty($strIds) ? $cat->id : $strIds . ', ' . $cat->id;
         }
         $query .= ' AND ' . $db->nameQuote('id') . ' NOT IN (' . $strIds . ')';
     }
     $query .= ' ORDER BY ' . $db->nameQuote('lft');
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($options['bind_table']) {
         $total = count($rows);
         $categories = array();
         for ($i = 0; $i < $total; $i++) {
             $ignore['alias'] = true;
             $category = DiscussHelper::getTable('Category');
             $category->bind($rows[$i], $ignore);
             $categories[] = $category;
         }
         return $categories;
     }
     return $rows;
 }
開發者ID:BetterBetterBetter,項目名稱:B3App,代碼行數:49,代碼來源:categories.php


注:本文中的DiscussHelper::getAclCategories方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。