mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Merge pull request #3718 from alchemy-fr/PHRAS-2283-port-access-windows
PHRAS-2283 merge Port to 4.1 - Prod - Account- Refacto - Request collection access Autorisation windows
This commit is contained in:
@@ -31,15 +31,15 @@ class CollectionRequestMapper
|
||||
$demands = array();
|
||||
|
||||
foreach ($databoxStatuses as $databoxId => $data) {
|
||||
foreach ($data['registrations']['by-type']['pending'] as $collectionId => $waiting) {
|
||||
foreach (['registrations-by-type']['pending'] as $collectionId => $waiting) {
|
||||
$demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "pending");
|
||||
}
|
||||
|
||||
foreach ($data['registrations']['by-type']['rejected'] as $collectionId => $waiting) {
|
||||
foreach ($data['registrations-by-type']['rejected'] as $collectionId => $waiting) {
|
||||
$demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "rejected");
|
||||
}
|
||||
|
||||
foreach ($data['registrations']['by-type']['accepted'] as $collectionId => $waiting) {
|
||||
foreach ($data['registrations-by-type']['accepted'] as $collectionId => $waiting) {
|
||||
$demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "accepted");
|
||||
}
|
||||
}
|
||||
|
@@ -289,7 +289,7 @@ class RegistrationService
|
||||
* @param array $selectedCollections
|
||||
* @return \collection[]
|
||||
*/
|
||||
private function getAuthorizedCollections(array $selectedCollections = null)
|
||||
private function getAuthorizedCollections($selectedCollections)
|
||||
{
|
||||
$inscriptions = $this->registrationManager->getRegistrationSummary();
|
||||
$authorizedCollections = [];
|
||||
@@ -300,7 +300,7 @@ class RegistrationService
|
||||
continue;
|
||||
}
|
||||
|
||||
if (\igorw\get_in($inscriptions, [$databox->get_sbas_id(), 'config', 'collections', $collection->get_base_id(), 'can-register'])) {
|
||||
if (\igorw\get_in($inscriptions, [$databox->get_sbas_id(), 'collections', $collection->get_base_id(), 'can-register'])) {
|
||||
$authorizedCollections[$collection->get_base_id()] = $collection;
|
||||
}
|
||||
}
|
||||
|
@@ -63,142 +63,108 @@ class RegistrationManager
|
||||
}
|
||||
|
||||
foreach ($this->appbox->get_databoxes() as $databox) {
|
||||
$data[$databox->get_sbas_id()] = [
|
||||
$sbas_id = $databox->get_sbas_id();
|
||||
$data[$sbas_id] = [
|
||||
// Registrations on databox by type
|
||||
'registrations' => [
|
||||
'by-type' => [
|
||||
'inactive' => [],
|
||||
'accepted' => [],
|
||||
'in-time' => [],
|
||||
'out-dated' => [],
|
||||
'pending' => [],
|
||||
'rejected' => [],
|
||||
]
|
||||
'registrations-by-type' => [
|
||||
'active' => [],
|
||||
'inactive' => [],
|
||||
'accepted' => [],
|
||||
'in-time' => [],
|
||||
'out-dated' => [],
|
||||
'pending' => [],
|
||||
'rejected' => [],
|
||||
],
|
||||
// Registration configuration on databox and collections that belong to the databox
|
||||
'config' => [
|
||||
'db-name' => $databox->get_dbname(),
|
||||
'cgu' => $databox->get_cgus(),
|
||||
'can-register' => $databox->isRegistrationEnabled(),
|
||||
// Configuration on collection
|
||||
'collections' => [],
|
||||
]
|
||||
'db-name' => $databox->get_dbname(),
|
||||
'cgu' => $databox->get_cgus(),
|
||||
'can-register' => $databox->isRegistrationEnabled(),
|
||||
// Configuration on collection
|
||||
'collections' => [],
|
||||
'display' => false, // set to true if there is at least one collection to display
|
||||
];
|
||||
|
||||
foreach ($databox->get_collections() as $collection) {
|
||||
$base_id = $collection->get_base_id();
|
||||
|
||||
$userRegistration = igorw\get_in($userData, [$sbas_id, $base_id]);
|
||||
|
||||
// Sets collection info
|
||||
$data[$databox->get_sbas_id()]['config']['collections'][$collection->get_base_id()] = $this->getCollectionSummary($collection, $userData);
|
||||
$data[$sbas_id]['collections'][$base_id] = [
|
||||
'coll-name' => $collection->get_label($this->locale),
|
||||
// gets collection registration or fallback to databox configuration
|
||||
'can-register' => $collection->isRegistrationEnabled(),
|
||||
// boolean to tell whether user has already requested an access to the collection
|
||||
'registration' => !is_null($userRegistration) && !is_null($userRegistration['active']),
|
||||
'type' => null
|
||||
];
|
||||
|
||||
// Sets registration by type
|
||||
if (null !== $registration = $this->getUserCollectionRegistration($collection, $userData)) {
|
||||
$data[$databox->get_sbas_id()]['registrations']['by-type'][$registration['type']][] = $registration;
|
||||
if (!is_null($userRegistration)) { // && !is_null($userRegistration['active'])) {
|
||||
|
||||
$userRegistration['coll-name'] = $collection->get_label($this->locale);
|
||||
$userRegistration['can-register'] = $collection->isRegistrationEnabled();
|
||||
// sets default type
|
||||
$type = 'inactive';
|
||||
|
||||
// gets registration entity
|
||||
$registration = $userRegistration['registration'];
|
||||
|
||||
if(!is_null($userRegistration['active'])) {
|
||||
// rights are set in basusr, we don't really care about registration
|
||||
$isTimeLimited = (Boolean) $userRegistration['time-limited'];
|
||||
if($isTimeLimited) {
|
||||
// any time limit overrides (=automates) the 'active' value
|
||||
$isOnTime = (Boolean) $userRegistration['in-time'];
|
||||
$type = $isOnTime ? 'in-time' : 'out-dated';
|
||||
}
|
||||
else {
|
||||
// no time limit, use the 'active' value - but be nice if this is the result of registration
|
||||
$isPending = !is_null($registration) && $registration->isPending();
|
||||
$isRejected = !is_null($registration) && !$isPending && $registration->isRejected();
|
||||
$isAccepted = !is_null($registration) && !$isPending && !$isRejected;
|
||||
if ($userRegistration['active'] === false) {
|
||||
// no access
|
||||
$type = $isRejected ? 'rejected' : 'inactive';
|
||||
}
|
||||
else {
|
||||
// access
|
||||
$type = $isAccepted ? 'accepted' : 'active';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// nothing in basusr, use only registration
|
||||
if(is_null($registration)) {
|
||||
// no registration
|
||||
$type = 'inactive';
|
||||
}
|
||||
else {
|
||||
// something in registration
|
||||
$isPending = $registration->isPending();
|
||||
$isRejected = !$isPending && $registration->isRejected();
|
||||
if($isPending) {
|
||||
$type = 'pending';
|
||||
}
|
||||
else {
|
||||
$type = $isRejected ? 'rejected' : 'accepted';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the twig template will not display an inactive collection, unless it is registrable
|
||||
if($type !== 'inactive' || $collection->isRegistrationEnabled()) {
|
||||
// at least one collection is displayed so the dbox must be displayed
|
||||
$data[$sbas_id]['display'] = true;
|
||||
}
|
||||
|
||||
$userRegistration['type'] = $type;
|
||||
$data[$sbas_id]['collections'][$base_id]['type'] = $type;
|
||||
$data[$sbas_id]['registrations-by-type'][$type][] = $userRegistration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether user has ever requested a registration on collection or not.
|
||||
*
|
||||
* @param \collection $collection
|
||||
* @param $userData
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function userHasRequestedARegistrationOnCollection(\collection $collection, $userData)
|
||||
{
|
||||
if (null === $userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !is_null($userRegistration['active']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user registration for given collection or null if no registration were requested.
|
||||
*
|
||||
* @param \collection $collection
|
||||
* @param $userData
|
||||
*
|
||||
* @return null|array
|
||||
*/
|
||||
private function getUserCollectionRegistration(\collection $collection, $userData)
|
||||
{
|
||||
if (false === $this->userHasRequestedARegistrationOnCollection($collection, $userData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$userRegistration = igorw\get_in($userData, [$collection->get_sbas_id(), $collection->get_base_id()]);
|
||||
|
||||
// sets collection name
|
||||
$userRegistration['coll-name'] = $collection->get_label($this->locale);
|
||||
// sets default type
|
||||
$userRegistration['type'] = 'active';
|
||||
|
||||
// gets registration entity
|
||||
$registration = $userRegistration['registration'];
|
||||
|
||||
// set registration type & return user registration
|
||||
$registrationStillExists = !is_null($registration);
|
||||
$registrationNoMoreExists = !$registrationStillExists;
|
||||
$isPending = $registrationStillExists && $registration->isPending() && !$registration->isRejected();
|
||||
$isRejected = $registrationStillExists && $registration->isRejected();
|
||||
$isDone = ($registrationNoMoreExists) || (!$isPending && !$isRejected);
|
||||
$isActive = (Boolean) $userRegistration['active'];
|
||||
$isTimeLimited = (Boolean) $userRegistration['time-limited'];
|
||||
$isNotTimeLimited = !$isTimeLimited;
|
||||
$isOnTime = (Boolean) $userRegistration['in-time'];
|
||||
$isOutDated = !$isOnTime;
|
||||
|
||||
if (!$isActive) {
|
||||
$userRegistration['type'] = 'inactive';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
if ($isDone) {
|
||||
$userRegistration['type'] = 'accepted';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
if ($isRejected) {
|
||||
$userRegistration['type'] = 'rejected';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
if ($isTimeLimited && $isOnTime && $isPending) {
|
||||
$userRegistration['type'] = 'in-time';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
if ($isTimeLimited && $isOutDated && $isPending) {
|
||||
$userRegistration['type'] = 'out-dated';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
if ($isNotTimeLimited && $isPending) {
|
||||
$userRegistration['type'] = 'pending';
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
return $userRegistration;
|
||||
}
|
||||
|
||||
private function getCollectionSummary(\collection $collection, $userData)
|
||||
{
|
||||
return [
|
||||
'coll-name' => $collection->get_label($this->locale),
|
||||
// gets collection registration or fallback to databox configuration
|
||||
'can-register' => $collection->isRegistrationEnabled(),
|
||||
'cgu' => $collection->getTermsOfUse(),
|
||||
// boolean to tell whether user has already requested an access to the collection
|
||||
'registration' => $this->userHasRequestedARegistrationOnCollection($collection, $userData)
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -73,8 +73,8 @@ class PhraseaRegisterForm extends AbstractType
|
||||
$choices = $baseIds = [];
|
||||
|
||||
foreach ($this->app['registration.manager']->getRegistrationSummary() as $baseInfo) {
|
||||
$dbName = $baseInfo['config']['db-name'];
|
||||
foreach ($baseInfo['config']['collections'] as $baseId => $collInfo) {
|
||||
$dbName = $baseInfo['db-name'];
|
||||
foreach ($baseInfo['collections'] as $baseId => $collInfo) {
|
||||
if (false === $collInfo['can-register']) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -84,40 +84,59 @@ class RegistrationRepository extends EntityRepository
|
||||
$data = [];
|
||||
$rsm = $this->createResultSetMappingBuilder('d');
|
||||
$rsm->addScalarResult('sbas_id','sbas_id');
|
||||
$rsm->addScalarResult('base_id','base_id');
|
||||
$rsm->addScalarResult('bas_id','bas_id');
|
||||
$rsm->addScalarResult('dbname','dbname');
|
||||
$rsm->addScalarResult('time_limited', 'time_limited');
|
||||
$rsm->addScalarResult('limited_from', 'limited_from');
|
||||
$rsm->addScalarResult('limited_to', 'limited_to');
|
||||
$rsm->addScalarResult('actif', 'actif');
|
||||
|
||||
$sql = "
|
||||
SELECT dbname, sbas.sbas_id, time_limited,
|
||||
UNIX_TIMESTAMP( limited_from ) AS limited_from,
|
||||
UNIX_TIMESTAMP( limited_to ) AS limited_to,
|
||||
bas.server_coll_id, Users.id, basusr.actif,
|
||||
bas.base_id, " . $rsm->generateSelectClause(['d' => 'd',]) . "
|
||||
FROM (Users, bas, sbas)
|
||||
LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )
|
||||
LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )
|
||||
WHERE basusr.actif = 1 AND bas.sbas_id = sbas.sbas_id
|
||||
AND Users.id = ?";
|
||||
// nb: UNIX_TIMESTAMP will return null if date is 0000-00-00 00:00:00
|
||||
$sql = "SELECT dbname, sbas.sbas_id, time_limited,\n"
|
||||
. " UNIX_TIMESTAMP( limited_from ) AS limited_from,\n"
|
||||
. " UNIX_TIMESTAMP( limited_to ) AS limited_to,\n"
|
||||
. " bas.server_coll_id, Users.id, basusr.actif,\n"
|
||||
. " bas.base_id AS bas_id, " . $rsm->generateSelectClause(['d' => 'd',]) . "\n"
|
||||
. "FROM (Users, bas, sbas)\n"
|
||||
. " LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )\n"
|
||||
. " LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )\n"
|
||||
. "WHERE bas.active = 1 AND bas.sbas_id = sbas.sbas_id\n"
|
||||
. " AND Users.id = ?\n"
|
||||
. " AND ISNULL(model_of)";
|
||||
|
||||
$query = $this->_em->createNativeQuery($sql, $rsm);
|
||||
$query->setParameter(1, $user->getId());
|
||||
|
||||
foreach ($query->getResult() as $row) {
|
||||
$registrationEntity = $row[0];
|
||||
$data[$row['sbas_id']][$row['base_id']] = [
|
||||
'base-id' => $row['base_id'],
|
||||
$in_time = null;
|
||||
if(($row['time_limited'] !== null) && ($row['limited_from'] !== null || $row['limited_to'] !== null)) {
|
||||
$in_time = true;
|
||||
if($row['limited_from'] !== null && time() < $row['limited_from']) {
|
||||
$in_time = false;
|
||||
}
|
||||
elseif($row['limited_to'] !== null && time() > $row['limited_to']) {
|
||||
$in_time = false;
|
||||
}
|
||||
}
|
||||
$data[$row['sbas_id']][$row['bas_id']] = [
|
||||
'base-id' => $row['bas_id'],
|
||||
'db-name' => $row['dbname'],
|
||||
'active' => (Boolean) $row['actif'],
|
||||
'time-limited' => (Boolean) $row['time_limited'],
|
||||
'in-time' => $row['time_limited'] && ! ($row['limited_from'] >= time() && $row['limited_to'] <= time()),
|
||||
'active' => self::nullOrBoolean($row['actif']),
|
||||
'time-limited' => self::nullOrBoolean($row['time_limited']),
|
||||
'in-time' => $in_time,
|
||||
'registration' => $registrationEntity
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
public static function nullOrBoolean($v)
|
||||
{
|
||||
if(!is_null($v)) {
|
||||
$v = (boolean)$v;
|
||||
}
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
@@ -821,22 +821,6 @@ class collection implements ThumbnailedElement, cache_cacheableInterface
|
||||
return $this->get_databox()->getAutoregisterModel($email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets terms of use.
|
||||
*
|
||||
* @return null|string
|
||||
*/
|
||||
public function getTermsOfUse()
|
||||
{
|
||||
if (false === $xml = simplexml_load_string($this->get_prefs())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($xml->xpath('/baseprefs/cgu') as $sbpcgu) {
|
||||
return $sbpcgu->saveXML();
|
||||
}
|
||||
}
|
||||
|
||||
public function get_cache_key($option = null)
|
||||
{
|
||||
return 'collection_' . $this->collectionVO->getCollectionId() . ($option ? '_' . $option : '');
|
||||
|
@@ -818,8 +818,8 @@ form[name=registerForm] .multiselect-container li.active label {
|
||||
}
|
||||
|
||||
form[name=registerForm] .multiselect b.caret {
|
||||
float: right;
|
||||
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
form[name=registerForm] .multiselect-group {
|
||||
@@ -1157,7 +1157,7 @@ h1, h2, h3, h4 {
|
||||
border-radius:10px;
|
||||
display:inline-block;
|
||||
position: relative;
|
||||
top: 0.35rem;
|
||||
top: -15px;
|
||||
}
|
||||
|
||||
#updatingDemand .icon.active {
|
||||
|
@@ -35,9 +35,9 @@
|
||||
{% if show == true %}
|
||||
<div class="registration">
|
||||
<div class="coll-name">
|
||||
<span>
|
||||
{{ collInfo["coll-name"] }}
|
||||
</span>
|
||||
<span>
|
||||
{{ collInfo["coll-name"] }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="icon-box">
|
||||
{% if type == 'registrable' %}
|
||||
@@ -47,23 +47,23 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="status-box">
|
||||
<span class="status {{ type }}" >
|
||||
{% if type == 'active' %}
|
||||
{{ "registration:collection.active" | trans }}
|
||||
{% elseif type == 'registrable' %}
|
||||
{{ "registration:collection.registrable" | trans }}
|
||||
{% elseif type == 'in-time' %}
|
||||
{{ "registration:collection.in-time" | trans }}
|
||||
{% elseif type == 'out-dated' %}
|
||||
{{ "registration:collection.out-dated" | trans }}
|
||||
{% elseif type == 'pending' %}
|
||||
{{ "registration:collection.pending" | trans }}
|
||||
{% elseif type == 'rejected' %}
|
||||
{{ "registration:collection.rejected" | trans }}
|
||||
{% elseif type == 'accepted' %}
|
||||
{{ "registration:collection.accepted" | trans }}
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="status {{ type }}" >
|
||||
{% if type == 'active' %}
|
||||
{{ "registration:collection.active" | trans }}
|
||||
{% elseif type == 'registrable' %}
|
||||
{{ "registration:collection.registrable" | trans }}
|
||||
{% elseif type == 'in-time' %}
|
||||
{{ "registration:collection.in-time" | trans }}
|
||||
{% elseif type == 'out-dated' %}
|
||||
{{ "registration:collection.out-dated" | trans }}
|
||||
{% elseif type == 'pending' %}
|
||||
{{ "registration:collection.pending" | trans }}
|
||||
{% elseif type == 'rejected' %}
|
||||
{{ "registration:collection.rejected" | trans }}
|
||||
{% elseif type == 'accepted' %}
|
||||
{{ "registration:collection.accepted" | trans }}
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@@ -67,7 +67,7 @@ class RegistrationManagerTest extends \PhraseanetTestCase
|
||||
$databox = current(self::$DI['app']->getDataboxes());
|
||||
$collection = current($databox->get_collections());
|
||||
|
||||
$this->assertEquals($value, count($rs[$databox->get_sbas_id()]['registrations']['by-type'][$type]));
|
||||
$this->assertEquals($value, count($rs[$databox->get_sbas_id()]['registrations-by-type'][$type]));
|
||||
}
|
||||
|
||||
public function userDataProvider()
|
||||
@@ -81,103 +81,121 @@ class RegistrationManagerTest extends \PhraseanetTestCase
|
||||
$rejectedRegistration = new Registration();
|
||||
$rejectedRegistration->setBaseId(1);
|
||||
$rejectedRegistration->setUser(new User());
|
||||
$rejectedRegistration->setPending(true);
|
||||
$rejectedRegistration->setPending(false);
|
||||
$rejectedRegistration->setRejected(true);
|
||||
|
||||
$acceptedRegistration = new Registration();
|
||||
$acceptedRegistration->setBaseId(1);
|
||||
$acceptedRegistration->setUser(new User());
|
||||
$acceptedRegistration->setPending(false);
|
||||
$acceptedRegistration->setRejected(false);
|
||||
|
||||
$registrations = [
|
||||
'pending' => $pendingRegistration,
|
||||
'accepted' => $acceptedRegistration,
|
||||
'rejected' => $rejectedRegistration,
|
||||
'inactive' => null
|
||||
];
|
||||
|
||||
$databox = current((new \appbox(new Application(Application::ENV_TEST)))->get_databoxes());
|
||||
$collection = current($databox->get_collections());
|
||||
|
||||
$noLimitedPendingRegistration = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => true,
|
||||
'time-limited' => false,
|
||||
'in-time' => null,
|
||||
'registration' => $pendingRegistration
|
||||
]
|
||||
]
|
||||
],
|
||||
'pending',
|
||||
1
|
||||
];
|
||||
$tests = [];
|
||||
|
||||
$rejectedRegistration = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'titi',
|
||||
'active' => true,
|
||||
'time-limited' => false,
|
||||
'in-time' => null,
|
||||
'registration' => $rejectedRegistration
|
||||
// ====== no access in basusr : result comes only from "registration" ======
|
||||
foreach($registrations as $k=>$registration) {
|
||||
// pending, accepted, rejected, inactive
|
||||
$tests[] = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => null,
|
||||
'time-limited' => null,
|
||||
'in-time' => null,
|
||||
'registration' => $registration
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'rejected',
|
||||
1
|
||||
];
|
||||
],
|
||||
$k,
|
||||
1
|
||||
];
|
||||
}
|
||||
|
||||
$noActiveRegistration = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => 1,
|
||||
'db-name' => 'tutu',
|
||||
'active' => false,
|
||||
'time-limited' => false,
|
||||
'in-time' => null,
|
||||
'registration' => $pendingRegistration
|
||||
// ======= rights with time limit : registration does not matter =======
|
||||
foreach($registrations as $registration) {
|
||||
$tests[] = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => true,
|
||||
'time-limited' => true,
|
||||
'in-time' => true,
|
||||
'registration' => $registration
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'inactive',
|
||||
1
|
||||
];
|
||||
|
||||
$limitedActiveIntimePendingRegistration = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'tata',
|
||||
'active' => true,
|
||||
'time-limited' => true,
|
||||
'in-time' => true,
|
||||
'registration' => $pendingRegistration
|
||||
],
|
||||
'in-time',
|
||||
1
|
||||
];
|
||||
$tests[] = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => true,
|
||||
'time-limited' => true,
|
||||
'in-time' => false,
|
||||
'registration' => $registration
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'in-time',
|
||||
1
|
||||
];
|
||||
],
|
||||
'out-dated',
|
||||
1
|
||||
];
|
||||
}
|
||||
|
||||
$limitedActiveOutdatedPendingRegistration = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toutou',
|
||||
'active' => true,
|
||||
'time-limited' => true,
|
||||
'in-time' => false,
|
||||
'registration' => $pendingRegistration
|
||||
// ======= rights, no time limit : registration may matter =======
|
||||
foreach($registrations as $k=>$registration) {
|
||||
// pending, accepted, rejected, inactive
|
||||
$tests[] = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => true,
|
||||
'time-limited' => false,
|
||||
'in-time' => null,
|
||||
'registration' => $registration
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'out-dated',
|
||||
1
|
||||
];
|
||||
],
|
||||
$k=='accepted' ? 'accepted' : 'active',
|
||||
1
|
||||
];
|
||||
$tests[] = [
|
||||
[
|
||||
$databox->get_sbas_id() => [
|
||||
$collection->get_base_id() => [
|
||||
'base-id' => $collection->get_base_id(),
|
||||
'db-name' => 'toto',
|
||||
'active' => false,
|
||||
'time-limited' => false,
|
||||
'in-time' => null,
|
||||
'registration' => $registration
|
||||
]
|
||||
]
|
||||
],
|
||||
$k=='rejected' ? 'rejected' : 'inactive',
|
||||
1
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
$noLimitedPendingRegistration,
|
||||
$noActiveRegistration,
|
||||
$limitedActiveIntimePendingRegistration,
|
||||
$limitedActiveOutdatedPendingRegistration,
|
||||
$rejectedRegistration
|
||||
];
|
||||
return $tests;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user