User safety settings

This commit is contained in:
Marcin Kurczewski
2013-10-14 00:25:40 +02:00
parent 11072779d9
commit 23fc89c30c
7 changed files with 157 additions and 22 deletions

View File

@ -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;
}
}