mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Merge pull request #1884 from aztech-dev/feature/api-databox-rights
PHRAS-572 List user rights by databox in /me route
This commit is contained in:
@@ -770,6 +770,32 @@ class V1Controller extends Controller
|
|||||||
return $grants;
|
return $grants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function listUserDataboxes(User $user)
|
||||||
|
{
|
||||||
|
$acl = $this->getAclForUser($user);
|
||||||
|
$rightsByDatabox = $acl->get_sbas_rights();
|
||||||
|
$grants = [];
|
||||||
|
|
||||||
|
foreach ($rightsByDatabox as $databoxId => $databoxRights) {
|
||||||
|
$rights = [];
|
||||||
|
|
||||||
|
foreach ($databoxRights as $name => $allowedFlag) {
|
||||||
|
if (! $allowedFlag) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rights[] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$grants[] = [
|
||||||
|
'databox_id' => $databoxId,
|
||||||
|
'rights' => $rights
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $grants;
|
||||||
|
}
|
||||||
|
|
||||||
private function listUserDemands(User $user)
|
private function listUserDemands(User $user)
|
||||||
{
|
{
|
||||||
return (new CollectionRequestMapper($this->app, $this->app['registration.manager']))->getUserRequests($user);
|
return (new CollectionRequestMapper($this->app, $this->app['registration.manager']))->getUserRequests($user);
|
||||||
@@ -2560,6 +2586,7 @@ class V1Controller extends Controller
|
|||||||
$ret = [
|
$ret = [
|
||||||
"user" => $this->listUser($this->getAuthenticatedUser()),
|
"user" => $this->listUser($this->getAuthenticatedUser()),
|
||||||
"collections" => $this->listUserCollections($this->getAuthenticatedUser()),
|
"collections" => $this->listUserCollections($this->getAuthenticatedUser()),
|
||||||
|
"databoxes" => $this->listUserDataboxes($this->getAuthenticatedUser())
|
||||||
];
|
];
|
||||||
|
|
||||||
if (defined('API_SKIP_USER_REGISTRATIONS') && ! constant('API_SKIP_USER_REGISTRATIONS')) {
|
if (defined('API_SKIP_USER_REGISTRATIONS') && ! constant('API_SKIP_USER_REGISTRATIONS')) {
|
||||||
|
|||||||
@@ -147,6 +147,18 @@ class ACL implements cache_cacheableInterface
|
|||||||
return self::$bas_rights;
|
return self::$bas_rights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of available rights by databox for the current user
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_sbas_rights()
|
||||||
|
{
|
||||||
|
$this->load_rights_sbas();
|
||||||
|
|
||||||
|
return $this->_rights_sbas;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a hd grant has been received for a record
|
* Check if a hd grant has been received for a record
|
||||||
*
|
*
|
||||||
@@ -580,10 +592,11 @@ class ACL implements cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user has the right, at least on one collection
|
* Check if the user has the right, on at least one collection
|
||||||
*
|
*
|
||||||
* @param string $right
|
* @param string $right
|
||||||
* @return boolean
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function has_right($right)
|
public function has_right($right)
|
||||||
{
|
{
|
||||||
@@ -598,9 +611,10 @@ class ACL implements cache_cacheableInterface
|
|||||||
/**
|
/**
|
||||||
* Check if the user has the required right on a database
|
* Check if the user has the required right on a database
|
||||||
*
|
*
|
||||||
* @param <type> $sbas_id
|
* @param int $sbas_id
|
||||||
* @param <type> $right
|
* @param string $right
|
||||||
* @return <type>
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function has_right_on_sbas($sbas_id, $right)
|
public function has_right_on_sbas($sbas_id, $right)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user