Exemple #1
0
 /**
  *
  * @param  DOMDocument $dom_struct
  * @return databox
  */
 public function saveStructure(DOMDocument $dom_struct)
 {
     $dom_struct->documentElement->setAttribute("modification_date", $now = date("YmdHis"));
     $sql = "UPDATE pref SET value= :structure, updated_on= :now\n        WHERE prop='structure'";
     $this->structure = $dom_struct->saveXML();
     $stmt = $this->get_connection()->prepare($sql);
     $stmt->execute([':structure' => $this->structure, ':now' => $now]);
     $stmt->closeCursor();
     $this->_sxml_structure = $this->_dom_structure = $this->_xpath_structure = null;
     $this->meta_struct = null;
     $this->app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $this->delete_data_from_cache(self::CACHE_STRUCTURE);
     $this->delete_data_from_cache(self::CACHE_META_STRUCT);
     cache_databox::update($this->app, $this->id, 'structure');
     return $this;
 }
Exemple #2
0
 public function delete_data_from_cache($option = null)
 {
     switch ($option) {
         case self::CACHE_STATUS:
             $this->status = null;
             break;
         case self::CACHE_SUBDEFS:
             $this->subdefs = null;
             break;
         default:
             break;
     }
     $databox = $this->get_databox();
     \cache_databox::update($this->app, $this->get_sbas_id(), 'record', $this->get_record_id());
     return $databox->delete_data_from_cache($this->get_cache_key($option));
 }
Exemple #3
0
 public static function mount_collection(Application $app, databox $databox, $coll_id, User $user)
 {
     $sql = "INSERT INTO bas (base_id, active, server_coll_id, sbas_id, aliases, ord)\n            VALUES\n            (null, 1, :server_coll_id, :sbas_id, '', :ord)";
     $stmt = $databox->get_appbox()->get_connection()->prepare($sql);
     $stmt->execute([':server_coll_id' => $coll_id, ':sbas_id' => $databox->get_sbas_id(), ':ord' => self::getNewOrder($databox->get_appbox()->get_connection(), $databox->get_sbas_id())]);
     $stmt->closeCursor();
     $new_bas = $databox->get_appbox()->get_connection()->lastInsertId();
     $databox->get_appbox()->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
     cache_databox::update($app, $databox->get_sbas_id(), 'structure');
     phrasea::reset_baseDatas($databox->get_appbox());
     $coll = self::get_from_base_id($app, $new_bas);
     $coll->set_admin($new_bas, $user);
     return $new_bas;
 }
Exemple #4
0
 /**
  *
  * @param  DOMDocument $dom_struct
  * @return databox
  */
 public function saveStructure(DOMDocument $dom_struct)
 {
     $old_structure = $this->get_dom_structure();
     $dom_struct->documentElement->setAttribute("modification_date", $now = date("YmdHis"));
     $sql = "UPDATE pref SET value= :structure, updated_on= :now WHERE prop='structure'";
     $this->structure = $dom_struct->saveXML();
     $stmt = $this->get_connection()->prepare($sql);
     $stmt->execute([':structure' => $this->structure, ':now' => $now]);
     $stmt->closeCursor();
     $this->_sxml_structure = $this->_dom_structure = $this->_xpath_structure = null;
     $this->meta_struct = null;
     $this->get_appbox()->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $this->delete_data_from_cache(self::CACHE_STRUCTURE);
     $this->delete_data_from_cache(self::CACHE_META_STRUCT);
     cache_databox::update($this->app, $this->id, 'structure');
     $this->app['dispatcher']->dispatch(DataboxEvents::STRUCTURE_CHANGED, new StructureChangedEvent($this, array('dom_before' => $old_structure)));
     return $this;
 }