function prepare($args) { parent::prepare($args); $this->user = common_current_user(); if (empty($this->user)) { $this->clientError(_('Only logged-in users can repeat notices.')); return false; } $id = $this->trimmed('notice'); if (empty($id)) { $this->clientError(_('No notice specified.')); return false; } $this->notice = Notice::staticGet('id', $id); if (empty($this->notice)) { $this->clientError(_('No notice specified.')); return false; } if ($this->user->id == $this->notice->profile_id) { $this->clientError(_("You can't repeat your own notice.")); return false; } $token = $this->trimmed('token-' . $id); if (empty($token) || $token != common_session_token()) { $this->clientError(_('There was a problem with your session token. Try again, please.')); return false; } $profile = $this->user->getProfile(); if ($profile->hasRepeated($id)) { $this->clientError(_('You already repeated that notice.')); return false; } return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { Action::prepare($argarray); $this->id = $this->trimmed('id'); $this->answer = QnA_Answer::staticGet('id', $this->id); if (empty($this->answer)) { // TRANS: Client exception thrown when requesting a non-existing answer. throw new ClientException(_m('No such answer.'), 404); } $this->question = $this->answer->getQuestion(); if (empty($this->question)) { // TRANS: Client exception thrown when requesting an answer that has no connected question. throw new ClientException(_m('No question for this answer.'), 404); } $this->notice = Notice::staticGet('uri', $this->answer->uri); if (empty($this->notice)) { // TRANS: Did we used to have it, and it got deleted? throw new ClientException(_m('No such answer.'), 404); } $this->user = User::staticGet('id', $this->answer->profile_id); if (empty($this->user)) { // TRANS: Client exception thrown when requesting answer data for a non-existing user. throw new ClientException(_m('No such user.'), 404); } $this->profile = $this->user->getProfile(); if (empty($this->profile)) { // TRANS: Client exception thrown when requesting answer data for a user without a profile. throw new ServerException(_m('User without a profile.')); } $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; }
function handle($notice) { assert($notice instanceof Notice); $this->notice = $notice; $this->user = User::staticGet($notice->profile_id); $this->pushUser(); foreach ($notice->getGroups() as $group) { $oprofile = Ostatus_profile::staticGet('group_id', $group->id); if ($oprofile) { $this->pingReply($oprofile); } else { $this->pushGroup($group->id); } } foreach ($notice->getReplies() as $profile_id) { $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id); if ($oprofile) { $this->pingReply($oprofile); } } if (!empty($this->notice->reply_to)) { $replyTo = Notice::staticGet('id', $this->notice->reply_to); if (!empty($replyTo)) { foreach ($replyTo->getReplies() as $profile_id) { $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id); if ($oprofile) { $this->pingReply($oprofile); } } } } return true; }
function prepare($args) { parent::prepare($args); $this->id = $this->trimmed('notice'); if (empty($this->id)) { $this->clientError(_('No notice ID.')); } $notice = Notice::staticGet('id', $this->id); if (empty($notice)) { $this->clientError(_('No notice.')); } $atts = $notice->attachments(); if (empty($atts)) { $this->clientError(_('No attachments.')); } foreach ($atts as $att) { if (!empty($att->filename)) { $this->filerec = $att; break; } } if (empty($this->filerec)) { $this->clientError(_('No uploaded attachments.')); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->user = $this->auth_user; $this->notice = Notice::staticGet($this->arg('id')); return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); // User must be logged in. $user = common_current_user(); if (empty($user)) { throw new ClientException(_("You must be logged in to train spam."), 403); } // User must have the right to review spam if (!$user->hasRight(ActivitySpamPlugin::TRAINSPAM)) { throw new ClientException(_('You cannot review spam on this site.'), 403); } $id = $this->trimmed('notice'); $this->notice = Notice::staticGet('id', $id); if (empty($this->notice)) { throw new ClientException(_("No such notice.")); } $this->checkSessionToken(); $filter = null; Event::handle('GetSpamFilter', array(&$filter)); if (empty($filter)) { throw new ServerException(_("No spam filter configured.")); } $this->filter = $filter; $this->category = $this->trimmed('category'); if ($this->category !== SpamFilter::SPAM && $this->category !== SpamFilter::HAM) { throw new ClientException(_("No such category.")); } return true; }
function prepare($args) { parent::prepare($args); $this->user = common_current_user(); if (empty($this->user)) { // TRANS: Client error displayed when trying to repeat a notice while not logged in. $this->clientError(_('Only logged-in users can repeat notices.')); return false; } $id = $this->trimmed('notice'); if (empty($id)) { // TRANS: Client error displayed when trying to repeat a notice while not providing a notice ID. $this->clientError(_('No notice specified.')); return false; } $this->notice = Notice::staticGet('id', $id); if (empty($this->notice)) { // TRANS: Client error displayed when trying to repeat a non-existing notice. $this->clientError(_('No notice specified.')); return false; } $token = $this->trimmed('token-' . $id); if (empty($token) || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return false; } return true; }
static function getStreamByIds($ids) { $cache = Cache::instance(); if (!empty($cache)) { $notices = array(); foreach ($ids as $id) { $n = Notice::staticGet('id', $id); if (!empty($n)) { $notices[] = $n; } } return new ArrayWrapper($notices); } else { $notice = new Notice(); if (empty($ids)) { //if no IDs requested, just return the notice object return $notice; } $notice->whereAdd('id in (' . implode(', ', $ids) . ')'); $notice->find(); $temp = array(); while ($notice->fetch()) { $temp[$notice->id] = clone $notice; } $wrapped = array(); foreach ($ids as $id) { if (array_key_exists($id, $temp)) { $wrapped[] = $temp[$id]; } } return new ArrayWrapper($wrapped); } }
function prepare($args) { parent::prepare($args); $this->id = $this->trimmed('notice'); if (empty($this->id)) { // TRANS: Client error displayed when no notice ID was given trying do display a file. $this->clientError(_('No notice ID.')); } $notice = Notice::staticGet('id', $this->id); if (empty($notice)) { // TRANS: Client error displayed when an invalid notice ID was given trying do display a file. $this->clientError(_('No notice.')); } $atts = $notice->attachments(); if (empty($atts)) { // TRANS: Client error displayed when trying do display a file for a notice without a file attachement. $this->clientError(_('No attachments.')); } foreach ($atts as $att) { if (!empty($att->filename)) { $this->filerec = $att; break; } } if (empty($this->filerec)) { // XXX: Is this translation hint correct? If yes, please remove comment, if no, please correct and remove comment. // TRANS: Client error displayed when trying do display a file for a notice with file attachements // TRANS: that could not be found. $this->clientError(_('No uploaded attachments.')); } return true; }
function twitter_status_array($notice, $include_user = true) { $profile = $notice->getProfile(); $twitter_status = array(); $twitter_status['text'] = $notice->content; $twitter_status['truncated'] = 'false'; # Not possible on Laconica $twitter_status['created_at'] = $this->date_twitter($notice->created); $twitter_status['in_reply_to_status_id'] = $notice->reply_to ? intval($notice->reply_to) : null; $twitter_status['source'] = $this->source_link($notice->source); $twitter_status['id'] = intval($notice->id); $replier_profile = null; if ($notice->reply_to) { $reply = Notice::staticGet(intval($notice->reply_to)); if ($reply) { $replier_profile = $reply->getProfile(); } } $twitter_status['in_reply_to_user_id'] = $replier_profile ? intval($replier_profile->id) : null; $twitter_status['in_reply_to_screen_name'] = $replier_profile ? $replier_profile->nickname : null; if (isset($this->auth_user)) { $twitter_status['favorited'] = $this->auth_user->hasFave($notice) ? 'true' : 'false'; } else { $twitter_status['favorited'] = 'false'; } if ($include_user) { # Don't get notice (recursive!) $twitter_user = $this->twitter_user_array($profile, false); $twitter_status['user'] = $twitter_user; } return $twitter_status; }
/** * Look up a notice from an argument, by poster's name to get last post * or notice_id prefixed with #. * * @return Notice * @throws CommandException */ function getNotice($arg) { $notice = null; if (Event::handle('StartCommandGetNotice', array($this, $arg, &$notice))) { if (substr($this->other, 0, 1) == '#') { // A specific notice_id #123 $notice = Notice::staticGet(substr($arg, 1)); if (!$notice) { throw new CommandException(_('Notice with that id does not exist')); } } if (Validate::uri($this->other)) { // A specific notice by URI lookup $notice = Notice::staticGet('uri', $arg); } if (!$notice) { // Local or remote profile name to get their last notice. // May throw an exception and report 'no such user' $recipient = $this->getProfile($arg); $notice = $recipient->getCurrentNotice(); if (!$notice) { throw new CommandException(_('User has no last notice')); } } } Event::handle('EndCommandGetNotice', array($this, $arg, &$notice)); if (!$notice) { throw new CommandException(_('Notice with that id does not exist')); } return $notice; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { // TRANS: Client error. POST is a HTTP command. It should not be translated. $this->clientError(_('This method requires a POST.'), 400, $this->format); return false; } $id = $this->trimmed('id'); $this->original = Notice::staticGet('id', $id); if (empty($this->original)) { $this->clientError(_('No such notice.'), 400, $this->format); return false; } $this->user = $this->auth_user; if ($this->user->id == $this->original->profile_id) { $this->clientError(_('Cannot repeat your own notice.'), 400, $this->format); return false; } $profile = $this->user->getProfile(); if ($profile->hasRepeated($id)) { $this->clientError(_('Already repeated that notice.'), 400, $this->format); return false; } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->user = $this->auth_user; $this->notice_id = (int) $this->trimmed('id'); if (empty($notice_id)) { $this->notice_id = (int) $this->arg('id'); } $this->notice = Notice::staticGet((int) $this->notice_id); return true; }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { // TRANS: Client error displayed when trying to remove a favorite while not logged in. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $fave = new Fave(); $fave->user_id = $user->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { // TRANS: Client error displayed when trying to remove favorite status for a notice that is not a favorite. $this->clientError(_('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); // TRANS: Server error displayed when removing a favorite from the database fails. $this->serverError(_('Could not delete favorite.')); return; } $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title for page on which favorites can be added. $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new FavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303); } }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->user = $this->auth_user; $this->notice = Notice::staticGet($this->arg('id')); if ($this->notice->repeat_of != '') { common_log(LOG_DEBUG, 'Trying to Fave ' . $this->notice->id . ', repeat of ' . $this->notice->repeat_of); common_log(LOG_DEBUG, 'Will Fave ' . $this->notice->repeat_of . ' instead'); $real_notice_id = $this->notice->repeat_of; $this->notice = Notice::staticGet($real_notice_id); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); // 'id' is an undocumented parameter in Twitter's API. Several // clients make use of it, so we support it too. // show.json?id=12345 takes precedence over /show/12345.json $this->notice_id = (int) $this->trimmed('id'); if (empty($notice_id)) { $this->notice_id = (int) $this->arg('id'); } $this->notice = Notice::staticGet((int) $this->notice_id); return true; }
function delete() { $profile = Profile::staticGet('id', $this->user_id); $notice = Notice::staticGet('id', $this->notice_id); $result = null; if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) { $result = parent::delete(); if ($result) { Event::handle('EndDisfavorNotice', array($profile, $notice)); } } return $result; }
function prepare($args) { parent::prepare($args); $this->user = common_current_user(); $notice_id = $this->trimmed('notice'); $this->notice = Notice::staticGet($notice_id); if (!$this->notice) { common_user_error(_('No such notice.')); exit; } $this->profile = $this->notice->getProfile(); $this->user_profile = $this->user->getProfile(); return true; }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { // TRANS: Error message displayed when trying to perform an action that requires a logged in user. $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error displayed when the session token does not match or is not given. $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } if ($user->hasFave($notice)) { // TRANS: Client error displayed when trying to mark a notice as favorite that already is a favorite. $this->clientError(_('This notice is already a favorite!')); return; } $fave = Fave::addNew($user->getProfile(), $notice); if (!$fave) { // TRANS: Server error displayed when trying to mark a notice as favorite fails in the database. $this->serverError(_('Could not create favorite.')); return; } $this->notify($notice, $user); $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Page title for page on which favorite notices can be unfavourited. $this->element('title', null, _('Disfavor favorite.')); $this->elementEnd('head'); $this->elementStart('body'); $disfavor = new DisFavorForm($this, $notice); $disfavor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)), 303); } }
function handle($args) { parent::handle($args); $notice = new Notice(); $notice->source = 'activity'; $notice->find(); while ($notice->fetch()) { $data = Notice::staticGet('id', $notice->id); $orign = clone $data; $data->content_type = NOTICE::CONTENT_TYPE_ACTIVITY; if (!$data->update($orign)) { echo 'profile update error' . $data->id; echo '<br>'; } } }
function getNotice() { $this->id = $this->trimmed('id'); $this->bookmark = Bookmark::staticGet('id', $this->id); if (empty($this->bookmark)) { // TRANS: Client exception thrown when referring to a non-existing bookmark. throw new ClientException(_m('No such bookmark.'), 404); } $notice = Notice::staticGet('uri', $this->bookmark->uri); if (empty($notice)) { // Did we used to have it, and it got deleted? // TRANS: Client exception thrown when referring to a non-existing bookmark. throw new ClientException(_m('No such bookmark.'), 404); } return $notice; }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); if (!common_logged_in()) { $this->clientError(_('Not logged in.')); return; } $user = common_current_user(); if ($_SERVER['REQUEST_METHOD'] != 'POST') { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { $this->clientError(_("There was a problem with your session token. Try again, please.")); return; } $fave = new Fave(); $fave->user_id = $this->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { $this->clientError(_('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); $this->serverError(_('Could not delete favorite.')); return; } $user->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new FavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); } }
/** * Class handler. * * @param array $args query arguments * * @return void */ function handle($args) { parent::handle($args); $profile = AnonymousFavePlugin::getAnonProfile(); if (empty($profile) || $_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError(_m('Could not disfavor notice! Please make sure your browser has cookies enabled.')); return; } $id = $this->trimmed('notice'); $notice = Notice::staticGet($id); $token = $this->trimmed('token-' . $notice->id); if (!$token || $token != common_session_token()) { // TRANS: Client error. $this->clientError(_m('There was a problem with your session token. Try again, please.')); return; } $fave = new Fave(); $fave->user_id = $profile->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { // TRANS: Client error. $this->clientError(_m('This notice is not a favorite!')); return; } $result = $fave->delete(); if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); // TRANS: Server error. $this->serverError(_m('Could not delete favorite.')); return; } $profile->blowFavesCache(); if ($this->boolean('ajax')) { $this->startHTML('text/xml;charset=utf-8'); $this->elementStart('head'); // TRANS: Title. $this->element('title', null, _m('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); $favor = new AnonFavorForm($this, $notice); $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { $this->returnToPrevious(); } }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $id = $this->trimmed('id'); $this->original = Notice::staticGet('id', $id); if (empty($this->original)) { $this->clientError(_('No such notice.'), 400, $this->format); return false; } $cnt = $this->trimmed('count'); if (empty($cnt) || !is_integer($cnt)) { $cnt = 100; } else { $this->cnt = min((int) $cnt, self::MAXCOUNT); } return true; }
/** * constructor * * Also initializes the profile attribute. * * @param Notice $notice The notice we'll display */ function __construct($notice, $out = null) { parent::__construct($out); if (!empty($notice->repeat_of)) { $original = Notice::staticGet('id', $notice->repeat_of); if (empty($original)) { // could have been deleted $this->notice = $notice; } else { $this->notice = $original; $this->repeat = $notice; } } else { $this->notice = $notice; } $this->profile = $this->notice->getProfile(); }
/** * Load attributes based on database arguments * * Loads all the DB stuff * * @param array $args $_REQUEST array * * @return success flag */ function prepare($args) { parent::prepare($args); $id = $this->arg('notice'); $this->notice = Notice::staticGet($id); if (!$this->notice) { $this->clientError(_('No such notice.'), 404); return false; } $this->profile = $this->notice->getProfile(); if (!$this->profile) { $this->serverError(_('Notice has no profile'), 500); return false; } $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; }
function save_notice(&$req, &$consumer, &$token) { $version = $req->get_parameter('omb_version'); if ($version != OMB_VERSION_01) { $this->clientError(_('Unsupported OMB version'), 400); return false; } # First, check to see $listenee = $req->get_parameter('omb_listenee'); $remote_profile = Remote_profile::staticGet('uri', $listenee); if (!$remote_profile) { $this->clientError(_('Profile unknown'), 403); return false; } $sub = Subscription::staticGet('token', $token->key); if (!$sub) { $this->clientError(_('No such subscription'), 403); return false; } $content = $req->get_parameter('omb_notice_content'); $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { $this->clientError(_('Invalid notice content'), 400); return false; } $notice_uri = $req->get_parameter('omb_notice'); if (!Validate::uri($notice_uri) && !common_valid_tag($notice_uri)) { $this->clientError(_('Invalid notice uri'), 400); return false; } $notice_url = $req->get_parameter('omb_notice_url'); if ($notice_url && !common_valid_http_url($notice_url)) { $this->clientError(_('Invalid notice url'), 400); return false; } $notice = Notice::staticGet('uri', $notice_uri); if (!$notice) { $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, null, $notice_uri); if (is_string($notice)) { common_server_serror($notice, 500); return false; } common_broadcast_notice($notice, true); } return true; }
function handle($notice) { assert($notice instanceof Notice); $this->notice = $notice; $this->user = User::staticGet('id', $notice->profile_id); try { $profile = $this->notice->getProfile(); } catch (Exception $e) { common_log(LOG_ERR, "Can't get profile for notice; skipping: " . $e->getMessage()); return true; } $this->pushUser(); foreach ($notice->getGroups() as $group) { $oprofile = Ostatus_profile::staticGet('group_id', $group->id); if ($oprofile) { $this->pingReply($oprofile); } else { $this->pushGroup($group->id); } } foreach ($notice->getReplies() as $profile_id) { $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id); if ($oprofile) { $this->pingReply($oprofile); } } if (!empty($this->notice->reply_to)) { $replyTo = Notice::staticGet('id', $this->notice->reply_to); if (!empty($replyTo)) { foreach ($replyTo->getReplies() as $profile_id) { $oprofile = Ostatus_profile::staticGet('profile_id', $profile_id); if ($oprofile) { $this->pingReply($oprofile); } } } } foreach ($notice->getProfileTags() as $ptag) { $oprofile = Ostatus_profile::staticGet('peopletag_id', $ptag->id); if (!$oprofile) { $this->pushPeopletag($ptag); } } return true; }
function run() { if (!$this->start()) { return false; } $this->log(LOG_INFO, 'checking for queued notices'); $transport = $this->transport(); do { $qi = Queue_item::top($transport); if ($qi) { $this->log(LOG_INFO, 'Got item enqueued ' . common_exact_date($qi->created)); $notice = Notice::staticGet($qi->notice_id); if ($notice) { $this->log(LOG_INFO, 'broadcasting notice ID = ' . $notice->id); # XXX: what to do if broadcast fails? $result = $this->handle_notice($notice); if (!$result) { $this->log(LOG_WARNING, 'Failed broadcast for notice ID = ' . $notice->id); $orig = $qi; $qi->claimed = null; $qi->update($orig); $this->log(LOG_WARNING, 'Abandoned claim for notice ID = ' . $notice->id); continue; } $this->log(LOG_INFO, 'finished broadcasting notice ID = ' . $notice->id); $notice->free(); unset($notice); $notice = null; } else { $this->log(LOG_WARNING, 'queue item for notice that does not exist'); } $qi->delete(); $qi->free(); unset($qi); $this->idle(0); } else { $this->clear_old_claims(); $this->idle(5); } } while (true); if (!$this->finish()) { return false; } return true; }
/** * show the list of notices * * "Uses up" the stream by looping through it. So, probably can't * be called twice on the same list. * * @return int count of notices listed. */ function show() { $this->out->elementStart('div', array('id' => 'notices_primary')); // TRANS: Header for Notices section. $this->out->element('h2', null, _m('HEADER', 'Notices')); $this->out->elementStart('ol', array('class' => 'notices threaded-notices xoxo')); $cnt = 0; $conversations = array(); while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { $cnt++; if ($cnt > NOTICES_PER_PAGE) { break; } // Collapse repeats into their originals... $notice = $this->notice; if ($notice->repeat_of) { $orig = Notice::staticGet('id', $notice->repeat_of); if ($orig) { $notice = $orig; } } $convo = $notice->conversation; if (!empty($conversations[$convo])) { // Seen this convo already -- skip! continue; } $conversations[$convo] = true; // Get the convo's root notice $root = $notice->conversationRoot($this->userProfile); if ($root) { $notice = $root; } try { $item = $this->newListItem($notice); $item->show(); } catch (Exception $e) { // we log exceptions and continue common_log(LOG_ERR, $e->getMessage()); continue; } } $this->out->elementEnd('ol'); $this->out->elementEnd('div'); return $cnt; }