/** * Save object as new version * @param boolean $log - log changes * @param boolean $useTransaction — using a transaction when changing data is optional. * @return boolean */ public function saveVersion($log = true, $useTransaction = true) { if (!$this->_config->isRevControl()) { return $this->save($log, $useTransaction); } if ($this->_config->hasEncrypted()) { $ivField = $this->_config->getIvField(); $ivData = $this->get($ivField); if (empty($ivData)) { $this->set($ivField, base64_encode($this->_config->createIv())); } } if ($this->_acl) { try { $this->_checkCanEdit(); } catch (Exception $e) { $this->_errors[] = $e->getMessage(); if (self::$_log) { self::$_log->log($e->getMessage()); } return false; } } if (!$this->getId()) { $this->published = false; $this->author_id = User::getInstance()->getId(); if (!$this->save(true, $useTransaction)) { return false; } } $this->date_updated = date('Y-m-d H:i:s'); $this->editor_id = User::getInstance()->getId(); $store = $this->_model->getStore(); if (self::$_log) { $store->setLog(self::$_log); } $vers = $store->addVersion($this, $log, $useTransaction); if ($vers) { $this->_version = $vers; $this->commitChanges(); return true; } else { return false; } }