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


PHP User::getAuthorisedViewLevels方法代码示例

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


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

示例1: onWhatsnew

 /**
  * 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;
     }
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:43,代码来源:kb.php

示例2: register

 /**
  * 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;
     };
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:33,代码来源:MenuServiceProvider.php

示例3: onWhatsnew

 /**
  * 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;
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:42,代码来源:kb.php

示例4: onSearch

 /**
  * 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);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:37,代码来源:blogs.php

示例5: __construct

 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');
         }
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:58,代码来源:languagefilter.php

示例6: run

 /**
  * 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();
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:14,代码来源:helper.php

示例7: onTagView

 /**
  * 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;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:62,代码来源:forum.php

示例8: onSearch

 /**
  * 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"));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:22,代码来源:kb.php

示例9: displayTask

 /**
  * 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();
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:20,代码来源:feeds.php

示例10: onSearch

 /**
  * 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);
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:56,代码来源:forum.php

示例11: onSearch

 /**
  * 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);
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:24,代码来源:content.php

示例12: onSearch

 /**
  * 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);
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:55,代码来源:wiki.php

示例13: onTagView

 /**
  * 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;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:53,代码来源:kb.php

示例14: _entry

 /**
  * 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();
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:43,代码来源:blog.php

示例15: onSearch

 /**
  * 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);
     }
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:100,代码来源:publications.php


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