/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->profile_a = $this->getTargetProfile($this->trimmed('user_a')); $this->profile_b = $this->getTargetProfile($this->trimmed('user_b')); 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->cursor = (int) $this->arg('cursor', -1); $this->list = $this->getTargetList($this->arg('user'), $this->arg('id')); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->group = $this->getTargetGroup($this->arg('id')); $this->profiles = $this->getProfiles(); return true; }
protected function prepare(array $args = array()) { parent::prepare($args); $this->tag = $this->arg('tag'); $this->notices = $this->getNotices(); 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->notifications = $this->getNotifications(); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->user = $this->getTargetUser(null); $this->groups = $this->getGroups(); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->user = User::staticGet('nickname', $this->arg('screen_name')); $this->size = $this->arg('size'); 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'; $profileurl = urldecode($this->arg('profileurl')); $nickname = urldecode($this->arg('nickname')); $this->profile = new stdClass(); $this->profile->external = null; $this->profile->local = null; // we can get urls of two types of urls (1) ://instance/nickname // (2) ://instance/user/1234 // // in case (1) we have the problem that the html can be outdated, // i.e. the user can have changed her nickname. we also have no idea // if it is a multi or single user instance, which forces us to // guess the api root url. // // in case (2) we have another problem: we can't use that url to find // the local profile for the external user, we need url:s of type (2) // for that. so we have to try getting the nickname from the external // instance first // case (2) if (strstr($profileurl, '/user/')) { $external_user_id = substr($profileurl, strpos($profileurl, '/user/') + 6); $external_instance_url = substr($profileurl, 0, strpos($profileurl, '/user/') + 1); if (!is_numeric($external_user_id)) { return true; } $external_profile = $this->getProfileFromExternalInstance($external_instance_url, $external_user_id); if (!isset($external_profile->statusnet_profile_url)) { return true; } $this->profile->external = $external_profile; $local_profile = Profile::getKV('profileurl', $external_profile->statusnet_profile_url); if (!$local_profile instanceof Profile) { return true; } $this->profile->local = $this->twitterUserArray($local_profile); return true; } // case (1) $local_profile = Profile::getKV('profileurl', $profileurl); if ($local_profile instanceof Profile) { // if profile url is not ending with nickname, this is probably a single user instance if (!substr($local_profile->profileurl, -strlen($local_profile->nickname)) === $local_profile->nickname) { $external_instance_url = $local_profile->profileurl; } else { $external_instance_url = substr($local_profile->profileurl, 0, strrpos($local_profile->profileurl, '/')); } $external_profile = $this->getProfileFromExternalInstance($external_instance_url, $local_profile->nickname); if (!isset($external_profile->statusnet_profile_url)) { return true; } $this->profile->external = $external_profile; $this->profile->local = $this->twitterUserArray($local_profile); return true; } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); common_debug("apitimelinetag prepare()"); $this->tag = $this->arg('tag'); $this->notices = $this->getNotices(); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $taginput = $this->trimmed('tag'); $this->tag = common_canonical_tag($taginput); $this->notices = $this->getNotices(); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $user_a_id = $this->trimmed('user_a'); $user_b_id = $this->trimmed('user_b'); $this->user_a = $this->getTargetUser($user_a_id); $this->user_b = $this->getTargetUser($user_b_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->group = $this->getTargetGroup($this->arg('id')); if (empty($this->group)) { // TRANS: Client error displayed trying to show group membership on a non-existing group. $this->clientError(_('Group not found.'), 404); } $this->profiles = $this->getProfiles(); 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->list = $this->getTargetList($this->arg('nickname'), $this->arg('id')); if (!$this->list instanceof Profile_list) { // TRANS: Client error displayed trying to show list membership on a non-existing list. $this->clientError(_('List not found.'), 404); } $this->profiles = $this->getProfiles(); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ protected function prepare(array $args = array()) { parent::prepare($args); $user = User::getKV('nickname', $this->arg('screen_name')); if (!$user instanceof User) { // TRANS: Client error displayed when requesting user information for a non-existing user. $this->clientError(_('User not found.'), 404); } $this->target = $user->getProfile(); $this->size = $this->arg('size'); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $email = $this->arg('email'); // XXX: email field deprecated in Twitter's API if (!empty($email)) { $this->user = User::staticGet('email', $email); } else { $this->user = $this->getTargetUser($this->arg('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; }
/** * 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); } $profileurl = urldecode($this->arg('profileurl')); // TODO: Make this more ... unique! $this->profile = Profile::getKV('profileurl', $profileurl); if (!$this->profile instanceof Profile) { // TRANS: Client error displayed when requesting profile information for a non-existing profile. $this->clientError(_('Profile not found.'), 404); } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag */ function prepare($args) { parent::prepare($args); $this->group = $this->getTargetGroup($this->arg('id')); if (empty($this->group)) { $alias = Group_alias::staticGet('alias', common_canonical_nickname($this->arg('id'))); if (!empty($alias)) { $args = array('id' => $alias->group_id, 'format' => $this->format); common_redirect(common_local_url('ApiGroupShow', $args), 301); } else { $this->clientError(_('Group not found.'), 404, $this->format); } return; } 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->group = $this->getTargetGroup($this->arg('id')); if (empty($this->group)) { $alias = Group_alias::getKV('alias', common_canonical_nickname($this->arg('id'))); if (!empty($alias)) { $args = array('id' => $alias->group_id, 'format' => $this->format); common_redirect(common_local_url('ApiGroupShow', $args), 301); } else { // TRANS: Client error displayed when trying to show a group that could not be found. $this->clientError(_('Group not found.'), 404); } return; } return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ protected function prepare(array $args = array()) { parent::prepare($args); $email = $this->arg('email'); // XXX: email field deprecated in Twitter's API if (!empty($email)) { $user = User::getKV('email', $email); } else { $user = $this->getTargetUser($this->arg('id')); } if (!$user instanceof User) { // TRANS: Client error displayed when requesting user information for a non-existing user. $this->clientError(_('User not found.'), 404); } $this->target = $user->getProfile(); 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->notice_id = $this->trimmed('notice_id'); $this->original = Notice::getKV('id', $this->notice_id); if (empty($this->original)) { // TRANS: Client error displayed trying to display redents of a non-exiting notice. $this->clientError(_('No such notice.'), 400, $this->format); return false; } $cnt = $this->trimmed('count'); if (empty($cnt) || !is_integer($cnt)) { $this->cnt = 100; } else { $this->cnt = min((int) $cnt, self::MAXCOUNT); } 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->count = (int) $this->arg('count', 100); $arg_user = $this->getTargetUser($this->arg('id')); $this->target = $this->auth_user ? $this->auth_user->getProfile() : null; if (!$this->target instanceof Profile) { // TRANS: Client error displayed when requesting a list of followers for a non-existing user. $this->clientError(_('No such user.'), 404); } else { if ($this->auth_user->id != $arg_user->id) { $this->clientError(_('You are only allowed to view your own blocks.'), 403); } } $this->profiles = $this->getProfiles(); return true; }
/** * Initialization. * * @param array $args Web and URL arguments * * @return boolean true if nothing goes wrong */ function prepare($args) { common_debug("apisearchjson prepare()"); parent::prepare($args); $this->query = $this->trimmed('q'); $this->lang = $this->trimmed('lang'); $this->rpp = $this->trimmed('rpp'); if (!$this->rpp) { $this->rpp = 15; } if ($this->rpp > 100) { $this->rpp = 100; } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } $this->since_id = $this->trimmed('since_id'); $this->geocode = $this->trimmed('geocode'); return true; }
/** * Initialization. * * @param array $args Web and URL arguments * * @return boolean true if nothing goes wrong */ function prepare($args) { parent::prepare($args); $this->query = $this->trimmed('q'); $this->lang = $this->trimmed('lang'); $this->rpp = $this->trimmed('rpp'); if (!$this->rpp) { $this->rpp = 15; } if ($this->rpp > 100) { $this->rpp = 100; } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } // TODO: Suppport max_id -- we need to tweak the backend // Search classes to support it. $this->since_id = $this->trimmed('since_id'); $this->geocode = $this->trimmed('geocode'); 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' 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'); $this->notice = Notice::getKV('id', $this->notice_id); if (!$this->notice instanceof Notice) { $deleted = Deleted_notice::getKV('id', $this->notice_id); if ($deleted instanceof Deleted_notice) { // TRANS: Client error displayed trying to show a deleted notice. $this->clientError(_('Notice deleted.'), 410); } // TRANS: Client error displayed trying to show a non-existing notice. $this->clientError(_('No such notice.'), 404); } if (!$this->notice->inScope($this->scoped)) { // TRANS: Client exception thrown when trying a view a notice the user has no access to. throw new ClientException(_('Access restricted.'), 403); } return true; }
/** * Initialization. * * @param array $args Web and URL arguments * * @return boolean false if user doesn't exist */ function prepare($args) { parent::prepare($args); return true; }
/** * Take arguments for running * * @param array $args $_REQUEST args * * @return boolean success flag * */ function prepare($args) { parent::prepare($args); $this->notices = $this->getNotices(); return true; }
/** * Read arguments and initialize members * * @param array $args Arguments from $_REQUEST * * @return boolean success */ function prepare($args) { common_debug("in apisearchatom prepare()"); parent::prepare($args); $this->query = $this->trimmed('q'); $this->lang = $this->trimmed('lang'); $this->rpp = $this->trimmed('rpp'); if (!$this->rpp) { $this->rpp = 15; } if ($this->rpp > 100) { $this->rpp = 100; } $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } // TODO: Suppport since_id -- we need to tweak the backend // Search classes to support it. $this->since_id = $this->trimmed('since_id'); $this->geocode = $this->trimmed('geocode'); // TODO: Also, language and geocode 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->group = $this->getTargetGroup($this->arg('id')); return true; }