12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiAccountUpdateBackgroundColorAction extends ApiAuthAction
- {
- var $backgroundcolor = null;
- protected $needPost = true;
-
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- if ($this->format !== 'json') {
- $this->clientError('This method currently only serves JSON.', 415);
- }
- $this->backgroundcolor = $this->trimmed('backgroundcolor');
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
-
- $validhex = preg_match('/^[a-f0-9]{6}$/i',$this->backgroundcolor);
- if ($validhex === false || $validhex == 0) {
- $this->clientError(_('Not a valid hex color.'), 400);
- }
-
-
- $original = clone($this->auth_user);
- $this->auth_user->backgroundcolor = $this->backgroundcolor;
- if (!$this->auth_user->update($original)) {
- $this->clientError(_('Error updating user.'), 404);
- }
- $twitter_user = $this->twitterUserArray($this->scoped, true);
- $this->initDocument('json');
- $this->showJsonObjects($twitter_user);
- $this->endDocument('json');
- }
- }
|