Merge branch 'uiredesign' of ../evan into uiredesign

This commit is contained in:
sarven 2009-01-15 23:05:57 +00:00
commit 0357ea505d
67 changed files with 275 additions and 275 deletions

View File

@ -38,7 +38,7 @@ class AccesstokenAction extends Action
common_debug('printing the access token', __FILE__); common_debug('printing the access token', __FILE__);
print $token; print $token;
} catch (OAuthException $e) { } catch (OAuthException $e) {
common_server_error($e->getMessage()); $this->serverError($e->getMessage());
} }
} }
} }

View File

@ -33,14 +33,14 @@ class AllAction extends StreamAction
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
$this->client_error(_('No such user.')); $this->clientError(_('No such user.'));
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }

View File

@ -34,7 +34,7 @@ class AllrssAction extends Rss10Action
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
if (!$this->user) { if (!$this->user) {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
return false; return false;
} else { } else {
return true; return true;

View File

@ -103,10 +103,10 @@ class ApiAction extends Action
call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata); call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
} else { } else {
common_user_error("API method not found!", $code=404); $this->clientError("API method not found!", $code=404);
} }
} else { } else {
common_user_error("API method not found!", $code=404); $this->clientError("API method not found!", $code=404);
} }
} }

View File

@ -26,28 +26,28 @@ class AvatarbynicknameAction extends Action
parent::handle($args); parent::handle($args);
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
if (!$nickname) { if (!$nickname) {
$this->client_error(_('No nickname.')); $this->clientError(_('No nickname.'));
return; return;
} }
$size = $this->trimmed('size'); $size = $this->trimmed('size');
if (!$size) { if (!$size) {
$this->client_error(_('No size.')); $this->clientError(_('No size.'));
return; return;
} }
$size = strtolower($size); $size = strtolower($size);
if (!in_array($size, array('original', '96', '48', '24'))) { if (!in_array($size, array('original', '96', '48', '24'))) {
$this->client_error(_('Invalid size.')); $this->clientError(_('Invalid size.'));
return; return;
} }
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
$this->client_error(_('No such user.')); $this->clientError(_('No such user.'));
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
$this->client_error(_('User has no profile.')); $this->clientError(_('User has no profile.'));
return; return;
} }
if ($size == 'original') { if ($size == 'original') {

View File

@ -30,28 +30,28 @@ class BlockAction extends Action
parent::prepare($args); parent::prepare($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return false; return false;
} }
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
$id = $this->trimmed('blockto'); $id = $this->trimmed('blockto');
if (!$id) { if (!$id) {
$this->client_error(_('No profile specified.')); $this->clientError(_('No profile specified.'));
return false; return false;
} }
$this->profile = Profile::staticGet('id', $id); $this->profile = Profile::staticGet('id', $id);
if (!$this->profile) { if (!$this->profile) {
$this->client_error(_('No profile with that ID.')); $this->clientError(_('No profile with that ID.'));
return false; return false;
} }
@ -119,14 +119,14 @@ class BlockAction extends Action
$cur = common_current_user(); $cur = common_current_user();
if ($cur->hasBlocked($this->profile)) { if ($cur->hasBlocked($this->profile)) {
$this->client_error(_('You have already blocked this user.')); $this->clientError(_('You have already blocked this user.'));
return; return;
} }
$result = $cur->block($this->profile); $result = $cur->block($this->profile);
if (!$result) { if (!$result) {
$this->server_error(_('Failed to save block information.')); $this->serverError(_('Failed to save block information.'));
return; return;
} }

View File

@ -32,26 +32,26 @@ class ConfirmaddressAction extends Action
} }
$code = $this->trimmed('code'); $code = $this->trimmed('code');
if (!$code) { if (!$code) {
$this->client_error(_('No confirmation code.')); $this->clientError(_('No confirmation code.'));
return; return;
} }
$confirm = Confirm_address::staticGet('code', $code); $confirm = Confirm_address::staticGet('code', $code);
if (!$confirm) { if (!$confirm) {
$this->client_error(_('Confirmation code not found.')); $this->clientError(_('Confirmation code not found.'));
return; return;
} }
$cur = common_current_user(); $cur = common_current_user();
if ($cur->id != $confirm->user_id) { 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; return;
} }
$type = $confirm->address_type; $type = $confirm->address_type;
if (!in_array($type, array('email', 'jabber', 'sms'))) { 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; return;
} }
if ($cur->$type == $confirm->address) { if ($cur->$type == $confirm->address) {
$this->client_error(_('That address has already been confirmed.')); $this->clientError(_('That address has already been confirmed.'));
return; return;
} }
@ -71,7 +71,7 @@ class ConfirmaddressAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($cur, 'UPDATE', __FILE__); common_log_db_error($cur, 'UPDATE', __FILE__);
$this->server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
@ -83,7 +83,7 @@ class ConfirmaddressAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__); common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_('Couldn\'t delete email confirmation.')); $this->serverError(_('Couldn\'t delete email confirmation.'));
return; return;
} }

View File

@ -24,7 +24,7 @@ class DeleteprofileAction extends Action
function handle($args) function handle($args)
{ {
parent::handle($args); parent::handle($args);
$this->server_error(_('Code not yet ready.')); $this->serverError(_('Code not yet ready.'));
return; return;
if ('POST' === $_SERVER['REQUEST_METHOD']) { if ('POST' === $_SERVER['REQUEST_METHOD']) {
$this->handle_post(); $this->handle_post();

View File

@ -28,7 +28,7 @@ class DisfavorAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return; return;
} }
@ -46,7 +46,7 @@ class DisfavorAction extends Action
$token = $this->trimmed('token-'.$notice->id); $token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_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; return;
} }
@ -54,7 +54,7 @@ class DisfavorAction extends Action
$fave->user_id = $this->id; $fave->user_id = $this->id;
$fave->notice_id = $notice->id; $fave->notice_id = $notice->id;
if (!$fave->find(true)) { if (!$fave->find(true)) {
$this->client_error(_('This notice is not a favorite!')); $this->clientError(_('This notice is not a favorite!'));
return; return;
} }
@ -62,7 +62,7 @@ class DisfavorAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($fave, 'DELETE', __FILE__); common_log_db_error($fave, 'DELETE', __FILE__);
$this->server_error(_('Could not delete favorite.')); $this->serverError(_('Could not delete favorite.'));
return; return;
} }

View File

@ -28,7 +28,7 @@ class DocAction extends Action
$title = $this->trimmed('title'); $title = $this->trimmed('title');
$filename = INSTALLDIR.'/doc/'.$title; $filename = INSTALLDIR.'/doc/'.$title;
if (!file_exists($filename)) { if (!file_exists($filename)) {
common_user_error(_('No such document.')); $this->clientError(_('No such document.'));
return; return;
} }
$c = file_get_contents($filename); $c = file_get_contents($filename);

View File

@ -182,7 +182,7 @@ class EmailsettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
@ -232,7 +232,7 @@ class EmailsettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__); common_log_db_error($confirm, 'INSERT', __FILE__);
common_server_error(_('Couldn\'t insert confirmation code.')); $this->serverError(_('Couldn\'t insert confirmation code.'));
return; return;
} }
@ -260,7 +260,7 @@ class EmailsettingsAction extends SettingsAction
if (!$result) { if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__); common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_('Couldn\'t delete email confirmation.')); $this->serverError(_('Couldn\'t delete email confirmation.'));
return; return;
} }
@ -286,7 +286,7 @@ class EmailsettingsAction extends SettingsAction
$result = $user->updateKeys($original); $result = $user->updateKeys($original);
if (!$result) { if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
$user->query('COMMIT'); $user->query('COMMIT');
@ -308,7 +308,7 @@ class EmailsettingsAction extends SettingsAction
if (!$user->updateKeys($orig)) { if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__); 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); $this->show_form(_('Incoming email address removed.'), true);
@ -323,7 +323,7 @@ class EmailsettingsAction extends SettingsAction
if (!$user->updateKeys($orig)) { if (!$user->updateKeys($orig)) {
common_log_db_error($user, 'UPDATE', __FILE__); 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); $this->show_form(_('New incoming email address added.'), true);

View File

@ -53,7 +53,7 @@ class FacebookremoveAction extends FacebookAction
if (!$result) { if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__); common_log_db_error($flink, 'DELETE', __FILE__);
common_server_error(_('Couldn\'t remove Facebook user.')); $this->serverError(_('Couldn\'t remove Facebook user.'));
return; return;
} }

View File

@ -29,7 +29,7 @@ class FavorAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return; return;
} }
@ -48,19 +48,19 @@ class FavorAction extends Action
$token = $this->trimmed('token-'.$notice->id); $token = $this->trimmed('token-'.$notice->id);
if (!$token || $token != common_session_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; return;
} }
if ($user->hasFave($notice)) { if ($user->hasFave($notice)) {
$this->client_error(_('This notice is already a favorite!')); $this->clientError(_('This notice is already a favorite!'));
return; return;
} }
$fave = Fave::addNew($user, $notice); $fave = Fave::addNew($user, $notice);
if (!$fave) { if (!$fave) {
$this->server_error(_('Could not create favorite.')); $this->serverError(_('Could not create favorite.'));
return; return;
} }

View File

@ -34,7 +34,7 @@ class FavoritesrssAction extends Rss10Action
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
if (!$this->user) { if (!$this->user) {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
return false; return false;
} else { } else {
return true; return true;

View File

@ -28,7 +28,7 @@ class FinishaddopenidAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
} else { } else {
$this->try_login(); $this->try_login();
} }

View File

@ -28,7 +28,7 @@ class FinishopenidloginAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
@ -179,7 +179,7 @@ class FinishopenidloginAction extends Action
# FIXME: save invite code before redirect, and check here # FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) { if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
common_user_error(_('Registration not allowed.')); $this->clientError(_('Registration not allowed.'));
return; return;
} }
@ -205,7 +205,7 @@ class FinishopenidloginAction extends Action
list($display, $canonical, $sreg) = $this->get_saved_values(); list($display, $canonical, $sreg) = $this->get_saved_values();
if (!$display || !$canonical) { if (!$display || !$canonical) {
common_server_error(_('Stored OpenID not found.')); $this->serverError(_('Stored OpenID not found.'));
return; return;
} }
@ -214,7 +214,7 @@ class FinishopenidloginAction extends Action
$other = oid_get_user($canonical); $other = oid_get_user($canonical);
if ($other) { 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; return;
} }
@ -274,14 +274,14 @@ class FinishopenidloginAction extends Action
list($display, $canonical, $sreg) = $this->get_saved_values(); list($display, $canonical, $sreg) = $this->get_saved_values();
if (!$display || !$canonical) { if (!$display || !$canonical) {
common_server_error(_('Stored OpenID not found.')); $this->serverError(_('Stored OpenID not found.'));
return; return;
} }
$result = oid_link_user($user->id, $canonical, $display); $result = oid_link_user($user->id, $canonical, $display);
if (!$result) { if (!$result) {
common_server_error(_('Error connecting user to OpenID.')); $this->serverError(_('Error connecting user to OpenID.'));
return; return;
} }

View File

@ -30,14 +30,14 @@ class FinishremotesubscribeAction extends Action
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('You can use the local subscription!')); $this->clientError(_('You can use the local subscription!'));
return; return;
} }
$omb = $_SESSION['oauth_authorization_request']; $omb = $_SESSION['oauth_authorization_request'];
if (!$omb) { if (!$omb) {
common_user_error(_('Not expecting this response!')); $this->clientError(_('Not expecting this response!'));
return; return;
} }
@ -51,38 +51,38 @@ class FinishremotesubscribeAction extends Action
# I think this is the success metric # I think this is the success metric
if ($token != $omb['token']) { if ($token != $omb['token']) {
common_user_error(_('Not authorized.')); $this->clientError(_('Not authorized.'));
return; return;
} }
$version = $req->get_parameter('omb_version'); $version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) { if ($version != OMB_VERSION_01) {
common_user_error(_('Unknown version of OMB protocol.')); $this->clientError(_('Unknown version of OMB protocol.'));
return; return;
} }
$nickname = $req->get_parameter('omb_listener_nickname'); $nickname = $req->get_parameter('omb_listener_nickname');
if (!$nickname) { if (!$nickname) {
common_user_error(_('No nickname provided by remote server.')); $this->clientError(_('No nickname provided by remote server.'));
return; return;
} }
$profile_url = $req->get_parameter('omb_listener_profile'); $profile_url = $req->get_parameter('omb_listener_profile');
if (!$profile_url) { if (!$profile_url) {
common_user_error(_('No profile URL returned by server.')); $this->clientError(_('No profile URL returned by server.'));
return; return;
} }
if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) { 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; return;
} }
if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) { 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; return;
} }
@ -91,14 +91,14 @@ class FinishremotesubscribeAction extends Action
$user = User::staticGet('nickname', $omb['listenee']); $user = User::staticGet('nickname', $omb['listenee']);
if (!$user) { if (!$user) {
common_user_error(_('User being listened to doesn\'t exist.')); $this->clientError(_('User being listened to doesn\'t exist.'));
return; return;
} }
$other = User::staticGet('uri', $omb['listener']); $other = User::staticGet('uri', $omb['listener']);
if ($other) { if ($other) {
common_user_error(_('You can use the local subscription!')); $this->clientError(_('You can use the local subscription!'));
return; return;
} }
@ -111,7 +111,7 @@ class FinishremotesubscribeAction extends Action
list($newtok, $newsecret) = $this->access_token($omb); list($newtok, $newsecret) = $this->access_token($omb);
if (!$newtok || !$newsecret) { 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; return;
} }
@ -155,7 +155,7 @@ class FinishremotesubscribeAction extends Action
$profile->created = DB_DataObject_Cast::dateTime(); # current time $profile->created = DB_DataObject_Cast::dateTime(); # current time
$id = $profile->insert(); $id = $profile->insert();
if (!$id) { if (!$id) {
common_server_error(_('Error inserting new profile')); $this->serverError(_('Error inserting new profile'));
return; return;
} }
$remote->id = $id; $remote->id = $id;
@ -163,7 +163,7 @@ class FinishremotesubscribeAction extends Action
if ($avatar_url) { if ($avatar_url) {
if (!$this->add_avatar($profile, $avatar_url)) { if (!$this->add_avatar($profile, $avatar_url)) {
common_server_error(_('Error inserting avatar')); $this->serverError(_('Error inserting avatar'));
return; return;
} }
} }
@ -173,19 +173,19 @@ class FinishremotesubscribeAction extends Action
if ($exists) { if ($exists) {
if (!$remote->update($orig_remote)) { if (!$remote->update($orig_remote)) {
common_server_error(_('Error updating remote profile')); $this->serverError(_('Error updating remote profile'));
return; return;
} }
} else { } else {
$remote->created = DB_DataObject_Cast::dateTime(); # current time $remote->created = DB_DataObject_Cast::dateTime(); # current time
if (!$remote->insert()) { if (!$remote->insert()) {
common_server_error(_('Error inserting remote profile')); $this->serverError(_('Error inserting remote profile'));
return; return;
} }
} }
if ($user->hasBlocked($profile)) { if ($user->hasBlocked($profile)) {
$this->client_error(_('That user has blocked you from subscribing.')); $this->clientError(_('That user has blocked you from subscribing.'));
return; return;
} }
@ -215,7 +215,7 @@ class FinishremotesubscribeAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__); 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; return;
} }

View File

@ -40,14 +40,14 @@ class FoafAction extends Action
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
common_user_error(_('No such user.'), 404); $this->clientError(_('No such user.'), 404);
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.'), 500); $this->serverError(_('User has no profile.'), 500);
return; return;
} }

View File

@ -149,7 +149,7 @@ class ImsettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
@ -199,7 +199,7 @@ class ImsettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__); common_log_db_error($confirm, 'INSERT', __FILE__);
common_server_error(_('Couldn\'t insert confirmation code.')); $this->serverError(_('Couldn\'t insert confirmation code.'));
return; return;
} }
@ -231,7 +231,7 @@ class ImsettingsAction extends SettingsAction
if (!$result) { if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__); common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_('Couldn\'t delete email confirmation.')); $this->serverError(_('Couldn\'t delete email confirmation.'));
return; return;
} }
@ -257,7 +257,7 @@ class ImsettingsAction extends SettingsAction
$result = $user->updateKeys($original); $result = $user->updateKeys($original);
if (!$result) { if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
$user->query('COMMIT'); $user->query('COMMIT');

View File

@ -31,7 +31,7 @@ class InviteAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { 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'))); common_config('site', 'name')));
return; return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {

View File

@ -31,7 +31,7 @@ class LoginAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (common_is_real_login()) { if (common_is_real_login()) {
common_user_error(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->check_login(); $this->check_login();
} else { } else {
@ -46,7 +46,7 @@ class LoginAction extends Action
# CSRF protection - token set in common_notice_form() # CSRF protection - token set in common_notice_form()
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
@ -55,7 +55,7 @@ class LoginAction extends Action
if (common_check_user($nickname, $password)) { if (common_check_user($nickname, $password)) {
# success! # success!
if (!common_set_user($nickname)) { if (!common_set_user($nickname)) {
common_server_error(_('Error setting user.')); $this->serverError(_('Error setting user.'));
return; return;
} }
common_real_login(true); common_real_login(true);
@ -81,7 +81,7 @@ class LoginAction extends Action
# success! # success!
if (!common_set_user($user)) { if (!common_set_user($user)) {
common_server_error(_('Error setting user.')); $this->serverError(_('Error setting user.'));
return; return;
} }

View File

@ -33,7 +33,7 @@ class LogoutAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
} else { } else {
common_set_user(null); common_set_user(null);
common_real_login(false); # not logged in common_real_login(false); # not logged in

View File

@ -31,14 +31,14 @@ class MicrosummaryAction extends Action
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
$this->client_error(_('No such user'), 404); $this->clientError(_('No such user'), 404);
return; return;
} }
$notice = $user->getCurrentNotice(); $notice = $user->getCurrentNotice();
if (!$notice) { if (!$notice) {
$this->client_error(_('No current status'), 404); $this->clientError(_('No current status'), 404);
} }
header('Content-Type: text/plain'); header('Content-Type: text/plain');

View File

@ -27,7 +27,7 @@ class NewmessageAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in.'), 403); $this->clientError(_('Not logged in.'), 403);
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->save_new_message(); $this->save_new_message();
} else { } else {
@ -71,10 +71,10 @@ class NewmessageAction extends Action
$this->show_form(_('No recipient specified.')); $this->show_form(_('No recipient specified.'));
return; return;
} else if (!$user->mutuallySubscribed($other)) { } 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; return;
} else if ($user->id == $other->id) { } 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; return;
} }
@ -113,12 +113,12 @@ class NewmessageAction extends Action
$other = User::staticGet('id', $to); $other = User::staticGet('id', $to);
if (!$other) { if (!$other) {
$this->client_error(_('No such user'), 404); $this->clientError(_('No such user'), 404);
return; return;
} }
if (!$user->mutuallySubscribed($other)) { 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; return;
} }

View File

@ -29,13 +29,13 @@ class NewnoticeAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
# CSRF protection - token set in common_notice_form() # CSRF protection - token set in common_notice_form()
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }

View File

@ -97,7 +97,7 @@ class NoticesearchAction extends SearchAction
$profile = $notice->getProfile(); $profile = $notice->getProfile();
if (!$profile) { if (!$profile) {
common_log_db_error($notice, 'SELECT', __FILE__); common_log_db_error($notice, 'SELECT', __FILE__);
$this->server_error(_('Notice without matching profile')); $this->serverError(_('Notice without matching profile'));
return; return;
} }
# XXX: RDFa # XXX: RDFa

View File

@ -29,7 +29,7 @@ class NudgeAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return; return;
} }
@ -46,12 +46,12 @@ class NudgeAction extends Action
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
if (!$other->email || !$other->emailnotifynudge) { 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; return;
} }

View File

@ -28,7 +28,7 @@ class OpenidloginAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$openid_url = $this->trimmed('openid_url'); $openid_url = $this->trimmed('openid_url');

View File

@ -177,7 +177,7 @@ class OthersettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }

View File

@ -32,7 +32,7 @@ class PeopletagAction extends Action
$tag = $this->trimmed('tag'); $tag = $this->trimmed('tag');
if (!common_valid_profile_tag($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; return;
} }

View File

@ -36,7 +36,7 @@ class PostnoticeAction extends Action
print "omb_version=".OMB_VERSION_01; print "omb_version=".OMB_VERSION_01;
} }
} catch (OAuthException $e) { } catch (OAuthException $e) {
common_server_error($e->getMessage()); $this->serverError($e->getMessage());
return; return;
} }
} }
@ -45,36 +45,36 @@ class PostnoticeAction extends Action
{ {
$version = $req->get_parameter('omb_version'); $version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) { if ($version != OMB_VERSION_01) {
common_user_error(_('Unsupported OMB version'), 400); $this->clientError(_('Unsupported OMB version'), 400);
return false; return false;
} }
# First, check to see # First, check to see
$listenee = $req->get_parameter('omb_listenee'); $listenee = $req->get_parameter('omb_listenee');
$remote_profile = Remote_profile::staticGet('uri', $listenee); $remote_profile = Remote_profile::staticGet('uri', $listenee);
if (!$remote_profile) { if (!$remote_profile) {
common_user_error(_('Profile unknown'), 403); $this->clientError(_('Profile unknown'), 403);
return false; return false;
} }
$sub = Subscription::staticGet('token', $token->key); $sub = Subscription::staticGet('token', $token->key);
if (!$sub) { if (!$sub) {
common_user_error(_('No such subscription'), 403); $this->clientError(_('No such subscription'), 403);
return false; return false;
} }
$content = $req->get_parameter('omb_notice_content'); $content = $req->get_parameter('omb_notice_content');
$content_shortened = common_shorten_links($content); $content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) { if (mb_strlen($content_shortened) > 140) {
common_user_error(_('Invalid notice content'), 400); $this->clientError(_('Invalid notice content'), 400);
return false; return false;
} }
$notice_uri = $req->get_parameter('omb_notice'); $notice_uri = $req->get_parameter('omb_notice');
if (!Validate::uri($notice_uri) && if (!Validate::uri($notice_uri) &&
!common_valid_tag($notice_uri)) { !common_valid_tag($notice_uri)) {
common_user_error(_('Invalid notice uri'), 400); $this->clientError(_('Invalid notice uri'), 400);
return false; return false;
} }
$notice_url = $req->get_parameter('omb_notice_url'); $notice_url = $req->get_parameter('omb_notice_url');
if ($notice_url && !common_valid_http_url($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; return false;
} }
$notice = Notice::staticGet('uri', $notice_uri); $notice = Notice::staticGet('uri', $notice_uri);

View File

@ -125,7 +125,7 @@ class ProfilesettingsAction extends SettingsAction
if (!$profile) { if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__); common_log_db_error($user, 'SELECT', __FILE__);
$this->server_error(_('User without matching profile')); $this->serverError(_('User without matching profile'));
return; return;
} }
@ -298,7 +298,7 @@ class ProfilesettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} else { } else {
# Re-initialize language environment if it changed # Re-initialize language environment if it changed
@ -318,7 +318,7 @@ class ProfilesettingsAction extends SettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); 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; return;
} }
} }
@ -341,7 +341,7 @@ class ProfilesettingsAction extends SettingsAction
if (!$result) { if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__); common_log_db_error($profile, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t save profile.')); $this->serverError(_('Couldn\'t save profile.'));
return; return;
} }
@ -350,7 +350,7 @@ class ProfilesettingsAction extends SettingsAction
$result = $user->setSelfTags($tags); $result = $user->setSelfTags($tags);
if (!$result) { if (!$result) {
common_server_error(_('Couldn\'t save tags.')); $this->serverError(_('Couldn\'t save tags.'));
return; return;
} }
@ -475,7 +475,7 @@ class ProfilesettingsAction extends SettingsAction
} }
if (!$user->update($original)) { if (!$user->update($original)) {
common_server_error(_('Can\'t save new password.')); $this->serverError(_('Can\'t save new password.'));
return; return;
} }

View File

@ -165,7 +165,7 @@ class PublicAction extends Action
NOTICES_PER_PAGE + 1); NOTICES_PER_PAGE + 1);
if (!$notice) { if (!$notice) {
$this->server_error(_('Could not retrieve public stream.')); $this->serverError(_('Could not retrieve public stream.'));
return; return;
} }

View File

@ -30,7 +30,7 @@ class RecoverpasswordAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
$this->client_error(_('You are already logged in!')); $this->clientError(_('You are already logged in!'));
return; return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('recover')) { if ($this->arg('recover')) {
@ -38,7 +38,7 @@ class RecoverpasswordAction extends Action
} else if ($this->arg('reset')) { } else if ($this->arg('reset')) {
$this->reset_password(); $this->reset_password();
} else { } else {
$this->client_error(_('Unexpected form submission.')); $this->clientError(_('Unexpected form submission.'));
} }
} else { } else {
if ($this->trimmed('code')) { if ($this->trimmed('code')) {
@ -56,18 +56,18 @@ class RecoverpasswordAction extends Action
$confirm = Confirm_address::staticGet('code', $code); $confirm = Confirm_address::staticGet('code', $code);
if (!$confirm) { if (!$confirm) {
$this->client_error(_('No such recovery code.')); $this->clientError(_('No such recovery code.'));
return; return;
} }
if ($confirm->address_type != 'recover') { if ($confirm->address_type != 'recover') {
$this->client_error(_('Not a recovery code.')); $this->clientError(_('Not a recovery code.'));
return; return;
} }
$user = User::staticGet($confirm->user_id); $user = User::staticGet($confirm->user_id);
if (!$user) { if (!$user) {
$this->server_error(_('Recovery code for unknown user.')); $this->serverError(_('Recovery code for unknown user.'));
return; return;
} }
@ -80,7 +80,7 @@ class RecoverpasswordAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__); common_log_db_error($confirm, 'DELETE', __FILE__);
common_server_error(_('Error with confirmation code.')); $this->serverError(_('Error with confirmation code.'));
return; return;
} }
@ -91,7 +91,7 @@ class RecoverpasswordAction extends Action
common_log(LOG_WARNING, common_log(LOG_WARNING,
'Attempted redemption on recovery code ' . 'Attempted redemption on recovery code ' .
'that is ' . $touched . ' seconds old. '); '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.')); 'Please start again.'));
return; return;
} }
@ -105,7 +105,7 @@ class RecoverpasswordAction extends Action
$result = $user->updateKeys($orig); $result = $user->updateKeys($orig);
if (!$result) { if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__); 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; return;
} }
} }
@ -240,7 +240,7 @@ class RecoverpasswordAction extends Action
} }
if (!$user->email && !$confirm_email) { 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; return;
} }
@ -254,7 +254,7 @@ class RecoverpasswordAction extends Action
if (!$confirm->insert()) { if (!$confirm->insert()) {
common_log_db_error($confirm, 'INSERT', __FILE__); common_log_db_error($confirm, 'INSERT', __FILE__);
$this->server_error(_('Error saving address confirmation.')); $this->serverError(_('Error saving address confirmation.'));
return; return;
} }
@ -298,7 +298,7 @@ class RecoverpasswordAction extends Action
$user = $this->get_temp_user(); $user = $this->get_temp_user();
if (!$user) { if (!$user) {
$this->client_error(_('Unexpected password reset.')); $this->clientError(_('Unexpected password reset.'));
return; return;
} }
@ -322,14 +322,14 @@ class RecoverpasswordAction extends Action
if (!$user->update($original)) { if (!$user->update($original)) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Can\'t save new password.')); $this->serverError(_('Can\'t save new password.'));
return; return;
} }
$this->clear_temp_user(); $this->clear_temp_user();
if (!common_set_user($user->nickname)) { if (!common_set_user($user->nickname)) {
common_server_error(_('Error setting user.')); $this->serverError(_('Error setting user.'));
return; return;
} }

View File

@ -26,9 +26,9 @@ class RegisterAction extends Action
parent::handle($args); parent::handle($args);
if (common_config('site', 'closed')) { if (common_config('site', 'closed')) {
common_user_error(_('Registration not allowed.')); $this->clientError(_('Registration not allowed.'));
} else if (common_logged_in()) { } else if (common_logged_in()) {
common_user_error(_('Already logged in.')); $this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') { } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->try_register(); $this->try_register();
} else { } else {
@ -65,7 +65,7 @@ class RegisterAction extends Action
} }
if (common_config('site', 'inviteonly') && !($code && $invite)) { 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; return;
} }
@ -115,7 +115,7 @@ class RegisterAction extends Action
} }
# success! # success!
if (!common_set_user($user)) { if (!common_set_user($user)) {
common_server_error(_('Error setting user.')); $this->serverError(_('Error setting user.'));
return; return;
} }
# this is a real login # this is a real login
@ -179,7 +179,7 @@ class RegisterAction extends Action
} }
if (common_config('site', 'inviteonly') && !($code && $invite)) { 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; return;
} }

View File

@ -30,7 +30,7 @@ class RemotesubscribeAction extends Action
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('You can use the local subscription!')); $this->clientError(_('You can use the local subscription!'));
return; return;
} }
@ -342,7 +342,7 @@ class RemotesubscribeAction extends Action
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__); common_log_db_error($user, 'SELECT', __FILE__);
$this->server_error(_('User without matching profile')); $this->serverError(_('User without matching profile'));
return; return;
} }

View File

@ -40,7 +40,7 @@ class RepliesAction extends StreamAction
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -57,7 +57,7 @@ class RepliesAction extends StreamAction
function no_such_user() function no_such_user()
{ {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
} }
function show_header($user) function show_header($user)

View File

@ -34,7 +34,7 @@ class RepliesrssAction extends Rss10Action
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
if (!$this->user) { if (!$this->user) {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
return false; return false;
} else { } else {
return true; return true;

View File

@ -39,7 +39,7 @@ class RequesttokenAction extends Action
$token = $server->fetch_request_token($req); $token = $server->fetch_request_token($req);
print $token; print $token;
} catch (OAuthException $e) { } catch (OAuthException $e) {
common_server_error($e->getMessage()); $this->serverError($e->getMessage());
} }
} }
} }

View File

@ -33,14 +33,14 @@ class ShowfavoritesAction extends StreamAction
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
$this->client_error(_('No such user.')); $this->clientError(_('No such user.'));
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -90,7 +90,7 @@ class ShowfavoritesAction extends StreamAction
$notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); $notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
if (!$notice) { if (!$notice) {
$this->server_error(_('Could not retrieve favorite notices.')); $this->serverError(_('Could not retrieve favorite notices.'));
return; return;
} }

View File

@ -32,7 +32,7 @@ class ShowmessageAction extends MailboxAction
$message = $this->get_message(); $message = $this->get_message();
if (!$message) { if (!$message) {
$this->client_error(_('No such message.'), 404); $this->clientError(_('No such message.'), 404);
return; return;
} }
@ -41,7 +41,7 @@ class ShowmessageAction extends MailboxAction
if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) { if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) {
$this->show_page($cur, 1); $this->show_page($cur, 1);
} else { } 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; return;
} }
} }

View File

@ -37,14 +37,14 @@ class ShownoticeAction extends StreamAction
$this->notice = Notice::staticGet($id); $this->notice = Notice::staticGet($id);
if (!$this->notice) { if (!$this->notice) {
$this->client_error(_('No such notice.'), 404); $this->clientError(_('No such notice.'), 404);
return false; return false;
} }
$this->profile = $this->notice->getProfile(); $this->profile = $this->notice->getProfile();
if (!$this->profile) { if (!$this->profile) {
$this->server_error(_('Notice has no profile'), 500); $this->serverError(_('Notice has no profile'), 500);
return false; return false;
} }
@ -119,6 +119,6 @@ class ShownoticeAction extends StreamAction
function no_such_notice() function no_such_notice()
{ {
common_user_error(_('No such notice.')); $this->clientError(_('No such notice.'));
} }
} }

View File

@ -56,7 +56,7 @@ class ShowstreamAction extends StreamAction
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -159,7 +159,7 @@ class ShowstreamAction extends StreamAction
function no_such_user() function no_such_user()
{ {
$this->client_error(_('No such user.'), 404); $this->clientError(_('No such user.'), 404);
} }
function show_profile($profile) function show_profile($profile)

View File

@ -168,7 +168,7 @@ class SmssettingsAction extends EmailsettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
@ -218,7 +218,7 @@ class SmssettingsAction extends EmailsettingsAction
if ($result === false) { if ($result === false) {
common_log_db_error($confirm, 'INSERT', __FILE__); common_log_db_error($confirm, 'INSERT', __FILE__);
common_server_error(_('Couldn\'t insert confirmation code.')); $this->serverError(_('Couldn\'t insert confirmation code.'));
return; return;
} }
@ -254,7 +254,7 @@ class SmssettingsAction extends EmailsettingsAction
if (!$result) { if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__); common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_('Couldn\'t delete email confirmation.')); $this->serverError(_('Couldn\'t delete email confirmation.'));
return; return;
} }
@ -283,7 +283,7 @@ class SmssettingsAction extends EmailsettingsAction
$result = $user->updateKeys($original); $result = $user->updateKeys($original);
if (!$result) { if (!$result) {
common_log_db_error($user, 'UPDATE', __FILE__); common_log_db_error($user, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t update user.')); $this->serverError(_('Couldn\'t update user.'));
return; return;
} }
$user->query('COMMIT'); $user->query('COMMIT');

View File

@ -30,28 +30,28 @@ class SubeditAction extends Action
parent::prepare($args); parent::prepare($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return false; return false;
} }
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
$id = $this->trimmed('profile'); $id = $this->trimmed('profile');
if (!$id) { if (!$id) {
$this->client_error(_('No profile specified.')); $this->clientError(_('No profile specified.'));
return false; return false;
} }
$this->profile = Profile::staticGet('id', $id); $this->profile = Profile::staticGet('id', $id);
if (!$this->profile) { if (!$this->profile) {
$this->client_error(_('No profile with that ID.')); $this->clientError(_('No profile with that ID.'));
return false; return false;
} }
@ -68,7 +68,7 @@ class SubeditAction extends Action
'subscribed' => $this->profile->id)); 'subscribed' => $this->profile->id));
if (!$sub) { if (!$sub) {
$this->client_error(_('You are not subscribed to that profile.')); $this->clientError(_('You are not subscribed to that profile.'));
return false; return false;
} }
@ -81,7 +81,7 @@ class SubeditAction extends Action
if (!$result) { if (!$result) {
common_log_db_error($sub, 'UPDATE', __FILE__); common_log_db_error($sub, 'UPDATE', __FILE__);
$this->server_error(_('Could not save subscription.')); $this->serverError(_('Could not save subscription.'));
return false; return false;
} }

View File

@ -27,7 +27,7 @@ class SubscribeAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return; return;
} }
@ -43,7 +43,7 @@ class SubscribeAction extends Action
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
@ -52,14 +52,14 @@ class SubscribeAction extends Action
$other = User::staticGet('id', $other_id); $other = User::staticGet('id', $other_id);
if (!$other) { if (!$other) {
$this->client_error(_('Not a local user.')); $this->clientError(_('Not a local user.'));
return; return;
} }
$result = subs_subscribe_to($user, $other); $result = subs_subscribe_to($user, $other);
if($result != true) { if($result != true) {
common_user_error($result); $this->clientError($result);
return; return;
} }

View File

@ -30,7 +30,7 @@ class TagotherAction extends Action
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in'), 403); $this->clientError(_('Not logged in'), 403);
return; return;
} }
@ -39,12 +39,12 @@ class TagotherAction extends Action
} else { } else {
$id = $this->trimmed('id'); $id = $this->trimmed('id');
if (!$id) { if (!$id) {
$this->client_error(_('No id argument.')); $this->clientError(_('No id argument.'));
return; return;
} }
$profile = Profile::staticGet('id', $id); $profile = Profile::staticGet('id', $id);
if (!$profile) { if (!$profile) {
$this->client_error(_('No profile with that ID.')); $this->clientError(_('No profile with that ID.'));
return; return;
} }
$this->show_form($profile); $this->show_form($profile);
@ -121,7 +121,7 @@ class TagotherAction extends Action
$profile = Profile::staticGet('id', $id); $profile = Profile::staticGet('id', $id);
if (!$profile) { if (!$profile) {
$this->client_error(_('No such profile.')); $this->clientError(_('No such profile.'));
return; return;
} }
@ -147,14 +147,14 @@ class TagotherAction extends Action
!Subscription::pkeyGet(array('subscriber' => $profile->id, !Subscription::pkeyGet(array('subscriber' => $profile->id,
'subscribed' => $user->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; return;
} }
$result = Profile_tag::setTags($user->id, $profile->id, $tags); $result = Profile_tag::setTags($user->id, $profile->id, $tags);
if (!$result) { if (!$result) {
$this->client_error(_('Could not save tags.')); $this->clientError(_('Could not save tags.'));
return; return;
} }

View File

@ -32,7 +32,7 @@ class TagrssAction extends Rss10Action
$this->tag = Notice_tag::staticGet('tag', $tag); $this->tag = Notice_tag::staticGet('tag', $tag);
if (!$this->tag) { if (!$this->tag) {
common_user_error(_('No such tag.')); $this->clientError(_('No such tag.'));
return false; return false;
} else { } else {
return true; return true;

View File

@ -29,7 +29,7 @@ class TwitapiaccountAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
@ -39,7 +39,7 @@ class TwitapiaccountAction extends TwitterapiAction
function end_session($args, $apidata) function end_session($args, $apidata)
{ {
parent::handle($args); 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) function update_location($args, $apidata)
@ -47,7 +47,7 @@ class TwitapiaccountAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { 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; return;
} }
@ -56,7 +56,7 @@ class TwitapiaccountAction extends TwitterapiAction
if (!is_null($location) && strlen($location) > 255) { if (!is_null($location) && strlen($location) > 255) {
// XXX: But Twitter just truncates and runs with it. -- Zach // 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; return;
} }
@ -64,7 +64,7 @@ class TwitapiaccountAction extends TwitterapiAction
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -75,7 +75,7 @@ class TwitapiaccountAction extends TwitterapiAction
if (!$result) { if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__); common_log_db_error($profile, 'UPDATE', __FILE__);
common_server_error(_('Couldn\'t save profile.')); $this->serverError(_('Couldn\'t save profile.'));
return; return;
} }
@ -91,12 +91,12 @@ class TwitapiaccountAction extends TwitterapiAction
function update_delivery_device($args, $apidata) function update_delivery_device($args, $apidata)
{ {
parent::handle($args); 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) function rate_limit_status($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); $this->serverError(_('API method under construction.'), $code=501);
} }
} }

View File

@ -32,7 +32,7 @@ class TwitapiblocksAction extends TwitterapiAction
$blockee = $this->get_user($apidata['api_arg'], $apidata); $blockee = $this->get_user($apidata['api_arg'], $apidata);
if (!$blockee) { if (!$blockee) {
$this->client_error('Not Found', 404, $apidata['content-type']); $this->clientError('Not Found', 404, $apidata['content-type']);
return; return;
} }
@ -44,7 +44,7 @@ class TwitapiblocksAction extends TwitterapiAction
$this->show_profile($blockee, $type); $this->show_profile($blockee, $type);
$this->end_document($type); $this->end_document($type);
} else { } else {
common_server_error(_('Block user failed.')); $this->serverError(_('Block user failed.'));
} }
} }
@ -54,7 +54,7 @@ class TwitapiblocksAction extends TwitterapiAction
$blockee = $this->get_user($apidata['api_arg'], $apidata); $blockee = $this->get_user($apidata['api_arg'], $apidata);
if (!$blockee) { if (!$blockee) {
$this->client_error('Not Found', 404, $apidata['content-type']); $this->clientError('Not Found', 404, $apidata['content-type']);
return; return;
} }
@ -66,7 +66,7 @@ class TwitapiblocksAction extends TwitterapiAction
$this->show_profile($blockee, $type); $this->show_profile($blockee, $type);
$this->end_document($type); $this->end_document($type);
} else { } else {
common_server_error(_('Unblock user failed.')); $this->serverError(_('Unblock user failed.'));
} }
} }
} }

View File

@ -108,7 +108,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$this->show_json_dmsgs($message); $this->show_json_dmsgs($message);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
} }
} }
@ -119,7 +119,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { 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; return;
} }
@ -134,11 +134,11 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$content = $this->trimmed('text'); $content = $this->trimmed('text');
if (!$content) { if (!$content) {
$this->client_error(_('No message text!'), $code = 406, $apidata['content-type']); $this->clientError(_('No message text!'), $code = 406, $apidata['content-type']);
} else { } else {
$content_shortened = common_shorten_links($content); $content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) { 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']); $code = 406, $apidata['content-type']);
return; return;
} }
@ -147,15 +147,15 @@ class Twitapidirect_messagesAction extends TwitterapiAction
$other = $this->get_user($this->trimmed('user')); $other = $this->get_user($this->trimmed('user'));
if (!$other) { 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; return;
} else if (!$user->mutuallySubscribed($other)) { } 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']); $code = 403, $apidata['content-type']);
return; return;
} else if ($user->id == $other->id) { } else if ($user->id == $other->id) {
// Sending msgs to yourself is allowed by Twitter // 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']); $code = 403, $apidata['content-type']);
return; return;
} }
@ -164,7 +164,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source); html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
if (is_string($message)) { if (is_string($message)) {
$this->server_error($message); $this->serverError($message);
return; return;
} }
@ -181,7 +181,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction
function destroy($args, $apidata) function destroy($args, $apidata)
{ {
parent::handle($args); 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) function show_xml_dmsgs($message)

View File

@ -32,14 +32,14 @@ class TwitapifavoritesAction extends TwitterapiAction
$user = $this->get_user($apidata['api_arg'], $apidata); $user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) { if (!$user) {
$this->client_error('Not Found', 404, $apidata['content-type']); $this->clientError('Not Found', 404, $apidata['content-type']);
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -56,7 +56,7 @@ class TwitapifavoritesAction extends TwitterapiAction
$notice = $user->favoriteNotices((($page-1)*20), $count); $notice = $user->favoriteNotices((($page-1)*20), $count);
if (!$notice) { if (!$notice) {
common_server_error(_('Could not retrieve favorite notices.')); $this->serverError(_('Could not retrieve favorite notices.'));
return; return;
} }
@ -82,7 +82,7 @@ class TwitapifavoritesAction extends TwitterapiAction
$this->show_json_timeline($notice); $this->show_json_timeline($notice);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
} }
} }
@ -94,12 +94,12 @@ class TwitapifavoritesAction extends TwitterapiAction
// Check for RESTfulness // Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON. // 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; return;
} }
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
@ -109,20 +109,20 @@ class TwitapifavoritesAction extends TwitterapiAction
$notice = Notice::staticGet($notice_id); $notice = Notice::staticGet($notice_id);
if (!$notice) { 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; return;
} }
// XXX: Twitter lets you fave things repeatedly via api. // XXX: Twitter lets you fave things repeatedly via api.
if ($user->hasFave($notice)) { 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; return;
} }
$fave = Fave::addNew($user, $notice); $fave = Fave::addNew($user, $notice);
if (!$fave) { if (!$fave) {
common_server_error(_('Could not create favorite.')); $this->serverError(_('Could not create favorite.'));
return; return;
} }
@ -140,7 +140,7 @@ class TwitapifavoritesAction extends TwitterapiAction
function destroy($args, $apidata) function destroy($args, $apidata)
{ {
parent::handle($args); 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? // XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?

View File

@ -29,7 +29,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { 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; return;
} }
@ -38,7 +38,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
$other = $this->get_user($id); $other = $this->get_user($id);
if (!$other) { 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; return;
} }
@ -46,7 +46,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
if ($user->isSubscribed($other)) { if ($user->isSubscribed($other)) {
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); $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; return;
} }
@ -62,7 +62,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
if (!$result) { if (!$result) {
$errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); $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; return;
} }
@ -82,7 +82,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { 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; return;
} }
@ -102,7 +102,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
$sub->delete(); $sub->delete();
$sub->query('COMMIT'); $sub->query('COMMIT');
} else { } 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; return;
} }
@ -118,7 +118,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
@ -129,7 +129,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
$user_b = $this->get_user($user_b_id); $user_b = $this->get_user($user_b_id);
if (!$user_a || !$user_b) { 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; return;
} }

View File

@ -41,7 +41,7 @@ class TwitapihelpAction extends TwitterapiAction
print '"ok"'; print '"ok"';
$this->end_document('json'); $this->end_document('json');
} else { } else {
common_user_error(_('API method not found!'), $code=404); $this->clientError(_('API method not found!'), $code=404);
} }
} }
@ -49,7 +49,7 @@ class TwitapihelpAction extends TwitterapiAction
function downtime_schedule($args, $apidata) function downtime_schedule($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); $this->serverError(_('API method under construction.'), $code=501);
} }
} }

View File

@ -79,7 +79,7 @@ class TwitapilaconicaAction extends TwitterapiAction
$this->end_document('json'); $this->end_document('json');
break; break;
default: default:
$this->client_error(_('API method not found!'), $code=404); $this->clientError(_('API method not found!'), $code=404);
} }
} }
@ -148,7 +148,7 @@ class TwitapilaconicaAction extends TwitterapiAction
$this->end_document('json'); $this->end_document('json');
break; break;
default: default:
$this->client_error(_('API method not found!'), $code=404); $this->clientError(_('API method not found!'), $code=404);
} }
} }
@ -169,6 +169,6 @@ class TwitapilaconicaAction extends TwitterapiAction
function wadl($args, $apidata) function wadl($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), 501); $this->serverError(_('API method under construction.'), 501);
} }
} }

View File

@ -28,13 +28,13 @@ class TwitapinotificationsAction extends TwitterapiAction
function follow($args, $apidata) function follow($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); $this->serverError(_('API method under construction.'), $code=501);
} }
function leave($args, $apidata) function leave($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); $this->serverError(_('API method under construction.'), $code=501);
} }
} }

View File

@ -76,12 +76,12 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_json_timeline($notice); $this->show_json_timeline($notice);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
break; break;
} }
} else { } else {
common_server_error(_('Couldn\'t find any statuses.'), $code = 503); $this->serverError(_('Couldn\'t find any statuses.'), $code = 503);
} }
} }
@ -144,7 +144,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_json_timeline($notice); $this->show_json_timeline($notice);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
} }
} }
@ -157,14 +157,14 @@ class TwitapistatusesAction extends TwitterapiAction
$user = $this->get_user($apidata['api_arg'], $apidata); $user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) { if (!$user) {
$this->client_error('Not Found', 404, $apidata['content-type']); $this->clientError('Not Found', 404, $apidata['content-type']);
return; return;
} }
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -225,7 +225,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_json_timeline($notice); $this->show_json_timeline($notice);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
} }
} }
@ -236,12 +236,12 @@ class TwitapistatusesAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
if ($_SERVER['REQUEST_METHOD'] != 'POST') { 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; return;
} }
@ -273,7 +273,7 @@ class TwitapistatusesAction extends TwitterapiAction
// as "truncated." Sending this error may screw up some clients // as "truncated." Sending this error may screw up some clients
// that assume Twitter will truncate for them. Should we just // that assume Twitter will truncate for them. Should we just
// truncate too? -- Zach // 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; return;
} }
@ -306,7 +306,7 @@ class TwitapistatusesAction extends TwitterapiAction
if ($reply) { if ($reply) {
$reply_to = $in_reply_to_status_id; $reply_to = $in_reply_to_status_id;
} else { } else {
$this->client_error(_('Not found'), $code = 404, $apidata['content-type']); $this->clientError(_('Not found'), $code = 404, $apidata['content-type']);
return; return;
} }
} }
@ -315,7 +315,7 @@ class TwitapistatusesAction extends TwitterapiAction
$source, 1, $reply_to); $source, 1, $reply_to);
if (is_string($notice)) { if (is_string($notice)) {
$this->server_error($notice); $this->serverError($notice);
return; return;
} }
@ -389,7 +389,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_json_timeline($notices); $this->show_json_timeline($notices);
break; break;
default: default:
common_user_error(_('API method not found!'), $code = 404); $this->clientError(_('API method not found!'), $code = 404);
} }
} }
@ -399,7 +399,7 @@ class TwitapistatusesAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
@ -415,7 +415,7 @@ class TwitapistatusesAction extends TwitterapiAction
} }
} else { } else {
// XXX: Twitter just sets a 404 header and doens't bother to return an err msg // 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']);
} }
} }
@ -426,14 +426,14 @@ class TwitapistatusesAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
// Check for RESTfulness // Check for RESTfulness
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
// XXX: Twitter just prints the err msg, no XML / JSON. // 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; return;
} }
@ -443,7 +443,7 @@ class TwitapistatusesAction extends TwitterapiAction
$notice = Notice::staticGet($notice_id); $notice = Notice::staticGet($notice_id);
if (!$notice) { 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; return;
} }
@ -460,7 +460,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_single_json_status($notice); $this->show_single_json_status($notice);
} }
} else { } 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']);
} }
} }
@ -487,7 +487,7 @@ class TwitapistatusesAction extends TwitterapiAction
$user = $this->get_user($apidata['api_arg'], $apidata); $user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) { if (!$user) {
$this->client_error('Not Found', 404, $apidata['content-type']); $this->clientError('Not Found', 404, $apidata['content-type']);
return; return;
} }
@ -500,7 +500,7 @@ class TwitapistatusesAction extends TwitterapiAction
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_server_error(_('User has no profile.')); $this->serverError(_('User has no profile.'));
return; return;
} }
@ -552,14 +552,14 @@ class TwitapistatusesAction extends TwitterapiAction
print json_encode($arrays); print json_encode($arrays);
break; break;
default: default:
$this->client_error(_('unsupported file type')); $this->clientError(_('unsupported file type'));
} }
} }
function featured($args, $apidata) function featured($args, $apidata)
{ {
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); $this->serverError(_('API method under construction.'), $code=501);
} }
function supported($cmd) function supported($cmd)

View File

@ -29,7 +29,7 @@ class TwitapiusersAction extends TwitterapiAction
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { 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; return;
} }
@ -44,7 +44,7 @@ class TwitapiusersAction extends TwitterapiAction
if (!$user) { if (!$user) {
// XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach // 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; return;
} }

View File

@ -285,7 +285,7 @@ class TwittersettingsAction extends SettingsAction
if (!$result) { if (!$result) {
common_log_db_error($flink, 'DELETE', __FILE__); common_log_db_error($flink, 'DELETE', __FILE__);
common_server_error(_('Couldn\'t remove Twitter user.')); $this->serverError(_('Couldn\'t remove Twitter user.'));
return; return;
} }

View File

@ -30,28 +30,28 @@ class UnblockAction extends Action
parent::prepare($args); parent::prepare($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return false; return false;
} }
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
$id = $this->trimmed('unblockto'); $id = $this->trimmed('unblockto');
if (!$id) { if (!$id) {
$this->client_error(_('No profile specified.')); $this->clientError(_('No profile specified.'));
return false; return false;
} }
$this->profile = Profile::staticGet('id', $id); $this->profile = Profile::staticGet('id', $id);
if (!$this->profile) { if (!$this->profile) {
$this->client_error(_('No profile with that ID.')); $this->clientError(_('No profile with that ID.'));
return false; return false;
} }
@ -74,7 +74,7 @@ class UnblockAction extends Action
$result = $cur->unblock($this->profile); $result = $cur->unblock($this->profile);
if (!$result) { if (!$result) {
$this->server_error(_('Error removing the block.')); $this->serverError(_('Error removing the block.'));
return; return;
} }

View File

@ -24,7 +24,7 @@ class UnsubscribeAction extends Action
{ {
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); $this->clientError(_('Not logged in.'));
return; return;
} }
@ -40,28 +40,28 @@ class UnsubscribeAction extends Action
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_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; return;
} }
$other_id = $this->arg('unsubscribeto'); $other_id = $this->arg('unsubscribeto');
if (!$other_id) { if (!$other_id) {
$this->client_error(_('No profile id in request.')); $this->clientError(_('No profile id in request.'));
return; return;
} }
$other = Profile::staticGet('id', $other_id); $other = Profile::staticGet('id', $other_id);
if (!$other_id) { if (!$other_id) {
$this->client_error(_('No profile with that id.')); $this->clientError(_('No profile with that id.'));
return; return;
} }
$result = subs_unsubscribe_to($user, $other); $result = subs_unsubscribe_to($user, $other);
if ($result != true) { if ($result != true) {
common_user_error($result); $this->clientError($result);
return; return;
} }

View File

@ -37,7 +37,7 @@ class UpdateprofileAction extends Action
print "omb_version=".OMB_VERSION_01; print "omb_version=".OMB_VERSION_01;
} }
} catch (OAuthException $e) { } catch (OAuthException $e) {
$this->server_error($e->getMessage()); $this->serverError($e->getMessage());
return; return;
} }
} }
@ -46,14 +46,14 @@ class UpdateprofileAction extends Action
{ {
$version = $req->get_parameter('omb_version'); $version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) { if ($version != OMB_VERSION_01) {
$this->client_error(_('Unsupported OMB version'), 400); $this->clientError(_('Unsupported OMB version'), 400);
return false; return false;
} }
# First, check to see if listenee exists # First, check to see if listenee exists
$listenee = $req->get_parameter('omb_listenee'); $listenee = $req->get_parameter('omb_listenee');
$remote = Remote_profile::staticGet('uri', $listenee); $remote = Remote_profile::staticGet('uri', $listenee);
if (!$remote) { if (!$remote) {
$this->client_error(_('Profile unknown'), 404); $this->clientError(_('Profile unknown'), 404);
return false; return false;
} }
# Second, check to see if they should be able to post updates! # Second, check to see if they should be able to post updates!
@ -64,72 +64,72 @@ class UpdateprofileAction extends Action
$sub->subscribed = $remote->id; $sub->subscribed = $remote->id;
$sub->token = $token->key; $sub->token = $token->key;
if (!$sub->find(true)) { 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; return false;
} }
$profile = Profile::staticGet('id', $remote->id); $profile = Profile::staticGet('id', $remote->id);
if (!$profile) { if (!$profile) {
# This one is our fault # 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; return false;
} }
$nickname = $req->get_parameter('omb_listenee_nickname'); $nickname = $req->get_parameter('omb_listenee_nickname');
if ($nickname && !Validate::string($nickname, array('min_length' => 1, if ($nickname && !Validate::string($nickname, array('min_length' => 1,
'max_length' => 64, 'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { '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; return false;
} }
$license = $req->get_parameter('omb_listenee_license'); $license = $req->get_parameter('omb_listenee_license');
if ($license && !common_valid_http_url($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; return false;
} }
$profile_url = $req->get_parameter('omb_listenee_profile'); $profile_url = $req->get_parameter('omb_listenee_profile');
if ($profile_url && !common_valid_http_url($profile_url)) { 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; return false;
} }
# optional stuff # optional stuff
$fullname = $req->get_parameter('omb_listenee_fullname'); $fullname = $req->get_parameter('omb_listenee_fullname');
if ($fullname && strlen($fullname) > 255) { 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; return false;
} }
$homepage = $req->get_parameter('omb_listenee_homepage'); $homepage = $req->get_parameter('omb_listenee_homepage');
if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) { 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; return false;
} }
$bio = $req->get_parameter('omb_listenee_bio'); $bio = $req->get_parameter('omb_listenee_bio');
if ($bio && strlen($bio) > 140) { 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; return false;
} }
$location = $req->get_parameter('omb_listenee_location'); $location = $req->get_parameter('omb_listenee_location');
if ($location && strlen($location) > 255) { 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; return false;
} }
$avatar = $req->get_parameter('omb_listenee_avatar'); $avatar = $req->get_parameter('omb_listenee_avatar');
if ($avatar) { if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) { 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; return false;
} }
$size = @getimagesize($avatar); $size = @getimagesize($avatar);
if (!$size) { 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; return false;
} }
if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) { 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; return false;
} }
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
IMAGETYPE_PNG))) { IMAGETYPE_PNG))) {
$this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar)); $this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
return false; return false;
} }
} }
@ -156,14 +156,14 @@ class UpdateprofileAction extends Action
} }
if (!$profile->update($orig_profile)) { 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; return false;
} else { } else {
if ($avatar) { if ($avatar) {
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar'); $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
copy($avatar, $temp_filename); copy($avatar, $temp_filename);
if (!$profile->setOriginal($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; return false;
} }
} }

View File

@ -54,7 +54,7 @@ class UserauthorizationAction extends Action
common_debug('getting new request', __FILE__); common_debug('getting new request', __FILE__);
$req = $this->get_new_request(); $req = $this->get_new_request();
if (!$req) { if (!$req) {
$this->client_error(_('No request found!')); $this->clientError(_('No request found!'));
} }
common_debug('validating request', __FILE__); common_debug('validating request', __FILE__);
# XXX: only validate new requests, since nonce is one-time use # XXX: only validate new requests, since nonce is one-time use
@ -64,7 +64,7 @@ class UserauthorizationAction extends Action
$this->show_form($req); $this->show_form($req);
} catch (OAuthException $e) { } catch (OAuthException $e) {
$this->clear_request(); $this->clear_request();
$this->client_error($e->getMessage()); $this->clientError($e->getMessage());
return; return;
} }
@ -137,7 +137,7 @@ class UserauthorizationAction extends Action
$req = $this->get_stored_request(); $req = $this->get_stored_request();
if (!$req) { if (!$req) {
common_user_error(_('No authorization request!')); $this->clientError(_('No authorization request!'));
return; return;
} }
@ -145,10 +145,10 @@ class UserauthorizationAction extends Action
if ($this->arg('accept')) { if ($this->arg('accept')) {
if (!$this->authorize_token($req)) { if (!$this->authorize_token($req)) {
$this->client_error(_('Error authorizing token')); $this->clientError(_('Error authorizing token'));
} }
if (!$this->save_remote_profile($req)) { if (!$this->save_remote_profile($req)) {
$this->client_error(_('Error saving remote profile')); $this->clientError(_('Error saving remote profile'));
} }
if (!$callback) { if (!$callback) {
$this->show_accept_message($req->get_parameter('oauth_token')); $this->show_accept_message($req->get_parameter('oauth_token'));
@ -160,7 +160,7 @@ class UserauthorizationAction extends Action
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__); common_log_db_error($user, 'SELECT', __FILE__);
$this->server_error(_('User without matching profile')); $this->serverError(_('User without matching profile'));
return; return;
} }
$params['omb_listener_nickname'] = $user->nickname; $params['omb_listener_nickname'] = $user->nickname;

View File

@ -32,11 +32,11 @@ class UserbyidAction extends Action
parent::handle($args); parent::handle($args);
$id = $this->trimmed('id'); $id = $this->trimmed('id');
if (!$id) { if (!$id) {
$this->client_error(_('No id.')); $this->clientError(_('No id.'));
} }
$user =& User::staticGet($id); $user =& User::staticGet($id);
if (!$user) { if (!$user) {
$this->client_error(_('No such user.')); $this->clientError(_('No such user.'));
} }
// support redirecting to FOAF rdf/xml if the agent prefers it // support redirecting to FOAF rdf/xml if the agent prefers it

View File

@ -34,7 +34,7 @@ class UserrssAction extends Rss10Action
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
if (!$this->user) { if (!$this->user) {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
return false; return false;
} else { } else {
return true; return true;
@ -78,7 +78,7 @@ class UserrssAction extends Rss10Action
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__); common_log_db_error($user, 'SELECT', __FILE__);
$this->server_error(_('User without matching profile')); $this->serverError(_('User without matching profile'));
return null; return null;
} }
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);

View File

@ -35,7 +35,7 @@ class XrdsAction extends Action
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
if (!$user) { if (!$user) {
common_user_error(_('No such user.')); $this->clientError(_('No such user.'));
return; return;
} }
$this->show_xrds($user); $this->show_xrds($user);

View File

@ -528,14 +528,14 @@ class Action extends HTMLOutputter // lawsuit
} }
} }
function server_error($msg, $code=500) function serverError($msg, $code=500)
{ {
$action = $this->trimmed('action'); $action = $this->trimmed('action');
common_debug("Server error '$code' on '$action': $msg", __FILE__); common_debug("Server error '$code' on '$action': $msg", __FILE__);
common_server_error($msg, $code); common_server_error($msg, $code);
} }
function client_error($msg, $code=400) function clientError($msg, $code=400)
{ {
$action = $this->trimmed('action'); $action = $this->trimmed('action');
common_debug("User error '$code' on '$action': $msg", __FILE__); common_debug("User error '$code' on '$action': $msg", __FILE__);