common_debug('printing the access token', __FILE__);
print $token;
} catch (OAuthException $e) {
- common_server_error($e->getMessage());
+ $this->serverError($e->getMessage());
}
}
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- $this->client_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return false;
} else {
return true;
call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
} else {
- common_user_error("API method not found!", $code=404);
+ $this->clientError("API method not found!", $code=404);
}
} else {
- common_user_error("API method not found!", $code=404);
+ $this->clientError("API method not found!", $code=404);
}
}
parent::handle($args);
$nickname = $this->trimmed('nickname');
if (!$nickname) {
- $this->client_error(_('No nickname.'));
+ $this->clientError(_('No nickname.'));
return;
}
$size = $this->trimmed('size');
if (!$size) {
- $this->client_error(_('No size.'));
+ $this->clientError(_('No size.'));
return;
}
$size = strtolower($size);
if (!in_array($size, array('original', '96', '48', '24'))) {
- $this->client_error(_('Invalid size.'));
+ $this->clientError(_('Invalid size.'));
return;
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- $this->client_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
- $this->client_error(_('User has no profile.'));
+ $this->clientError(_('User has no profile.'));
return;
}
if ($size == 'original') {
parent::prepare($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$id = $this->trimmed('blockto');
if (!$id) {
- $this->client_error(_('No profile specified.'));
+ $this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
- $this->client_error(_('No profile with that ID.'));
+ $this->clientError(_('No profile with that ID.'));
return false;
}
$cur = common_current_user();
if ($cur->hasBlocked($this->profile)) {
- $this->client_error(_('You have already blocked this user.'));
+ $this->clientError(_('You have already blocked this user.'));
return;
}
$result = $cur->block($this->profile);
if (!$result) {
- $this->server_error(_('Failed to save block information.'));
+ $this->serverError(_('Failed to save block information.'));
return;
}
}
$code = $this->trimmed('code');
if (!$code) {
- $this->client_error(_('No confirmation code.'));
+ $this->clientError(_('No confirmation code.'));
return;
}
$confirm = Confirm_address::staticGet('code', $code);
if (!$confirm) {
- $this->client_error(_('Confirmation code not found.'));
+ $this->clientError(_('Confirmation code not found.'));
return;
}
$cur = common_current_user();
if ($cur->id != $confirm->user_id) {
- $this->client_error(_('That confirmation code is not for you!'));
+ $this->clientError(_('That confirmation code is not for you!'));
return;
}
$type = $confirm->address_type;
if (!in_array($type, array('email', 'jabber', 'sms'))) {
- $this->server_error(sprintf(_('Unrecognized address type %s'), $type));
+ $this->serverError(sprintf(_('Unrecognized address type %s'), $type));
return;
}
if ($cur->$type == $confirm->address) {
- $this->client_error(_('That address has already been confirmed.'));
+ $this->clientError(_('That address has already been confirmed.'));
return;
}
if (!$result) {
common_log_db_error($cur, 'UPDATE', __FILE__);
- $this->server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
- $this->server_error(_('Couldn\'t delete email confirmation.'));
+ $this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
function handle($args)
{
parent::handle($args);
- $this->server_error(_('Code not yet ready.'));
+ $this->serverError(_('Code not yet ready.'));
return;
if ('POST' === $_SERVER['REQUEST_METHOD']) {
$this->handle_post();
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return;
}
$token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_token()) {
- $this->client_error(_("There was a problem with your session token. Try again, please."));
+ $this->clientError(_("There was a problem with your session token. Try again, please."));
return;
}
$fave->user_id = $this->id;
$fave->notice_id = $notice->id;
if (!$fave->find(true)) {
- $this->client_error(_('This notice is not a favorite!'));
+ $this->clientError(_('This notice is not a favorite!'));
return;
}
if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__);
- $this->server_error(_('Could not delete favorite.'));
+ $this->serverError(_('Could not delete favorite.'));
return;
}
$title = $this->trimmed('title');
$filename = INSTALLDIR.'/doc/'.$title;
if (!file_exists($filename)) {
- common_user_error(_('No such document.'));
+ $this->clientError(_('No such document.'));
return;
}
$c = file_get_contents($filename);
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
- common_server_error(_('Couldn\'t insert confirmation code.'));
+ $this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
- $this->server_error(_('Couldn\'t delete email confirmation.'));
+ $this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
$result = $user->updateKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
- $this->server_error(_("Couldn't update user record."));
+ $this->serverError(_("Couldn't update user record."));
}
$this->show_form(_('Incoming email address removed.'), true);
if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__);
- $this->server_error(_("Couldn't update user record."));
+ $this->serverError(_("Couldn't update user record."));
}
$this->show_form(_('New incoming email address added.'), true);
if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__);
- common_server_error(_('Couldn\'t remove Facebook user.'));
+ $this->serverError(_('Couldn\'t remove Facebook user.'));
return;
}
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return;
}
$token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_token()) {
- $this->client_error(_("There was a problem with your session token. Try again, please."));
+ $this->clientError(_("There was a problem with your session token. Try again, please."));
return;
}
if ($user->hasFave($notice)) {
- $this->client_error(_('This notice is already a favorite!'));
+ $this->clientError(_('This notice is already a favorite!'));
return;
}
$fave = Fave::addNew($user, $notice);
if (!$fave) {
- $this->server_error(_('Could not create favorite.'));
+ $this->serverError(_('Could not create favorite.'));
return;
}
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return false;
} else {
return true;
{
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
} else {
$this->try_login();
}
{
parent::handle($args);
if (common_logged_in()) {
- common_user_error(_('Already logged in.'));
+ $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
# FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
- common_user_error(_('Registration not allowed.'));
+ $this->clientError(_('Registration not allowed.'));
return;
}
list($display, $canonical, $sreg) = $this->get_saved_values();
if (!$display || !$canonical) {
- common_server_error(_('Stored OpenID not found.'));
+ $this->serverError(_('Stored OpenID not found.'));
return;
}
$other = oid_get_user($canonical);
if ($other) {
- common_server_error(_('Creating new account for OpenID that already has a user.'));
+ $this->serverError(_('Creating new account for OpenID that already has a user.'));
return;
}
list($display, $canonical, $sreg) = $this->get_saved_values();
if (!$display || !$canonical) {
- common_server_error(_('Stored OpenID not found.'));
+ $this->serverError(_('Stored OpenID not found.'));
return;
}
$result = oid_link_user($user->id, $canonical, $display);
if (!$result) {
- common_server_error(_('Error connecting user to OpenID.'));
+ $this->serverError(_('Error connecting user to OpenID.'));
return;
}
parent::handle($args);
if (common_logged_in()) {
- common_user_error(_('You can use the local subscription!'));
+ $this->clientError(_('You can use the local subscription!'));
return;
}
$omb = $_SESSION['oauth_authorization_request'];
if (!$omb) {
- common_user_error(_('Not expecting this response!'));
+ $this->clientError(_('Not expecting this response!'));
return;
}
# I think this is the success metric
if ($token != $omb['token']) {
- common_user_error(_('Not authorized.'));
+ $this->clientError(_('Not authorized.'));
return;
}
$version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) {
- common_user_error(_('Unknown version of OMB protocol.'));
+ $this->clientError(_('Unknown version of OMB protocol.'));
return;
}
$nickname = $req->get_parameter('omb_listener_nickname');
if (!$nickname) {
- common_user_error(_('No nickname provided by remote server.'));
+ $this->clientError(_('No nickname provided by remote server.'));
return;
}
$profile_url = $req->get_parameter('omb_listener_profile');
if (!$profile_url) {
- common_user_error(_('No profile URL returned by server.'));
+ $this->clientError(_('No profile URL returned by server.'));
return;
}
if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
- common_user_error(_('Invalid profile URL returned by server.'));
+ $this->clientError(_('Invalid profile URL returned by server.'));
return;
}
if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
- common_user_error(_('You can use the local subscription!'));
+ $this->clientError(_('You can use the local subscription!'));
return;
}
$user = User::staticGet('nickname', $omb['listenee']);
if (!$user) {
- common_user_error(_('User being listened to doesn\'t exist.'));
+ $this->clientError(_('User being listened to doesn\'t exist.'));
return;
}
$other = User::staticGet('uri', $omb['listener']);
if ($other) {
- common_user_error(_('You can use the local subscription!'));
+ $this->clientError(_('You can use the local subscription!'));
return;
}
list($newtok, $newsecret) = $this->access_token($omb);
if (!$newtok || !$newsecret) {
- common_user_error(_('Couldn\'t convert request tokens to access tokens.'));
+ $this->clientError(_('Couldn\'t convert request tokens to access tokens.'));
return;
}
$profile->created = DB_DataObject_Cast::dateTime(); # current time
$id = $profile->insert();
if (!$id) {
- common_server_error(_('Error inserting new profile'));
+ $this->serverError(_('Error inserting new profile'));
return;
}
$remote->id = $id;
if ($avatar_url) {
if (!$this->add_avatar($profile, $avatar_url)) {
- common_server_error(_('Error inserting avatar'));
+ $this->serverError(_('Error inserting avatar'));
return;
}
}
if ($exists) {
if (!$remote->update($orig_remote)) {
- common_server_error(_('Error updating remote profile'));
+ $this->serverError(_('Error updating remote profile'));
return;
}
} else {
$remote->created = DB_DataObject_Cast::dateTime(); # current time
if (!$remote->insert()) {
- common_server_error(_('Error inserting remote profile'));
+ $this->serverError(_('Error inserting remote profile'));
return;
}
}
if ($user->hasBlocked($profile)) {
- $this->client_error(_('That user has blocked you from subscribing.'));
+ $this->clientError(_('That user has blocked you from subscribing.'));
return;
}
if (!$result) {
common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__);
- common_user_error(_('Couldn\'t insert new subscription.'));
+ $this->clientError(_('Couldn\'t insert new subscription.'));
return;
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- common_user_error(_('No such user.'), 404);
+ $this->clientError(_('No such user.'), 404);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'), 500);
+ $this->serverError(_('User has no profile.'), 500);
return;
}
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
- common_server_error(_('Couldn\'t insert confirmation code.'));
+ $this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
- $this->server_error(_('Couldn\'t delete email confirmation.'));
+ $this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
$result = $user->updateKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
{
parent::handle($args);
if (!common_logged_in()) {
- $this->client_error(sprintf(_('You must be logged in to invite other users to use %s'),
+ $this->clientError(sprintf(_('You must be logged in to invite other users to use %s'),
common_config('site', 'name')));
return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
{
parent::handle($args);
if (common_is_real_login()) {
- common_user_error(_('Already logged in.'));
+ $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->check_login();
} else {
# CSRF protection - token set in common_notice_form()
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if (common_check_user($nickname, $password)) {
# success!
if (!common_set_user($nickname)) {
- common_server_error(_('Error setting user.'));
+ $this->serverError(_('Error setting user.'));
return;
}
common_real_login(true);
# success!
if (!common_set_user($user)) {
- common_server_error(_('Error setting user.'));
+ $this->serverError(_('Error setting user.'));
return;
}
{
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
} else {
common_set_user(null);
common_real_login(false); # not logged in
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- $this->client_error(_('No such user'), 404);
+ $this->clientError(_('No such user'), 404);
return;
}
$notice = $user->getCurrentNotice();
if (!$notice) {
- $this->client_error(_('No current status'), 404);
+ $this->clientError(_('No current status'), 404);
}
header('Content-Type: text/plain');
parent::handle($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in.'), 403);
+ $this->clientError(_('Not logged in.'), 403);
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->save_new_message();
} else {
$this->show_form(_('No recipient specified.'));
return;
} else if (!$user->mutuallySubscribed($other)) {
- $this->client_error(_('You can\'t send a message to this user.'), 404);
+ $this->clientError(_('You can\'t send a message to this user.'), 404);
return;
} else if ($user->id == $other->id) {
- $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403);
+ $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403);
return;
}
$other = User::staticGet('id', $to);
if (!$other) {
- $this->client_error(_('No such user'), 404);
+ $this->clientError(_('No such user'), 404);
return;
}
if (!$user->mutuallySubscribed($other)) {
- $this->client_error(_('You can\'t send a message to this user.'), 404);
+ $this->clientError(_('You can\'t send a message to this user.'), 404);
return;
}
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
# CSRF protection - token set in common_notice_form()
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$profile = $notice->getProfile();
if (!$profile) {
common_log_db_error($notice, 'SELECT', __FILE__);
- $this->server_error(_('Notice without matching profile'));
+ $this->serverError(_('Notice without matching profile'));
return;
}
# XXX: RDFa
parent::handle($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
if (!$other->email || !$other->emailnotifynudge) {
- $this->client_error(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.'));
+ $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.'));
return;
}
{
parent::handle($args);
if (common_logged_in()) {
- common_user_error(_('Already logged in.'));
+ $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$openid_url = $this->trimmed('openid_url');
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
$tag = $this->trimmed('tag');
if (!common_valid_profile_tag($tag)) {
- $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
+ $this->clientError(sprintf(_('Not a valid people tag: %s'), $tag));
return;
}
print "omb_version=".OMB_VERSION_01;
}
} catch (OAuthException $e) {
- common_server_error($e->getMessage());
+ $this->serverError($e->getMessage());
return;
}
}
{
$version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) {
- common_user_error(_('Unsupported OMB version'), 400);
+ $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) {
- common_user_error(_('Profile unknown'), 403);
+ $this->clientError(_('Profile unknown'), 403);
return false;
}
$sub = Subscription::staticGet('token', $token->key);
if (!$sub) {
- common_user_error(_('No such subscription'), 403);
+ $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) {
- common_user_error(_('Invalid notice content'), 400);
+ $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)) {
- common_user_error(_('Invalid notice uri'), 400);
+ $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)) {
- common_user_error(_('Invalid notice url'), 400);
+ $this->clientError(_('Invalid notice url'), 400);
return false;
}
$notice = Notice::staticGet('uri', $notice_uri);
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
- $this->server_error(_('User without matching profile'));
+ $this->serverError(_('User without matching profile'));
return;
}
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
} else {
# Re-initialize language environment if it changed
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user for autosubscribe.'));
+ $this->serverError(_('Couldn\'t update user for autosubscribe.'));
return;
}
}
if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t save profile.'));
+ $this->serverError(_('Couldn\'t save profile.'));
return;
}
$result = $user->setSelfTags($tags);
if (!$result) {
- common_server_error(_('Couldn\'t save tags.'));
+ $this->serverError(_('Couldn\'t save tags.'));
return;
}
}
if (!$user->update($original)) {
- common_server_error(_('Can\'t save new password.'));
+ $this->serverError(_('Can\'t save new password.'));
return;
}
NOTICES_PER_PAGE + 1);
if (!$notice) {
- $this->server_error(_('Could not retrieve public stream.'));
+ $this->serverError(_('Could not retrieve public stream.'));
return;
}
{
parent::handle($args);
if (common_logged_in()) {
- $this->client_error(_('You are already logged in!'));
+ $this->clientError(_('You are already logged in!'));
return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('recover')) {
} else if ($this->arg('reset')) {
$this->reset_password();
} else {
- $this->client_error(_('Unexpected form submission.'));
+ $this->clientError(_('Unexpected form submission.'));
}
} else {
if ($this->trimmed('code')) {
$confirm = Confirm_address::staticGet('code', $code);
if (!$confirm) {
- $this->client_error(_('No such recovery code.'));
+ $this->clientError(_('No such recovery code.'));
return;
}
if ($confirm->address_type != 'recover') {
- $this->client_error(_('Not a recovery code.'));
+ $this->clientError(_('Not a recovery code.'));
return;
}
$user = User::staticGet($confirm->user_id);
if (!$user) {
- $this->server_error(_('Recovery code for unknown user.'));
+ $this->serverError(_('Recovery code for unknown user.'));
return;
}
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
- common_server_error(_('Error with confirmation code.'));
+ $this->serverError(_('Error with confirmation code.'));
return;
}
common_log(LOG_WARNING,
'Attempted redemption on recovery code ' .
'that is ' . $touched . ' seconds old. ');
- $this->client_error(_('This confirmation code is too old. ' .
+ $this->clientError(_('This confirmation code is too old. ' .
'Please start again.'));
return;
}
$result = $user->updateKeys($orig);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
- $this->server_error(_('Could not update user with confirmed email address.'));
+ $this->serverError(_('Could not update user with confirmed email address.'));
return;
}
}
}
if (!$user->email && !$confirm_email) {
- $this->client_error(_('No registered email address for that user.'));
+ $this->clientError(_('No registered email address for that user.'));
return;
}
if (!$confirm->insert()) {
common_log_db_error($confirm, 'INSERT', __FILE__);
- $this->server_error(_('Error saving address confirmation.'));
+ $this->serverError(_('Error saving address confirmation.'));
return;
}
$user = $this->get_temp_user();
if (!$user) {
- $this->client_error(_('Unexpected password reset.'));
+ $this->clientError(_('Unexpected password reset.'));
return;
}
if (!$user->update($original)) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Can\'t save new password.'));
+ $this->serverError(_('Can\'t save new password.'));
return;
}
$this->clear_temp_user();
if (!common_set_user($user->nickname)) {
- common_server_error(_('Error setting user.'));
+ $this->serverError(_('Error setting user.'));
return;
}
parent::handle($args);
if (common_config('site', 'closed')) {
- common_user_error(_('Registration not allowed.'));
+ $this->clientError(_('Registration not allowed.'));
} else if (common_logged_in()) {
- common_user_error(_('Already logged in.'));
+ $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->try_register();
} else {
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
- $this->client_error(_('Sorry, only invited people can register.'));
+ $this->clientError(_('Sorry, only invited people can register.'));
return;
}
}
# success!
if (!common_set_user($user)) {
- common_server_error(_('Error setting user.'));
+ $this->serverError(_('Error setting user.'));
return;
}
# this is a real login
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
- $this->client_error(_('Sorry, only invited people can register.'));
+ $this->clientError(_('Sorry, only invited people can register.'));
return;
}
parent::handle($args);
if (common_logged_in()) {
- common_user_error(_('You can use the local subscription!'));
+ $this->clientError(_('You can use the local subscription!'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
- $this->server_error(_('User without matching profile'));
+ $this->serverError(_('User without matching profile'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
function no_such_user()
{
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
}
function show_header($user)
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return false;
} else {
return true;
$token = $server->fetch_request_token($req);
print $token;
} catch (OAuthException $e) {
- common_server_error($e->getMessage());
+ $this->serverError($e->getMessage());
}
}
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- $this->client_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
$notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if (!$notice) {
- $this->server_error(_('Could not retrieve favorite notices.'));
+ $this->serverError(_('Could not retrieve favorite notices.'));
return;
}
$message = $this->get_message();
if (!$message) {
- $this->client_error(_('No such message.'), 404);
+ $this->clientError(_('No such message.'), 404);
return;
}
if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) {
$this->show_page($cur, 1);
} else {
- $this->client_error(_('Only the sender and recipient may read this message.'), 403);
+ $this->clientError(_('Only the sender and recipient may read this message.'), 403);
return;
}
}
$this->notice = Notice::staticGet($id);
if (!$this->notice) {
- $this->client_error(_('No such notice.'), 404);
+ $this->clientError(_('No such notice.'), 404);
return false;
}
$this->profile = $this->notice->getProfile();
if (!$this->profile) {
- $this->server_error(_('Notice has no profile'), 500);
+ $this->serverError(_('Notice has no profile'), 500);
return false;
}
function no_such_notice()
{
- common_user_error(_('No such notice.'));
+ $this->clientError(_('No such notice.'));
}
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
function no_such_user()
{
- $this->client_error(_('No such user.'), 404);
+ $this->clientError(_('No such user.'), 404);
}
function show_profile($profile)
if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__);
- common_server_error(_('Couldn\'t insert confirmation code.'));
+ $this->serverError(_('Couldn\'t insert confirmation code.'));
return;
}
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
- $this->server_error(_('Couldn\'t delete email confirmation.'));
+ $this->serverError(_('Couldn\'t delete email confirmation.'));
return;
}
$result = $user->updateKeys($original);
if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t update user.'));
+ $this->serverError(_('Couldn\'t update user.'));
return;
}
$user->query('COMMIT');
parent::prepare($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$id = $this->trimmed('profile');
if (!$id) {
- $this->client_error(_('No profile specified.'));
+ $this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
- $this->client_error(_('No profile with that ID.'));
+ $this->clientError(_('No profile with that ID.'));
return false;
}
'subscribed' => $this->profile->id));
if (!$sub) {
- $this->client_error(_('You are not subscribed to that profile.'));
+ $this->clientError(_('You are not subscribed to that profile.'));
return false;
}
if (!$result) {
common_log_db_error($sub, 'UPDATE', __FILE__);
- $this->server_error(_('Could not save subscription.'));
+ $this->serverError(_('Could not save subscription.'));
return false;
}
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$other = User::staticGet('id', $other_id);
if (!$other) {
- $this->client_error(_('Not a local user.'));
+ $this->clientError(_('Not a local user.'));
return;
}
$result = subs_subscribe_to($user, $other);
if($result != true) {
- common_user_error($result);
+ $this->clientError($result);
return;
}
parent::handle($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in'), 403);
+ $this->clientError(_('Not logged in'), 403);
return;
}
} else {
$id = $this->trimmed('id');
if (!$id) {
- $this->client_error(_('No id argument.'));
+ $this->clientError(_('No id argument.'));
return;
}
$profile = Profile::staticGet('id', $id);
if (!$profile) {
- $this->client_error(_('No profile with that ID.'));
+ $this->clientError(_('No profile with that ID.'));
return;
}
$this->show_form($profile);
$profile = Profile::staticGet('id', $id);
if (!$profile) {
- $this->client_error(_('No such profile.'));
+ $this->clientError(_('No such profile.'));
return;
}
!Subscription::pkeyGet(array('subscriber' => $profile->id,
'subscribed' => $user->id)))
{
- $this->client_error(_('You can only tag people you are subscribed to or who are subscribed to you.'));
+ $this->clientError(_('You can only tag people you are subscribed to or who are subscribed to you.'));
return;
}
$result = Profile_tag::setTags($user->id, $profile->id, $tags);
if (!$result) {
- $this->client_error(_('Could not save tags.'));
+ $this->clientError(_('Could not save tags.'));
return;
}
$this->tag = Notice_tag::staticGet('tag', $tag);
if (!$this->tag) {
- common_user_error(_('No such tag.'));
+ $this->clientError(_('No such tag.'));
return false;
} else {
return true;
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
function end_session($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
function update_location($args, $apidata)
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
return;
}
if (!is_null($location) && strlen($location) > 255) {
// XXX: But Twitter just truncates and runs with it. -- Zach
- $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
+ $this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__);
- common_server_error(_('Couldn\'t save profile.'));
+ $this->serverError(_('Couldn\'t save profile.'));
return;
}
function update_delivery_device($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
function rate_limit_status($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
}
\ No newline at end of file
$blockee = $this->get_user($apidata['api_arg'], $apidata);
if (!$blockee) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$this->show_profile($blockee, $type);
$this->end_document($type);
} else {
- common_server_error(_('Block user failed.'));
+ $this->serverError(_('Block user failed.'));
}
}
$blockee = $this->get_user($apidata['api_arg'], $apidata);
if (!$blockee) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$this->show_profile($blockee, $type);
$this->end_document($type);
} else {
- common_server_error(_('Unblock user failed.'));
+ $this->serverError(_('Unblock user failed.'));
}
}
}
\ No newline at end of file
$this->show_json_dmsgs($message);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
return;
}
$content = $this->trimmed('text');
if (!$content) {
- $this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
+ $this->clientError(_('No message text!'), $code = 406, $apidata['content-type']);
} else {
$content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) {
- $this->client_error(_('That\'s too long. Max message size is 140 chars.'),
+ $this->clientError(_('That\'s too long. Max message size is 140 chars.'),
$code = 406, $apidata['content-type']);
return;
}
$other = $this->get_user($this->trimmed('user'));
if (!$other) {
- $this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
+ $this->clientError(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
return;
} else if (!$user->mutuallySubscribed($other)) {
- $this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'),
+ $this->clientError(_('Can\'t send direct messages to users who aren\'t your friend.'),
$code = 403, $apidata['content-type']);
return;
} else if ($user->id == $other->id) {
// Sending msgs to yourself is allowed by Twitter
- $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
+ $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
$code = 403, $apidata['content-type']);
return;
}
html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
if (is_string($message)) {
- $this->server_error($message);
+ $this->serverError($message);
return;
}
function destroy($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
function show_xml_dmsgs($message)
$user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
$notice = $user->favoriteNotices((($page-1)*20), $count);
if (!$notice) {
- common_server_error(_('Could not retrieve favorite notices.'));
+ $this->serverError(_('Could not retrieve favorite notices.'));
return;
}
$this->show_json_timeline($notice);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
// Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON.
- $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
return;
}
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
$notice = Notice::staticGet($notice_id);
if (!$notice) {
- $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
+ $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
return;
}
// XXX: Twitter lets you fave things repeatedly via api.
if ($user->hasFave($notice)) {
- $this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']);
+ $this->clientError(_('This notice is already a favorite!'), 403, $apidata['content-type']);
return;
}
$fave = Fave::addNew($user, $notice);
if (!$fave) {
- common_server_error(_('Could not create favorite.'));
+ $this->serverError(_('Could not create favorite.'));
return;
}
function destroy($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
// XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?
parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
return;
}
$other = $this->get_user($id);
if (!$other) {
- $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
+ $this->clientError(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
return;
}
if ($user->isSubscribed($other)) {
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
- $this->client_error($errmsg, 403, $apidata['content-type']);
+ $this->clientError($errmsg, 403, $apidata['content-type']);
return;
}
if (!$result) {
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
- $this->client_error($errmsg, 400, $apidata['content-type']);
+ $this->clientError($errmsg, 400, $apidata['content-type']);
return;
}
parent::handle($args);
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
- $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
return;
}
$sub->delete();
$sub->query('COMMIT');
} else {
- $this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
+ $this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
return;
}
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
$user_b = $this->get_user($user_b_id);
if (!$user_a || !$user_b) {
- $this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
+ $this->clientError(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
return;
}
print '"ok"';
$this->end_document('json');
} else {
- common_user_error(_('API method not found!'), $code=404);
+ $this->clientError(_('API method not found!'), $code=404);
}
}
function downtime_schedule($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
}
\ No newline at end of file
$this->end_document('json');
break;
default:
- $this->client_error(_('API method not found!'), $code=404);
+ $this->clientError(_('API method not found!'), $code=404);
}
}
$this->end_document('json');
break;
default:
- $this->client_error(_('API method not found!'), $code=404);
+ $this->clientError(_('API method not found!'), $code=404);
}
}
function wadl($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), 501);
+ $this->serverError(_('API method under construction.'), 501);
}
}
function follow($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
function leave($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
}
\ No newline at end of file
$this->show_json_timeline($notice);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
break;
}
} else {
- common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
+ $this->serverError(_('Couldn\'t find any statuses.'), $code = 503);
}
}
$this->show_json_timeline($notice);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
$user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
$this->show_json_timeline($notice);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']);
return;
}
// as "truncated." Sending this error may screw up some clients
// that assume Twitter will truncate for them. Should we just
// truncate too? -- Zach
- $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
+ $this->clientError(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
return;
}
if ($reply) {
$reply_to = $in_reply_to_status_id;
} else {
- $this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
+ $this->clientError(_('Not found'), $code = 404, $apidata['content-type']);
return;
}
}
$source, 1, $reply_to);
if (is_string($notice)) {
- $this->server_error($notice);
+ $this->serverError($notice);
return;
}
$this->show_json_timeline($notices);
break;
default:
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
}
}
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
}
} else {
// XXX: Twitter just sets a 404 header and doens't bother to return an err msg
- $this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']);
+ $this->clientError(_('No status with that ID found.'), 404, $apidata['content-type']);
}
}
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
// Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON.
- $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+ $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
return;
}
$notice = Notice::staticGet($notice_id);
if (!$notice) {
- $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
+ $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']);
return;
}
$this->show_single_json_status($notice);
}
} else {
- $this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
+ $this->clientError(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
}
}
$user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) {
- $this->client_error('Not Found', 404, $apidata['content-type']);
+ $this->clientError('Not Found', 404, $apidata['content-type']);
return;
}
$profile = $user->getProfile();
if (!$profile) {
- common_server_error(_('User has no profile.'));
+ $this->serverError(_('User has no profile.'));
return;
}
print json_encode($arrays);
break;
default:
- $this->client_error(_('unsupported file type'));
+ $this->clientError(_('unsupported file type'));
}
}
function featured($args, $apidata)
{
parent::handle($args);
- common_server_error(_('API method under construction.'), $code=501);
+ $this->serverError(_('API method under construction.'), $code=501);
}
function supported($cmd)
parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) {
- common_user_error(_('API method not found!'), $code = 404);
+ $this->clientError(_('API method not found!'), $code = 404);
return;
}
if (!$user) {
// XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
- $this->client_error(_('Not found.'), 404, $apidata['content-type']);
+ $this->clientError(_('Not found.'), 404, $apidata['content-type']);
return;
}
if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__);
- common_server_error(_('Couldn\'t remove Twitter user.'));
+ $this->serverError(_('Couldn\'t remove Twitter user.'));
return;
}
parent::prepare($args);
if (!common_logged_in()) {
- $this->client_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return false;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$id = $this->trimmed('unblockto');
if (!$id) {
- $this->client_error(_('No profile specified.'));
+ $this->clientError(_('No profile specified.'));
return false;
}
$this->profile = Profile::staticGet('id', $id);
if (!$this->profile) {
- $this->client_error(_('No profile with that ID.'));
+ $this->clientError(_('No profile with that ID.'));
return false;
}
$result = $cur->unblock($this->profile);
if (!$result) {
- $this->server_error(_('Error removing the block.'));
+ $this->serverError(_('Error removing the block.'));
return;
}
{
parent::handle($args);
if (!common_logged_in()) {
- common_user_error(_('Not logged in.'));
+ $this->clientError(_('Not logged in.'));
return;
}
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->client_error(_('There was a problem with your session token. Try again, please.'));
+ $this->clientError(_('There was a problem with your session token. Try again, please.'));
return;
}
$other_id = $this->arg('unsubscribeto');
if (!$other_id) {
- $this->client_error(_('No profile id in request.'));
+ $this->clientError(_('No profile id in request.'));
return;
}
$other = Profile::staticGet('id', $other_id);
if (!$other_id) {
- $this->client_error(_('No profile with that id.'));
+ $this->clientError(_('No profile with that id.'));
return;
}
$result = subs_unsubscribe_to($user, $other);
if ($result != true) {
- common_user_error($result);
+ $this->clientError($result);
return;
}
print "omb_version=".OMB_VERSION_01;
}
} catch (OAuthException $e) {
- $this->server_error($e->getMessage());
+ $this->serverError($e->getMessage());
return;
}
}
{
$version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) {
- $this->client_error(_('Unsupported OMB version'), 400);
+ $this->clientError(_('Unsupported OMB version'), 400);
return false;
}
# First, check to see if listenee exists
$listenee = $req->get_parameter('omb_listenee');
$remote = Remote_profile::staticGet('uri', $listenee);
if (!$remote) {
- $this->client_error(_('Profile unknown'), 404);
+ $this->clientError(_('Profile unknown'), 404);
return false;
}
# Second, check to see if they should be able to post updates!
$sub->subscribed = $remote->id;
$sub->token = $token->key;
if (!$sub->find(true)) {
- $this->client_error(_('You did not send us that profile'), 403);
+ $this->clientError(_('You did not send us that profile'), 403);
return false;
}
$profile = Profile::staticGet('id', $remote->id);
if (!$profile) {
# This one is our fault
- $this->server_error(_('Remote profile with no matching profile'), 500);
+ $this->serverError(_('Remote profile with no matching profile'), 500);
return false;
}
$nickname = $req->get_parameter('omb_listenee_nickname');
if ($nickname && !Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
- $this->client_error(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+ $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return false;
}
$license = $req->get_parameter('omb_listenee_license');
if ($license && !common_valid_http_url($license)) {
- $this->client_error(sprintf(_("Invalid license URL '%s'"), $license));
+ $this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
return false;
}
$profile_url = $req->get_parameter('omb_listenee_profile');
if ($profile_url && !common_valid_http_url($profile_url)) {
- $this->client_error(sprintf(_("Invalid profile URL '%s'."), $profile_url));
+ $this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url));
return false;
}
# optional stuff
$fullname = $req->get_parameter('omb_listenee_fullname');
if ($fullname && strlen($fullname) > 255) {
- $this->client_error(_("Full name is too long (max 255 chars)."));
+ $this->clientError(_("Full name is too long (max 255 chars)."));
return false;
}
$homepage = $req->get_parameter('omb_listenee_homepage');
if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
- $this->client_error(sprintf(_("Invalid homepage '%s'"), $homepage));
+ $this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
return false;
}
$bio = $req->get_parameter('omb_listenee_bio');
if ($bio && strlen($bio) > 140) {
- $this->client_error(_("Bio is too long (max 140 chars)."));
+ $this->clientError(_("Bio is too long (max 140 chars)."));
return false;
}
$location = $req->get_parameter('omb_listenee_location');
if ($location && strlen($location) > 255) {
- $this->client_error(_("Location is too long (max 255 chars)."));
+ $this->clientError(_("Location is too long (max 255 chars)."));
return false;
}
$avatar = $req->get_parameter('omb_listenee_avatar');
if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
- $this->client_error(sprintf(_("Invalid avatar URL '%s'"), $avatar));
+ $this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar));
return false;
}
$size = @getimagesize($avatar);
if (!$size) {
- $this->client_error(sprintf(_("Can't read avatar URL '%s'"), $avatar));
+ $this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar));
return false;
}
if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
- $this->client_error(sprintf(_("Wrong size image at '%s'"), $avatar));
+ $this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar));
return false;
}
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
IMAGETYPE_PNG))) {
- $this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar));
+ $this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
return false;
}
}
}
if (!$profile->update($orig_profile)) {
- $this->server_error(_('Could not save new profile info'), 500);
+ $this->serverError(_('Could not save new profile info'), 500);
return false;
} else {
if ($avatar) {
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
copy($avatar, $temp_filename);
if (!$profile->setOriginal($temp_filename)) {
- $this->server_error(_('Could not save avatar info'), 500);
+ $this->serverError(_('Could not save avatar info'), 500);
return false;
}
}
common_debug('getting new request', __FILE__);
$req = $this->get_new_request();
if (!$req) {
- $this->client_error(_('No request found!'));
+ $this->clientError(_('No request found!'));
}
common_debug('validating request', __FILE__);
# XXX: only validate new requests, since nonce is one-time use
$this->show_form($req);
} catch (OAuthException $e) {
$this->clear_request();
- $this->client_error($e->getMessage());
+ $this->clientError($e->getMessage());
return;
}
$req = $this->get_stored_request();
if (!$req) {
- common_user_error(_('No authorization request!'));
+ $this->clientError(_('No authorization request!'));
return;
}
if ($this->arg('accept')) {
if (!$this->authorize_token($req)) {
- $this->client_error(_('Error authorizing token'));
+ $this->clientError(_('Error authorizing token'));
}
if (!$this->save_remote_profile($req)) {
- $this->client_error(_('Error saving remote profile'));
+ $this->clientError(_('Error saving remote profile'));
}
if (!$callback) {
$this->show_accept_message($req->get_parameter('oauth_token'));
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
- $this->server_error(_('User without matching profile'));
+ $this->serverError(_('User without matching profile'));
return;
}
$params['omb_listener_nickname'] = $user->nickname;
parent::handle($args);
$id = $this->trimmed('id');
if (!$id) {
- $this->client_error(_('No id.'));
+ $this->clientError(_('No id.'));
}
$user =& User::staticGet($id);
if (!$user) {
- $this->client_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
}
// support redirecting to FOAF rdf/xml if the agent prefers it
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return false;
} else {
return true;
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
- $this->server_error(_('User without matching profile'));
+ $this->serverError(_('User without matching profile'));
return null;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$nickname = $this->trimmed('nickname');
$user = User::staticGet('nickname', $nickname);
if (!$user) {
- common_user_error(_('No such user.'));
+ $this->clientError(_('No such user.'));
return;
}
$this->show_xrds($user);
}
}
- function server_error($msg, $code=500)
+ function serverError($msg, $code=500)
{
$action = $this->trimmed('action');
common_debug("Server error '$code' on '$action': $msg", __FILE__);
common_server_error($msg, $code);
}
- function client_error($msg, $code=400)
+ function clientError($msg, $code=400)
{
$action = $this->trimmed('action');
common_debug("User error '$code' on '$action': $msg", __FILE__);