/**
  * 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']);
 }
Esempio n. 2
0
 /**
  * Returns true if a collection is available given a configuration.
  *
  * @param \collection $collection
  *
  * @return Boolean
  */
 public function isCollectionAvailable(\collection $collection)
 {
     if (!$this->isRestricted()) {
         return true;
     }
     $availableCollections = $this->cache->fetch('available_collections_' . $collection->get_databox()->get_sbas_id()) ?: [];
     return in_array($collection->get_base_id(), $availableCollections, true);
 }
Esempio n. 3
0
 /**
  * Resets admin rights on a collection.
  *
  * @param \ACL        $acl
  * @param \collection $collection
  */
 private function doResetRightsOnCollection(\ACL $acl, \collection $collection)
 {
     $baseId = $collection->get_base_id();
     $acl->set_limits($baseId, false);
     $acl->remove_quotas_on_base($baseId);
     $acl->set_masks_on_base($baseId, '0', '0', '0', '0');
     $acl->update_rights_to_base($baseId, ['canputinalbum' => '1', 'candwnldhd' => '1', 'candwnldsubdef' => '1', 'nowatermark' => '1', 'candwnldpreview' => '1', 'cancmd' => '1', 'canadmin' => '1', 'canreport' => '1', 'canpush' => '1', 'creationdate' => '1', 'canaddrecord' => '1', 'canmodifrecord' => '1', 'candeleterecord' => '1', 'chgstatus' => '1', 'imgtools' => '1', 'manage' => '1', 'modify_struct' => '1', 'bas_modify_struct' => '1']);
 }
Esempio n. 4
0
 /**
  *
  * @param  collection $collection
  * @param  <type>     $ordre
  * @return appbox
  */
 public function set_collection_order(collection $collection, $ordre)
 {
     $sqlupd = "UPDATE bas SET ord = :ordre WHERE base_id = :base_id";
     $stmt = $this->get_connection()->prepare($sqlupd);
     $stmt->execute([':ordre' => $ordre, ':base_id' => $collection->get_base_id()]);
     $stmt->closeCursor();
     $collection->get_databox()->delete_data_from_cache(\databox::CACHE_COLLECTIONS);
     return $this;
 }
Esempio n. 5
0
 /**
  * Creates a EmptyCollection task given a collection
  *
  * @param \collection $collection
  *
  * @return Task
  */
 public function createEmptyCollectionJob(\collection $collection)
 {
     $job = new EmptyCollectionJob($this->translator);
     $settings = simplexml_load_string($job->getEditor()->getDefaultSettings());
     $settings->bas_id = $collection->get_base_id();
     $task = new Task();
     $task->setName($job->getName())->setJobId($job->getJobId())->setSettings($settings->asXML())->setPeriod($job->getEditor()->getDefaultPeriod());
     $this->om->persist($task);
     $this->om->flush();
     $this->notify(NotifierInterface::MESSAGE_CREATE);
     return $task;
 }
Esempio n. 6
0
 /**
  * Sets the user as "order_master" on a collection
  *
  * @param \collection $collection The collection to apply
  * @param Boolean     $bool       Wheter the user is order master or not
  *
  * @return ACL
  */
 public function set_order_master(\collection $collection, $bool)
 {
     $sql = 'UPDATE basusr SET order_master = :master
             WHERE usr_id = :usr_id AND base_id = :base_id';
     $stmt = $this->app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute([':master' => $bool ? 1 : 0, ':usr_id' => $this->user->getId(), ':base_id' => $collection->get_base_id()]);
     $stmt->closeCursor();
     return $this;
 }
Esempio n. 7
0
 /**
  * @param \collection $collection
  *
  * @return $this
  */
 public function setCollection(\collection $collection)
 {
     $this->baseId = $collection->get_base_id();
     return $this;
 }
Esempio n. 8
0
 /**
  * Sets the collection.
  *
  * @param \collection $collection
  *
  * @return void
  */
 public function setCollection(\collection $collection = null)
 {
     if ($collection === null) {
         $this->baseId = null;
         return;
     }
     $this->baseId = $collection->get_base_id();
 }
Esempio n. 9
0
 public function testGet_base_id()
 {
     $this->assertTrue(is_int(self::$object->get_base_id()));
     $this->assertTrue(self::$object->get_base_id() > 0);
 }
Esempio n. 10
0
 /**
  *
  * @param  collection     $collection
  * @param  appbox         $appbox
  * @return record_adapter
  */
 public function move_to_collection(collection $collection, appbox $appbox)
 {
     if ($this->get_collection()->get_base_id() === $collection->get_base_id()) {
         return $this;
     }
     $sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
     $params = [':coll_id' => $collection->get_coll_id(), ':record_id' => $this->get_record_id()];
     $stmt = $this->get_databox()->get_connection()->prepare($sql);
     $stmt->execute($params);
     $stmt->closeCursor();
     $this->base_id = $collection->get_base_id();
     $this->app['phraseanet.SE']->updateRecord($this);
     $this->app['phraseanet.logger']($this->get_databox())->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '');
     $this->delete_data_from_cache();
     return $this;
 }
 /**
  * Deletes registrations on given collection.
  *
  * @param $baseId
  */
 public function deleteRegistrationsOnCollection(\collection $collection)
 {
     $qb = $this->getRepository()->createQueryBuilder('d');
     $qb->delete('Phraseanet:Registration', 'd');
     $qb->where($qb->expr()->eq('d.baseId', ':base'));
     $qb->setParameter(':base', $collection->get_base_id());
     $qb->getQuery()->execute();
 }
Esempio n. 12
0
 /**
  * Retrieve detailled informations about one collection
  *
  * @param  collection $collection
  *
  * @return array
  */
 private function list_collection(\collection $collection)
 {
     return ['base_id' => $collection->get_base_id(), 'collection_id' => $collection->get_coll_id(), 'name' => $collection->get_name(), 'labels' => ['fr' => $collection->get_label('fr'), 'en' => $collection->get_label('en'), 'de' => $collection->get_label('de'), 'nl' => $collection->get_label('nl')], 'record_amount' => $collection->get_record_amount()];
 }
Esempio n. 13
0
 /**
  * Retrieve detailled informations about one collection
  *
  * @param  collection $collection
  * @return array
  */
 protected function list_collection(collection $collection)
 {
     $ret = ['base_id' => $collection->get_base_id(), 'collection_id' => $collection->get_coll_id(), 'name' => $collection->get_name(), 'labels' => ['fr' => $collection->get_label('fr'), 'en' => $collection->get_label('en'), 'de' => $collection->get_label('de'), 'nl' => $collection->get_label('nl')], 'record_amount' => $collection->get_record_amount()];
     return $ret;
 }