Example #1
0
 /**
  * @copydoc Saver::save
  *
  * @note After saving site data it creates new section, translations and rights.
  */
 public function save()
 {
     $mainTableName = 'share_sites';
     if (isset($_POST[$mainTableName]['site_is_default']) && $_POST[$mainTableName]['site_is_default'] !== '0') {
         $this->dbh->modify(QAL::UPDATE, $mainTableName, array('site_is_default' => '0'));
     }
     $result = parent::save();
     $id = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName('site_id')->getRowData(0);
     //Сохраняем информацию о доменах
     $domainIDs = $this->dbh->getColumn('SELECT domain_id FROM share_domains WHERE domain_id NOT IN (SELECT domain_id FROM share_domain2site)');
     if (!empty($domainIDs)) {
         foreach ($domainIDs as $domainID) {
             $this->dbh->modify(QAL::INSERT, 'share_domain2site', array('site_id' => $id, 'domain_id' => $domainID));
         }
     }
     //Записываем информацию в таблицу тегов
     $tm = new TagManager($this->dataDescription, $this->data, 'share_sites');
     $tm->save($id);
     if ($this->getMode() == QAL::INSERT) {
         //При создании нового проекта   ищем параметр конфигурации указывающий на идентификатор
         //шаблонного раздела
         if (isset($_POST['copy_site_structure'])) {
             $this->copyStructure((int) $_POST['copy_site_structure'], $id);
         } else {
             $this->createMainPage($id);
         }
     }
     return $result;
 }
Example #2
0
 function testShouldSaveAsHash()
 {
     $imageData = '<pretend this is image data>';
     $saver = new Saver($imageData);
     $saver->save();
     $this->assertTrue(file_exists('./data/images/427d0d1bb2c597b5faceb50786c0d6cfb9bdee0d'));
 }
Example #3
0
 public function run()
 {
     $return = $this->experiment->run();
     // Save experiment to temporary storage
     $saver = new Saver(new Results($this->experiment), $this->getPayloadSaver(), $this->getStorage());
     $saver->save();
     if ($this->experiment->hasException()) {
         throw $this->experiment->getExcepion();
     }
     return $return;
 }
Example #4
0
 /**
  * Save data into the table of uploads and tags.
  */
 public function save()
 {
     $result = parent::save();
     $entityID = $this->getMode() == QAL::INSERT ? $result : $this->getData()->getFieldByName($this->pk)->getRowData(0);
     $tm = new TagManager($this->dataDescription, $this->data, $this->mainTableName);
     $tm->save($entityID);
     // обновление записей из _uploads таблицы, в которых PK = NULL по ID сессии
     if ($result && $this->dbh->tableExists($this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX)) {
         $id = is_int($result) ? $result : (int) $_POST[$this->getTableName()][$this->getPK()];
         //throw new SystemException($id);
         $this->dbh->modify(QAL::UPDATE, $this->getTableName() . AttachmentManager::ATTACH_TABLE_SUFFIX, array($this->getPK() => $id), array($this->getPK() => null, 'session_id' => session_id()));
     }
     return $result;
 }