93 lines
4.2 KiB
PHP
93 lines
4.2 KiB
PHP
<?php
|
|
|
|
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
|
· ·
|
|
· ·
|
|
· Q V I T T E R ·
|
|
· ·
|
|
· http://github.com/hannesmannerheim/qvitter ·
|
|
· ·
|
|
· ·
|
|
· <o) ·
|
|
· /_//// ·
|
|
· (____/ ·
|
|
· (o< ·
|
|
· o> \\\\_\ ·
|
|
· \\) \____) ·
|
|
· ·
|
|
· ·
|
|
· ·
|
|
· Qvitter is free software: you can redistribute it and / or modify it ·
|
|
· under the terms of the GNU Affero General Public License as published by ·
|
|
· the Free Software Foundation, either version three of the License or (at ·
|
|
· your option) any later version. ·
|
|
· ·
|
|
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
|
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
|
|
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
|
|
· more details. ·
|
|
· ·
|
|
· You should have received a copy of the GNU Affero General Public License ·
|
|
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
|
· ·
|
|
· Contact h@nnesmannerhe.im if you have any questions. ·
|
|
· ·
|
|
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
|
|
|
if (!defined('GNUSOCIAL')) { exit(1); }
|
|
|
|
class ApiQvitterUpdateBackgroundColorAction extends ApiAuthAction
|
|
{
|
|
var $backgroundcolor = null;
|
|
|
|
protected $needPost = true;
|
|
|
|
/**
|
|
* Take arguments for running
|
|
*
|
|
* @param array $args $_REQUEST args
|
|
*
|
|
* @return boolean success flag
|
|
*/
|
|
protected function prepare(array $args=array())
|
|
{
|
|
parent::prepare($args);
|
|
|
|
$this->backgroundcolor = $this->trimmed('backgroundcolor');
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Handle the request
|
|
*
|
|
* Try to save the user's colors in her design. Create a new design
|
|
* if the user doesn't already have one.
|
|
*
|
|
* @param array $args $_REQUEST data (unused)
|
|
*
|
|
* @return void
|
|
*/
|
|
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);
|
|
}
|
|
|
|
Profile_prefs::setData($this->scoped, 'theme', 'backgroundcolor', $this->backgroundcolor);
|
|
|
|
// unset background-image
|
|
Profile_prefs::setData($this->scoped, 'qvitter', 'background_image', '');
|
|
|
|
$twitter_user = $this->twitterUserArray($this->scoped, true);
|
|
|
|
$this->initDocument('json');
|
|
$this->showJsonObjects($twitter_user);
|
|
$this->endDocument('json');
|
|
}
|
|
|
|
|
|
}
|