コード例 #1
0
ファイル: kb.php プロジェクト: sumudinie/hubzero-cms
 /**
  * Pull a list of records that were created within the time frame ($period)
  *
  * @param      object  $period     Time period to pull results for
  * @param      mixed   $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      array   $areas      Active area(s)
  * @param      array   $tagids     Array of tag IDs
  * @return     array
  */
 public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array())
 {
     if (is_array($areas) && $limit) {
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) {
             return array();
         }
     }
     // Do we have a search term?
     if (!is_object($period)) {
         return array();
     }
     $database = App::get('db');
     // Build the query
     $f_count = "SELECT COUNT(*)";
     $f_fields = "SELECT" . " f.id, " . " f.title, " . " 'kb' AS section, NULL AS subsection, " . " f.fulltxt AS text," . " CONCAT('index.php?option=com_kb&task=article&id=', f.id) AS href";
     $f_from = " FROM #__kb_articles AS f";
     $f_where = "f.state=1 AND f.created > '{$period->cStartDate}' AND f.created < '{$period->cEndDate}' AND f.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")";
     $order_by = " ORDER BY created DESC, title";
     $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : "";
     if (!$limit) {
         // Get a count
         $database->setQuery($f_count . $f_from . " WHERE " . $f_where);
         return $database->loadResult();
     } else {
         // Get results
         $database->setQuery($f_fields . $f_from . " WHERE " . $f_where . $order_by);
         $rows = $database->loadObjectList();
         foreach ($rows as $key => $row) {
             $rows[$key]->href = Route::url($row->href);
         }
         return $rows;
     }
 }
コード例 #2
0
 /**
  * Register the service provider.
  *
  * @return  void
  */
 public function register()
 {
     $this->app['menu.manager'] = function ($app) {
         return $manager = new Manager();
     };
     $this->app['menu'] = function ($app) {
         $options = ['language_filter' => null, 'language' => null, 'access' => \User::getAuthorisedViewLevels()];
         $options['db'] = $app->get('db');
         if ($app->has('language.filter')) {
             $options['language_filter'] = $app->get('language.filter');
             $options['language'] = $app->get('language')->getTag();
         }
         return $app['menu.manager']->menu($app['client']->name, $options);
     };
     $this->app['menu.params'] = function ($app) {
         $params = new Registry();
         $menu = $app['menu']->getActive();
         if (is_object($menu)) {
             $params->parse($menu->params);
         } else {
             if ($app->has('component')) {
                 $temp = clone $app['component']->params('com_menus');
                 $params->merge($temp);
             }
         }
         return $params;
     };
 }
コード例 #3
0
ファイル: kb.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Pull a list of records that were created within the time frame ($period)
  *
  * @param      object  $period     Time period to pull results for
  * @param      mixed   $limit      Number of records to pull
  * @param      integer $limitstart Start of records to pull
  * @param      array   $areas      Active area(s)
  * @param      array   $tagids     Array of tag IDs
  * @return     array
  */
 public function onWhatsnew($period, $limit = 0, $limitstart = 0, $areas = null, $tagids = array())
 {
     if (is_array($areas) && $limit) {
         if (!isset($areas[$this->_name]) && !in_array($this->_name, $areas)) {
             return array();
         }
     }
     // Do we have a search term?
     if (!is_object($period)) {
         return array();
     }
     $database = App::get('db');
     // Build the query
     $f_count = "SELECT COUNT(*)";
     $f_fields = "SELECT\n\t\t\tf.id,\n\t\t\tf.title,\n\t\t\tf.fulltxt AS `text`,\n\t\t\tconcat('index.php?option=com_kb&section=', coalesce(concat(c.path, '/'), ''), f.alias) AS href,\n\t\t\t'kb' AS section,\n\t\t\tc.alias AS subsection";
     $f_from = " FROM `#__kb_articles` AS f\n\t\t\tLEFT JOIN `#__categories` AS c\n\t\t\t\tON c.id = f.category\n\t\t\tWHERE f.state=1\n\t\t\t\tAND c.published = 1\n\t\t\t\tAND f.created > " . $database->quote($period->cStartDat) . "\n\t\t\t\tAND f.created < " . $database->quote($period->cEndDate) . "\n\t\t\t\tAND f.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")";
     $order_by = " ORDER BY f.created DESC, f.title";
     $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : "";
     if (!$limit) {
         // Get a count
         $database->setQuery($f_count . $f_from);
         return $database->loadResult();
     } else {
         // Get results
         $database->setQuery($f_fields . $f_from . $order_by);
         $rows = $database->loadObjectList();
         foreach ($rows as $key => $row) {
             $rows[$key]->href = Route::url($row->href);
         }
         return $rows;
     }
 }
コード例 #4
0
ファイル: blogs.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $now = Date::toSql();
     $terms = $request->get_term_ar();
     $weight = '(match(be.title, be.content) against (\'' . join(' ', $terms['stemmed']) . '\'))';
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(be.title LIKE '%{$mand}%' OR be.content LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(be.title NOT LIKE '%{$forb}%' AND be.content NOT LIKE '%{$forb}%')";
     }
     $addtl_where[] = "(be.publish_up <= '{$now}')";
     $addtl_where[] = "(be.publish_down = '0000-00-00 00:00:00' OR (be.publish_down != '0000-00-00 00:00:00' AND be.publish_down > '{$now}'))";
     $addtl_where[] = '(be.access IN (0,' . implode(',', User::getAuthorisedViewLevels()) . '))';
     $rows = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\tbe.id,\n\t\t\t\tbe.title,\n\t\t\t\tbe.content AS description,\n\t\t\t\t(CASE WHEN be.scope_id > 0 AND be.scope='group' THEN\n\t\t\t\t\tconcat('index.php?option=com_groups&cn=', g.cn, '&active=blog&scope=', extract(year from be.created), '/', extract(month from be.created), '/', be.alias)\n\t\t\t\tWHEN be.scope='member' AND be.scope_id > 0 THEN\n\t\t\t\t\tconcat('index.php?option=com_members&id=', be.created_by, '&active=blog&task=', extract(year from be.created), '/', extract(month from be.created), '/', be.alias)\n\t\t\t\tELSE\n\t\t\t\t\tconcat('index.php?option=com_blog&year=', extract(year from be.created), '&month=', extract(month from be.created), '&alias=', be.alias)\n\t\t\t\tEND) AS link,\n\t\t\t\t{$weight} AS weight,\n\t\t\t\t'Blog Entry' AS section,\n\t\t\t\tbe.created AS date,\n\t\t\t\tu.name AS contributors,\n\t\t\t\tbe.created_by AS contributor_ids\n\t\t\tFROM `#__blog_entries` be\n\t\t\tINNER JOIN `#__users` u ON u.id = be.created_by\n\t\t\tLEFT JOIN `#__xgroups` AS g ON g.gidNumber=be.scope_id AND be.scope='group'\n\t\t\tWHERE\n\t\t\t\tbe.state=1 AND\n\t\t\t\t{$weight} > 0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : ''));
     if (($rows = $rows->to_associative()) instanceof \Components\Search\Models\Basic\Result\Blank) {
         return;
     }
     $id_map = array();
     foreach ($rows as $idx => $row) {
         $id_map[$row->get('id')] = $idx;
     }
     $comments = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t \tCASE WHEN bc.anonymous THEN 'Anonymous Comment' ELSE concat('Comment by ', u.name) END AS title,\n\t\t\tbc.content AS description,\n\t\t\tconcat('index.php?option=com_members&id=', be.created_by, '&active=blog&task=', extract(year from be.created), '/', extract(month from be.created), '/', be.alias) AS link,\n\t\t\tbc.created AS date,\n\t\t\t'Comments' AS section,\n\t\t\tbc.entry_id\n\t\t\tFROM `#__blog_comments` bc\n\t\t\tINNER JOIN `#__blog_entries` be\n\t\t\t\tON be.id = bc.entry_id\n\t\t\tINNER JOIN `#__users` u\n\t\t\t\tON u.id = bc.created_by\n\t\t\tWHERE bc.entry_id IN (" . implode(',', array_keys($id_map)) . ")\n\t\t\tORDER BY bc.created");
     foreach ($comments->to_associative() as $comment) {
         $rows->at($id_map[$comment->get('entry_id')])->add_child($comment);
     }
     $results->add($rows);
 }
コード例 #5
0
 public function __construct(&$subject, $config)
 {
     parent::__construct($subject, $config);
     // Ensure that constructor is called one time
     self::$cookie = SID == '';
     if (!self::$default_lang) {
         $app = JFactory::getApplication();
         $router = $app->getRouter();
         if (App::isSite()) {
             // setup language data
             self::$mode_sef = $router->getMode() == JROUTER_MODE_SEF ? true : false;
             self::$sefs = JLanguageHelper::getLanguages('sef');
             self::$lang_codes = JLanguageHelper::getLanguages('lang_code');
             self::$default_lang = Component::params('com_languages')->get('site', 'en-GB');
             self::$default_sef = self::$lang_codes[self::$default_lang]->sef;
             self::$homes = MultilangstatusHelper::getHomepages();
             $levels = User::getAuthorisedViewLevels();
             foreach (self::$sefs as $sef => &$language) {
                 if (isset($language->access) && $language->access && !in_array($language->access, $levels)) {
                     unset(self::$sefs[$sef]);
                 }
             }
             App::forget('language.filter');
             App::set('language.filter', true);
             $uri = JFactory::getURI();
             if (self::$mode_sef) {
                 // Get the route path from the request.
                 $path = JString::substr($uri->toString(), JString::strlen($uri->base()));
                 // Apache mod_rewrite is Off
                 $path = Config::get('sef_rewrite') ? $path : JString::substr($path, 10);
                 // Trim any spaces or slashes from the ends of the path and explode into segments.
                 $path = JString::trim($path, '/ ');
                 $parts = explode('/', $path);
                 // The language segment is always at the beginning of the route path if it exists.
                 $sef = $uri->getVar('lang');
                 if (!empty($parts) && empty($sef)) {
                     $sef = reset($parts);
                 }
             } else {
                 $sef = $uri->getVar('lang');
             }
             if (isset(self::$sefs[$sef])) {
                 $lang_code = self::$sefs[$sef]->lang_code;
                 // Create a cookie
                 $cookie_domain = Config::get('cookie_domain', '');
                 $cookie_path = Config::get('cookie_path', '/');
                 setcookie(App::hash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
                 // set the request var
                 Request::setVar('language', $lang_code);
             }
         }
         parent::__construct($subject, $config);
         // 	Detect browser feature
         if (App::isSite()) {
             $app->setDetectBrowser($this->params->get('detect_browser', '1') == '1');
         }
     }
 }
コード例 #6
0
ファイル: helper.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Get module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once \Component::path('com_kb') . DS . 'models' . DS . 'archive.php';
     $a = new Archive();
     $popular = $a->articles()->whereIn('access', \User::getAuthorisedViewLevels())->whereEquals('state', 1)->order('helpful', 'desc')->limit(intval($this->params->get('limit', 5)))->rows();
     $this->cssId = $this->params->get('cssId');
     $this->cssClass = $this->params->get('cssClass');
     require $this->getLayoutPath();
 }
コード例 #7
0
ファイル: forum.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Retrieve records for items tagged with specific tags
  *
  * @param      array   $tags       Tags to match records against
  * @param      mixed   $limit      SQL record limit
  * @param      integer $limitstart SQL record limit start
  * @param      string  $sort       The field to sort records by
  * @param      mixed   $areas      An array or string of areas that should retrieve records
  * @return     mixed Returns integer when counting records, array when retrieving records
  */
 public function onTagView($tags, $limit = 0, $limitstart = 0, $sort = '', $areas = null)
 {
     $response = array('name' => $this->_name, 'title' => Lang::txt('PLG_TAGS_FORUM'), 'total' => 0, 'results' => null, 'sql' => '');
     $database = App::get('db');
     $ids = array();
     foreach ($tags as $tag) {
         $ids[] = $tag->get('id');
     }
     $ids = implode(',', $ids);
     $addtl_where = array();
     $gids = $this->_getGroupIds(User::get('id'));
     if (!User::authorise('core.view', 'com_forum')) {
         $addtl_where[] = 'e.scope_id IN (0' . ($gids ? ',' . join(',', $gids) : '') . ')';
     } else {
         $viewlevels = '0,' . implode(',', User::getAuthorisedViewLevels());
         if ($gids) {
             $addtl_where[] = '(e.access IN (' . $viewlevels . ') OR ((e.access = 4 OR e.access = 5) AND e.scope_id IN (0,' . join(',', $gids) . ')))';
         } else {
             $addtl_where[] = '(e.access IN (' . $viewlevels . '))';
         }
     }
     // Build the query
     $e_count = "SELECT COUNT(f.id) FROM (SELECT e.id, COUNT(DISTINCT t.tagid) AS uniques";
     $e_fields = "SELECT e.id, e.title, e.id AS alias, e.comment AS itext, e.comment AS ftext, e.state, e.created, e.created_by, e.modified, e.created AS publish_up, NULL AS publish_down,\n\t\t\t\t\t(CASE WHEN e.scope_id > 0 AND e.scope='group' THEN\n\t\t\t\t\t\tconcat('/groups/', g.cn, concat('/forum/', coalesce(concat(s.alias, '/', coalesce(concat(c.alias, '/'), ''))), CASE WHEN e.parent > 0 THEN e.parent ELSE e.id END))\n\t\t\t\t\tELSE\n\t\t\t\t\t\tconcat('/forum/', coalesce(concat(s.alias, '/', coalesce(concat(c.alias, '/'), ''))), CASE WHEN e.parent > 0 THEN e.parent ELSE e.id END)\n\t\t\t\t\tEND) AS href,\n\t\t\t\t\t'forum' AS section, COUNT(DISTINCT t.tagid) AS uniques, CONCAT(e.thread, ':', e.parent) AS params, e.scope AS rcount, c.alias AS data1, s.alias AS data2, e.scope_id AS data3 ";
     //e.last_activity AS rcount, c.alias AS data1, s.alias AS data2, g.cn AS data3
     $e_from = " FROM #__forum_posts AS e\n\t\t \t\t\tLEFT JOIN #__forum_categories c ON c.id = e.category_id\n\t\t\t\t\tLEFT JOIN #__forum_sections s ON s.id = c.section_id\n\t\t\t\t\tLEFT JOIN #__xgroups g ON g.gidNumber = e.scope_id\n\t\t\t\t\tLEFT JOIN #__tags_object AS t ON t.objectid=e.id AND t.tbl='forum' AND t.tagid IN ({$ids})";
     $e_where = " WHERE e.state=1 AND e.parent=0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '');
     $e_where .= " GROUP BY e.id HAVING uniques=" . count($tags);
     $order_by = " ORDER BY ";
     switch ($sort) {
         case 'title':
             $order_by .= 'title ASC, created';
             break;
         case 'id':
             $order_by .= "id DESC";
             break;
         case 'date':
         default:
             $order_by .= 'created DESC, title';
             break;
     }
     $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : "";
     $database->setQuery($e_count . $e_from . $e_where . ") AS f");
     $response['total'] = $database->loadResult();
     if ($areas && $areas == $response['name']) {
         $database->setQuery($e_fields . $e_from . $e_where . $order_by);
         $response['results'] = $database->loadObjectList();
     } else {
         $response['sql'] = $e_fields . $e_from . $e_where;
     }
     return $response;
 }
コード例 #8
0
ファイル: kb.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $terms = $request->get_term_ar();
     $weight = 'match(f.title, f.`fulltxt`) against (\'' . join(' ', $terms['stemmed']) . '\')';
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(f.title LIKE '%{$mand}%' OR f.`fulltxt` LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(f.title NOT LIKE '%{$forb}%' AND f.`fulltxt` NOT LIKE '%{$forb}%')";
     }
     $addtl_where[] = '(f.access IN (0,' . implode(',', User::getAuthorisedViewLevels()) . '))';
     $results->add(new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\tf.title,\n\t\t\t\tcoalesce(f.`fulltxt`, '') AS description,\n\t\t\t\tconcat('index.php?option=com_kb&category=', coalesce(concat(c.alias, '/'), ''), f.alias) AS link,\n\t\t\t\t{$weight} AS weight,\n\t\t\t\tcreated AS date,\n\t\t\t\tc.path AS section\n\t\t\tFROM `#__kb_articles` f\n\t\t\tLEFT JOIN `#__categories` c\n\t\t\t\tON c.id = f.category\n\t\t\tWHERE\n\t\t\t\tf.state = 1 AND c.published = 1 AND\n\t\t\t\t{$weight} > 0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . " ORDER BY {$weight} DESC"));
 }
コード例 #9
0
ファイル: feeds.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Default component view
  *
  * @return  void
  */
 public function displayTask()
 {
     if (User::isGuest()) {
         $rtrn = Request::getVar('REQUEST_URI', Route::url('index.php?option=' . $this->_option . '&task=' . $this->_task), 'server');
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($rtrn)), Lang::txt('COM_FEEDAGGREGATOR_LOGIN_NOTICE'), 'warning');
     }
     $authlevel = User::getAuthorisedViewLevels();
     $access_level = 3;
     //author_level
     if (!in_array($access_level, $authlevel)) {
         App::redirect(Route::url('index.php?option=com_feedaggregator'), Lang::txt('COM_FEEDAGGREGATOR_NOT_AUTH'), 'warning');
     }
     $feeds = Feed::all()->rows();
     $this->view->set('title', Lang::txt('COM_FEEDAGGREGATOR'))->set('feeds', $feeds)->display();
 }
コード例 #10
0
ファイル: forum.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $terms = $request->get_term_ar();
     $weight = "match(f.title, f.comment) against ('" . join(' ', $terms['stemmed']) . "')";
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(f.title LIKE '%{$mand}%' OR f.comment LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(f.title NOT LIKE '%{$forb}%' AND f.comment NOT LIKE '%{$forb}%')";
     }
     $gids = $authz->get_group_ids();
     if (!User::authorise('core.view', 'com_groups')) {
         $addtl_where[] = 'f.scope_id IN (0' . ($gids ? ',' . join(',', $gids) : '') . ')';
     } else {
         $viewlevels = implode(',', User::getAuthorisedViewLevels());
         if ($gids) {
             $addtl_where[] = '(f.access IN (0,' . $viewlevels . ') OR ((f.access = 4 OR f.access = 5) AND f.scope_id IN (0,' . join(',', $gids) . ')))';
         } else {
             $addtl_where[] = '(f.access IN (0,' . $viewlevels . '))';
         }
     }
     // fml
     $groupAuth = array();
     if ($authz->is_super_admin()) {
         $groupAuth[] = '1';
     } else {
         $groupAuth[] = "g.plugins LIKE '%forum=anyone%'";
         if (!$authz->is_guest()) {
             $groupAuth[] = "g.plugins LIKE '%forum=registered%'";
             if ($gids) {
                 $groupAuth[] = "(g.plugins LIKE '%wiki=members%' AND g.gidNumber IN (" . join(',', $gids) . "))";
             }
         }
     }
     $rows = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\tf.title,\n\t\t\t\tcoalesce(f.comment, '') AS description, f.scope_id, s.alias as sect, c.alias as cat, CASE WHEN f.parent > 0 THEN f.parent ELSE f.id END as `thread`,\n\t\t\t\t(CASE\n\t\t\t\t\tWHEN f.scope_id > 0 AND f.scope='group' THEN concat('index.php?option=com_groups&cn=', g.cn, '&active=forum')\n\t\t\t\t\tELSE concat('index.php?option=com_forum&section=', coalesce(concat(s.alias, '&category=', coalesce(concat(c.alias, '&thread='), ''))), CASE WHEN f.parent > 0 THEN f.parent ELSE f.id END)\n\t\t\t\tEND) AS `link`,\n\t\t\t\t{$weight} AS `weight`,\n\t\t\t\tf.created AS `date`,\n\t\t\t\tconcat(s.alias, ', ', c.alias) AS `section`\n\t\t\tFROM `#__forum_posts` f\n\t\t\tLEFT JOIN `#__forum_categories` AS c\n\t\t\t\tON c.id = f.category_id\n\t\t\tLEFT JOIN `#__forum_sections` AS s\n\t\t\t\tON s.id = c.section_id\n\t\t\tLEFT JOIN `#__xgroups` AS g\n\t\t\t\tON g.gidNumber = f.scope_id AND f.scope='group'\n\t\t\tWHERE\n\t\t\t\tf.state = 1 AND\n\t\t\t\tf.scope != 'course' AND\n\t\t\t\t{$weight} > 0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . " AND (g.gidNumber IS NULL OR (" . implode(' OR ', $groupAuth) . "))\n\t\t\tORDER BY {$weight} DESC");
     foreach ($rows->to_associative() as $row) {
         if (!$row) {
             continue;
         }
         if ($row->scope_id) {
             $row->link .= '/' . ($row->sect ? $row->sect : 'defaultsection') . '/';
             $row->link .= ($row->cat ? $row->cat : 'discussion') . '/';
             $row->link .= $row->thread;
         }
         $results->add($row);
     }
 }
コード例 #11
0
ファイル: content.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $terms = $request->get_term_ar();
     $weight = 'match(c.title, c.introtext, c.`fulltext`) against (\'' . join(' ', $terms['stemmed']) . '\')';
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(c.title LIKE '%{$mand}%' OR c.introtext LIKE '%{$mand}%' OR c.`fulltext` LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(c.title NOT LIKE '%{$forb}%' AND c.introtext NOT LIKE '%{$forb}%' AND c.`fulltext` NOT LIKE '%{$forb}%')";
     }
     $addtl_where[] = '(c.access IN (' . implode(',', User::getAuthorisedViewLevels()) . '))';
     $query = "SELECT\n\t\t\tc.title,\n\t\t\tconcat(coalesce(c.introtext, ''), coalesce(c.`fulltext`, '')) AS description,\n\t\t\tCASE\n\t\t\t\tWHEN ca.alias OR c.alias THEN\n\t\t\t\t\tconcat(\n\t\t\t\t\t\tCASE WHEN ca.alias THEN concat('/', ca.alias) ELSE '' END,\n\t\t\t\t\t\tCASE WHEN c.alias THEN concat('/', c.alias) ELSE '' END\n\t\t\t\t\t)\n\t\t\t\tELSE concat('index.php?option=com_content&view=article&id=', c.id)\n\t\t\tEND AS link,\n\t\t\t{$weight} AS weight,\n\t\t\tpublish_up AS date,\n\t\t\tca.title AS section,\n\t\t\t(SELECT group_concat(u1.name separator '\\n') FROM `#__author_assoc` anames INNER JOIN `#__xprofiles` u1 ON u1.uidNumber = anames.authorid WHERE subtable = 'content' AND subid = c.id ORDER BY anames.ordering) AS contributors,\n\t\t\t(SELECT group_concat(ids.authorid separator '\\n') FROM `#__author_assoc` ids WHERE subtable = 'content' AND subid = c.id ORDER BY ids.ordering) AS contributor_ids\n\t\tFROM `#__content` c\n\t\tLEFT JOIN `#__categories` ca\n\t\t\tON ca.id = c.catid\n\t\tWHERE\n\t\t\tstate = 1 AND\n\t\t\t(publish_up AND UTC_TIMESTAMP() > publish_up) AND (NOT publish_down OR UTC_TIMESTAMP() < publish_down)\n\t\t\tAND {$weight} > 0" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . " ORDER BY {$weight} DESC";
     $sql = new \Components\Search\Models\Basic\Result\Sql($query);
     $results->add($sql);
 }
コード例 #12
0
ファイル: wiki.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $terms = $request->get_term_ar();
     $weight = '(match(wp.title) against (\'' . join(' ', $terms['stemmed']) . '\') + match(wv.pagetext) against (\'' . join(' ', $terms['stemmed']) . '\'))';
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(wp.title LIKE '%{$mand}%' OR wv.pagetext LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(wp.title NOT LIKE '%{$forb}%' AND wv.pagetext NOT LIKE '%{$forb}%')";
     }
     $viewlevels = implode(',', User::getAuthorisedViewLevels());
     if ($gids = $authz->get_group_ids()) {
         $authorization = '(wp.access IN (0,' . $viewlevels . ') OR (wp.access = 1 AND xg.gidNumber IN (' . join(',', $gids) . ')))';
     } else {
         $authorization = '(wp.access IN (0,' . $viewlevels . '))';
     }
     // fml
     $groupAuth = array();
     if ($authz->is_super_admin()) {
         $groupAuth[] = '1';
     } else {
         $groupAuth[] = 'xg.plugins LIKE \'%wiki=anyone%\'';
         if (!$authz->is_guest()) {
             $groupAuth[] = 'xg.plugins LIKE \'%wiki=registered%\'';
             if ($gids = $authz->get_group_ids()) {
                 $groupAuth[] = '(xg.plugins LIKE \'%wiki=members%\' AND xg.gidNumber IN (' . join(',', $gids) . '))';
             }
         }
     }
     $rows = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\twp.title,\n\t\t\t\twp.scope,\n\t\t\t\twp.scope_id,\n\t\t\t\twv.pagehtml AS description,\n\t\t\t\tCASE\n\t\t\t\t\tWHEN wp.path != '' THEN concat(wp.path, '/', wp.pagename)\n\t\t\t\t\tELSE wp.pagename\n\t\t\t\tEND AS link,\n\t\t\t\t{$weight} AS weight,\n\t\t\t\twv.created AS date,\n\t\t\t\tCASE\n\t\t\t\t\tWHEN wp.scope='project' THEN 'Project Notes'\n\t\t\t\t\tELSE 'Wiki'\n\t\t\t\tEND AS section\n\t\t\tFROM `#__wiki_versions` wv\n\t\t\tINNER JOIN `#__wiki_pages` wp\n\t\t\t\tON wp.id = wv.page_id\n\t\t\tLEFT JOIN `#__xgroups` xg ON xg.gidNumber = wp.scope_id AND wp.scope='group'\n\t\t\tWHERE\n\t\t\t\t{$authorization} AND\n\t\t\t\t{$weight} > 0 AND\n\t\t\t\twp.state < 2 AND\n\t\t\t\twv.id = (SELECT MAX(wv2.id) FROM `#__wiki_versions` wv2 WHERE wv2.page_id = wv.page_id) " . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . " AND (xg.gidNumber IS NULL OR (" . implode(' OR ', $groupAuth) . "))\n\t\t\t ORDER BY {$weight} DESC");
     include_once Component::path('com_wiki') . DS . 'models' . DS . 'page.php';
     foreach ($rows->to_associative() as $row) {
         if (!$row) {
             continue;
         }
         $page = \Components\Wiki\Models\Page::blank();
         $page->set('pagename', $row->link);
         $page->set('scope', $row->scope);
         $page->set('scope_id', $row->scope_id);
         $row->set_link(Route::url($page->link()));
         // rough de-wikifying. probably a bit faster than rendering to html and then stripping the tags, but not perfect
         //$row->set_description(preg_replace('/(\[+.*?\]+|\{+.*?\}+|[=*])/', '', $row->get_description()));
         $row->set_description(strip_tags($row->get_description()));
         $results->add($row);
     }
 }
コード例 #13
0
ファイル: kb.php プロジェクト: sumudinie/hubzero-cms
 /**
  * Retrieve records for items tagged with specific tags
  *
  * @param      array   $tags       Tags to match records against
  * @param      mixed   $limit      SQL record limit
  * @param      integer $limitstart SQL record limit start
  * @param      string  $sort       The field to sort records by
  * @param      mixed   $areas      An array or string of areas that should retrieve records
  * @return     mixed Returns integer when counting records, array when retrieving records
  */
 public function onTagView($tags, $limit = 0, $limitstart = 0, $sort = '', $areas = null)
 {
     $response = array('name' => $this->_name, 'title' => Lang::txt('PLG_TAGS_KB'), 'total' => 0, 'results' => null, 'sql' => '');
     if (empty($tags)) {
         return $response;
     }
     $database = App::get('db');
     $ids = array();
     foreach ($tags as $tag) {
         $ids[] = $tag->get('id');
     }
     $ids = implode(',', $ids);
     $now = Date::toSql();
     // Build the query
     $e_count = "SELECT COUNT(f.id) FROM (SELECT e.id, COUNT(DISTINCT t.tagid) AS uniques";
     $e_fields = "SELECT e.id, e.title, e.alias, e.fulltxt AS itext, e.fulltxt AS ftext, e.state, e.created, e.created_by, e.modified, e.created AS publish_up,\n\t\t\t\t\tNULL AS publish_down, CONCAT('index.php?option=com_kb&category=&alias=', e.alias) AS href, 'kb' AS section, COUNT(DISTINCT t.tagid) AS uniques,\n\t\t\t\t\tNULL AS params, e.helpful AS rcount, cc.alias AS data1, c.alias AS data2, NULL AS data3 ";
     $e_from = " FROM #__kb_articles AS e\n\t\t\t\t\tLEFT JOIN #__categories AS cc ON cc.id = e.category\n\t\t\t\t\tLEFT JOIN #__tags_object AS t ON t.objectid=e.id AND t.tbl='kb' AND t.tagid IN ({$ids})";
     $e_where = " WHERE e.state=1 AND e.access IN (" . implode(',', User::getAuthorisedViewLevels()) . ")";
     $e_where .= " GROUP BY e.id HAVING uniques=" . count($tags);
     $order_by = " ORDER BY ";
     switch ($sort) {
         case 'title':
             $order_by .= 'title ASC, created';
             break;
         case 'id':
             $order_by .= "id DESC";
             break;
         case 'date':
         default:
             $order_by .= 'created DESC, title';
             break;
     }
     $order_by .= $limit != 'all' ? " LIMIT {$limitstart},{$limit}" : "";
     $database->setQuery($e_count . $e_from . $e_where . ") AS f");
     $response['total'] = $database->loadResult();
     if ($areas && $areas == $response['name']) {
         $database->setQuery($e_fields . $e_from . $e_where . $order_by);
         $response['results'] = $database->loadObjectList();
     } else {
         $response['sql'] = $e_fields . $e_from . $e_where;
     }
     return $response;
 }
コード例 #14
0
ファイル: blog.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Display a blog entry
  *
  * @return  string
  */
 private function _entry()
 {
     if (isset($this->entry) && is_object($this->entry)) {
         $row = $this->entry;
     } else {
         $path = Request::path();
         if (strstr($path, '/')) {
             $bits = $this->_parseUrl();
             $alias = end($bits);
         }
         $row = \Components\Blog\Models\Entry::oneByScope($alias, $this->model->get('scope'), $this->model->get('scope_id'));
     }
     if (!$row->get('id') || $row->isDeleted()) {
         App::abort(404, Lang::txt('PLG_GROUPS_BLOG_NO_ENTRY_FOUND'));
         return;
         // $this->_browse(); Can cause infinite loop
     }
     // Check authorization
     if ($row->get('access') == 2 && User::isGuest() || $row->get('state') == 0 && User::get('id') != $row->get('created_by') && $this->authorized != 'member' && $this->authorized != 'manager' && $this->authorized != 'admin') {
         App::abort(403, Lang::txt('PLG_GROUPS_BLOG_NOT_AUTH'));
         return;
     }
     // make sure the group owns this
     if ($row->get('scope_id') != $this->group->get('gidNumber')) {
         App::abort(403, Lang::txt('PLG_GROUPS_BLOG_NOT_AUTH'));
         return;
     }
     // Filters for returning results
     $filters = array('limit' => 10, 'start' => 0, 'scope' => 'group', 'scope_id' => $this->group->get('gidNumber'), 'created_by' => 0, 'state' => 1, 'access' => User::getAuthorisedViewLevels());
     if ($this->authorized == 'member' || $this->authorized == 'manager' || $this->authorized == 'admin') {
         array_push($filters['access'], 5);
         $filters['authorized'] = true;
     } else {
         $filters['authorized'] = false;
     }
     $view = $this->view('default', 'entry')->set('option', $this->option)->set('group', $this->group)->set('config', $this->params)->set('archive', $this->model)->set('task', $this->action)->set('row', $row)->set('filters', $filters)->set('canpost', $this->_getPostingPermissions())->set('authorized', $this->authorized)->setErrors($this->getErrors());
     return $view->loadTemplate();
 }
コード例 #15
0
 /**
  * Build search query and add it to the $results
  *
  * @param      object $request  \Components\Search\Models\Basic\Request
  * @param      object &$results \Components\Search\Models\Basic\Result\Set
  * @param      object $authz    \Components\Search\Models\Basic\Authorization
  * @return     void
  */
 public static function onSearch($request, &$results, $authz)
 {
     $dbg = isset($_GET['dbg']);
     $database = App::get('db');
     $groups = array_map(array($database, 'escape'), $authz->get_group_names());
     $viewlevels = implode(',', User::getAuthorisedViewLevels());
     /*if ($groups)
     		{
     			$group_list = '(\'' . join('\', \'', $groups) . '\')';
     			$access = '(p.access IN (' . $viewlevels . ') OR ((v.access = 4 OR access = 5) AND r.group_owner IN ' . $group_list . '))';
     		}
     		else
     		{*/
     $access = '(p.access IN (0, ' . $viewlevels . '))';
     //}
     $term_parser = $request->get_terms();
     $terms = $request->get_term_ar();
     $quoted_terms = array();
     foreach ($terms['optional'] as $idx => $term) {
         if ($term_parser->is_quoted($idx)) {
             foreach ($terms['stemmed'] as $sidx => $stem) {
                 if (strpos($term, $stem) === 0 || strpos($stem, $term) === 0) {
                     unset($terms['stemmed'][$sidx]);
                 }
             }
             $quoted_terms[] = $term;
         }
     }
     $tag_map = array();
     foreach ($request->get_tagged_ids('publications') as $id) {
         if (array_key_exists($id, $tag_map)) {
             ++$tag_map[$id];
         } else {
             $tag_map[$id] = 1;
         }
     }
     $weight_authors = 'a.name LIKE \'%' . implode(' ', $terms['optional']) . '%\'';
     $weight = $terms['stemmed'] ? 'match(v.title, v.description, v.abstract) against (\'' . join(' ', $terms['stemmed']) . '\')' : '0';
     foreach ($quoted_terms as $term) {
         $weight .= " + (CASE WHEN v.title LIKE '%{$term}%' OR v.description LIKE '%{$term}%' OR v.abstract LIKE '%{$term}%' THEN 1 ELSE 0 END)";
     }
     $addtl_where = array();
     foreach ($terms['mandatory'] as $mand) {
         $addtl_where[] = "(v.title LIKE '%{$mand}%' OR v.description LIKE '%{$mand}%' OR v.abstract LIKE '%{$mand}%')";
     }
     foreach ($terms['forbidden'] as $forb) {
         $addtl_where[] = "(v.title NOT LIKE '%{$forb}%' AND v.description NOT LIKE '%{$forb}%' AND v.abstract NOT LIKE '%{$forb}%')";
     }
     $sql = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\tp.id,\n\t\t\t\tv.publication_id,\n\t\t\t\tv.title,\n\t\t\t\tv.description,\n\t\t\t\tconcat('index.php?option=com_publications&id=', coalesce(case when p.alias = '' then null else p.alias end, p.id)) AS link,\n\t\t\t\t{$weight} AS weight,\n\t\t\t\tv.published_up AS date,\n\t\t\t\tc.alias AS section,\n\t\t\t\t(SELECT group_concat(a.name order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\tAS contributors,\n\t\t\t\t(SELECT group_concat(a.user_id order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\tAS contributor_ids,\n\t\t\t\tNULL AS parents\n\t\t\tFROM #__publication_versions v\n\t\t\tINNER JOIN #__publications p\n\t\t\t\tON p.id = v.publication_id\n\t\t\tLEFT JOIN #__publication_categories c\n\t\t\t\tON c.id = p.category\n\t\t\tWHERE\n\t\t\t\tv.state = 1 AND {$access} AND (v.published_up AND NOW() > v.published_up) AND (NOT v.published_down OR NOW() < v.published_down)\n\t\t\t\tAND ({$weight} > 0)" . ($addtl_where ? ' AND ' . join(' AND ', $addtl_where) : '') . "UNION\n\t\t\tSELECT\n\t\t\t\tp.id,\n\t\t\t\tv.publication_id,\n\t\t\t\tv.title,\n\t\t\t\tv.description,\n\t\t\t\tconcat('index.php?option=com_publications&id=', coalesce(case when p.alias = '' then null else p.alias end, p.id)) AS link,\n\t\t\t\t1 AS weight,\n\t\t\t\tv.published_up AS date,\n\t\t\t\tc.alias AS section,\n\t\t\t\t(SELECT group_concat(a.name order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\tAS contributors,\n\t\t\t\t(SELECT group_concat(a.user_id order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\tAS contributor_ids,\n\t\t\t\tNULL AS parents\n\t\t\tFROM #__publication_authors a\n\t\t\tINNER JOIN #__publication_versions v\n\t\t\t\tON v.id = a.publication_version_id\n\t\t\tINNER JOIN #__publications p\n\t\t\t\tON p.id = v.publication_id\n\t\t\tLEFT JOIN #__publication_categories c\n\t\t\t\tON c.id = p.category\n\t\t\tWHERE\n\t\t\t\tv.state = 1 AND {$access} AND (v.published_up AND NOW() > v.published_up) AND (NOT v.published_down OR NOW() < v.published_down)\n\t\t\t\tAND a.status = 1 AND {$weight_authors}");
     $assoc = $sql->to_associative();
     $id_assoc = array();
     foreach ($assoc as $row) {
         $id_assoc[$row->get('id')] = $row;
     }
     $placed = array();
     if (!$quoted_terms) {
         // Find ids of tagged resources that did not match regular fulltext searching
         foreach ($assoc as $row) {
             $id = (int) $row->get('id');
             if (array_key_exists($id, $tag_map)) {
                 $row->add_weight((1 + $tag_map[$id]) / 12, 'tag bonus from publications plugin');
                 unset($tag_map[$id]);
             }
         }
         // Fill in tagged resources that did not match on fulltext
         if ($tag_map) {
             $sql = new \Components\Search\Models\Basic\Result\Sql("SELECT\n\t\t\t\t\t\tp.id,\n\t\t\t\t\t\tv.publication_id,\n\t\t\t\t\t\tv.title,\n\t\t\t\t\t\tv.description,\n\t\t\t\t\t\tconcat('index.php?option=com_publications&id=', coalesce(case when p.alias = '' then null else p.alias end, p.id)) AS link,\n\t\t\t\t\t\t0.5 as weight,\n\t\t\t\t\t\tv.published_up AS date,\n\t\t\t\t\t\tc.alias AS section,\n\t\t\t\t\t\t(SELECT group_concat(a.name order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\t\t\tAS contributors,\n\t\t\t\t\t\t(SELECT group_concat(a.user_id order by a.ordering separator '\\n') FROM #__publication_authors a WHERE a.publication_version_id = v.id AND a.status=1)\n\t\t\t\t\t\t\tAS contributor_ids,\n\t\t\t\t\t\tNULL AS parents\n\t\t\t\t\tFROM #__publication_versions v\n\t\t\t\t\tINNER JOIN #__publications p\n\t\t\t\t\t\tON p.id = v.publication_id\n\t\t\t\t\tLEFT JOIN #__publication_categories c\n\t\t\t\t\t\tON c.id = p.category\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tv.state = 1 AND {$access} AND (v.published_up AND NOW() > v.published_up) AND (NOT v.published_down OR NOW() < v.published_down)\n\t\t\t\t\t\tAND p.id in (" . implode(',', array_keys($tag_map)) . ")" . ($addtl_where ? ' AND ' . implode(' AND ', $addtl_where) : ''));
             foreach ($sql->to_associative() as $row) {
                 $rows = $sql->to_associative();
                 foreach ($rows as $row) {
                     if ($tag_map[$row->get('id')] > 1) {
                         $row->adjust_weight($tag_map[$row->get('id')] / 8, 'tag bonus for non-matching but tagged publications');
                     }
                     $id_assoc[$row->get('id')] = $row;
                 }
             }
         }
     }
     $sorter = new PublicationChildSorter($placed);
     $rows = array();
     foreach ($id_assoc as $id => $row) {
         if (!array_key_exists((int) $id, $placed)) {
             $row->sort_children(array($sorter, 'sort'));
             $rows[] = $row;
         }
     }
     usort($rows, create_function('$a, $b', 'return (($res = $a->get_weight() - $b->get_weight()) == 0 ? 0 : $res > 0 ? -1 : 1);'));
     foreach ($rows as $row) {
         $row->set_link(Route::url($row->get_raw_link()));
         $results->add($row);
     }
 }
コード例 #16
0
ファイル: articles.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to get a list of articles.
  *
  * Overriden to inject convert the attribs field into a JParameter object.
  *
  * @return	mixed	An array of objects on success, false on failure.
  * @since	1.6
  */
 public function getItems()
 {
     $items = parent::getItems();
     $userId = User::get('id');
     $guest = User::get('guest');
     $groups = User::getAuthorisedViewLevels();
     // Get the global params
     $globalParams = Component::params('com_content', true);
     // Convert the parameter fields into objects.
     foreach ($items as &$item) {
         $articleParams = new \Hubzero\Config\Registry($item->attribs);
         // Unpack readmore and layout params
         $item->alternative_readmore = $articleParams->get('alternative_readmore');
         $item->layout = $articleParams->get('layout');
         $item->params = clone $this->getState('params');
         // For blogs, article params override menu item params only if menu param = 'use_article'
         // Otherwise, menu item params control the layout
         // If menu item is 'use_article' and there is no article param, use global
         if (Request::getString('layout') == 'blog' || Request::getString('view') == 'featured' || $this->getState('params')->get('layout_type') == 'blog') {
             // create an array of just the params set to 'use_article'
             $menuParamsArray = $this->getState('params')->toArray();
             $articleArray = array();
             foreach ($menuParamsArray as $key => $value) {
                 if ($value === 'use_article') {
                     // if the article has a value, use it
                     if ($articleParams->get($key) != '') {
                         // get the value from the article
                         $articleArray[$key] = $articleParams->get($key);
                     } else {
                         // otherwise, use the global value
                         $articleArray[$key] = $globalParams->get($key);
                     }
                 }
             }
             // merge the selected article params
             if (count($articleArray) > 0) {
                 $articleParams = new \Hubzero\Config\Registry($articleArray);
                 $item->params->merge($articleParams);
             }
         } else {
             // For non-blog layouts, merge all of the article params
             $item->params->merge($articleParams);
         }
         // get display date
         switch ($item->params->get('list_show_date')) {
             case 'modified':
                 $item->displayDate = $item->modified;
                 break;
             case 'published':
                 $item->displayDate = $item->publish_up == 0 ? $item->created : $item->publish_up;
                 break;
             default:
             case 'created':
                 $item->displayDate = $item->created;
                 break;
         }
         // Compute the asset access permissions.
         // Technically guest could edit an article, but lets not check that to improve performance a little.
         if (!$guest) {
             $asset = 'com_content.article.' . $item->id;
             // Check general edit permission first.
             if (User::authorise('core.edit', $asset)) {
                 $item->params->set('access-edit', true);
             } elseif (!empty($userId) && User::authorise('core.edit.own', $asset)) {
                 // Check for a valid user and that they are the owner.
                 if ($userId == $item->created_by) {
                     $item->params->set('access-edit', true);
                 }
             }
         }
         $access = $this->getState('filter.access');
         if ($access) {
             // If the access filter has been set, we already have only the articles this user can view.
             $item->params->set('access-view', true);
         } else {
             // If no access filter is set, the layout takes some responsibility for display of limited information.
             if ($item->catid == 0 || $item->category_access === null) {
                 $item->params->set('access-view', in_array($item->access, $groups));
             } else {
                 $item->params->set('access-view', in_array($item->access, $groups) && in_array($item->category_access, $groups));
             }
         }
     }
     return $items;
 }
コード例 #17
0
         if ($contributor->middleName != NULL) {
             $name .= $this->escape(stripslashes($contributor->middleName)) . ' ';
         }
         $name .= $this->escape(stripslashes($contributor->surname));
     } else {
         $name = $this->escape(stripslashes($contributor->xname));
     }
 }
 if (!$contributor->org) {
     $contributor->org = $contributor->xorg;
 }
 $contributor->org = $this->escape(stripslashes(trim($contributor->org)));
 $link = $name;
 if ($contributor->id) {
     $profile = User::getInstance($contributor->id);
     if ($profile->get('id') && in_array($profile->get('access'), User::getAuthorisedViewLevels())) {
         $link = '<a href="' . Route::url($profile->link()) . '" rel="contributor" title="' . Lang::txt('COM_RESOURCES_VIEW_MEMBER_PROFILE', $name) . '">' . $name . '</a>';
     }
 }
 $link .= $contributor->role ? ' (' . $contributor->role . ')' : '';
 if (trim($contributor->org) != '' && !in_array(trim($contributor->org), $orgs)) {
     $orgs[$i - 1] = trim($contributor->org);
     $orgsln .= $i . '. ' . trim($contributor->org) . ' ';
     $orgsln_s .= trim($contributor->org) . ' ';
     $k = $i;
     $i++;
 } else {
     $k = array_search(trim($contributor->org), $orgs) + 1;
 }
 $link_s = $link;
 if (trim($contributor->org) != '') {
コード例 #18
0
ファイル: category.php プロジェクト: kevinwojo/hubzero-cms
								</a>
							</li>
						</ul>
					</nav>

					<table class="articles entries">
						<tbody>
						<?php 
$filters = array('state' => 1, 'access' => User::getAuthorisedViewLevels());
$categories = $this->archive->categories($filters);
if (!$this->category->get('id')) {
    $articles = $this->archive->articles();
} else {
    $articles = $this->category->articles();
}
$articles->whereEquals('state', 1)->whereIn('access', User::getAuthorisedViewLevels());
if (isset($this->filters['search']) && $this->filters['search']) {
    $articles->where('title', 'LIKE', '%' . $this->filters['search'] . '%')->orWhere('fulltxt', 'LIKE', '%' . $this->filters['search'] . '%');
}
if ($this->filters['sort'] == 'popularity') {
    $articles->order('helpful', 'desc');
} else {
    $articles->order('modified', 'desc')->order('created', 'desc');
}
$articles = $articles->paginated();
foreach ($articles as $row) {
    if (!$this->category->get('id')) {
        foreach ($categories as $cat) {
            if ($cat->get('id') == $row->get('category')) {
                $row->set('ctitle', $cat->get('title'));
                $row->set('calias', $cat->get('path'));
コード例 #19
0
ファイル: wish.php プロジェクト: kevinwojo/hubzero-cms
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
$this->css()->css('vote.css', 'com_answers')->css('jquery.ui.css', 'system')->js();
$error = $this->getError();
// What name should we dispay for the submitter?
$user = $this->wish->proposer();
$name = Lang::txt('COM_WISHLIST_ANONYMOUS');
if (!$this->wish->get('anonymous')) {
    $name = $this->escape(stripslashes($this->wish->proposer()->get('name', $name)));
    if (in_array($this->wish->proposer()->get('access'), User::getAuthorisedViewLevels())) {
        $name = '<a href="' . Route::url($this->wish->proposer()->link()) . '">' . $name . '</a>';
    }
}
// && ($this->wish->get('admin')==2 or $this->wish->get('admin')==1)
$assigned = $this->wish->get('assigned') ? Lang::txt('COM_WISHLIST_WISH_ASSIGNED_TO', '<a href="' . Route::url('index.php?option=' . $this->option . '&task=wish&category=' . $this->wishlist->get('category') . '&rid=' . $this->wishlist->get('referenceid') . '&wishid=' . $this->wish->get('id')) . '?filterby=' . $this->filters['filterby'] . '&sortby=' . $this->filters['sortby'] . '&tags=' . $this->filters['tag'] . '&action=editplan#plan">' . $this->wish->owner('name') . '</a>') : '';
if (!$assigned && ($this->wish->get('admin') == 2 or $this->wish->get('admin') == 1) && $this->wish->get('status') == 0) {
    $assigned = '<a href="' . Route::url('index.php?option=' . $this->option . '&task=wish&category=' . $this->wishlist->get('category') . '&rid=' . $this->wishlist->get('referenceid') . '&wishid=' . $this->wish->get('id')) . '?filterby=' . $this->filters['filterby'] . '&sortby=' . $this->filters['sortby'] . '&tags=' . $this->filters['tag'] . '&action=editplan#plan">' . Lang::txt('unassigned') . '</a>';
}
$this->wish->set('status', $this->wish->get('accepted') == 1 && $this->wish->get('status') == 0 ? 6 : $this->wish->get('status'));
$due = $this->wish->get('due') != '0000-00-00 00:00:00' ? Date::of($this->wish->get('due'))->toLocal(Lang::txt('DATE_FORMAT_HZ1')) : '';
?>
	<header id="content-header">
		<h2><?php 
echo $this->title . ': ' . Lang::txt('COM_WISHLIST_WISH') . ' #' . $this->wish->get('id');
?>
コード例 #20
0
ファイル: entry.php プロジェクト: kevinwojo/hubzero-cms
" id="commentform">
				<p class="comment-member-photo">
					<img src="<?php 
    echo User::picture(User::isGuest() ? 1 : 0);
    ?>
" alt="" />
				</p>
				<fieldset>
					<?php 
    $replyto = $this->row->comments()->whereEquals('id', Request::getInt('reply', 0))->whereIn('state', array(Components\Blog\Models\Comment::STATE_PUBLISHED, Components\Blog\Models\Comment::STATE_FLAGGED))->row();
    if (!User::isGuest()) {
        if ($replyto->get('id')) {
            $name = Lang::txt('COM_BLOG_ANONYMOUS');
            if (!$replyto->get('anonymous')) {
                $name = $this->escape(stripslashes($replyto->creator->get('name', $name)));
                if (in_array($replyto->creator->get('access'), User::getAuthorisedViewLevels())) {
                    $name = '<a href="' . Route::url($replyto->creator->link()) . '">' . $name . '</a>';
                }
            }
            ?>
						<blockquote cite="c<?php 
            echo $replyto->get('id');
            ?>
">
							<p>
								<strong><?php 
            echo $name;
            ?>
</strong>
								<span class="comment-date-at"><?php 
            echo Lang::txt('COM_BLOG_AT');
コード例 #21
0
ファイル: articles.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to get a list of articles.
  * Overridden to add a check for access levels.
  *
  * @return	mixed	An array of data items on success, false on failure.
  * @since	1.6.1
  */
 public function getItems()
 {
     $items = parent::getItems();
     $app = JFactory::getApplication();
     if ($app->isSite()) {
         $groups = User::getAuthorisedViewLevels();
         for ($x = 0, $count = count($items); $x < $count; $x++) {
             //Check the access level. Remove articles the user shouldn't see
             if (!in_array($items[$x]->access, $groups)) {
                 unset($items[$x]);
             }
         }
     }
     return $items;
 }
コード例 #22
0
ファイル: Loader.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Module cache helper
  *
  * Caching modes:
  * To be set in XML:
  * 'static'      One cache file for all pages with the same module parameters
  * 'oldstatic'   1.5 definition of module caching, one cache file for all pages
  * with the same module id and user aid,
  * 'itemid'      Changes on itemid change, to be called from inside the module:
  * 'safeuri'     Id created from $cacheparams->modeparams array,
  * 'id'          Module sets own cache id's
  *
  * @param   object  $module        Module object
  * @param   object  $moduleparams  Module parameters
  * @param   object  $cacheparams   Module cache parameters - id or url parameters, depending on the module cache mode
  * @return  string
  */
 public function cache($module, $moduleparams, $cacheparams)
 {
     // [!] Deprecated. Needs to be refactored.
     return true;
     if (!isset($cacheparams->modeparams)) {
         $cacheparams->modeparams = null;
     }
     if (!isset($cacheparams->cachegroup)) {
         $cacheparams->cachegroup = $module->module;
     }
     $cache = \JFactory::getCache($cacheparams->cachegroup, 'callback');
     // Turn cache off for internal callers if parameters are set to off and for all logged in users
     if ($moduleparams->get('owncache', null) === '0' || $this->app['config']->get('caching') == 0 || \User::get('id')) {
         $cache->setCaching(false);
     }
     // module cache is set in seconds, global cache in minutes, setLifeTime works in minutes
     $cache->setLifeTime($moduleparams->get('cache_time', $this->app['config']->get('cachetime') * 60) / 60);
     $wrkaroundoptions = array('nopathway' => 1, 'nohead' => 0, 'nomodules' => 1, 'modulemode' => 1, 'mergehead' => 1);
     $wrkarounds = true;
     $view_levels = md5(serialize(\User::getAuthorisedViewLevels()));
     switch ($cacheparams->cachemode) {
         case 'id':
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $cacheparams->modeparams, $wrkarounds, $wrkaroundoptions);
             break;
         case 'safeuri':
             $secureid = null;
             if (is_array($cacheparams->modeparams)) {
                 $uri = \Request::get();
                 $safeuri = new \stdClass();
                 foreach ($cacheparams->modeparams as $key => $value) {
                     // Use int filter for id/catid to clean out spamy slugs
                     if (isset($uri[$key])) {
                         $safeuri->{$key} = \Request::_cleanVar($uri[$key], 0, $value);
                     }
                 }
             }
             $secureid = md5(serialize(array($safeuri, $cacheparams->method, $moduleparams)));
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . $secureid, $wrkarounds, $wrkaroundoptions);
             break;
         case 'static':
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->module . md5(serialize($cacheparams->methodparams)), $wrkarounds, $wrkaroundoptions);
             break;
         case 'oldstatic':
             // provided for backward compatibility, not really usefull
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels, $wrkarounds, $wrkaroundoptions);
             break;
         case 'itemid':
         default:
             $ret = $cache->get(array($cacheparams->class, $cacheparams->method), $cacheparams->methodparams, $module->id . $view_levels . \Request::getVar('Itemid', null, 'default', 'INT'), $wrkarounds, $wrkaroundoptions);
             break;
     }
     return $ret;
 }
コード例 #23
0
ファイル: display.php プロジェクト: kevinwojo/hubzero-cms
        ?>
										</span>
									</td>
									<td>
										<span><?php 
        echo Lang::txt('Last Post:');
        ?>
</span>
										<span class="entry-details">
											<?php 
        $lastpost = $row->lastActivity();
        if ($lastpost->get('id')) {
            $lname = Lang::txt('PLG_COURSES_DISCUSSIONS_ANONYMOUS');
            if (!$lastpost->get('anonymous')) {
                $lname = $this->escape(stripslashes($lastpost->creator->get('name')));
                if (in_array($lastpost->creator->get('access'), User::getAuthorisedViewLevels())) {
                    $lname = '<a href="' . Route::url($lastpost->creator->link()) . '">' . $lname . '</a>';
                }
            }
            ?>
												<span class="entry-date">
													<time datetime="<?php 
            echo $lastpost->created();
            ?>
"><?php 
            echo $lastpost->created('date');
            ?>
</time>
												</span>
												<?php 
            echo Lang::txt('PLG_COURSES_DISCUSSIONS_BY_USER', '<span class="entry-author">' . $lname . '</span>');
コード例 #24
0
ファイル: default.php プロジェクト: kevinwojo/hubzero-cms
     }
     if ($hasEvents) {
         $scripts[] = '	});';
         $scripts[] = implode("\n", $toggle);
     }
 }
 //---
 if (!isset($fields[$field->get('name')])) {
     $fields[$field->get('name')] = Components\Members\Models\Profile::blank();
     $fields[$field->get('name')]->set('access', 1);
 }
 $profile = $fields[$field->get('name')];
 if (!$profile->get('access')) {
     $profile->set('access', 5);
 }
 if (in_array($profile->get('access', $field->get('access', 5)), User::getAuthorisedViewLevels()) || $isUser) {
     $cls = array('profile-' . $field->get('name'));
     if ($profile->get('access', $field->get('access')) == 2) {
         $cls[] = 'registered';
     }
     if ($profile->get('access', $field->get('access')) == 5) {
         $cls[] = 'private';
     }
     // Tags need to be rendered a little differently
     if ($field->get('type') == 'tags') {
         $value = $this->profile->tags();
     } else {
         $value = $profile->get('profile_value');
         if (!is_array($value)) {
             $value = $profile->get('label', $value);
         }
コード例 #25
0
ファイル: _comment.php プロジェクト: kevinwojo/hubzero-cms
defined('_HZEXEC_') or die;
$cls = isset($this->cls) ? $this->cls : 'odd';
if ($this->page->get('created_by') == $this->comment->get('created_by')) {
    $cls .= ' author';
}
$cls .= $this->comment->isReported() ? ' abusive' : '';
$lnk = $this->page->link();
$d = '?';
if (strstr($lnk, '?')) {
    $d = '&';
}
$this->comment->base = $lnk . $d . ($this->page->get('scope_id') ? 'action' : 'task');
$name = Lang::txt('COM_WIKI_ANONYMOUS');
if (!$this->comment->get('anonymous')) {
    $name = $this->escape(stripslashes($this->comment->creator->get('name', $name)));
    if (in_array($this->comment->creator->get('access'), User::getAuthorisedViewLevels())) {
        $name = '<a href="' . Route::url($this->comment->creator->link()) . '">' . $name . '</a>';
    }
}
if ($this->comment->isReported()) {
    $comment = '<p class="warning">' . Lang::txt('COM_WIKI_COMMENT_REPORTED_AS_ABUSIVE') . '</p>';
} else {
    $comment = $this->comment->content('parsed');
}
$this->comment->set('category', 'answercomment');
?>
	<li class="comment <?php 
echo $cls;
?>
" id="c<?php 
echo $this->comment->get('id');
コード例 #26
0
ファイル: Site.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Gets menu items by attribute
  *
  * @param   string   $attributes  The field name
  * @param   string   $values      The value of the field
  * @param   boolean  $firstonly   If true, only returns the first item found
  * @return  array
  */
 public function getItems($attributes, $values, $firstonly = false)
 {
     $attributes = (array) $attributes;
     $values = (array) $values;
     if (\App::isSite()) {
         // Filter by language if not set
         if (($key = array_search('language', $attributes)) === false) {
             if (\App::get('language.filter')) {
                 $attributes[] = 'language';
                 $values[] = array(\App::get('language')->getTag(), '*');
             }
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
         // Filter by access level if not set
         if (($key = array_search('access', $attributes)) === false) {
             $attributes[] = 'access';
             $values[] = \User::getAuthorisedViewLevels();
         } elseif ($values[$key] === null) {
             unset($attributes[$key]);
             unset($values[$key]);
         }
     }
     return parent::getItems($attributes, $values, $firstonly);
 }
コード例 #27
0
ファイル: newsfeed.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Method to get newsfeed data.
  *
  * @param	integer	The id of the newsfeed.
  *
  * @return	mixed	Menu item data object on success, false on failure.
  * @since	1.6
  */
 public function &getItem($pk = null)
 {
     // Initialise variables.
     $pk = !empty($pk) ? $pk : (int) $this->getState('newsfeed.id');
     if ($this->_item === null) {
         $this->_item = array();
     }
     if (!isset($this->_item[$pk])) {
         try {
             $db = $this->getDbo();
             $query = $db->getQuery(true);
             $query->select($this->getState('item.select', 'a.*'));
             $query->from('#__newsfeeds AS a');
             // Join on category table.
             $query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access');
             $query->join('LEFT', '#__categories AS c on c.id = a.catid');
             // Join on user table.
             $query->select('u.name AS author');
             $query->join('LEFT', '#__users AS u on u.id = a.created_by');
             // Join over the categories to get parent category titles
             $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias');
             $query->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
             $query->where('a.id = ' . (int) $pk);
             // Filter by start and end dates.
             $nullDate = $db->Quote($db->getNullDate());
             $nowDate = $db->Quote(Date::toSql());
             // Filter by published state.
             $published = $this->getState('filter.published');
             $archived = $this->getState('filter.archived');
             if (is_numeric($published)) {
                 $query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')');
                 $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')');
                 $query->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
                 $query->where('(c.published = ' . (int) $published . ' OR c.published =' . (int) $archived . ')');
             }
             $db->setQuery($query);
             $data = $db->loadObject();
             if ($error = $db->getErrorMsg()) {
                 throw new Exception($error);
             }
             if (empty($data)) {
                 throw new Exception(Lang::txt('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'), 404);
             }
             // Check for published state if filter set.
             if ((is_numeric($published) || is_numeric($archived)) && ($data->published != $published && $data->published != $archived)) {
                 App::abort(404, Lang::txt('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
             }
             // Convert parameter fields to objects.
             $registry = new \Hubzero\Config\Registry($data->params);
             $data->params = clone $this->getState('params');
             $data->params->merge($registry);
             $registry = new \Hubzero\Config\Registry($data->metadata);
             $data->metadata = $registry;
             // Compute access permissions.
             if ($access = $this->getState('filter.access')) {
                 // If the access filter has been set, we already know this user can view.
                 $data->params->set('access-view', true);
             } else {
                 // If no access filter is set, the layout takes some responsibility for display of limited information.
                 $groups = User::getAuthorisedViewLevels();
                 $data->params->set('access-view', in_array($data->access, $groups) && in_array($data->category_access, $groups));
             }
             $this->_item[$pk] = $data;
         } catch (JException $e) {
             $this->setError($e);
             $this->_item[$pk] = false;
         }
     }
     return $this->_item[$pk];
 }
コード例 #28
0
ファイル: default.php プロジェクト: kevinwojo/hubzero-cms
								<span class="img-link">
									<img src="<?php 
            echo $row->creator()->picture();
            ?>
" alt="<?php 
            echo Lang::txt('PLG_GROUPS_COLLECTIONS_PROFILE_PICTURE', $name);
            ?>
" />
								</span>
							<?php 
        }
        ?>
							<p>
								<?php 
        $who = $name;
        if (in_array($row->creator()->get('access'), User::getAuthorisedViewLevels())) {
            $who = '<a href="' . Route::url($row->creator()->link()) . '">' . $name . '</a>';
        }
        $where = '<a href="' . Route::url($row->link()) . '">' . $this->escape(stripslashes($row->get('title'))) . '</a>';
        echo Lang::txt('PLG_GROUPS_COLLECTIONS_ONTO', $who, $where);
        ?>
								<br />
								<span class="entry-date">
									<span class="entry-date-at"><?php 
        echo Lang::txt('PLG_GROUPS_COLLECTIONS_DATE_AT');
        ?>
</span>
									<span class="time"><time datetime="<?php 
        echo $row->created();
        ?>
"><?php 
コード例 #29
0
ファイル: authors.php プロジェクト: kevinwojo/hubzero-cms
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access.
defined('_HZEXEC_') or die;
if ($this->page->param('mode', 'wiki') == 'knol' && !$this->page->param('hide_authors', 0)) {
    $author = $this->escape(stripslashes($this->page->creator->get('name', Lang::txt('COM_WIKI_UNKNOWN'))));
    $auths = array();
    $auths[] = in_array($this->page->creator->get('access'), User::getAuthorisedViewLevels()) ? '<a href="' . Route::url($this->page->creator->link()) . '">' . $author . '</a>' : $author;
    foreach ($this->page->authors()->rows() as $auth) {
        if ($auth->get('user_id') == $this->page->get('created_by')) {
            continue;
        }
        $name = $this->escape(stripslashes($auth->get('name')));
        $name = in_array($auth->get('access'), User::getAuthorisedViewLevels()) ? '<a href="' . Route::url($auth->link()) . '">' . $name . '</a>' : $name;
        $auths[] = $name;
    }
    ?>
	<p class="topic-authors"><?php 
    echo Lang::txt('COM_WIKI_BY_AUTHORS', implode(', ', $auths));
    ?>
</p>
	<?php 
}
コード例 #30
0
 /**
  * Build an SQL query to load the list data.
  *
  * @return	JDatabaseQuery
  */
 protected function getListQuery()
 {
     // Create a new query object.
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     // Select the required fields from the table.
     $query->select($this->getState('list.select', 'a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.catid,' . 'a.numarticles, a.cache_time, ' . ' a.published, a.access, a.ordering, a.language, a.publish_up, a.publish_down'));
     $query->from($db->quoteName('#__newsfeeds') . ' AS a');
     // Join over the language
     $query->select('l.title AS language_title');
     $query->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
     // Join over the users for the checked out user.
     $query->select('uc.name AS editor');
     $query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
     // Join over the asset groups.
     $query->select('ag.title AS access_level');
     $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
     // Join over the categories.
     $query->select('c.title AS category_title');
     $query->join('LEFT', '#__categories AS c ON c.id = a.catid');
     // Filter by access level.
     if ($access = $this->getState('filter.access')) {
         $query->where('a.access = ' . (int) $access);
     }
     // Implement View Level Access
     if (!User::authorise('core.admin')) {
         $groups = implode(',', User::getAuthorisedViewLevels());
         $query->where('a.access IN (' . $groups . ')');
     }
     // Filter by published state.
     $published = $this->getState('filter.state');
     if (is_numeric($published)) {
         $query->where('a.published = ' . (int) $published);
     } elseif ($published === '') {
         $query->where('(a.published IN (0, 1))');
     }
     // Filter by category.
     $categoryId = $this->getState('filter.category_id');
     if (is_numeric($categoryId)) {
         $query->where('a.catid = ' . (int) $categoryId);
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('a.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->Quote('%' . $db->escape($search, true) . '%');
             $query->where('(a.name LIKE ' . $search . ' OR a.alias LIKE ' . $search . ')');
         }
     }
     // Filter on the language.
     if ($language = $this->getState('filter.language')) {
         $query->where('a.language = ' . $db->quote($language));
     }
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering');
     $orderDirn = $this->state->get('list.direction');
     if ($orderCol == 'a.ordering' || $orderCol == 'category_title') {
         $orderCol = 'c.title ' . $orderDirn . ', a.ordering';
     }
     $query->order($db->escape($orderCol . ' ' . $orderDirn));
     //echo nl2br(str_replace('#__','jos_',$query));
     return $query;
 }