]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountupdatedeliverydevice.php
Profile/Peopletag file splitting for autoload
[quix0rs-gnu-social.git] / actions / apiaccountupdatedeliverydevice.php
index e25b9a954d1ada5e1fea82d9fa83a66ab8dfa92a..a3cbb418b65d60c899ca865fbbe9a34efcbc69e1 100644 (file)
@@ -32,8 +32,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Sets which channel (device) StatusNet delivers updates to for
  * the authenticating user. Sending none as the device parameter
@@ -45,18 +43,17 @@ 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
 {
+    protected $needPost = true;
+
     /**
      * Take arguments for running
      *
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
     function prepare($args)
     {
         parent::prepare($args);
@@ -76,43 +73,30 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
 
-        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-            $this->clientError(
-                _('This method requires a POST.'),
-                400, $this->format
-            );
-            return;
-        }
-
         if (!in_array($this->format, array('xml', 'json'))) {
             $this->clientError(
+                // TRANS: Client error displayed when coming across a non-supported API method.
                 _('API method not found.'),
                 404,
                 $this->format
             );
-            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.'
-                )
-            );
-            return;
+            // 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.' ));
         }
 
         if (empty($this->user)) {
-            $this->clientError(_('No such user.'), 404, $this->format);
-            return;
+            // TRANS: Client error displayed when no existing user is provided for a user's delivery device setting.
+            $this->clientError(_('No such user.'), 404);
         }
 
         $original = clone($this->user);
@@ -136,8 +120,8 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
 
         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;
         }
 
         $profile = $this->user->getProfile();
@@ -152,7 +136,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
 
         if ($this->format == 'xml') {
             $this->initDocument('xml');
-            $this->showTwitterXmlUser($twitter_user);
+            $this->showTwitterXmlUser($twitter_user, 'user', true);
             $this->endDocument('xml');
         } elseif ($this->format == 'json') {
             $this->initDocument('json');
@@ -160,5 +144,4 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
             $this->endDocument('json');
         }
     }
-
 }