123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiAccountUpdateLinkColorAction extends ApiAuthAction
- {
- var $linkcolor = 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->linkcolor = $this->trimmed('linkcolor');
- return true;
- }
-
- protected function handle()
- {
- parent::handle();
-
- $validhex = preg_match('/^[a-f0-9]{6}$/i',$this->linkcolor);
- if ($validhex === false || $validhex == 0) {
- $this->clientError(_('Not a valid hex color.'), 400);
- }
-
-
- $original = clone($this->auth_user);
- $this->auth_user->linkcolor = $this->linkcolor;
- if (!$this->auth_user->update($original)) {
- $this->clientError(_('Error updating user.'), 400);
- }
- $twitter_user = $this->twitterUserArray($this->scoped, true);
- $this->initDocument('json');
- $this->showJsonObjects($twitter_user);
- $this->endDocument('json');
- }
- }
|