]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountupdateprofilecolors.php
Only unbind privacy checkbox when actually on mobile profile, oops.
[quix0rs-gnu-social.git] / actions / apiaccountupdateprofilecolors.php
index 3cac829749679353ec4fc608a2ee9894367698da..4fa85c68770f9bcf67b51e0da4ed213137e2aedf 100644 (file)
@@ -22,7 +22,7 @@
  * @category  API
  * @package   StatusNet
  * @author    Zach Copley <zach@status.net>
- * @copyright 2009 StatusNet, Inc.
+ * @copyright 2009-2010 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link      http://status.net/
  */
@@ -43,10 +43,8 @@ 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 ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 {
-
     var $profile_background_color     = null;
     var $profile_text_color           = null;
     var $profile_link_color           = null;
@@ -59,9 +57,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
      * @param array $args $_REQUEST args
      *
      * @return boolean success flag
-     *
      */
-
     function prepare($args)
     {
         parent::prepare($args);
@@ -100,13 +96,13 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
      *
      * @return void
      */
-
     function handle($args)
     {
         parent::handle($args);
 
         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
             $this->clientError(
+                // TRANS: Client error. POST is a HTTP command. It should not be translated.
                 _('This method requires a POST.'),
                 400, $this->format
             );
@@ -115,6 +111,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 
         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
@@ -125,13 +122,12 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
         $design = $this->user->getDesign();
 
         if (!empty($design)) {
-
             $original = clone($design);
 
             try {
                 $this->setColors($design);
             } catch (WebColorException $e) {
-                $this->clientError($e->getMessage());
+                $this->clientError($e->getMessage(), 400, $this->format);
                 return false;
             }
 
@@ -139,12 +135,11 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 
             if ($result === false) {
                 common_log_db_error($design, 'UPDATE', __FILE__);
+                // TRANS: Client error displayed when a database error occurs updating profile colours.
                 $this->clientError(_('Could not update your design.'));
                 return;
             }
-
         } else {
-
             $this->user->query('BEGIN');
 
             // save new design
@@ -153,7 +148,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
             try {
                 $this->setColors($design);
             } catch (WebColorException $e) {
-                $this->clientError($e->getMessage());
+                $this->clientError($e->getMessage(), 400, $this->format);
                 return false;
             }
 
@@ -161,6 +156,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 
             if (empty($id)) {
                 common_log_db_error($id, 'INSERT', __FILE__);
+                // TRANS: Client error displayed when a database error occurs inserting profile colours.
                 $this->clientError(_('Unable to save your design settings.'));
                 return;
             }
@@ -171,6 +167,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 
             if (empty($result)) {
                 common_log_db_error($original, 'UPDATE', __FILE__);
+                // TRANS: Client error displayed when a database error occurs updating profile colours.
                 $this->clientError(_('Unable to save your design settings.'));
                 $this->user->query('ROLLBACK');
                 return;
@@ -182,6 +179,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
         $profile = $this->user->getProfile();
 
         if (empty($profile)) {
+            // TRANS: Error message displayed when referring to a user without a profile.
             $this->clientError(_('User has no profile.'));
             return;
         }
@@ -190,7 +188,7 @@ class ApiAccountUpdateProfileColorsAction 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');
@@ -206,7 +204,6 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
      *
      * @return void
      */
-
     function setColors($design)
     {
         $bgcolor = empty($this->profile_background_color) ?
@@ -242,5 +239,4 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
 
         return true;
     }
-
 }