/**
  * Show the item
  *
  * @return void
  */
 function show()
 {
     $group = $this->gm->getGroup();
     $sender = $this->gm->getSender();
     $this->out->elementStart('li', array('class' => 'hentry notice message group-message', 'id' => 'message-' . $this->gm->id));
     $this->out->elementStart('div', 'entry-title');
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('href' => $sender->profileurl, 'class' => 'url'));
     $avatar = $sender->getAvatar(AVATAR_STREAM_SIZE);
     $this->out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'class' => 'photo avatar', 'alt' => $sender->getBestName()));
     $this->out->element('span', array('class' => 'nickname fn'), $sender->nickname);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->elementStart('p', array('class' => 'entry-content message-content'));
     $this->out->raw($this->gm->rendered);
     $this->out->elementEnd('p');
     $this->out->elementEnd('div');
     $this->out->elementStart('div', 'entry-content');
     $this->out->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => $this->gm->url));
     $dt = common_date_iso8601($this->gm->created);
     $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->gm->created));
     $this->out->elementEnd('a');
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
 /**
  * Show the widget
  *
  * @return void
  */
 function show()
 {
     $this->out->elementStart('li', array('class' => 'h-entry notice', 'id' => 'message-' . $this->message->id));
     $profile = $this->getMessageProfile();
     $this->out->elementStart('a', array('href' => $profile->profileurl, 'class' => 'p-author'));
     $avatarUrl = $profile->avatarUrl(AVATAR_STREAM_SIZE);
     $this->out->element('img', array('src' => $avatarUrl, 'class' => 'avatar u-photo', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $profile->getBestName()));
     $this->out->element('span', array('class' => 'nickname fn'), $profile->getNickname());
     $this->out->elementEnd('a');
     // FIXME: URL, image, video, audio
     $this->out->elementStart('div', array('class' => 'e-content'));
     $this->out->raw($this->message->rendered);
     $this->out->elementEnd('div');
     $messageurl = common_local_url('showmessage', array('message' => $this->message->id));
     // XXX: we need to figure this out better. Is this right?
     if (strcmp($this->message->uri, $messageurl) != 0 && preg_match('/^http/', $this->message->uri)) {
         $messageurl = $this->message->uri;
     }
     $this->out->elementStart('div', 'entry-metadata');
     $this->out->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => $messageurl));
     $dt = common_date_iso8601($this->message->created);
     $this->out->element('time', array('class' => 'dt-published', 'datetime' => common_date_iso8601($this->message->created), 'title' => common_exact_date($this->message->created)), common_date_string($this->message->created));
     $this->out->elementEnd('a');
     if ($this->message->source) {
         $this->out->elementStart('span', 'source');
         // FIXME: bad i18n. Device should be a parameter (from %s).
         // TRANS: Followed by notice source (usually the client used to send the notice).
         $this->out->text(_('from'));
         $this->showSource($this->message->source);
         $this->out->elementEnd('span');
     }
     $this->out->elementEnd('div');
     $this->out->elementEnd('li');
 }
Example #3
0
 function showProfile()
 {
     $tagsub = $this->profile;
     $tag = $tagsub->tag;
     // Relevant portion!
     $cur = common_current_user();
     if (!empty($cur) && $cur->id == $this->owner->id) {
         $this->showOwnerControls();
     }
     $url = common_local_url('tag', array('tag' => $tag));
     // TRANS: %1$s is a URL to a tag, %2$s is a tag,
     // TRANS: %3$s a date string.
     $linkline = sprintf(_m('#<a href="%1$s">%2$s</a> since %3$s'), htmlspecialchars($url), htmlspecialchars($tag), common_date_string($tagsub->created));
     $this->out->elementStart('div', 'tagsub-item');
     $this->out->raw($linkline);
     $this->out->element('div', array('style' => 'clear: both'));
     $this->out->elementEnd('div');
 }
Example #4
0
 function showConnection()
 {
     $app = Oauth_application::staticGet('id', $this->connection->application_id);
     $this->out->elementStart('li', array('class' => 'application', 'id' => 'oauthclient-' . $app->id));
     $this->out->elementStart('span', 'vcard author');
     $this->out->elementStart('a', array('href' => $app->source_url, 'class' => 'url'));
     if (!empty($app->icon)) {
         $this->out->element('img', array('src' => $app->icon, 'class' => 'photo avatar'));
     }
     if ($app->name != 'anonymous') {
         $this->out->element('span', 'fn', $app->name);
     }
     $this->out->elementEnd('a');
     if ($app->name == 'anonymous') {
         // TRANS: Name for an anonymous application in application list.
         $this->out->element('span', 'fn', _('Unknown application'));
     }
     $this->out->elementEnd('span');
     if ($app->name != 'anonymous') {
         // @todo FIXME: i18n trouble.
         // TRANS: Message has a leading space and a trailing space. Used in application list.
         // TRANS: Before this message the application name is put, behind it the organisation that manages it.
         $this->out->raw(_(' by '));
         $this->out->element('a', array('href' => $app->homepage, 'class' => 'url'), $app->organization);
     }
     // TRANS: Application access type
     $readWriteText = _('read-write');
     // TRANS: Application access type
     $readOnlyText = _('read-only');
     $access = $this->connection->access_type & Oauth_application::$writeAccess ? $readWriteText : $readOnlyText;
     $modifiedDate = common_date_string($this->connection->modified);
     // TRANS: Used in application list. %1$s is a modified date, %2$s is access type ("read-write" or "read-only")
     $txt = sprintf(_('Approved %1$s - "%2$s" access.'), $modifiedDate, $access);
     // @todo FIXME: i18n trouble.
     $this->out->raw(" - {$txt}");
     if (!empty($app->description)) {
         $this->out->element('p', array('class' => 'application_description'), $app->description);
     }
     $this->out->element('p', array('class' => 'access_token'), sprintf(_('Access token starting with: %s'), substr($this->connection->token, 0, 7)));
     $this->out->elementStart('form', array('id' => 'form_revoke_app', 'class' => 'form_revoke_app', 'method' => 'POST', 'action' => common_local_url('oauthconnectionssettings')));
     $this->out->elementStart('fieldset');
     $this->out->hidden('oauth_token', $this->connection->token);
     $this->out->hidden('token', common_session_token());
     // TRANS: Button label in application list to revoke access to user data.
     $this->out->submit('revoke', _m('BUTTON', 'Revoke'));
     $this->out->elementEnd('fieldset');
     $this->out->elementEnd('form');
     $this->out->elementEnd('li');
 }
Example #5
0
 function showUpdated()
 {
     if (!empty($this->peopletag->modified)) {
         $this->out->element('abbr', array('title' => common_date_w3dtf($this->peopletag->modified), 'class' => 'updated'), common_date_string($this->peopletag->modified));
     }
 }
Example #6
0
 /**
  * show the link to the main page for the notice
  *
  * Displays a link to the page for a notice, with "relative" time. Tries to
  * get remote notice URLs correct, but doesn't always succeed.
  *
  * @return void
  */
 function showNoticeLink()
 {
     $noticeurl = $this->notice->bestUrl();
     // above should always return an URL
     assert(!empty($noticeurl));
     $this->out->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => $noticeurl));
     $dt = common_date_iso8601($this->notice->created);
     $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created));
     $this->out->elementEnd('a');
 }
Example #7
0
 /**
  * show a single message in the list format
  *
  * XXX: This needs to be extracted out into a MessageList similar
  * to NoticeList.
  *
  * @param Message $message the message to show
  *
  * @return void
  */
 function showMessage($message)
 {
     $this->elementStart('li', array('class' => 'hentry notice', 'id' => 'message-' . $message->id));
     $profile = $this->getMessageProfile($message);
     $this->elementStart('div', 'entry-title');
     $this->elementStart('span', 'vcard author');
     $this->elementStart('a', array('href' => $profile->profileurl, 'class' => 'url'));
     $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
     $this->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), 'class' => 'photo avatar', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $profile->fullname ? $profile->fullname : $profile->nickname));
     $this->element('span', array('class' => 'nickname fn'), $profile->nickname);
     $this->elementEnd('a');
     $this->elementEnd('span');
     // FIXME: URL, image, video, audio
     $this->elementStart('p', array('class' => 'entry-content'));
     $this->raw($message->rendered);
     $this->elementEnd('p');
     $this->elementEnd('div');
     $messageurl = common_local_url('showmessage', array('message' => $message->id));
     // XXX: we need to figure this out better. Is this right?
     if (strcmp($message->uri, $messageurl) != 0 && preg_match('/^http/', $message->uri)) {
         $messageurl = $message->uri;
     }
     $this->elementStart('div', 'entry-content');
     $this->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => $messageurl));
     $dt = common_date_iso8601($message->created);
     $this->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($message->created));
     $this->elementEnd('a');
     if ($message->source) {
         $this->elementStart('span', 'source');
         $this->text(_('from'));
         $this->element('span', 'device', $this->showSource($message->source));
         $this->elementEnd('span');
     }
     $this->elementEnd('div');
     $this->elementEnd('li');
 }
 function showApplication()
 {
     $user = common_current_user();
     $this->out->elementStart('li', array('class' => 'application', 'id' => 'oauthclient-' . $this->application->id));
     $this->out->elementStart('span', 'vcard author');
     if (!$this->connections) {
         $this->out->elementStart('a', array('href' => common_local_url('showapplication', array('id' => $this->application->id)), 'class' => 'url'));
     } else {
         $this->out->elementStart('a', array('href' => $this->application->source_url, 'class' => 'url'));
     }
     if (!empty($this->application->icon)) {
         $this->out->element('img', array('src' => $this->application->icon, 'class' => 'photo avatar'));
     }
     $this->out->element('span', 'fn', $this->application->name);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->raw(' by ');
     $this->out->element('a', array('href' => $this->application->homepage, 'class' => 'url'), $this->application->organization);
     $this->out->element('p', 'note', $this->application->description);
     $this->out->elementEnd('li');
     if ($this->connections) {
         $appUser = Oauth_application_user::getByKeys($this->owner, $this->application);
         if (empty($appUser)) {
             common_debug("empty appUser!");
         }
         $this->out->elementStart('li');
         $access = $this->application->access_type & Oauth_application::$writeAccess ? 'read-write' : 'read-only';
         $txt = 'Approved ' . common_date_string($appUser->modified) . " - {$access} access.";
         $this->out->raw($txt);
         $this->out->elementEnd('li');
         $this->out->elementStart('li', 'entity_revoke');
         $this->out->elementStart('form', array('id' => 'form_revoke_app', 'class' => 'form_revoke_app', 'method' => 'POST', 'action' => common_local_url('oauthconnectionssettings')));
         $this->out->elementStart('fieldset');
         $this->out->hidden('id', $this->application->id);
         $this->out->hidden('token', common_session_token());
         $this->out->submit('revoke', _('Revoke'));
         $this->out->elementEnd('fieldset');
         $this->out->elementEnd('form');
         $this->out->elementEnd('li');
     }
 }
 /**
  * Send a summary email to the user
  *
  * @param mixed $object
  * @return boolean true on success, false on failure
  */
 function handle($user_id)
 {
     // Skip if they've asked not to get summaries
     $ess = Email_summary_status::staticGet('user_id', $user_id);
     if (!empty($ess) && !$ess->send_summary) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s by request.', $user_id));
         return true;
     }
     $since_id = null;
     if (!empty($ess)) {
         $since_id = $ess->last_summary_id;
     }
     $user = User::staticGet('id', $user_id);
     if (empty($user)) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no such user.', $user_id));
         return true;
     }
     if (empty($user->email)) {
         common_log(LOG_INFO, sprintf('Not sending email summary for user %s; no email address.', $user_id));
         return true;
     }
     $profile = $user->getProfile();
     if (empty($profile)) {
         common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no profile.', $user_id));
         return true;
     }
     $stream = new InboxNoticeStream($user, $user->getProfile());
     $notice = $stream->getNotices(0, self::MAX_NOTICES, $since_id);
     if (empty($notice) || $notice->N == 0) {
         common_log(LOG_WARNING, sprintf('Not sending email summary for user %s; no notices.', $user_id));
         return true;
     }
     // XXX: This is risky fingerpoken in der objektvars, but I didn't feel like
     // figuring out a better way. -ESP
     $new_top = null;
     if ($notice instanceof ArrayWrapper) {
         $new_top = $notice->_items[0]->id;
     }
     // TRANS: Subject for e-mail.
     $subject = sprintf(_m('Your latest updates from %s'), common_config('site', 'name'));
     $out = new XMLStringer(true);
     $out->elementStart('html');
     $out->elementStart('head');
     $out->element('title', null, $subject);
     $out->elementEnd('head');
     $out->elementStart('body');
     $out->elementStart('div', array('width' => '100%', 'style' => 'background-color: #ffffff; border: 4px solid #4c609a; padding: 10px;'));
     $out->elementStart('div', array('style' => 'color: #ffffff; background-color: #4c609a; font-weight: bold; margin-bottom: 10px; padding: 4px;'));
     // TRANS: Text in e-mail summary.
     // TRANS: %1$s is the StatusNet sitename, %2$s is the recipient's profile name.
     $out->raw(sprintf(_m('Recent updates from %1$s for %2$s:'), common_config('site', 'name'), $profile->getBestName()));
     $out->elementEnd('div');
     $out->elementStart('table', array('width' => '550px', 'style' => 'border: none; border-collapse: collapse;', 'cellpadding' => '6'));
     while ($notice->fetch()) {
         $profile = Profile::staticGet('id', $notice->profile_id);
         if (empty($profile)) {
             continue;
         }
         $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
         $out->elementStart('tr');
         $out->elementStart('td', array('width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'align' => 'left', 'valign' => 'top', 'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
         $out->element('img', array('src' => $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => $profile->getBestName()));
         $out->elementEnd('td');
         $out->elementStart('td', array('align' => 'left', 'valign' => 'top', 'style' => 'border-bottom: 1px dotted #C5CEE3; padding: 10px 6px 10px 6px;'));
         $out->element('a', array('href' => $profile->profileurl), $profile->nickname);
         $out->text(' ');
         $out->raw($notice->rendered);
         $out->elementStart('div', array('style' => 'font-size: 0.8em; padding-top: 4px;'));
         $noticeurl = $notice->bestUrl();
         // above should always return an URL
         assert(!empty($noticeurl));
         $out->elementStart('a', array('rel' => 'bookmark', 'href' => $noticeurl));
         $dt = common_date_iso8601($notice->created);
         $out->element('abbr', array('style' => 'border-bottom: none;', 'title' => $dt), common_date_string($notice->created));
         $out->elementEnd('a');
         if ($notice->hasConversation()) {
             $conv = Conversation::staticGet('id', $notice->conversation);
             $convurl = $conv->uri;
             if (!empty($convurl)) {
                 $out->text(' ');
                 $out->element('a', array('href' => $convurl . '#notice-' . $notice->id), _m('in context'));
             }
         }
         $out->elementEnd('div');
         $out->elementEnd('td');
         $out->elementEnd('tr');
     }
     $out->elementEnd('table');
     // TRANS: Link text for link to e-mail settings.
     // TRANS: %1$s is a link to the e-mail settings, %2$s is the StatusNet sitename.
     $out->raw("<p>" . sprintf(_m('<a href="%1$s">change your email settings for %2$s</a>'), common_local_url('emailsettings'), common_config('site', 'name')) . "</p>");
     $out->elementEnd('div');
     $out->elementEnd('body');
     $out->elementEnd('html');
     $body = $out->getString();
     // FIXME: do something for people who don't like HTML email
     mail_to_user($user, $subject, $body, array('Content-Type' => 'text/html; charset=utf-8', 'Mime-Version' => '1.0'));
     if (empty($ess)) {
         $ess = new Email_summary_status();
         $ess->user_id = $user_id;
         $ess->created = common_sql_now();
         $ess->last_summary_id = $new_top;
         $ess->modified = common_sql_now();
         $ess->insert();
     } else {
         $orig = clone $ess;
         $ess->last_summary_id = $new_top;
         $ess->modified = common_sql_now();
         $ess->update($orig);
     }
     return true;
 }
Example #10
0
 /**
  * show the link to the main page for the notice
  *
  * Displays a link to the page for a notice, with "relative" time. Tries to
  * get remote notice URLs correct, but doesn't always succeed.
  *
  * @return void
  */
 function showNoticeLink()
 {
     $noticeurl = $this->notice->bestUrl();
     // above should always return an URL
     assert(!empty($noticeurl));
     $dt = common_date_iso8601($this->notice->created);
     $this->out->element('div', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created));
 }
Example #11
0
 function showProfile()
 {
     $searchsub = $this->profile;
     $search = $searchsub->search;
     // Relevant portion!
     $cur = common_current_user();
     if (!empty($cur) && $cur->id == $this->owner->id) {
         $this->showOwnerControls();
     }
     $url = common_local_url('noticesearch', array('q' => $search));
     // TRANS: Search subscription list item. %1$s is a URL to a notice search,
     // TRANS: %2$s are the search criteria, %3$s is a datestring.
     $linkline = sprintf(_m('"<a href="%1$s">%2$s</a>" since %3$s'), htmlspecialchars($url), htmlspecialchars($search), common_date_string($searchsub->created));
     $this->out->elementStart('div', 'searchsub-item');
     $this->out->raw($linkline);
     $this->out->element('div', array('style' => 'clear: both'));
     $this->out->elementEnd('div');
 }
Example #12
0
 /**
  * show the link to the main page for the notice
  *
  * Displays a local link to the rendered notice, with "relative" time.
  *
  * @return void
  */
 function showNoticeLink()
 {
     $this->out->elementStart('a', array('rel' => 'bookmark', 'class' => 'timestamp', 'href' => Conversation::getUrlFromNotice($this->notice)));
     $this->out->element('time', array('class' => 'dt-published', 'datetime' => common_date_iso8601($this->notice->created), 'title' => common_exact_date($this->notice->created)), common_date_string($this->notice->created));
     $this->out->elementEnd('a');
 }
Example #13
0
 function showNoticeLink()
 {
     $noticeurl = common_local_url('shownotice', array('notice' => $this->notice->id));
     // XXX: we need to figure this out better. Is this right?
     if (strcmp($this->notice->uri, $noticeurl) != 0 && preg_match('/^http/', $this->notice->uri)) {
         $noticeurl = $this->notice->uri;
     }
     $this->out->elementStart('dl', 'timestamp');
     $this->out->element('dt', null, _('Published'));
     $this->out->elementStart('dd', null);
     $this->out->elementStart('a', array('rel' => 'bookmark', 'href' => $noticeurl));
     $dt = common_date_iso8601($this->notice->created);
     $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created));
     $this->out->elementEnd('a');
     $this->out->elementEnd('dd');
     $this->out->elementEnd('dl');
 }
Example #14
0
 function showApplication()
 {
     $user = common_current_user();
     $this->out->elementStart('li', array('class' => 'application', 'id' => 'oauthclient-' . $this->application->id));
     $this->out->elementStart('span', 'vcard author');
     if (!$this->connections) {
         $this->out->elementStart('a', array('href' => common_local_url('showapplication', array('id' => $this->application->id)), 'class' => 'url'));
     } else {
         $this->out->elementStart('a', array('href' => $this->application->source_url, 'class' => 'url'));
     }
     if (!empty($this->application->icon)) {
         $this->out->element('img', array('src' => $this->application->icon, 'class' => 'photo avatar'));
     }
     $this->out->element('span', 'fn', $this->application->name);
     $this->out->elementEnd('a');
     $this->out->elementEnd('span');
     $this->out->raw(' by ');
     $this->out->element('a', array('href' => $this->application->homepage, 'class' => 'url'), $this->application->organization);
     $this->out->element('p', 'note', $this->application->description);
     $this->out->elementEnd('li');
     if ($this->connections) {
         $appUser = Oauth_application_user::getByKeys($this->owner, $this->application);
         if (empty($appUser)) {
             common_debug("empty appUser!");
         }
         $this->out->elementStart('li');
         // TRANS: Application access type
         $readWriteText = _('read-write');
         // TRANS: Application access type
         $readOnlyText = _('read-only');
         $access = $this->application->access_type & Oauth_application::$writeAccess ? $readWriteText : $readOnlyText;
         $modifiedDate = common_date_string($appUser->modified);
         // TRANS: Used in application list. %1$s is a modified date, %2$s is access type (read-write or read-only)
         $txt = sprintf(_('Approved %1$s - "%2$s" access.'), $modifiedDate, $access);
         $this->out->raw($txt);
         $this->out->elementEnd('li');
         $this->out->elementStart('li', 'entity_revoke');
         $this->out->elementStart('form', array('id' => 'form_revoke_app', 'class' => 'form_revoke_app', 'method' => 'POST', 'action' => common_local_url('oauthconnectionssettings')));
         $this->out->elementStart('fieldset');
         $this->out->hidden('id', $this->application->id);
         $this->out->hidden('token', common_session_token());
         // TRANS: Button label
         $this->out->submit('revoke', _m('BUTTON', 'Revoke'));
         $this->out->elementEnd('fieldset');
         $this->out->elementEnd('form');
         $this->out->elementEnd('li');
     }
 }