From b150cd89256e19a35fff12d25447dbe912c23d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Burnichon?= Date: Fri, 18 Mar 2016 00:51:27 +0100 Subject: [PATCH] Allow some Acl method to be used with RecordReference --- lib/classes/ACL.php | 56 ++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/lib/classes/ACL.php b/lib/classes/ACL.php index 395175e443..b57a6551ff 100644 --- a/lib/classes/ACL.php +++ b/lib/classes/ACL.php @@ -10,15 +10,11 @@ */ use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Model\Entities\User; -use Doctrine\DBAL\DBALException; -use Alchemy\Phrasea\Model\RecordInterface; - -use Alchemy\Phrasea\Core\Event\Acl\AclEvents; use Alchemy\Phrasea\Core\Event\Acl\AccessPeriodChangedEvent; use Alchemy\Phrasea\Core\Event\Acl\AccessToBaseGrantedEvent; use Alchemy\Phrasea\Core\Event\Acl\AccessToBaseRevokedEvent; use Alchemy\Phrasea\Core\Event\Acl\AccessToSbasGrantedEvent; +use Alchemy\Phrasea\Core\Event\Acl\AclEvents; use Alchemy\Phrasea\Core\Event\Acl\DownloadQuotasOnBaseChangedEvent; use Alchemy\Phrasea\Core\Event\Acl\DownloadQuotasOnBaseRemovedEvent; use Alchemy\Phrasea\Core\Event\Acl\DownloadQuotasResetEvent; @@ -26,6 +22,10 @@ use Alchemy\Phrasea\Core\Event\Acl\MasksOnBaseChangedEvent; use Alchemy\Phrasea\Core\Event\Acl\RightsToBaseChangedEvent; use Alchemy\Phrasea\Core\Event\Acl\RightsToSbasChangedEvent; use Alchemy\Phrasea\Core\Event\Acl\SysadminChangedEvent; +use Alchemy\Phrasea\Model\Entities\User; +use Alchemy\Phrasea\Model\RecordInterface; +use Alchemy\Phrasea\Model\RecordReferenceInterface; +use Doctrine\DBAL\DBALException; class ACL implements cache_cacheableInterface @@ -52,51 +52,40 @@ class ACL implements cache_cacheableInterface ]; /** - * - * @var user + * @var User */ protected $user; /** - * - * @var Array + * @var array */ protected $_rights_sbas; /** - * - * @var Array + * @var array */ protected $_rights_bas; /** - * - * @var Array + * @var array */ protected $_rights_records_document; /** - * - * @var Array + * @var array */ protected $_rights_records_preview; /** - * - * @var Array + * @var array */ protected $_limited; /** - * - * @var boolean + * @var bool */ protected $is_admin; - /** - * - * @var Array - */ protected $_global_rights = [ 'addrecord' => false, 'addtoalbum' => false, @@ -121,7 +110,6 @@ class ACL implements cache_cacheableInterface ]; /** - * * @var Application */ protected $app; @@ -140,15 +128,11 @@ class ACL implements cache_cacheableInterface * * @param User $user * @param Application $app - * - * @return \ACL */ public function __construct(User $user, Application $app) { $this->user = $user; $this->app = $app; - - return $this; } /** @@ -164,10 +148,10 @@ class ACL implements cache_cacheableInterface /** * Check if a hd grant has been received for a record * - * @param \record_adapter $record - * @return boolean + * @param RecordReferenceInterface $record + * @return bool */ - public function has_hd_grant(RecordInterface $record) + public function has_hd_grant(RecordReferenceInterface $record) { $this->load_hd_grant(); @@ -179,7 +163,7 @@ class ACL implements cache_cacheableInterface return false; } - public function grant_hd_on(RecordInterface $record, User $pusher, $action) + public function grant_hd_on(RecordReferenceInterface $record, User $pusher, $action) { $sql = 'REPLACE INTO records_rights (id, usr_id, sbas_id, record_id, document, `case`, pusher_usr_id) @@ -203,7 +187,7 @@ class ACL implements cache_cacheableInterface return $this; } - public function grant_preview_on(RecordInterface $record, User $pusher, $action) + public function grant_preview_on(RecordReferenceInterface $record, User $pusher, $action) { $sql = 'REPLACE INTO records_rights (id, usr_id, sbas_id, record_id, preview, `case`, pusher_usr_id) @@ -230,10 +214,10 @@ class ACL implements cache_cacheableInterface /** * Check if a hd grant has been received for a record * - * @param \record_adapter $record - * @return boolean + * @param RecordReferenceInterface $record + * @return bool */ - public function has_preview_grant(RecordInterface $record) + public function has_preview_grant(RecordReferenceInterface $record) { $this->load_hd_grant();