// pre-invite someone $invited = ''; if (isset($_REQUEST['invited']) && ($user = Users::get($_REQUEST['invited']))) { $invited = $user['nick_name']; } else { $handle = $item['anchor']; while ($handle && ($parent = Anchors::get($handle))) { $handle = $parent->get_parent(); // invitation to a private page should be limited to editors if ($item['active'] == 'N') { if ($editors = Members::list_editors_for_member($parent->get_reference(), 0, 1000, $layout)) { $input .= Skin::build_box(sprintf(i18n::s('Invite editors of %s'), $parent->get_title()), Skin::build_list($editors, 'compact'), 'folded'); } // else invitation should be extended to watchers } else { if ($watchers = Members::list_watchers_by_name_for_anchor($parent->get_reference(), 0, 1000, $layout)) { $input .= Skin::build_box(sprintf(i18n::s('Invite watchers of %s'), $parent->get_title()), Skin::build_list($watchers, 'compact'), 'folded'); } } } } // add some names manually $input .= Skin::build_box(i18n::s('Invite some persons'), '<textarea name="to" id="names" rows="3" cols="50">' . $invited . '</textarea><div><span class="tiny">' . i18n::s('Enter nick names, or email addresses, separated by commas.') . '</span></div>', 'unfolded'); // combine all these elements $fields[] = array($label, $input); // the subject $label = i18n::s('Message title'); if (is_object($overlay)) { $title = $overlay->get_live_title($item); } else { $title = $item['title'];
$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:'******'user:'******'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 $prefix = $suffix = $type = $icon = ''; if (isset($user['full_name']) && $user['full_name']) { $label = $user['full_name'] . ' (' . $user['nick_name'] . ')'; } else { $label = $user['nick_name']; } // format the item
$output .= Skin::finalize_list($menu, 'menu_bar'); // list watched users by posts $watched = ''; if ($items =& Members::list_connections_for_user('user:'******'id'], 0, 200, 'watch')) { if (is_array($items)) { $items = Skin::build_list($items, 'decorated'); } $watched .= $items; } elseif (Surfer::get_id() == $item['id']) { $watched .= '<p>' . i18n::s('Click on the link above to follow someone.') . '</p>'; } else { $watched .= '<p>' . sprintf(i18n::s('%s is not yet following other persons.'), $item['full_name']) . '</p>'; } // the list of followers $followers = ''; if ($items = Members::list_watchers_by_name_for_anchor('user:'******'id'], 0, 1000, 'compact')) { if (is_array($items)) { $items = Skin::build_list($items, 'compact'); } if (Surfer::get_id() == $item['id']) { $followers .= '<p>' . i18n::s('Persons who follow you:') . '</p>' . $items; } else { $followers .= '<p>' . sprintf(i18n::s('Persons who follow %s:'), $item['full_name']) . '</p>' . $items; } } // connect to people if (Surfer::get_id() && Surfer::get_id() != $item['id']) { // suggest a new connection if (!Members::check('user:'******'id'], 'user:'******'USERS_WATCH_IMG', 'users/watch.gif'); $link = Users::get_url('user:'******'id'], 'track');
/** * list watchers of a section in alphabetical order * * If the section is public or restricted to any member, the full list of persons watching this * specific section, or any parent section, is provided. * * For example, if the root section A contains a section B, which contains section C, and if * C is public, the function looks for persons assigned either to A, to B or to C. * * If the section is private, then the function looks for any private parent, and list all * persons watching one of these sections. * * For example, if the root section A is public, and if it contains a section B that is private, * and if B contains section C, the function looks for persons assigned either to B or to C. * This is because watchers of section A may not be entitled to watch content of B nor of C. * * @param array attributes of the watched section * @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_name($item, $offset = 0, $count = 7, $variant = 'comma5') { global $context; // this section itself $anchors = array('section:' . $item['id']); // there is at least a parent section if ($anchor = Anchors::get($item['anchor'])) { // this section is private, list only hidden parent sections if ($item['active'] == 'N') { // parent is hidden if ($anchor->is_hidden()) { $anchors[] = $anchor->get_reference(); // look for grand parents $handle = $anchor->get_parent(); while ($handle && ($parent = Anchors::get($handle))) { if (!$parent->is_hidden()) { break; } $anchors[] = $handle; $handle = $parent->get_parent(); } } // else list all parent sections } else { // add parent section $anchors[] = $anchor->get_reference(); // look for all grand parents $handle = $anchor->get_parent(); while ($handle && ($parent = Anchors::get($handle))) { $anchors[] = $handle; $handle = $parent->get_parent(); } } } // list users watching one of these anchors return Members::list_watchers_by_name_for_anchor($anchors, $offset, $count, $variant); }
/** * 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_name($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:'******'user:')); } } } // list users watching one of these anchors return Members::list_watchers_by_name_for_anchor($anchors, $offset, $count, $variant, $restricted); }