/**
  * Resets rights for a user.
  *
  * @param User $user
  */
 private function doResetAdminRights(User $user)
 {
     $acl = $this->ACLProvider->get($user);
     $databoxes = $this->appbox->get_databoxes();
     $acl->give_access_to_sbas(array_map(function (\databox $databox) {
         return $databox->get_sbas_id();
     }, $databoxes));
     foreach ($databoxes as $databox) {
         $this->doResetAdminRightsOnDatabox($acl, $databox);
     }
 }
 public function __construct(\appbox $appbox)
 {
     $this->setName('Databoxes structure');
     foreach ($appbox->get_databoxes() as $databox) {
         foreach ($databox->get_meta_structure() as $field) {
             $this->verifyDataboxField($databox->get_dbname(), $field->get_name(), $field->get_original_source(), $field->get_tag()->getTagname());
         }
     }
 }
 /**
  * Gets information about registration configuration and registration status if a user id is provided.
  *
  * @param null|user $user
  *
  * @return array
  */
 public function getRegistrationSummary(User $user = null)
 {
     $data = $userData = [];
     // Gets user data
     if (null !== $user) {
         $userData = $this->repository->getRegistrationsSummaryForUser($user);
     }
     foreach ($this->appbox->get_databoxes() as $databox) {
         $data[$databox->get_sbas_id()] = ['registrations' => ['by-type' => ['inactive' => [], 'accepted' => [], 'in-time' => [], 'out-dated' => [], 'pending' => [], 'rejected' => []]], 'config' => ['db-name' => $databox->get_dbname(), 'cgu' => $databox->get_cgus(), 'can-register' => $databox->isRegistrationEnabled(), 'collections' => []]];
         foreach ($databox->get_collections() as $collection) {
             // Sets collection info
             $data[$databox->get_sbas_id()]['config']['collections'][$collection->get_base_id()] = $this->getCollectionSummary($collection, $userData);
             // Sets registration by type
             if (null !== ($registration = $this->getUserCollectionRegistration($collection, $userData))) {
                 $data[$databox->get_sbas_id()]['registrations']['by-type'][$registration['type']][] = $registration;
             }
         }
     }
     return $data;
 }
Example #4
0
 public function __construct(\appbox $appbox)
 {
     $this->setName('Subdefs Paths');
     foreach ($appbox->get_databoxes() as $databox) {
         $this->ensureWriteableSubdefsPath($databox->get_dbname(), 'document', (string) $databox->get_sxml_structure()->path);
         foreach ($databox->get_subdef_structure() as $group => $subdefs) {
             foreach ($subdefs as $subdef) {
                 $this->ensureWriteableSubdefsPath($databox->get_dbname(), $group . '/' . $subdef->get_name(), (string) $databox->get_sxml_structure()->path);
             }
         }
     }
 }
 private function extractPath(\appbox $appbox)
 {
     $paths = [];
     foreach ($appbox->get_databoxes() as $databox) {
         $paths[] = (string) $databox->get_sxml_structure()->path;
         foreach ($databox->get_subdef_structure() as $group => $subdefs) {
             foreach ($subdefs as $subdef) {
                 $paths[] = $subdef->get_path();
             }
         }
     }
     return array_filter(array_unique($paths));
 }
 private function extractPath(\appbox $appbox)
 {
     $paths = [];
     foreach ($appbox->get_databoxes() as $databox) {
         foreach ($databox->get_subdef_structure() as $group => $subdefs) {
             if ('video' !== $group) {
                 continue;
             }
             foreach ($subdefs as $subdef) {
                 $paths[] = $subdef->get_path();
             }
         }
     }
     return array_filter(array_unique($paths));
 }
Example #7
0
 private function updateDataboxPrefs(\appbox $appbox)
 {
     foreach ($appbox->get_databoxes() as $databox) {
         $sql = 'SELECT id, locale FROM pref WHERE prop = "ToU"';
         $stmt = $databox->get_connection()->prepare($sql);
         $stmt->execute();
         $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
         $stmt->closeCursor();
         $sql = 'UPDATE pref SET locale = :locale WHERE id = :id';
         $stmt = $databox->get_connection()->prepare($sql);
         foreach ($rows as $row) {
             $stmt->execute([':locale' => $this->extractLocale($row['locale']), ':id' => $row['id']]);
         }
         $stmt->closeCursor();
     }
 }
 /**
  * @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;
 }
Example #9
0
 protected function get_feed(Application $app, appbox $appbox, User $user, $pub_restrict, $homelink)
 {
     $user_key = 'user_' . $user->getId();
     if ($homelink == '1') {
         $feed_key = 'feed_homelink';
     } elseif ($pub_restrict == '1') {
         $feed_key = 'feed_restricted';
     } else {
         $feed_key = 'feed_public';
     }
     if (!array_key_exists($user_key, self::$feeds) || !isset(self::$feeds[$user_key][$feed_key])) {
         if ($homelink == '1') {
             $title = $user->getDisplayName() . ' - ' . 'homelink Feed';
         } elseif ($pub_restrict == '1') {
             $title = $user->getDisplayName() . ' - ' . 'private Feed';
         } else {
             $title = $user->getDisplayName() . ' - ' . 'public Feed';
         }
         $feed = new Feed();
         $publisher = new FeedPublisher();
         $feed->setTitle('title');
         $feed->setSubtitle('');
         $feed->addPublisher($publisher);
         $publisher->setFeed($feed);
         $publisher->setIsOwner(true);
         $publisher->setUser($user);
         if ($homelink) {
             $feed->setIsPublic(true);
             $app['orm.em']->persist($feed);
             $app['orm.em']->persist($user);
             $app['orm.em']->flush();
         } elseif ($pub_restrict == 1) {
             $collections = $app->getAclForUser($user)->get_granted_base();
             $collection = array_shift($collections);
             if (!$collection instanceof collection) {
                 foreach ($appbox->get_databoxes() as $databox) {
                     foreach ($databox->get_collections() as $coll) {
                         $collection = $coll;
                         break;
                     }
                     if ($collection instanceof collection) {
                         break;
                     }
                 }
             }
             if (!$collection instanceof collection) {
                 return false;
             }
             $feed->setCollection($collection);
         }
         self::$feeds[$user_key][$feed_key] = $feed;
     } else {
         $feed = self::$feeds[$user_key][$feed_key];
     }
     return $feed;
 }
 private function getFlagsKey(\appbox $appbox)
 {
     $flags = [];
     foreach ($appbox->get_databoxes() as $databox) {
         $databoxId = $databox->get_sbas_id();
         $statusStructure = $databox->getStatusStructure();
         foreach ($statusStructure as $bit => $status) {
             $flags[$databoxId][$bit] = Flag::normalizeName($status['labelon']);
         }
     }
     return $flags;
 }
Example #11
0
 /**
  * Index the records flagged as "to_index" on all databoxes
  *
  * @param BulkOperation $bulk
  */
 public function indexScheduled(BulkOperation $bulk)
 {
     foreach ($this->appbox->get_databoxes() as $databox) {
         $this->indexScheduledInDatabox($bulk, $databox);
     }
 }