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


PHP DiscussHelper::getPrivateCategories方法代码示例

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


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

示例1: getData

 public function getData($params)
 {
     if (!class_exists('EasyDiscussModelPosts')) {
         jimport('joomla.application.component.model');
         JLoader::import('posts', DISCUSS_MODELS);
     }
     $count = (int) trim($params->get('count', 0));
     $db = DiscussHelper::getDBO();
     $queryExclude = '';
     $excludeCats = DiscussHelper::getPrivateCategories();
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     // posts
     $query = 'select a.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`id` as `parent_id`, a.category_id,';
     $query .= ' (select count(1) from `#__discuss_votes` as b1 where b1.`post_id` = a.`id`) as `VotedCnt`, count( c.id ) as `num_replies`';
     $query .= ' from `#__discuss_posts` as a ';
     $query .= ' left join `#__discuss_posts` as c on a.`id` = c.`parent_id`';
     $query .= ' 	and c.`published` = 1';
     $query .= ' inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
     $query .= ' where a.`parent_id` = 0';
     $query .= ' and a.`published` = 1';
     if (!empty($excludeCats)) {
         $query .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $query .= ' group by a.`id`';
     // union both posts and replies
     $query .= ' union ';
     // replies
     $query .= ' select c.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`parent_id`, c.category_id, ';
     $query .= ' count( b.id ) as `VotedCnt`, 0 as `num_replies`';
     $query .= ' from `#__discuss_posts` as a';
     $query .= '   inner join `#__discuss_posts` as c on a.`parent_id` = c.`id`';
     $query .= '   inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
     $query .= ' where a.`published` = 1';
     $query .= ' and c.`published` = 1';
     if (!empty($excludeCats)) {
         $query .= ' and c.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $query .= ' group by a.`id`';
     // ordring
     $query .= ' order by VotedCnt desc';
     if ($count > 0) {
         $query .= ' limit ' . $count;
     }
     $db->setQuery($query);
     $posts = $db->loadObjectList();
     return $posts;
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:49,代码来源:helper.php

示例2: getChildCategories

 public static function getChildCategories(&$result, $params, &$categories, $level = 1)
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $order = $params->get('order', 'popular');
     $sort = $params->get('sort', 'desc');
     $count = (int) trim($params->get('count', 0));
     $hideEmptyPost = $params->get('hideemptypost', '0');
     $queryExclude = '';
     $excludeCats = DiscussHelper::getPrivateCategories();
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     foreach ($result as $row) {
         $categories[$row->id] = $row;
         $categories[$row->id]->childs = array();
         $query = 'SELECT a.`id`, a.`title`, a.`parent_id`, a.`alias`, a.`avatar`, COUNT(b.`id`) AS `discussioncount`' . ', ' . $db->quote($level) . ' AS level,' . ' ( SELECT COUNT(id) FROM ' . $db->nameQuote('#__discuss_category') . ' WHERE lft < a.lft AND rgt > a.rgt AND a.lft != ' . $db->Quote(0) . ' ) AS depth' . ' FROM ' . $db->nameQuote('#__discuss_category') . ' AS `a`' . ' LEFT JOIN ' . $db->nameQuote('#__discuss_posts') . ' AS b' . ' ON a.`id` = b.`category_id`' . ' AND b.`parent_id` = ' . $db->Quote('0') . ' AND b.`published` = ' . $db->Quote('1');
         $query .= ' WHERE a.`published` = 1';
         $query .= ' AND a.`parent_id`=' . $db->Quote($row->id);
         $query .= $queryExclude;
         if (!$hideEmptyPost) {
             $query .= ' GROUP BY a.`id`';
         } else {
             $query .= ' GROUP BY a.`id` HAVING (COUNT(b.`id`) > 0)';
         }
         switch ($order) {
             case 'popular':
                 $orderBy = ' ORDER BY `discussioncount` ';
                 break;
             case 'alphabet':
                 $orderBy = ' ORDER BY a.`title` ';
                 break;
             case 'latest':
             default:
                 $orderBy = ' ORDER BY a.`created` ';
                 break;
         }
         $query .= $orderBy . $sort;
         $db->setQuery($query);
         $records = $db->loadObjectList();
         if ($records) {
             modEasydiscussCategoriesHelper::getChildCategories($records, $params, $categories[$row->id]->childs, ++$level);
         }
     }
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:46,代码来源:helper.php

示例3: getSimilarQuestion

 /**
  * Retrieve similar question based on the keywords
  *
  * @access	public
  * @param	string	$keywords
  */
 public static function getSimilarQuestion($text = '')
 {
     if (empty($text)) {
         return '';
     }
     $config = Discusshelper::getConfig();
     if (!$config->get('main_similartopic', 0)) {
         return '';
     }
     // $text   = 'how to configure facebook integration?';
     $itemLimit = $config->get('main_similartopic_limit', '5');
     $db = DiscussHelper::getDBO();
     // remove punctuation from the string.
     $text = preg_replace("/(?![.=\$'â?])\\p{P}/u", "", $text);
     //$text = preg_replace("/(?![.=$'â?)\p{P}/u", "", $text);
     $queryExclude = '';
     if (!$config->get('main_similartopic_privatepost', 0)) {
         $excludeCats = DiscussHelper::getPrivateCategories();
         if (!empty($excludeCats)) {
             $queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
         }
     }
     // lets check if db has more than 2 records or not.
     $query = 'SELECT COUNT(1) FROM `#__discuss_posts` as a';
     $query .= ' WHERE a.`published` = ' . $db->Quote('1');
     $query .= ' AND a.`parent_id` = ' . $db->Quote('0');
     $query .= $queryExclude;
     $db->setQuery($query);
     $rCount = $db->loadResult();
     if ($rCount <= 2) {
         // full index search will fail if record has only two. So we do a normal like search.
         $phrase = 'or';
         $words = explode(' ', $text);
         $wheres = array();
         foreach ($words as $word) {
             $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false);
             $wheres2 = array();
             $wheres2[] = 'a.title LIKE ' . $word;
             $wheres2[] = 'a.content LIKE ' . $word;
             $wheres[] = implode(' OR ', $wheres2);
         }
         $whereString = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
         $query = 'select a.`id`,  a.`title`, 0 AS score';
         $query .= ' FROM `#__discuss_posts` as a';
         $query .= ' WHERE a.`published` = ' . $db->Quote('1');
         $query .= ' AND a.`parent_id` = ' . $db->Quote('0');
         $query .= ' AND ' . $whereString;
         $query .= $queryExclude;
         $query .= ' LIMIT ' . $itemLimit;
         $db->setQuery($query);
         $result = $db->loadObjectList();
         return $result;
     }
     // we know table has more than 3 records.
     // lets do a full index search.
     // lets get the tags match the keywords
     $tagkeywords = explode(' ', $text);
     for ($i = 0; $i < count($tagkeywords); $i++) {
         if (JString::strlen($tagkeywords[$i]) > 3) {
             $tagkeywords[$i] = $tagkeywords[$i] . '*';
         } else {
             $tagkeywords[$i] = $tagkeywords[$i];
         }
     }
     $tagkeywords = implode(' ', $tagkeywords);
     $query = 'select `id` FROM `#__discuss_tags`';
     $query .= ' WHERE MATCH(`title`) AGAINST (' . $db->Quote($tagkeywords) . ' IN BOOLEAN MODE)';
     $db->setQuery($query);
     $tagResults = $db->loadResultArray();
     // now try to get the main topic
     $query = 'select a.`id`,  a.`title`, MATCH(a.`title`,a.`content`) AGAINST (' . $db->Quote($text) . ' WITH QUERY EXPANSION) AS score';
     $query .= ' FROM `#__discuss_posts` as a';
     $query .= ' WHERE MATCH(a.`title`,a.`content`) AGAINST (' . $db->Quote($text) . ' WITH QUERY EXPANSION)';
     $query .= ' AND a.`published` = ' . $db->Quote('1');
     $query .= ' AND a.`parent_id` = ' . $db->Quote('0');
     $query .= $queryExclude;
     $tagQuery = '';
     if (count($tagResults) > 0) {
         $tagQuery = 'select a.`id`,  a.`title`, MATCH(a.`title`,a.`content`) AGAINST (' . $db->Quote($text) . ' WITH QUERY EXPANSION) AS score';
         $tagQuery .= ' FROM `#__discuss_posts` as a';
         $tagQuery .= ' 	INNER JOIN `#__discuss_posts_tags` as b ON a.id = b.post_id';
         $tagQuery .= ' WHERE MATCH(a.`title`,a.`content`) AGAINST (' . $db->Quote($text) . ' WITH QUERY EXPANSION)';
         $tagQuery .= ' AND a.`published` = ' . $db->Quote('1');
         $tagQuery .= ' AND a.`parent_id` = ' . $db->Quote('0');
         $tagQuery .= ' AND b.`tag_id` IN (' . implode(',', $tagResults) . ')';
         $tagQuery .= $queryExclude;
         $query = 'SELECT * FROM (' . $query . ' UNION ' . $tagQuery . ') AS x LIMIT ' . $itemLimit;
     } else {
         $query .= ' LIMIT ' . $itemLimit;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:100,代码来源:helper.php

示例4: getFeaturedPosts

 public function getFeaturedPosts($category = '')
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $queryExclude = '';
     $excludeCats = array();
     // get all private categories id
     $excludeCats = DiscussHelper::getPrivateCategories();
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $query = 'SELECT a.* FROM `#__discuss_posts` AS a';
     if (!empty($tagId)) {
         $query .= ' INNER JOIN `#__discuss_posts_tags` AS b ON a.`id` = b.`post_id`';
         $query .= ' AND b.`tag_id` = ' . $db->Quote($tagId);
     }
     $query .= ' WHERE a.`featured` = ' . $db->Quote('1');
     $query .= ' AND a.`parent_id` = ' . $db->Quote('0');
     $query .= ' AND a.`published` = ' . $db->Quote('1');
     if ($category) {
         $query .= ' AND a.`category_id`=' . $db->Quote($category);
     }
     $query .= $queryExclude;
     $db->setQuery($query);
     $result = $db->loadResult();
     return $result;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:27,代码来源:posts.php

示例5: getTagCloud

 function getTagCloud($limit = '', $order = 'title', $sort = 'asc', $userId = '')
 {
     $db = DiscussHelper::getDBO();
     $query = 'select a.`id`, a.`title`, a.`alias`, a.`created`, count(c.`id`) as `post_count`';
     $query .= ' from #__discuss_tags as a';
     $query .= '    left join #__discuss_posts_tags as b';
     $query .= '    on a.`id` = b.`tag_id`';
     $query .= '    left join #__discuss_posts as c';
     $query .= '    on b.post_id = c.id';
     $query .= '    and c.`private`=' . $db->Quote(0);
     $query .= '    and c.`published` = ' . $db->Quote('1');
     $exclude = DiscussHelper::getPrivateCategories();
     if (!empty($exclude)) {
         $query .= ' AND c.`category_id` NOT IN(' . implode(',', $exclude) . ')';
     }
     $query .= ' where a.`published` = ' . $db->Quote('1');
     if (!empty($userId)) {
         $query .= ' AND a.`user_id`=' . $db->Quote($userId);
     }
     $query .= ' group by (a.`id`)';
     //order
     switch ($order) {
         case 'postcount':
             $query .= ' ORDER BY (post_count)';
             break;
         case 'title':
         default:
             $query .= ' ORDER BY (a.`title`)';
     }
     //sort
     switch ($sort) {
         case 'asc':
             $query .= ' asc ';
             break;
         case 'desc':
         default:
             $query .= ' desc ';
     }
     //limit
     if (!empty($limit)) {
         $query .= ' LIMIT ' . (int) $limit;
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     return $result;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:46,代码来源:tags.php

示例6: canViewReplies

 public function canViewReplies()
 {
     if (DiscussHelper::isModerator($this->id)) {
         return true;
     }
     $privCats = DiscussHelper::getPrivateCategories(DISCUSS_CATEGORY_ACL_ACTION_VIEWREPLY);
     $canView = in_array($this->id, $privCats) ? false : true;
     return $canView;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:9,代码来源:category.php

示例7: getCategoryTree

 public function getCategoryTree($sortParentChild = true)
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $sortConfig = $config->get('layout_ordering_category', 'latest');
     $queryExclude = '';
     $excludeCats = array();
     // get all private categories id
     $excludeCats = DiscussHelper::getPrivateCategories();
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $query = 'SELECT a.*, COUNT(b.id) -1 as depth';
     $query .= ' FROM ' . $db->nameQuote('#__discuss_category') . ' AS a ';
     $query .= ' INNER JOIN ' . $db->nameQuote('#__discuss_category') . ' AS b';
     $query .= ' WHERE a.`published`=' . $db->Quote(DISCUSS_ID_PUBLISHED);
     $query .= ' AND (a.lft between b.lft and b.rgt)';
     $query .= $queryExclude;
     $query .= ' GROUP BY a.id';
     if (!$config->get('layout_show_all_subcategories')) {
         $query .= ' HAVING ' . $db->nameQuote('depth') . ' = 0';
     }
     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);
     $rows = $db->loadObjectList();
     $total = count($rows);
     $categories = array();
     for ($i = 0; $i < $total; $i++) {
         $category = DiscussHelper::getTable('Category');
         $category->bind($rows[$i]);
         $category->depth = $rows[$i]->depth;
         $categories[] = $category;
     }
     if ($sortParentChild && ($sortConfig == 'alphabet' || $sortConfig == 'latest')) {
         $cats = array();
         $groups = array();
         foreach ($categories as $row) {
             $cats[$row->parent_id][] = $row;
         }
         $this->sortAlpha($groups, $cats, 0);
         $categories = $groups;
     }
     return $categories;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:60,代码来源:categories.php

示例8: _buildQuery

 /**
  * Method to build the query for the tags
  *
  * @access private
  * @return string
  */
 private function _buildQuery($sort = 'latest', $filter = '', $category = '')
 {
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $date = DiscussHelper::getDate();
     $db = DiscussHelper::getDBO();
     // Get the WHERE and ORDER BY clauses for the query
     if (empty($this->_parent)) {
         $parent_id = JRequest::getInt('parent_id', 0);
         $this->_parent = $parent_id;
     }
     $filteractive = empty($filter) ? JRequest::getString('filter', 'allposts') : $filter;
     $where = '';
     $orderby = '';
     $queryExclude = '';
     $excludeCats = array();
     $excludeCats = DiscussHelper::getPrivateCategories();
     if (!empty($excludeCats)) {
         $queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     // // Posts
     $pquery = 'SELECT DATEDIFF(' . $db->Quote($date->toMySQL()) . ', a.`created` ) as `noofdays`, ';
     $pquery .= ' DATEDIFF(' . $db->Quote($date->toMySQL()) . ', IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) ) as `daydiff`, ';
     $pquery .= ' TIMEDIFF(' . $db->Quote($date->toMySQL()) . ', IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) ) as `timediff`,';
     $pquery .= ' ' . $db->Quote('posts') . ' as `itemtype`,';
     $pquery .= ' a.`id`, a.`title`, a.`content`, a.`user_id`, a.`category_id`, a.`parent_id`, a.`user_type`, a.`created` AS `created`, a.`poster_name`,';
     $pquery .= ' b.`title` AS `category`, a.password, a.`featured` AS `featured`, a.`islock` AS `islock`, a.`isresolve` AS `isresolve`,';
     $pquery .= ' IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) as `lastupdate`';
     $pquery .= ' ,a.`legacy`, pt.`suffix` AS post_type_suffix, pt.`title` AS post_type_title';
     $pquery .= ' FROM `#__discuss_posts` AS a';
     $pquery .= '	LEFT JOIN ' . $db->nameQuote('#__discuss_category') . ' AS b ON a.`category_id`=b.`id`';
     $pquery .= '	LEFT JOIN ' . $db->nameQuote('#__discuss_post_types') . ' AS pt ON a.`post_type`= pt.`alias`';
     $pquery .= $this->_buildQueryWhere('posts', 'a', $category);
     $pquery .= $queryExclude;
     // // Replies
     $rquery = 'SELECT DATEDIFF(' . $db->Quote($date->toMySQL()) . ', a.`created` ) as `noofdays`, ';
     $rquery .= ' DATEDIFF(' . $db->Quote($date->toMySQL()) . ', IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) ) as `daydiff`, ';
     $rquery .= ' TIMEDIFF(' . $db->Quote($date->toMySQL()) . ', IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) ) as `timediff`,';
     $rquery .= ' ' . $db->Quote('replies') . ' as `itemtype`,';
     $rquery .= ' a.`id`, a.`title`, a.`content`, a.`user_id`, a.`category_id`, a.`parent_id`, a.`user_type`,a.`created` AS `created`, a.`poster_name`,';
     $rquery .= ' b.`title` AS `category`, a.password, a.`featured` AS `featured`, a.`islock` AS `islock`, a.`isresolve` AS `isresolve`,';
     $rquery .= ' IF(a.`replied` = ' . $db->Quote('0000-00-00 00:00:00') . ', a.`created`, a.`replied`) as `lastupdate`';
     $rquery .= ' ,a.`legacy`, ' . $db->Quote('') . ' AS `post_type_suffix`, ' . $db->Quote('') . ' AS `post_type_title`';
     $rquery .= ' FROM `#__discuss_posts` AS a';
     $rquery .= '	LEFT JOIN ' . $db->nameQuote('#__discuss_category') . ' AS b ON a.`category_id`=b.`id`';
     $rquery .= $this->_buildQueryWhere('replies', 'a', $category);
     $rquery .= $queryExclude;
     // Categories
     $cquery = 'SELECT 0 as `noofdays`, ';
     $cquery .= ' 0 as `daydiff`, ';
     $cquery .= ' ' . $db->Quote('00:00:00') . ' as `timediff`,';
     $cquery .= ' ' . $db->Quote('category') . ' as `itemtype`,';
     $cquery .= ' a.`id`, a.`title`, a.`description` as `content`, a.`created_by` as `user_id`, a.`id` as `category_id`, 0 as `parent_id`, 0 AS `user_type`, a.`created` AS `created`, 0 as `poster_name`,';
     $cquery .= ' a.`title` AS `category`, 0 AS `password`,0 as `featured`, 0 as `islock` , 0 as `isresolve`,';
     $cquery .= ' a.`created` as `lastupdate`,';
     $cquery .= ' 1 as `legacy`, ' . $db->Quote('') . ' AS `post_type_suffix`, ' . $db->Quote('') . ' AS `post_type_title`';
     $cquery .= ' FROM `#__discuss_category` AS a';
     $cquery .= $this->_buildQueryWhere('category', 'a', $category);
     if (!empty($excludeCats)) {
         $cquery .= ' AND a.`id` NOT IN (' . implode(',', $excludeCats) . ')';
     }
     $query = 'SELECT * FROM (';
     $query .= '(' . $pquery . ') UNION (' . $rquery . ') UNION (' . $cquery . ')';
     $query .= ') as x';
     $query .= ' ORDER BY x.`lastupdate` DESC';
     return $query;
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:73,代码来源:search.php


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