acl table

This commit is contained in:
Yuri Kuznetsov
2014-04-07 15:46:44 +03:00
parent af0c09c88d
commit 36870f031f
3 changed files with 36 additions and 8 deletions
+1 -1
View File
@@ -24,6 +24,6 @@ namespace Espo\Controllers;
class Role extends \Espo\Core\Controllers\Record
{
}
+25 -2
View File
@@ -22,7 +22,30 @@
namespace Espo\Controllers;
class User extends \Espo\Core\Controllers\Record
{
use \Espo\Core\Exceptions\Error;
use \Espo\Core\Exceptions\NotFound;
use \Espo\Core\Exceptions\Forbidden;
class User extends \Espo\Core\Controllers\Record
{
public function actionAcl($params, $data, $request)
{
$userId = $request->get('id');
if (empty($userId)) {
throw new Error();
}
if (!$this->getUser()->isAdmin() && $this->getUser()->id != $userId) {
throw new Forbidden();
}
$user = $this->getEntityManager()->getEntity('User', $userId);
if (empty($user)) {
throw new NotFound();
}
$acl = new \Espo\Core\Acl($user);
return $acl->toArray();
}
}
+10 -5
View File
@@ -36,10 +36,9 @@ class Acl
private $fileManager;
public function __construct(\Espo\Entities\User $user, $config, $fileManager)
public function __construct(\Espo\Entities\User $user, $config = null, $fileManager = null)
{
$this->user = $user;
$this->fileManager = $fileManager;
$this->user = $user;
if (!$this->user->isFetched()) {
throw new Error();
@@ -47,17 +46,23 @@ class Acl
$this->user->loadLinkMultipleField('teams');
if ($fileManager) {
$this->fileManager = $fileManager;
}
$this->cacheFile = 'data/cache/application/acl/' . $user->id . '.php';
if ($config->get('useCache') && file_exists($this->cacheFile)) {
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
$cached = include $this->cacheFile;
} else {
$this->load();
$this->initSolid();
if ($config->get('useCache')) {
if ($config && $fileManager && $config->get('useCache')) {
$this->buildCache();
}
}
}
public function checkScope($scope, $action = null, $isOwner = null, $inTeam = null)