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


PHP Surfer::assigned_articles方法代码示例

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


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

示例1: NOT

 /**
  * list articles of one user
  *
  * This function that are either:
  * - owned by the user
  * - or assigned to the user
  *
  * @param string passed to _get_order()
  * @param int the id of the target surfer
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param string the list variant, if any
  * @return NULL on error, else the outcome of the layout
  *
  * @see users/print.php
  * @see users/view.php
  */
 public static function &list_for_user_by($order, $user_id, $offset = 0, $count = 10, $variant = 'full')
 {
     global $context;
     // sanity check
     if (!$user_id) {
         return NULL;
     }
     // limit the scope of the request
     $where = Articles::get_sql_where();
     // show only published articles if not looking at self record
     if (Surfer::get_id() != $user_id && !Surfer::is_associate()) {
         $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
     }
     // strip dead pages
     if (Surfer::get_id() != $user_id && !Surfer::is_associate()) {
         $where .= " AND ((articles.expiry_date is NULL) " . "OR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . $context['now'] . "'))";
     }
     // order these pages
     $order = Articles::_get_order($order);
     // the list of watched sections
     $watched_sections = "(SELECT CONCAT('section:', sections.id) AS target" . "\tFROM (" . SQL::table_name('members') . " AS members" . ", " . SQL::table_name('sections') . " AS sections)" . " WHERE (members.member = 'user:" . SQL::escape($user_id) . "')" . "\tAND (members.anchor LIKE 'section:%')" . "\tAND (sections.id = SUBSTRING(members.anchor, 9))" . " ORDER BY sections.edit_date DESC, sections.title LIMIT 0, 1000)";
     // the list of forwarding sections
     $forwarding_sections = "(SELECT CONCAT('section:', sections.id) AS target" . " FROM " . $watched_sections . " AS anchors" . ", " . SQL::table_name('sections') . " AS sections" . " WHERE (sections.anchor = anchors.target) AND (sections.options LIKE '%forward_notifications%')" . " ORDER BY sections.edit_date DESC, sections.title LIMIT 0, 1000)";
     // look for pages in watched sections
     $query = "(SELECT articles.* FROM (" . $watched_sections . " UNION " . $forwarding_sections . ") AS anchors" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE (articles.anchor = anchors.target)" . "\tAND " . $where . ") UNION ";
     // look for watched pages
     $query .= "(SELECT articles.* FROM (SELECT DISTINCT CAST(SUBSTRING(members.anchor, 9) AS UNSIGNED) AS target FROM " . SQL::table_name('members') . " AS members WHERE (members.member LIKE 'user:" . SQL::escape($user_id) . "') AND (members.anchor LIKE 'article:%')) AS ids" . ", " . SQL::table_name('articles') . " AS articles" . " WHERE (articles.id = ids.target)" . "\tAND " . $where . ")";
     // include articles assigned to this surfer
     if ($these_items = Surfer::assigned_articles($user_id)) {
         $query = "(SELECT articles.* FROM " . SQL::table_name('articles') . " AS articles" . " WHERE articles.id IN (" . join(', ', $these_items) . ")" . "\tAND " . $where . ")" . " UNION " . $query;
     }
     // include articles owned by this surfer
     $query = "(SELECT articles.* FROM " . SQL::table_name('articles') . " AS articles" . " WHERE articles.owner_id = " . $user_id . "\tAND " . $where . ")" . " UNION " . $query;
     // finalize the query
     $query .= " ORDER BY " . $order . " LIMIT " . $offset . ',' . $count;
     // use existing listing facility
     $output =& Articles::list_selected(SQL::query($query), $variant);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:56,代码来源:articles.php

示例2: IN

 /**
  * search for some keywords in all files
  *
  * Only files matching following criteria are returned:
  * - file is visible (active='Y')
  * - file is restricted (active='R'), but surfer is a logged user
  * - file is restricted (active='N'), but surfer is an associate
  *
  * @param string searched tokens
  * @param float maximum score to look at
  * @param int the number of items to display
  * @param string the list variant, if any
  * @return NULL on error, else an ordered array of array($score, $summary)
  */
 public static function &search($pattern, $offset = 1.0, $count = 50, $variant = 'search')
 {
     global $context;
     // sanity check
     if (!($pattern = trim($pattern))) {
         $output = NULL;
         return $output;
     }
     // limit the scope of the request
     $where = "active='Y'";
     if (Surfer::is_logged() || Surfer::is_teased()) {
         $where .= " OR active='R'";
     }
     if (Surfer::is_associate() || Surfer::is_teased()) {
         $where .= " OR active='N'";
     } else {
         // files attached to managed sections
         if ($my_sections = Surfer::assigned_sections()) {
             $where .= " OR anchor IN ('section:" . join("', 'section:", $my_sections) . "')";
             // files attached to pages in managed sections
             $where .= " OR anchor IN (SELECT CONCAT('article:', id) FROM " . SQL::table_name('articles') . "  WHERE anchor IN ('section:" . join("', 'section:", $my_sections) . "'))";
         }
         // files attached to managed articles
         if ($my_articles = Surfer::assigned_articles()) {
             $where .= " OR anchor IN ('article:" . join("', 'article:", $my_articles) . "')";
         }
     }
     // how to compute the score for files
     $score = "(MATCH(title, source, keywords)" . " AGAINST('" . SQL::escape($pattern) . "' IN BOOLEAN MODE)" . "/SQRT(GREATEST(1.1, DATEDIFF(NOW(), edit_date))))";
     // the list of files
     $query = "SELECT *, " . $score . " AS score FROM " . SQL::table_name('files') . " AS files" . " WHERE (" . $score . " < " . $offset . ") AND (" . $score . " > 0)" . "  AND (" . $where . ")" . " ORDER BY score DESC" . " LIMIT " . $count;
     // do the query
     $output =& Files::list_selected(SQL::query($query), $variant);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:49,代码来源:files.php

示例3: IN

 /**
  * list the articles by rating sum related to a given category or to any other anchor
  *
  * Actually list articles by rating sum, then by date. Note that articles are never ranked into a category list.
  *
  * Only articles matching following criteria are returned:
  * - article is visible (active='Y')
  * - article is restricted (active='R'), but surfer is a logged user
  * - article is restricted (active='N'), but surfer is an associate
  * - article has been officially published
  * - an expiry date has not been defined, or is not yet passed
  *
  * @param the target anchor
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param string the list variant, if any
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  *
  * @see categories/print.php
  * @see categories/view.php
  */
 public static function &list_articles_by_rating_for_anchor($anchor, $offset = 0, $count = 10, $variant = NULL, $lang = false)
 {
     global $context;
     // locate where we are
     if (!$variant) {
         $variant = $anchor;
     }
     // limit the scope of the request
     $where = "(articles.active='Y'";
     if (Surfer::is_logged()) {
         $where .= " OR articles.active='R'";
     }
     if (Surfer::is_empowered('S')) {
         $where .= " OR articles.active='N'";
     }
     // include managed sections
     if ($my_sections = Surfer::assigned_sections()) {
         $where .= " OR articles.anchor IN ('section:" . join("', 'section:", $my_sections) . "')";
     }
     // include managed pages for editors
     if ($my_articles = Surfer::assigned_articles()) {
         $where .= " OR articles.id IN (" . join(', ', $my_articles) . ")";
     }
     $where .= ")";
     // limit the scope by language
     if ($lang) {
         $where .= " AND ( articles.language='" . SQL::escape($lang) . "' OR articles.language='')";
     }
     // see only published articles in categories
     $where .= " AND NOT ((articles.publish_date is NULL) OR (articles.publish_date <= '0000-00-00'))" . " AND (articles.publish_date < '" . $context['now'] . "')";
     // only consider live articles
     $where .= " AND ((articles.expiry_date is NULL) " . "OR (articles.expiry_date <= '" . NULL_DATE . "') OR (articles.expiry_date > '" . $context['now'] . "'))";
     // the list of articles
     $query = "SELECT articles.*" . " FROM (" . SQL::table_name('members') . " AS members" . ", " . SQL::table_name('articles') . " AS articles)" . " WHERE (members.anchor LIKE '" . SQL::escape($anchor) . "')" . "\tAND (members.member_type LIKE 'article')" . "\tAND (articles.id = members.member_id)" . "\tAND " . $where . " ORDER BY rating_sum, edit_date DESC LIMIT " . $offset . ',' . $count;
     // use existing listing facility
     $output =& Articles::list_selected(SQL::query($query), $variant);
     return $output;
 }
开发者ID:rair,项目名称:yacs,代码行数:59,代码来源:members.php


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