/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); // TRANS: Server error displayed calling unimplemented API method for 'retweeted by me'. $this->serverError(_('Unimplemented.'), 503); return false; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->user = $this->auth_user; if (empty($this->user)) { // TRANS: Client error given when a user was not found (404). $this->clientError(_('No such user.'), 404, $this->format); return; } $server = common_root_url(); $taguribase = TagURI::base(); if ($this->arg('sent')) { // Action was called by /api/direct_messages/sent.format $this->title = sprintf(_("Direct messages from %s"), $this->user->nickname); $this->subtitle = sprintf(_("All the direct messages sent from %s"), $this->user->nickname); $this->link = $server . $this->user->nickname . '/outbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages/sent'; $this->id = "tag:{$taguribase}:SentDirectMessages:" . $this->user->id; } else { $this->title = sprintf(_("Direct messages to %s"), $this->user->nickname); $this->subtitle = sprintf(_("All the direct messages sent to %s"), $this->user->nickname); $this->link = $server . $this->user->nickname . '/inbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages'; $this->id = "tag:{$taguribase}:DirectMessages:" . $this->user->id; } $this->messages = $this->getMessages(); 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->device = $this->trimmed('device'); 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->tile = $this->arg('tile'); return true; }
/** * 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->other = $this->getTargetProfile($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); $subscriberId = $this->trimmed('subscriber'); $this->_subscriber = Profile::staticGet('id', $subscriberId); if (empty($this->_subscriber)) { // TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID. // TRANS: %d is the non-existing profile ID number. throw new ClientException(sprintf(_('No such profile id: %d.'), $subscriberId), 404); } $subscribedId = $this->trimmed('subscribed'); $this->_subscribed = Profile::staticGet('id', $subscribedId); if (empty($this->_subscribed)) { // TRANS: Client exception thrown when trying to display a subscription for a non-existing profile ID. // TRANS: %d is the non-existing profile ID number. throw new ClientException(sprintf(_('No such profile id: %d.'), $subscribedId), 404); } $this->_subscription = Subscription::pkeyGet(array('subscriber' => $subscriberId, 'subscribed' => $subscribedId)); if (empty($this->_subscription)) { // TRANS: Client exception thrown when trying to display a subscription for a non-subscribed profile ID. // TRANS: %1$d is the non-existing subscriber ID number, $2$d is the ID of the profile that was not subscribed to. $msg = sprintf(_('Profile %1$d not subscribed to profile %2$d.'), $subscriberId, $subscribedId); throw new ClientException($msg, 404); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); if (!$this->scoped instanceof Profile) { // TRANS: Client error given when a user was not found (404). $this->clientError(_('No such user.'), 404); } $server = common_root_url(); $taguribase = TagURI::base(); if ($this->arg('sent')) { // Action was called by /api/direct_messages/sent.format $this->title = sprintf(_("Direct messages from %s"), $this->scoped->getNickname()); $this->subtitle = sprintf(_("All the direct messages sent from %s"), $this->scoped->getNickname()); $this->link = $server . $this->scoped->getNickname() . '/outbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages/sent'; $this->id = "tag:{$taguribase}:SentDirectMessages:" . $this->scoped->getID(); } else { $this->title = sprintf(_("Direct messages to %s"), $this->scoped->getNickname()); $this->subtitle = sprintf(_("All the direct messages sent to %s"), $this->scoped->getNickname()); $this->link = $server . $this->scoped->getNickname() . '/inbox'; $this->selfuri_base = common_root_url() . 'api/direct_messages'; $this->id = "tag:{$taguribase}:DirectMessages:" . $this->scoped->getID(); } $this->messages = $this->getMessages(); 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->group = $this->getTargetGroup($this->arg('id')); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->format = 'json'; $this->backgroundcolor = $this->trimmed('backgroundcolor'); 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); $convId = $this->trimmed('id'); if (empty($convId)) { // TRANS: Client exception thrown when no conversation ID is given. throw new ClientException(_('No conversation ID.')); } $this->conversation = Conversation::staticGet('id', $convId); if (empty($this->conversation)) { // TRANS: Client exception thrown when referring to a non-existing conversation ID (%d). $this->clientError(_('No conversation ID found'), 404); return false; } $profile = Profile::current(); $stream = new ConversationNoticeStream($convId, $profile); $notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id); $this->notices = $notice->fetchAll(); $originalConversation = new Notice(); $originalConversation->whereAdd('conversation=' . $convId); $originalConversation->limit(1); $originalConversation->orderBy('created'); $originalConversation->find(); if ($originalConversation->fetch()) { $this->originalNotice = $originalConversation; } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->format = 'json'; $this->bookmarks = $this->trimmed('bookmarks'); return true; }
function prepare($args) { parent::prepare($args); $this->userId = $this->auth_user->id; $this->getNotices(); 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->other = $this->getTargetUser($id); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->prefNamespace = $this->trimmed('namespace'); $this->prefTopic = $this->trimmed('topic'); $this->prefData = $this->trimmed('data'); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); if ($this->format !== 'json') { $this->clientError('This method currently only serves JSON.', 415); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1); $page = $this->int('page', 1, self::MAXNOTICES / $this->cnt); $since_id = $this->int('since_id'); $max_id = $this->int('max_id'); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); if ($this->format !== 'json') { $this->clientError('This method currently only serves JSON.', 415); } $this->backgroundcolor = $this->trimmed('backgroundcolor'); 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->name = $this->trimmed('name'); $this->url = $this->trimmed('url'); $this->location = $this->trimmed('location'); $this->description = $this->trimmed('description'); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->nickname = Nickname::normalize($this->arg('nickname'), true); $this->fullname = $this->arg('full_name'); $this->homepage = $this->arg('homepage'); $this->description = $this->arg('description'); $this->location = $this->arg('location'); $this->aliasstring = $this->arg('aliases'); 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; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $id = $this->trimmed('id'); $this->original = Notice::getKV('id', $id); if (!$this->original instanceof Notice) { // TRANS: Client error displayed trying to repeat a non-existing notice through the API. $this->clientError(_('No such notice.'), 400, $this->format); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->user = $this->auth_user; $this->cropW = $this->trimmed('cropW'); $this->cropH = $this->trimmed('cropH'); $this->cropX = $this->trimmed('cropX'); $this->cropY = $this->trimmed('cropY'); $this->img = $this->trimmed('img'); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ protected function prepare(array $args = array()) { parent::prepare($args); $this->format = 'json'; $this->user = $this->auth_user; $this->cropW = $this->trimmed('width'); $this->cropH = $this->trimmed('height'); $this->cropX = $this->trimmed('offset_left'); $this->cropY = $this->trimmed('offset_top'); $this->img = $this->trimmed('banner'); return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $this->notice = Notice::getKV($this->arg('id')); if (!empty($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::getKV($real_notice_id); } 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->nickname = $this->arg('nickname'); $this->fullname = $this->arg('full_name'); $this->homepage = $this->arg('homepage'); $this->description = $this->arg('description'); $this->location = $this->arg('location'); $this->aliasstring = $this->arg('aliases'); return true; }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($argarray) { parent::prepare($argarray); $this->_profile = Profile::staticGet('id', $this->trimmed('profile')); if (empty($this->_profile)) { // TRANS: Client exception thrown when requesting a favorite feed for a non-existing profile. throw new ClientException(_('No such profile.'), 404); } $offset = ($this->page - 1) * $this->count; $limit = $this->count + 1; $this->_faves = Fave::byProfile($this->_profile->id, $offset, $limit); 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')); 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 * */ protected function prepare(array $args = array()) { parent::prepare($args); $this->nickname = Nickname::normalize($this->trimmed('nickname')); $this->fullname = $this->trimmed('fullname'); $this->homepage = $this->trimmed('homepage'); $this->description = $this->trimmed('description'); $this->location = $this->trimmed('location'); $this->aliasstring = $this->trimmed('aliases'); $this->user = $this->auth_user; $this->group = $this->getTargetGroup($this->arg('id')); return true; }