iId = -1; $this->iDocumentID = $iNewDocumentID; $this->sComment = $sNewComment; $this->iTransactionID = $iNewTransactionID; $oDocument = & Document::get($iNewDocumentID); $this->sVersion = $oDocument->getMajorVersionNumber() . "." . $oDocument->getMinorVersionNumber(); $this->iUserID = $_SESSION["userID"]; $this->dDateTime = getCurrentDateTime(); $this->sIP = $_SERVER["REMOTE_ADDR"]; $this->sFileName = Folder::getFolderPath($oDocument->getFolderID()) . "/" . $oDocument->getName(); } /** * Create the document transaction in the database * * @return boolean true on successful creation, false otherwise and set $_SESSION["errorMessage"] * */ function create() { global $default, $lang_err_object_exists; //if the object hasn't been stored yet if ($this->iId < 0) { $sql = $default->db; $result = $sql->query("INSERT INTO " . $default->owl_document_transactions_table . " (document_id, version, user_id, datetime, ip, filename, comment, transaction_id) " . "VALUES ($this->iDocumentID, '" . addslashes($this->sVersion) . "', $this->iUserID, '" . addslashes($this->dDateTime) . "', '" . addslashes($this->sIP) . "', '" . addslashes($this->sFileName) . "', '" . addslashes($this->sComment) . "', $this->iTransactionID)"); if ($result) { //object has been stored, set the primary key $this->iId = $sql->insert_id(); return true; } else { $_SESSION["errorMessage"] = $lang_err_database; return false; } } else { $_SESSION["errorMessage"] = $lang_err_object_exists; return false; } } function delete() { global $default, $lang_err_database, $lang_err_object_key; if ($this->iId >= 0) { $sql = $default->db; // TODO: insert into sys_deleted //$result = $sql->query("INSERT INTO " . $default->owl_sys_deleted_table . " () VALUES ()"); $result = $sql->query("DELETE FROM " . $default->owl_document_transactions_table . " WHERE id = " . $this->iId); if ($result) { $this->iId = -1; return true; } $_SESSION["errorMessage"] = $lang_err_database; return false; } $_SESSION["errorMessage"] = $lang_err_object_key; return false; } } ?>