2016-03-01 03:37:06 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
· ·
|
|
|
|
· Unsandbox a user ·
|
|
|
|
· ·
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
· ·
|
|
|
|
· ·
|
|
|
|
· Q V I T T E R ·
|
|
|
|
· ·
|
|
|
|
· https://git.gnu.io/h2p/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 ApiQvitterSandboxDestroyAction extends ApiAuthAction
|
|
|
|
{
|
|
|
|
|
2016-03-01 09:08:55 +09:00
|
|
|
protected $needPost = true;
|
2016-03-01 03:37:06 +09:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Take arguments for running
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST args
|
|
|
|
*
|
|
|
|
* @return boolean success flag
|
|
|
|
*/
|
|
|
|
protected function prepare(array $args=array())
|
|
|
|
{
|
|
|
|
parent::prepare($args);
|
|
|
|
|
2016-03-01 09:08:55 +09:00
|
|
|
$this->format = 'json';
|
|
|
|
|
2016-03-01 03:37:06 +09:00
|
|
|
$this->other = $this->getTargetProfile($this->arg('id'));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the request
|
|
|
|
*
|
|
|
|
* @param array $args $_REQUEST data (unused)
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function handle()
|
|
|
|
{
|
|
|
|
parent::handle();
|
|
|
|
|
|
|
|
if (!$this->other instanceof Profile) {
|
|
|
|
$this->clientError(_('No such user.'), 404);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->scoped->id == $this->other->id) {
|
|
|
|
$this->clientError(_("You cannot unsandbox yourself!"), 403);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$this->scoped->hasRight(Right::SANDBOXUSER)) {
|
|
|
|
$this->clientError(_('You cannot unsandbox users on this site.'), 403);
|
|
|
|
}
|
|
|
|
|
|
|
|
// only unsandbox if the user is sandboxed
|
2016-03-01 09:08:55 +09:00
|
|
|
if ($this->other->isSandboxed()) {
|
2016-03-01 03:37:06 +09:00
|
|
|
try {
|
2016-03-01 09:08:55 +09:00
|
|
|
$this->other->unsandbox();
|
2016-03-01 03:37:06 +09:00
|
|
|
} catch (Exception $e) {
|
|
|
|
$this->clientError($e->getMessage(), $e->getCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->initDocument('json');
|
|
|
|
$this->showJsonObjects($this->twitterUserArray($this->other));
|
|
|
|
$this->endDocument('json');
|
|
|
|
}
|
|
|
|
}
|