X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapiaccountupdatedeliverydevice.php;h=d5be6dc6528cb77ab36c9d4e828f3ad5de310d95;hb=255ba42ef120a3ee0ac21c0c639730d8317b7e79;hp=5b7176bbbecb723839f4c0cf7e76d5a0d65b4065;hpb=4e4ba24c007fee94662018e7135f2db1e7c847b3;p=quix0rs-gnu-social.git diff --git a/actions/apiaccountupdatedeliverydevice.php b/actions/apiaccountupdatedeliverydevice.php index 5b7176bbbe..d5be6dc652 100644 --- a/actions/apiaccountupdatedeliverydevice.php +++ b/actions/apiaccountupdatedeliverydevice.php @@ -21,6 +21,7 @@ * * @category API * @package StatusNet + * @author Siebrand Mazeland * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -44,7 +45,6 @@ require_once INSTALLDIR . '/lib/apiauth.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction { /** @@ -55,7 +55,6 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction * @return boolean success flag * */ - function prepare($args) { parent::prepare($args); @@ -75,13 +74,13 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction * * @return void */ - function handle($args) { parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->clientError( + // TRANS: Client error message. POST is a HTTP command. It should not be translated. _('This method requires a POST.'), 400, $this->format ); @@ -90,6 +89,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction if (!in_array($this->format, array('xml', 'json'))) { $this->clientError( + // TRANS: Client error displayed handling a non-existing API method. _('API method not found.'), 404, $this->format @@ -97,17 +97,17 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction return; } + // Note: Twitter no longer supports IM + if (!in_array(strtolower($this->device), array('sms', 'im', 'none'))) { - $this->clientError( - _( - 'You must specify a parameter named ' . - '\'device\' with a value of one of: sms, im, none' - ) - ); + // TRANS: Client error displayed when no valid device parameter is provided for a user's delivery device setting. + $this->clientError(_( 'You must specify a parameter named ' . + '\'device\' with a value of one of: sms, im, none.' )); return; } if (empty($this->user)) { + // TRANS: Client error displayed when no existing user is provided for a user's delivery device setting. $this->clientError(_('No such user.'), 404, $this->format); return; } @@ -117,16 +117,23 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction if (strtolower($this->device) == 'sms') { $this->user->smsnotify = true; } elseif (strtolower($this->device) == 'im') { - $this->user->jabbernotify = true; + //TODO IM is pluginized now, so what should we do? + //Enable notifications for all IM plugins? + //For now, don't do anything + //$this->user->jabbernotify = true; } elseif (strtolower($this->device == 'none')) { $this->user->smsnotify = false; - $this->user->jabbernotify = false; + //TODO IM is pluginized now, so what should we do? + //Disable notifications for all IM plugins? + //For now, don't do anything + //$this->user->jabbernotify = false; } $result = $this->user->update($original); if ($result === false) { common_log_db_error($this->user, 'UPDATE', __FILE__); + // TRANS: Server error displayed when a user's delivery device cannot be updated. $this->serverError(_('Could not update user.')); return; } @@ -135,6 +142,12 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction $twitter_user = $this->twitterUserArray($profile, true); + // Note: this Twitter API method is retarded because it doesn't give + // any success/failure information. Twitter's docs claim that the + // notification field will change to reflect notification choice, + // but that's not true; notification> is used to indicate + // whether the auth user is following the user in question. + if ($this->format == 'xml') { $this->initDocument('xml'); $this->showTwitterXmlUser($twitter_user); @@ -145,5 +158,4 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction $this->endDocument('json'); } } - }