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


PHP DiscussHelper::getAccessibleCategories方法代码示例

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


在下文中一共展示了DiscussHelper::getAccessibleCategories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildNestedCategories

 public static function buildNestedCategories($parentId, $parent, $ignorePrivate = false, $isPublishedOnly = false, $showPrivate = true, $selectACLOnly = false)
 {
     $catsModel = self::getModel('Categories');
     // [model:category]
     $catModel = self::getModel('Category');
     $childs = $catsModel->getChildCategories($parentId, $isPublishedOnly, $showPrivate);
     $aclType = $selectACLOnly ? DISCUSS_CATEGORY_ACL_ACTION_SELECT : DISCUSS_CATEGORY_ACL_ACTION_VIEW;
     $accessibleCatsIds = DiscussHelper::getAccessibleCategories($parentId, $aclType);
     if (!empty($childs)) {
         for ($j = 0; $j < count($childs); $j++) {
             $child = $childs[$j];
             $child->count = $catModel->getTotalPostCount($child->id);
             $child->childs = null;
             if (!$ignorePrivate) {
                 if (count($accessibleCatsIds) > 0) {
                     $access = false;
                     foreach ($accessibleCatsIds as $canAccess) {
                         if ($canAccess->id == $child->id) {
                             $access = true;
                         }
                     }
                     if (!$access) {
                         continue;
                     }
                 } else {
                     continue;
                 }
             }
             if (!DiscussHelper::buildNestedCategories($child->id, $child, $ignorePrivate, $isPublishedOnly, $showPrivate, $selectACLOnly)) {
                 $parent->childs[] = $child;
             }
         }
         // for $j
         if (!empty($parent->childs)) {
             // $parent->childs	= array_reverse( $parent->childs );
         }
     } else {
         return false;
     }
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:40,代码来源:helper.php

示例2: getParentCategories

 function getParentCategories($contentId, $type = 'all', $isPublishedOnly = false, $showPrivateCat = true)
 {
     $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('0');
     if ($type == 'poster') {
         $query .= ' and a.created_by = ' . $db->Quote($contentId);
     } else {
         if ($type == 'category') {
             $query .= ' and a.`id` = ' . $db->Quote($contentId);
         }
     }
     if ($isPublishedOnly) {
         $query .= ' and a.`published` = ' . $db->Quote('1');
     }
     if (!$mainframe->isAdmin()) {
         // we do not need to see the privacy when user accessing category via backend because only admin can access it.
         // in a way, we do not resttict for admin.
         //check categories acl here.
         $catIds = DiscussHelper::getAccessibleCategories('0', DISCUSS_CATEGORY_ACL_ACTION_SELECT);
         if (count($catIds) > 0) {
             $strIds = '';
             foreach ($catIds as $cat) {
                 $strIds = empty($strIds) ? $cat->id : $strIds . ', ' . $cat->id;
             }
             $query .= count($catIds) == 1 ? ' and a.id = ' . $strIds : ' and a.id IN (' . $strIds . ')';
         }
     }
     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();
     return $result;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:53,代码来源:categories.php

示例3: getAccessibleCategories

 private function getAccessibleCategories($categoryId)
 {
     // We only want the user to view stuffs that they can really see.
     if (!is_array($categoryId)) {
         $accessibleCategories = DiscussHelper::getAccessibleCategories();
         $cats = array();
         if ($accessibleCategories) {
             foreach ($accessibleCategories as $category) {
                 $cats[] = $category->id;
             }
         }
     } else {
         $accessibleCategories = DiscussHelper::getAccessibleCategories();
         $cats = array();
         if ($accessibleCategories) {
             foreach ($accessibleCategories as $category) {
                 if (in_array($category->id, $categoryId)) {
                     $cats[] = $category->id;
                 }
             }
         }
     }
     return $cats;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:24,代码来源:view.html.php

示例4: getPointsHistory

 /**
  * Get a list of user badge history
  *
  **/
 public function getPointsHistory($userId)
 {
     $db = DiscussHelper::getDBO();
     // $query	= 'SELECT * FROM ' . $db->nameQuote( '#__discuss_users_history' )
     // 		. ' WHERE ' . $db->nameQuote( 'user_id' ) . '=' . $db->Quote( $userId )
     // 		. ' ORDER BY `created` DESC'
     // 		. ' LIMIT 0,20';
     $my = JFactory::getUser();
     // Obtain the category that I can view
     // I am able to view if my usergroup is added in the category permission "view discussion"
     $viewableCats = array();
     // First get all the accessible parentId
     $parentCats = array();
     $childCats = array();
     $parentCats = DiscussHelper::getAccessibleCategories();
     foreach ($parentCats as $parentCat) {
         $viewableCats[] = $parentCat->id;
     }
     // Second get the child cats that are accessible
     foreach ($parentCats as $parentCat) {
         $childCats = DiscussHelper::getAccessibleCategories($parentCat->id);
         foreach ($childCats as $childCat) {
             $viewableCats[] = $childCat->id;
         }
     }
     $query = 'SELECT a.*, ' . $db->Quote('post') . ' as `type`' . ' FROM ' . $db->nameQuote('#__discuss_users_history') . ' AS a' . ' LEFT JOIN ' . $db->nameQuote('#__discuss_posts') . ' AS b' . ' ON a.' . $db->nameQuote('content_id') . '=' . 'b.' . $db->nameQuote('id') . ' WHERE a.' . $db->nameQuote('user_id') . '=' . $db->Quote($userId) . ' AND a.' . $db->nameQuote('command') . ' IN(' . $db->Quote('easydiscuss.new.discussion') . ',' . $db->Quote('easydiscuss.new.reply') . ',' . $db->Quote('easydiscuss.answer.reply') . ',' . $db->Quote('easydiscuss.new.comment') . ',' . $db->Quote('easydiscuss.like.discussion') . ',' . $db->Quote('easydiscuss.like.reply') . ',' . $db->Quote('easydiscuss.resolved.discussion') . ',' . $db->Quote('easydiscuss.vote.reply') . ',' . $db->Quote('easydiscuss.unvote.reply') . ')' . ' AND b.' . $db->nameQuote('category_id') . ' IN(' . implode($viewableCats, ',') . ')' . ' UNION' . ' SELECT a.*, ' . $db->Quote('profile') . ' as `type`' . ' FROM ' . $db->nameQuote('#__discuss_users_history') . ' AS a' . ' WHERE a.' . $db->nameQuote('user_id') . '=' . $db->Quote($userId) . ' AND a.' . $db->nameQuote('command') . ' IN(' . $db->Quote('easydiscuss.new.avatar') . ' , ' . $db->Quote('easydiscuss.update.profile') . ')' . ' ORDER BY ' . $db->nameQuote('created') . ' DESC' . ' LIMIT 0,20';
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:34,代码来源:points.php


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