/**
  * @dataProvider userDataProvider
  */
 public function testGetRegistrationSummaryWithUserData($data, $type, $value)
 {
     $repoMock = $this->getMockBuilder('Alchemy\\Phrasea\\Model\\Repositories\\RegistrationRepository')->disableOriginalConstructor()->setMethods(['getRegistrationsSummaryForUser'])->getMock();
     $repoMock->expects($this->once())->method('getRegistrationsSummaryForUser')->will($this->returnValue($data));
     $service = new RegistrationManager(self::$DI['app']['phraseanet.appbox'], $repoMock, self::$DI['app']['locale']);
     $rs = $service->getRegistrationSummary(self::$DI['user']);
     $databox = current(self::$DI['app']->getDataboxes());
     $collection = current($databox->get_collections());
     $this->assertEquals($value, count($rs[$databox->get_sbas_id()]['registrations']['by-type'][$type]));
 }
 public function getUserRequests(User $user)
 {
     $databoxStatuses = $this->registrationManager->getRegistrationSummary($user);
     $demands = array();
     foreach ($databoxStatuses as $databoxId => $data) {
         foreach ($data['registrations']['by-type']['pending'] as $collectionId => $waiting) {
             $demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "pending");
         }
         foreach ($data['registrations']['by-type']['rejected'] as $collectionId => $waiting) {
             $demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "rejected");
         }
         foreach ($data['registrations']['by-type']['accepted'] as $collectionId => $waiting) {
             $demands[] = $this->mapCollectionStatus($databoxId, $collectionId, "accepted");
         }
     }
     return $demands;
 }
Exemplo n.º 3
0
 /**
  * @param array $selectedCollections
  * @return array
  */
 private function getAuthorizedCollections(array $selectedCollections = null)
 {
     $inscriptions = $this->registrationManager->getRegistrationSummary();
     $authorizedCollections = [];
     foreach ($this->appbox->get_databoxes() as $databox) {
         foreach ($databox->get_collections() as $collection) {
             if (null !== $selectedCollections && !in_array($collection->get_base_id(), $selectedCollections)) {
                 continue;
             }
             if ($canRegister = \igorw\get_in($inscriptions, [$databox->get_sbas_id(), 'config', 'collections', $collection->get_base_id(), 'can-register'])) {
                 $authorizedCollections[$collection->get_base_id()] = $canRegister;
             }
         }
     }
     return $authorizedCollections;
 }