mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
User safety settings
This commit is contained in:
@ -19,4 +19,23 @@ class UserController
|
||||
$this->context->subTitle = $name;
|
||||
throw new SimpleException('Not implemented');
|
||||
}
|
||||
|
||||
/**
|
||||
* @route /user/toggle-safety/{safety}
|
||||
*/
|
||||
public function toggleSafetyAction($safety)
|
||||
{
|
||||
if (!$this->context->loggedIn)
|
||||
throw new SimpleException('Not logged in');
|
||||
|
||||
if (!in_array($safety, PostSafety::getAll()))
|
||||
throw new SimpleExcetpion('Invalid safety');
|
||||
|
||||
$this->context->user->enableSafety($safety,
|
||||
!$this->context->user->hasEnabledSafety($safety));
|
||||
|
||||
R::store($this->context->user);
|
||||
|
||||
$this->context->transport->success = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user