当前位置: 首页>>代码示例>>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;未经允许,请勿转载。