예제 #1
0
파일: invite.php 프로젝트: rair/yacs
 $layout = Layouts::new_('mail', 'user');
 // avoid links to this page
 if (is_object($layout) && is_callable(array($layout, 'set_variant'))) {
     $layout->set_variant('unchecked');
 }
 // 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
예제 #2
0
파일: anchor.php 프로젝트: rair/yacs
 /**
  * alert watchers of this anchor
  *
  * @param array message attributes, such as 'subject', 'message', 'headers'
  * @param string description of the on-going action (e.g., 'file:create')
  * @param boolean TRUE if access to the target object is restricted, FALSE otherwise
  * @return boolean TRUE on success, FALSE otherwise
  */
 function alert_watchers($mail, $action = NULL, $restricted = FALSE)
 {
     global $context;
     // do not notify watchers if overlay prevents it
     if (is_object($this->overlay) && !$this->overlay->should_notify_watchers($mail)) {
         return FALSE;
     }
     // list all items in the watching context
     $containers = $this->get_watched_context($action);
     // finalize the message
     $mail['message'] = Mailer::build_notification($mail['notification'], 1);
     // allow for message threading
     if (!isset($mail['headers'])) {
         $mail['headers'] = Mailer::set_thread($this->get_reference());
     }
     // we are private, so consider only watchers who are also editors
     if ($this->item['active'] == 'N') {
         $restricted = TRUE;
     }
     // list editors if access is restricted
     $editors = NULL;
     if ($restricted) {
         $editors = Members::list_editors_for_member($this->get_focus(), 0, 10000, 'ids');
     }
     // do the job
     return Users::alert_watchers($containers, $mail, $editors);
 }
예제 #3
0
파일: sections.php 프로젝트: rair/yacs
 /**
  * list all editors of a section
  *
  * This function lists editors of this section, or of any parent section.
  *
  * @param array attributes of the 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_editors_by_name($item, $offset = 0, $count = 7, $variant = 'comma5')
 {
     global $context;
     // this page itself
     $anchors = array('section:' . $item['id']);
     // look at parents
     if ($anchor = Anchors::get($item['anchor'])) {
         // look for editors of parent section
         $anchors[] = $anchor->get_reference();
         // look for editors of any ancestor
         $handle = $anchor->get_parent();
         while ($handle && ($parent = Anchors::get($handle))) {
             $anchors[] = $handle;
             $handle = $parent->get_parent();
         }
     }
     // list users assigned to any of these anchors
     return Members::list_editors_for_member($anchors, $offset, $count, $variant);
 }