本文整理汇总了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];
}
示例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;
}