本文整理汇总了PHP中DiscussHelper::accessNestedCategoriesId方法的典型用法代码示例。如果您正苦于以下问题:PHP DiscussHelper::accessNestedCategoriesId方法的具体用法?PHP DiscussHelper::accessNestedCategoriesId怎么用?PHP DiscussHelper::accessNestedCategoriesId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiscussHelper
的用法示例。
在下文中一共展示了DiscussHelper::accessNestedCategoriesId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getParentIdsWithPost
protected function _getParentIdsWithPost()
{
$db = DiscussHelper::getDBO();
$my = JFactory::getUser();
$query = 'select * from `#__discuss_category`';
$query .= ' where `published` = 1';
$query .= ' and `parent_id` = 0';
if ($my->id == 0) {
$query .= ' and `private` = 0';
}
$db->setQuery($query);
$result = $db->loadObjectList();
$validCat = array();
if (count($result) > 0) {
for ($i = 0; $i < count($result); $i++) {
$item =& $result[$i];
$item->childs = null;
DiscussHelper::buildNestedCategories($item->id, $item);
$catIds = array();
$catIds[] = $item->id;
DiscussHelper::accessNestedCategoriesId($item, $catIds);
$item->cnt = $this->getTotalPostCount($catIds);
if ($item->cnt > 0) {
$validCat[] = $item->id;
}
}
}
return $validCat;
}
示例2: getPrivateCategories
public static function getPrivateCategories($acltype = DISCUSS_CATEGORY_ACL_ACTION_VIEW)
{
$db = DiscussHelper::getDBO();
$my = JFactory::getUser();
static $result = array();
$excludeCats = array();
$sig = (int) $my->id . '-' . (int) $acltype;
if (!isset($result[$sig])) {
if ($my->id == 0) {
$catQuery = 'select distinct a.`id`, a.`private`';
$catQuery .= ' from `#__discuss_category` as a';
$catQuery .= ' left join `#__discuss_category_acl_map` as b on a.`id` = b.`category_id`';
$catQuery .= ' and b.`acl_id` = ' . $db->Quote($acltype);
$catQuery .= ' and b.`type` = ' . $db->Quote('group');
$catQuery .= ' where a.`private` != ' . $db->Quote('0');
$gid = array();
$gids = '';
if (DiscussHelper::getJoomlaVersion() >= '1.6') {
// $gid = JAccess::getGroupsByUser(0, false);
$gid = DiscussHelper::getUserGroupId($my);
} else {
$gid = DiscussHelper::getUserGids();
}
if (count($gid) > 0) {
foreach ($gid as $id) {
$gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
}
$catQuery .= ' and a.`id` NOT IN (';
$catQuery .= ' SELECT c.category_id FROM `#__discuss_category_acl_map` as c ';
$catQuery .= ' WHERE c.acl_id = ' . $db->Quote($acltype);
$catQuery .= ' AND c.type = ' . $db->Quote('group');
$catQuery .= ' AND c.content_id IN (' . $gids . ') )';
}
$db->setQuery($catQuery);
$result = $db->loadObjectList();
} else {
$result = self::getAclCategories($acltype, $my->id);
}
for ($i = 0; $i < count($result); $i++) {
$item =& $result[$i];
$item->childs = null;
DiscussHelper::buildNestedCategories($item->id, $item, true);
$catIds = array();
$catIds[] = $item->id;
DiscussHelper::accessNestedCategoriesId($item, $catIds);
$excludeCats = array_merge($excludeCats, $catIds);
}
$result[$sig] = $excludeCats;
}
return $result[$sig];
}
示例3: getPostCount
/**
* Retrieves the number of post count from a particular category.
*
* @since 3.0
* @access public
*/
public function getPostCount()
{
$db = DiscussHelper::getDBO();
$my = JFactory::getUser();
$queryExclude = '';
$excludeCats = array();
// We need to determine if the user is a guest.
// If it is a guest, we need to retrieve all private categories.
if (!$my->id) {
$query = 'SELECT a.' . $db->nameQuote('id') . ',' . $db->nameQuote('private');
$query .= ' FROM ' . $db->nameQuote('#__discuss_category') . ' AS a';
$query .= ' WHERE a.' . $db->nameQuote('private') . '=' . $db->Quote(1);
$db->setQuery($query);
$result = $db->loadObjectList();
for ($i = 0; $i < count($result); $i++) {
$item = $result[$i];
$item->childs = null;
DiscussHelper::buildNestedCategories($item->id, $item);
$catIds = array();
$catIds[] = $item->id;
DiscussHelper::accessNestedCategoriesId($item, $catIds);
$excludeCats = array_merge($excludeCats, $catIds);
}
}
$model = DiscussHelper::getModel('Categories');
$childs = $model->getChildIds($this->id);
$total = count($childs);
$subcategories = array();
$subcategories[] = $this->id;
if ($childs) {
for ($i = 0; $i < $total; $i++) {
$subcategories[] = $childs[$i];
}
}
$filtered = array_diff($subcategories, $excludeCats);
if (empty($filtered)) {
// just a temp fix when DiscussHelper::getPrivateCategories()
// failed to get correct result and it will cause the following
// query fails with error 500.
return;
}
$allowedCategories = array();
foreach ($filtered as $filteredCategory) {
if ($filteredCategory) {
$allowedCategories[] = $db->Quote($filteredCategory);
}
}
$query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__discuss_posts') . ' ' . 'WHERE ' . $db->nameQuote('category_id') . ' IN (' . implode(',', $allowedCategories) . ') ' . 'AND ' . $db->nameQuote('parent_id') . '=' . $db->Quote(0) . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote(DISCUSS_ID_PUBLISHED);
$db->setQuery($query);
$count = $db->loadResult();
return $count;
}