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


PHP Members::list_anchors_for_member方法代码示例

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


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

示例1: sprintf

 $context['page_title'] = sprintf(i18n::s('Watchers of %s'), $anchor->get_title());
 // watchers of a page
 if (!strncmp($anchor->get_reference(), 'article:', 8)) {
     $users = Articles::list_watchers_by_name($anchor->item, 0, 5 * USERS_LIST_SIZE, 'raw');
 } elseif (!strncmp($anchor->get_reference(), 'section:', 8)) {
     $users = Sections::list_watchers_by_name($anchor->item, 0, 5 * USERS_LIST_SIZE, 'raw');
 } else {
     $anchors = array($anchor->get_reference());
     $handle = $anchor->get_parent();
     while ($handle && ($parent = Anchors::get($handle))) {
         $anchors[] = $handle;
         $handle = $parent->get_parent();
     }
     // authorized users
     $restricted = NULL;
     if ($anchor->is_hidden() && ($editors =& Members::list_anchors_for_member($anchors))) {
         foreach ($editors as $editor) {
             if (strpos($editor, 'user:') === 0) {
                 $restricted[] = substr($editor, strlen('user:'));
             }
         }
     }
     $users = Members::list_watchers_by_name_for_anchor($anchors, 0, 5 * USERS_LIST_SIZE, 'raw', $restricted);
 }
 // the current list of watchers
 if (count($users)) {
     // browse the list
     foreach ($users as $id => $user) {
         // make an url
         $url = Users::get_permalink($user);
         // gather information on this user
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select.php

示例2: list_watchers_by_posts

 /**
  * list all watchers of a page
  *
  * If the page is public or restricted to any member, the full list of persons watching this
  * page, and its parent section. If the parent section has the option 'forward_notifications'
  * the persons assigned to grand parent section are added.
  *
  * For example, if the root section A contains a section B, which contains page P, and if
  * P is public, the function looks for persons assigned either to B or to P.
  *
  * If the parent section has option 'forward_notifications', then this fonction adds watchers
  * of grand-parent section to the list.
  *
  * If the page is private, then the function looks for wtahcers of it, and for editors of the
  * parent section that may also be watchers.
  *
  * For example, if the section A is public, and if it contains private page P, the function
  * looks for watchers of P and for editors of A that are also watchers of A.
  * This is because watchers of section A who are not editors are not entitled to watch P.
  *
  * @param array attributes of the watched page
  * @param int the offset from the start of the list; usually, 0 or 1
  * @param int the number of items to display
  * @param string 'full', etc or object, i.e., an instance of Layout_Interface adapted to list of users
  * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
  *
  */
 public static function list_watchers_by_posts($item, $offset = 0, $count = 7, $variant = 'comma5')
 {
     global $context;
     // this page itself
     $anchors = array('article:' . $item['id']);
     // to list persons entitled to access this page
     $ancestors = array('article:' . $item['id']);
     // look at parents
     if ($anchor = Anchors::get($item['anchor'])) {
         // notify watchers of parent section
         $anchors[] = $anchor->get_reference();
         // notify watchers of grand-parent section too
         if ($anchor->has_option('forward_notifications', FALSE) && $anchor->get_parent()) {
             $anchors[] = $anchor->get_parent();
         }
         // editors of parent and grand parent section are entitled to access the page too
         $ancestors[] = $anchor->get_reference();
         $handle = $anchor->get_parent();
         while ($handle && ($parent = Anchors::get($handle))) {
             // notify watchers of grand-parent section too
             if ($parent->has_option('forward_notifications', FALSE) && $parent->get_parent()) {
                 $anchors[] = $parent->get_parent();
             }
             $ancestors[] = $handle;
             $handle = $parent->get_parent();
         }
     }
     // authorized users only
     $restricted = NULL;
     if ($item['active'] == 'N' && ($editors =& Members::list_anchors_for_member($ancestors))) {
         foreach ($editors as $editor) {
             if (strpos($editor, 'user:') === 0) {
                 $restricted[] = substr($editor, strlen('user:'));
             }
         }
     }
     // list users watching one of these anchors
     return Members::list_watchers_by_posts_for_anchor($anchors, $offset, $count, $variant, $restricted);
 }
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:articles.php


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