/** * @namespace */ namespace Application; use Bluz\Common\Nil; use Bluz\Proxy\Cache; use Bluz\Proxy\Messages; return function () { /** * @var Bootstrap $this */ if (!Cache::getInstance() instanceof Nil) { // routers Cache::delete('router:routers'); Cache::delete('router:reverse'); // roles Cache::deleteByTag('roles'); Cache::deleteByTag('privileges'); // reflection data Cache::deleteByTag('reflection'); // db metadata Cache::deleteByTag('db'); // view data Cache::deleteByTag('view'); // html data Cache::deleteByTag('html'); Messages::addSuccess("Cache is cleaned"); } else { Messages::addNotice("Cache is disabled"); }
* @accept HTML * @accept JSON * @privilege Management * * @param int $id * @return bool * @throws Exception */ return function ($id) { /** * @var Controller $this */ $user = Users\Table::findRow($id); if (!$user) { throw new Exception('User ID is incorrect'); } if (Request::isPost()) { $roles = Request::getParam('roles'); // update roles Db::delete('acl_users_roles')->where('userId = ?', $user->id)->execute(); foreach ($roles as $role) { Db::insert('acl_users_roles')->set('userId', $user->id)->set('roleId', $role)->execute(); } // clean cache Cache::delete('user:'******'User roles was updated'); return false; } $this->assign('user', $user); $this->assign('roles', Roles\Table::getInstance()->getRoles()); };