Exemplo n.º 1
0
 function onHandleQueuedNotice($notice)
 {
     if (intval($notice->is_local) === Notice::LOCAL_PUBLIC) {
         // Try to avoid actually mucking with the
         // notice content
         $c = $notice->content;
         $this->notice = $notice;
         if (!$notice->getProfile()->getPref("linkbackplugin", "disable_linkbacks")) {
             // Ignoring results
             common_replace_urls_callback($c, array($this, 'linkbackUrl'));
         }
         if ($notice->isRepeat()) {
             $repeat = Notice::getByID($notice->repeat_of);
             $this->linkbackUrl($repeat->getUrl());
         } else {
             if (!empty($notice->reply_to)) {
                 $parent = $notice->getParent();
                 $this->linkbackUrl($parent->getUrl());
             }
         }
         $replyProfiles = Profile::multiGet('id', $notice->getReplies());
         foreach ($replyProfiles->fetchAll('profileurl') as $profileurl) {
             $this->linkbackUrl($profileurl);
         }
     }
     return true;
 }
Exemplo n.º 2
0
 protected function showEvent(Notice $stored, HTMLOutputter $out, Profile $scoped = null)
 {
     $profile = $stored->getProfile();
     $event = Happening::fromNotice($stored);
     if (!$event instanceof Happening) {
         // TRANS: Content for a deleted RSVP list item (RSVP stands for "please respond").
         $out->element('p', null, _m('Deleted.'));
         return;
     }
     $out->elementStart('div', 'h-event');
     $out->elementStart('h3', 'p-summary p-name');
     try {
         $out->element('a', array('href' => $event->getUrl()), $event->title);
     } catch (InvalidUrlException $e) {
         $out->text($event->title);
     }
     $out->elementEnd('h3');
     $now = new DateTime();
     $startDate = new DateTime($event->start_time);
     $endDate = new DateTime($event->end_time);
     $userTz = new DateTimeZone(common_timezone());
     // Localize the time for the observer
     $now->setTimeZone($userTz);
     $startDate->setTimezone($userTz);
     $endDate->setTimezone($userTz);
     $thisYear = $now->format('Y');
     $startYear = $startDate->format('Y');
     $endYear = $endDate->format('Y');
     $dateFmt = 'D, F j, ';
     // e.g.: Mon, Aug 31
     if ($startYear != $thisYear || $endYear != $thisYear) {
         $dateFmt .= 'Y,';
         // append year if we need to think about years
     }
     $startDateStr = $startDate->format($dateFmt);
     $endDateStr = $endDate->format($dateFmt);
     $timeFmt = 'g:ia';
     $startTimeStr = $startDate->format($timeFmt);
     $endTimeStr = $endDate->format("{$timeFmt} (T)");
     $out->elementStart('div', 'event-times');
     // VEVENT/EVENT-TIMES IN
     // TRANS: Field label for event description.
     $out->element('strong', null, _m('Time:'));
     $out->element('time', array('class' => 'dt-start', 'datetime' => common_date_iso8601($event->start_time)), $startDateStr . ' ' . $startTimeStr);
     $out->text(' – ');
     $out->element('time', array('class' => 'dt-end', 'datetime' => common_date_iso8601($event->end_time)), $startDateStr != $endDateStr ? "{$endDateStr} {$endTimeStr}" : $endTimeStr);
     $out->elementEnd('div');
     // VEVENT/EVENT-TIMES OUT
     if (!empty($event->location)) {
         $out->elementStart('div', 'event-location');
         // TRANS: Field label for event description.
         $out->element('strong', null, _m('Location:'));
         $out->element('span', 'p-location', $event->location);
         $out->elementEnd('div');
     }
     if (!empty($event->description)) {
         $out->elementStart('div', 'event-description');
         // TRANS: Field label for event description.
         $out->element('strong', null, _m('Description:'));
         $out->element('div', 'p-description', $event->description);
         $out->elementEnd('div');
     }
     $rsvps = $event->getRSVPs();
     $out->elementStart('div', 'event-rsvps');
     // TRANS: Field label for event description.
     $out->element('strong', null, _m('Attending:'));
     $out->elementStart('ul', 'attending-list');
     foreach ($rsvps as $verb => $responses) {
         $out->elementStart('li', 'rsvp-list');
         switch ($verb) {
             case RSVP::POSITIVE:
                 $out->text(_('Yes:'));
                 break;
             case RSVP::NEGATIVE:
                 $out->text(_('No:'));
                 break;
             case RSVP::POSSIBLE:
                 $out->text(_('Maybe:'));
                 break;
         }
         $ids = array();
         foreach ($responses as $response) {
             $ids[] = $response->profile_id;
         }
         $ids = array_slice($ids, 0, ProfileMiniList::MAX_PROFILES + 1);
         $minilist = new ProfileMiniList(Profile::multiGet('id', $ids), $out);
         $minilist->show();
         $out->elementEnd('li');
     }
     $out->elementEnd('ul');
     $out->elementEnd('div');
     if ($scoped instanceof Profile) {
         $rsvp = $event->getRSVP($scoped);
         if (empty($rsvp)) {
             $form = new RSVPForm($event, $out);
         } else {
             $form = new CancelRSVPForm($rsvp, $out);
         }
         $form->show();
     }
     $out->elementEnd('div');
 }
Exemplo n.º 3
0
 /**
  * Pull the complete list of @-reply targets for this notice.
  *
  * @return array of Profiles
  */
 function getAttentionProfiles()
 {
     $ids = array_unique(array_merge($this->getReplies(), $this->getGroupProfileIDs(), $this->getAttentionProfileIDs()));
     $profiles = Profile::multiGet('id', (array) $ids);
     return $profiles->fetchAll();
 }
Exemplo n.º 4
0
 function getSubscribers($offset = 0, $limit = null)
 {
     $subs = Subscription::getSubscriberIDs($this->id, $offset, $limit);
     try {
         $profiles = Profile::multiGet('id', $subs);
     } catch (NoResultException $e) {
         return $e->obj;
     }
     return $profiles;
 }
Exemplo n.º 5
0
 /**
  * Pull the complete list of @-reply targets for this notice.
  *
  * @return array of Profiles
  */
 function getReplyProfiles()
 {
     $ids = $this->getReplies();
     $profiles = Profile::multiGet('id', $ids);
     return $profiles->fetchAll();
 }
Exemplo n.º 6
0
 function getGroups()
 {
     $group = new User_group();
     // Disable this to get global group searches
     $group->joinAdd(array('id', 'local_group:group_id'));
     $order = false;
     if (!empty($this->q)) {
         $wheres = array('nickname', 'fullname', 'homepage', 'description', 'location');
         foreach ($wheres as $where) {
             // Double % because of sprintf
             $group->whereAdd(sprintf('LOWER(%1$s.%2$s) LIKE LOWER("%%%3$s%%")', $group->escapedTableName(), $where, $group->escape($this->q)), 'OR');
         }
         $order = sprintf('%1$s.%2$s %3$s', $group->escapedTableName(), $this->getSortKey('created'), $this->reverse ? 'DESC' : 'ASC');
     } else {
         // User is browsing via AlphaNav
         switch ($this->filter) {
             case 'all':
                 // NOOP
                 break;
             case '0-9':
                 $group->whereAdd(sprintf('LEFT(%1$s.%2$s, 1) BETWEEN %3$s AND %4$s', $group->escapedTableName(), 'nickname', $group->_quote("0"), $group->_quote("9")));
                 break;
             default:
                 $group->whereAdd(sprintf('LEFT(LOWER(%1$s.%2$s), 1) = %3$s', $group->escapedTableName(), 'nickname', $group->_quote($this->filter)));
         }
         $order = sprintf('%1$s.%2$s %3$s, %1$s.%4$s ASC', $group->escapedTableName(), $this->getSortKey('nickname'), $this->reverse ? 'DESC' : 'ASC', 'nickname');
     }
     $offset = ($this->page - 1) * PROFILES_PER_PAGE;
     $limit = PROFILES_PER_PAGE + 1;
     $group->selectAdd();
     $group->selectAdd('profile_id');
     $group->orderBy($order);
     $group->limit($offset, $limit);
     $group->find();
     return Profile::multiGet('id', $group->fetchAll('profile_id'));
 }
Exemplo n.º 7
0
 function getMembers($offset = 0, $limit = null)
 {
     $ids = null;
     if (is_null($limit) || $offset + $limit > User_group::CACHE_WINDOW) {
         $ids = $this->getMemberIDs($offset, $limit);
     } else {
         $key = sprintf('group:member_ids:%d', $this->id);
         $window = self::cacheGet($key);
         if ($window === false) {
             $window = $this->getMemberIDs(0, User_group::CACHE_WINDOW);
             self::cacheSet($key, $window);
         }
         $ids = array_slice($window, $offset, $limit);
     }
     return Profile::multiGet('id', $ids);
 }