Пример #1
0
 protected function buildJson(ilECSSetting $a_server)
 {
     $json = $this->getJsonCore('application/ecs-file');
     $json->version = $this->content_obj->getVersion();
     require_once "./Services/History/classes/class.ilHistory.php";
     $entries = ilHistory::_getEntriesForObject($this->content_obj->getId(), $this->content_obj->getType());
     if (count($entries)) {
         $entry = array_shift($entries);
         $entry = new ilDateTime($entry["date"], IL_CAL_DATETIME);
         $json->version_date = $entry->get(IL_CAL_UNIX);
     } else {
         $json->version_date = time();
     }
     return $json;
 }
Пример #2
0
 /**
  * add change comment to history
  */
 function addChangeComment()
 {
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->page->getId(), "update", "", $this->page->getParentType() . ":pg", ilUtil::stripSlashes($_POST["change_comment"]), true);
     ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
     $this->ctrl->returnToParent($this);
 }
 /**
  * get versions table
  */
 function getVersionsTable($a_header_params, $a_user_comment = false)
 {
     global $ilCtrl;
     $ref_id = $a_header_params["ref_id"];
     require_once "./Services/Table/classes/class.ilTableGUI.php";
     $tbl = new ilTableGUI(0, false);
     // table header
     $tbl->setTitle($this->lng->txt("versions"));
     $tbl->setHeaderNames(array($this->lng->txt("date") . "/" . $this->lng->txt("user"), $this->lng->txt("action")));
     $tbl->setColumnWidth(array("40%", "60%"));
     $cols = array("date_user", "action");
     if ($a_header_params == "") {
         $a_header_params = array();
     }
     $header_params = $a_header_params;
     $tbl->setHeaderVars($cols, $header_params);
     // table variables
     $tbl->setOrderColumn($_GET["sort_by"]);
     $tbl->setOrderDirection($_GET["sort_order"]);
     $tbl->setLimit($_GET["limit"]);
     $tbl->setOffset($_GET["offset"]);
     $tbl->setMaxCount($this->maxcount);
     // ???
     $tbl->disable("header");
     // footer
     $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
     // get history entries
     $entries = ilHistory::_getEntriesForObject($this->obj_id, $this->obj_type);
     $tbl->setMaxCount(count($entries));
     $entries = array_slice($entries, $_GET["offset"], $_GET["limit"]);
     $this->tpl =& $tbl->getTemplateObject();
     $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.history_row.html", "Services/History");
     if (count($entries) > 0) {
         $i = 0;
         foreach ($entries as $entry) {
             $this->tpl->setCurrentBlock("tbl_content");
             $css_row = $css_row != "tblrow1" ? "tblrow1" : "tblrow2";
             $this->tpl->setVariable("CSS_ROW", $css_row);
             $this->tpl->setVariable('TXT_DATE', ilDatePresentation::formatDate(new ilDateTime($entry['date'], IL_CAL_DATETIME)));
             $name = ilObjUser::_lookupName($entry["user_id"]);
             $this->tpl->setVariable("TXT_USER", $name["title"] . " " . $name["firstname"] . " " . $name["lastname"] . " [" . $entry["user_id"] . "]");
             $info_params = explode(",", $entry["info_params"]);
             $info_text = $this->lng->txt("hist_" . $this->obj_type . "_" . $entry["action"]);
             $i = 1;
             foreach ($info_params as $info_param) {
                 $info_text = str_replace("%" . $i, $info_param, $info_text);
                 $i++;
             }
             $this->tpl->setVariable("TXT_ACTION", $info_text);
             if ($a_user_comment) {
                 $this->tpl->setCurrentBlock("user_comment");
                 $this->tpl->setVariable("TXT_USER_COMMENT", $entry["user_comment"]);
                 $this->tpl->parseCurrentBlock();
                 $this->tpl->setCurrentBlock("tbl_content");
             }
             $this->tpl->setCurrentBlock("dl_link");
             $this->tpl->setVariable("TXT_DL", $this->lng->txt("download"));
             $ilCtrl->setParameterByClass("ilobjfilegui", "hist_id", $entry["hist_entry_id"]);
             $this->tpl->setVariable("DL_LINK", $ilCtrl->getLinkTargetByClass("ilobjfilegui", "sendfile"));
             $this->tpl->setCurrentBlock("tbl_content");
             $this->tpl->parseCurrentBlock();
         }
     } else {
         $this->tpl->setCurrentBlock("tbl_content_cell");
         $this->tpl->setVariable("TBL_CONTENT_CELL", $this->lng->txt("hist_no_entries"));
         $this->tpl->setVariable("TBL_COL_SPAN", 4);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("tbl_content_row");
         $this->tpl->setVariable("ROWCOLOR", "tblrow1");
         $this->tpl->parseCurrentBlock();
     }
     $tbl->render();
     //$this->tpl->parseCurrentBlock();
     return $this->tpl->get();
 }
 /**
  * Execute Drag Drop Action
  *
  * @param	string	$source_id		Source element ID
  * @param	string	$target_id		Target element ID
  * @param	string	$first_child	Insert as first child of target
  * @param	string	$movecopy		Position ("move" | "copy")
  */
 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
 {
     $lmtree = new ilTree($this->getId());
     $lmtree->setTableNames('lm_tree', 'lm_data');
     $lmtree->setTreeTablePK("lm_id");
     //echo "-".$source_id."-".$target_id."-".$first_child."-".$as_subitem."-";
     $source_obj = ilLMObjectFactory::getInstance($this, $source_id, true);
     $source_obj->setLMId($this->getId());
     if (!$first_child) {
         $target_obj = ilLMObjectFactory::getInstance($this, $target_id, true);
         $target_obj->setLMId($this->getId());
         $target_parent = $lmtree->getParentId($target_id);
     }
     // handle pages
     if ($source_obj->getType() == "pg") {
         //echo "1";
         if ($lmtree->isInTree($source_obj->getId())) {
             $node_data = $lmtree->getNodeData($source_obj->getId());
             // cut on move
             if ($movecopy == "move") {
                 $parent_id = $lmtree->getParentId($source_obj->getId());
                 $lmtree->deleteTree($node_data);
                 // write history entry
                 require_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($source_obj->getId(), "cut", array(ilLMObject::_lookupTitle($parent_id), $parent_id), $this->getType() . ":pg");
                 ilHistory::_createEntry($parent_id, "cut_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
             } else {
                 // copy page
                 $new_page =& $source_obj->copy();
                 $source_id = $new_page->getId();
                 $source_obj =& $new_page;
             }
             // paste page
             if (!$lmtree->isInTree($source_obj->getId())) {
                 if ($first_child) {
                     $target_pos = IL_FIRST_NODE;
                     $parent = $target_id;
                 } else {
                     if ($as_subitem) {
                         $parent = $target_id;
                         $target_pos = IL_FIRST_NODE;
                         $pg_childs =& $lmtree->getChildsByType($parent, "pg");
                         if (count($pg_childs) != 0) {
                             $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
                         }
                     } else {
                         $target_pos = $target_id;
                         $parent = $target_parent;
                     }
                 }
                 // insert page into tree
                 $lmtree->insertNode($source_obj->getId(), $parent, $target_pos);
                 // write history entry
                 if ($movecopy == "move") {
                     // write history comments
                     include_once "./Services/History/classes/class.ilHistory.php";
                     ilHistory::_createEntry($source_obj->getId(), "paste", array(ilLMObject::_lookupTitle($parent), $parent), $this->getType() . ":pg");
                     ilHistory::_createEntry($parent, "paste_page", array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()), $this->getType() . ":st");
                 }
             }
         }
     }
     // handle chapters
     if ($source_obj->getType() == "st") {
         //echo "2";
         $source_node = $lmtree->getNodeData($source_id);
         $subnodes = $lmtree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             $pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
             if (count($pg_childs) != 0) {
                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
             }
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs =& $lmtree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // insert into
         /*
         			if ($position == "into")
         			{
         				$target_parent = $target_id;
         				$target_pos = IL_FIRST_NODE;
         
         				// if target_pos is still first node we must skip all pages
         				if ($target_pos == IL_FIRST_NODE)
         				{
         					$pg_childs =& $lmtree->getChildsByType($target_parent, "pg");
         					if (count($pg_childs) != 0)
         					{
         						$target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
         					}
         				}
         			}
         */
         // delete source tree
         if ($movecopy == "move") {
             $lmtree->deleteTree($source_node);
         } else {
             // copy chapter (incl. subcontents)
             $new_chapter =& $source_obj->copy($lmtree, $target_parent, $target_pos);
         }
         if (!$lmtree->isInTree($source_id)) {
             $lmtree->insertNode($source_id, $target_parent, $target_pos);
             // insert moved tree
             if ($movecopy == "move") {
                 foreach ($subnodes as $node) {
                     if ($node["obj_id"] != $source_id) {
                         $lmtree->insertNode($node["obj_id"], $node["parent"]);
                     }
                 }
             }
         }
         // check the tree
         $this->checkTree();
     }
     $this->checkTree();
 }
 function doDelete($leave_out_il_bibl_data = false, $leave_out_delete_file = false)
 {
     global $ilDB;
     if (!$leave_out_delete_file) {
         $this->deleteFile();
     }
     //il_bibl_attribute
     $ilDB->manipulate("DELETE FROM il_bibl_attribute WHERE il_bibl_attribute.entry_id IN " . "(SELECT il_bibl_entry.id FROM il_bibl_entry WHERE il_bibl_entry.data_id = " . $ilDB->quote($this->getId(), "integer") . ");");
     //il_bibl_entry
     $ilDB->manipulate("DELETE FROM il_bibl_entry WHERE data_id = " . $ilDB->quote($this->getId(), "integer"));
     if (!$leave_out_il_bibl_data) {
         //il_bibl_data
         $ilDB->manipulate("DELETE FROM il_bibl_data WHERE id = " . $ilDB->quote($this->getId(), "integer"));
     }
     // delete history entries
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_removeEntriesForObject($this->getId());
 }
 /**
  * update history
  */
 function updateHistory()
 {
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->obj->getId(), "update", "", $this->content_object->getType() . ":pg", "", true);
 }
 function add($a_update_history = true)
 {
     global $ilDB;
     $this->__setLastUpdateDate(time());
     $this->__setCreateDate(time());
     $next_id = $ilDB->nextId('webr_items');
     $query = "INSERT INTO webr_items (link_id,title,description,target,active,disable_check," . "last_update,create_date,webr_id,valid) " . "VALUES( " . $ilDB->quote($next_id, 'integer') . ", " . $ilDB->quote($this->getTitle(), 'text') . ", " . $ilDB->quote($this->getDescription(), 'text') . ", " . $ilDB->quote($this->getTarget(), 'text') . ", " . $ilDB->quote($this->getActiveStatus(), 'integer') . ", " . $ilDB->quote($this->getDisableCheckStatus(), 'integer') . ", " . $ilDB->quote($this->getLastUpdateDate(), 'integer') . ", " . $ilDB->quote($this->getCreateDate(), 'integer') . ", " . $ilDB->quote($this->getLinkResourceId(), 'integer') . ", " . $ilDB->quote($this->getValidStatus(), 'integer') . ' ' . ")";
     $res = $ilDB->manipulate($query);
     $link_id = $next_id;
     $this->setLinkId($link_id);
     if ($a_update_history) {
         include_once "./Services/History/classes/class.ilHistory.php";
         ilHistory::_createEntry($this->getLinkResourceId(), "add", $this->getTitle());
     }
     return $link_id;
 }
 /**
  * show information screen
  */
 function infoScreenForward()
 {
     global $ilTabs, $ilErr;
     $ilTabs->activateTab("id_info");
     if (!$this->checkPermissionBool("visible")) {
         $ilErr->raiseError($this->lng->txt("msg_no_perm_read"));
     }
     include_once "./Services/InfoScreen/classes/class.ilInfoScreenGUI.php";
     $info = new ilInfoScreenGUI($this);
     if ($this->checkPermissionBool("read", "sendfile")) {
         // 9876
         $this->lng->loadLanguageModule("file");
         $info->addButton($this->lng->txt("file_download"), $this->ctrl->getLinkTarget($this, "sendfile"));
     }
     $info->enablePrivateNotes();
     if ($this->checkPermissionBool("read")) {
         $info->enableNews();
     }
     // no news editing for files, just notifications
     $info->enableNewsEditing(false);
     if ($this->checkPermissionBool("write")) {
         $news_set = new ilSetting("news");
         $enable_internal_rss = $news_set->get("enable_rss_for_internal");
         if ($enable_internal_rss) {
             $info->setBlockProperty("news", "settings", true);
             $info->setBlockProperty("news", "public_notifications_option", true);
         }
     }
     // standard meta data
     $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
     $info->addSection($this->lng->txt("file_info"));
     $info->addProperty($this->lng->txt("filename"), $this->object->getFileName());
     // BEGIN WebDAV Guess file type.
     $info->addProperty($this->lng->txt("type"), $this->object->guessFileType());
     // END WebDAV Guess file type.
     $info->addProperty($this->lng->txt("size"), ilFormat::formatSize(ilObjFile::_lookupFileSize($this->object->getId()), 'long'));
     $info->addProperty($this->lng->txt("version"), $this->object->getVersion());
     include_once "./Services/History/classes/class.ilHistory.php";
     $uploader = ilHistory::_getEntriesForObject($this->object->getId(), $this->object->getType());
     $uploader = array_shift($uploader);
     $uploader = $uploader["user_id"];
     $this->lng->loadLanguageModule("file");
     include_once "Services/User/classes/class.ilUserUtil.php";
     $info->addProperty($this->lng->txt("file_uploaded_by"), ilUserUtil::getNamePresentation($uploader));
     if ($this->id_type == self::WORKSPACE_NODE_ID) {
         $info->addProperty($this->lng->txt("perma_link"), $this->getPermanentLinkWidget());
     }
     // forward the command
     // $this->ctrl->setCmd("showSummary");
     // $this->ctrl->setCmdClass("ilinfoscreengui");
     $this->ctrl->forwardCommand($info);
 }
Пример #9
0
 /**
  * Makes the specified version the current one and returns theSummary of rollbackVersion
  * 
  * @param int $version_id The id of the version to make the current one.
  * @return array The new actual version. 
  */
 public function rollback($version_id)
 {
     global $ilDB, $ilUser;
     $source = $this->getSpecificVersion($version_id);
     if ($source === false) {
         $this->ilErr->raiseError($this->lng->txt("obj_not_found"), $this->ilErr->MESSAGE);
     }
     // get the new version number
     $new_version_nr = $this->getVersion() + 1;
     // copy file
     $source_path = $this->getDirectory($source["version"]) . "/" . $source["filename"];
     $dest_dir = $this->getDirectory($new_version_nr);
     if (@(!is_dir($dest_dir))) {
         ilUtil::makeDir($dest_dir);
     }
     copy($source_path, $dest_dir . "/" . $source["filename"]);
     // create new history entry based on the old one
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "rollback", $source["filename"] . "," . $new_version_nr . "|" . $source["version"] . "|" . $ilUser->getId());
     // get id of newest entry
     $new_version = $this->getSpecificVersion($ilDB->getLastInsertId());
     // change user back to the original uploader
     ilHistory::_changeUserId($new_version["hist_entry_id"], $source["user_id"]);
     // update this file with the new version
     $this->updateWithVersion($new_version);
     $this->addNewsNotification("file_updated");
     return $new_version;
 }
 /**
  * paste page
  */
 function pastePage()
 {
     global $ilUser;
     if (!$ilUser->clipboardHasObjectsOfType("pg")) {
         $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"), $this->ilias->error_obj->MESSAGE);
     }
     return $this->insertPageClip();
     return;
     $tree = new ilTree($this->content_object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // paste selected object
     $id = ilEditClipboard::getContentObjectId();
     // copy page, if action is copy
     if (ilEditClipboard::getAction() == "copy") {
         // check wether page belongs to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) == $this->content_object->getID()) {
             $lm_page = new ilLMPageObject($this->content_object, $id);
             $new_page =& $lm_page->copy();
             $id = $new_page->getId();
         } else {
             // get page from other content object into current content object
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $copied_nodes = array();
             $new_page =& $lm_page->copyToOtherContObject($this->content_object, $copied_nodes);
             $id = $new_page->getId();
             ilLMObject::updateInternalLinks($copied_nodes);
         }
     }
     if (ilEditClipboard::getAction() == "cut") {
         // check wether page belongs not to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) != $this->content_object->getID()) {
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $lm_page->setLMId($this->content_object->getID());
             $lm_page->update();
             $page =& $lm_page->getPageObject();
             $page->buildDom();
             $page->setParentId($this->content_object->getID());
             $page->update();
         }
     }
     if (!$tree->isInTree($id)) {
         if (!isset($_POST["id"])) {
             $target = IL_FIRST_NODE;
         } else {
             $target = $_POST["id"][0];
         }
         $tree->insertNode($id, $this->obj->getId(), $target);
         ilEditClipboard::clear();
     }
     // write history comments
     include_once "./Services/History/classes/class.ilHistory.php";
     $parent_id = $tree->getParentId($id);
     ilHistory::_createEntry($id, "paste", array(ilLMObject::_lookupTitle($this->obj->getId()), $this->obj->getId()), $this->content_object->getType() . ":pg");
     ilHistory::_createEntry($parent_id, "paste_page", array(ilLMObject::_lookupTitle($id), $id), $this->content_object->getType() . ":st");
     // check the tree
     $this->checkTree();
     $this->ctrl->redirect($this, "view");
 }
Пример #11
0
 protected function doDelete()
 {
     global $ilDB;
     // delete file data entry
     $q = "DELETE FROM file_data WHERE file_id = " . $ilDB->quote($this->getId(), 'integer');
     $this->ilias->db->query($q);
     // delete history entries
     require_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_removeEntriesForObject($this->getId());
     // delete entire directory and its content
     if (@is_dir($this->getDirectory())) {
         ilUtil::delDir($this->getDirectory());
     }
     // delete meta data
     if ($this->getMode() != "filelist") {
         $this->deleteMetaData();
     }
 }
Пример #12
0
 /**
  * Get data and put it into an array
  */
 public function getDataFromDb()
 {
     $entries = ilHistory::_getEntriesForObject($this->getObjId(), $this->getObjType());
     $this->setData($entries);
 }
 /**
  * update file according to filename and version and create history entry
  * has to be called after (!) file save for new objects, since file storage will be initialised with obj id.
  *
  */
 public function updateFileContents()
 {
     if ($this->setFileContents()) {
         require_once "./Services/History/classes/class.ilHistory.php";
         ilHistory::_createEntry($this->file->getId(), "replace", $this->file->getFilename() . "," . $this->file->getVersion());
         $this->file->addNewsNotification("file_updated");
     }
 }
 /**
  * delete page object or structure objects
  *
  * @param	int		$a_parent_subobj_id		id of parent object (structure object)
  *											of the objects, that should be deleted
  *											(or no parent object id for top level)
  */
 function confirmedDelete($a_parent_subobj_id = 0)
 {
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     // check number of objects
     if (!$_POST["id"]) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     // delete all selected objects
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj =& ilLMObjectFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setLMId($this->object->getId());
                 include_once "./Services/History/classes/class.ilHistory.php";
                 ilHistory::_createEntry($this->object->getId(), "delete_" . $obj->getType(), array(ilLMObject::_lookupTitle($id), $id), $this->object->getType());
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     $this->object->checkTree();
     // feedback
     ilUtil::sendSuccess($this->lng->txt("info_deleted"), true);
     if ($a_parent_subobj_id == 0) {
         $this->ctrl->redirect($this, $_GET["backcmd"]);
     }
 }
Пример #15
0
 function start()
 {
     $this->__buildHeader();
     $attribs = array("obj_id" => "il_" . IL_INST_ID . "_file_" . $this->file->getId(), "version" => $this->file->getVersion(), "size" => $this->file->getFileSize(), "type" => $this->file->getFileType());
     $this->xmlStartTag("File", $attribs);
     $this->xmlElement("Filename", null, $this->file->getFileName());
     $this->xmlElement("Title", null, $this->file->getTitle());
     $this->xmlElement("Description", null, $this->file->getDescription());
     $this->xmlElement("Rating", null, (int) $this->file->hasRating());
     if ($this->attachFileContents) {
         $filename = $this->file->getDirectory($this->file->getVersion()) . "/" . $this->file->getFileName();
         if (@is_file($filename)) {
             if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_COPY) {
                 $attribs = array("mode" => "COPY");
                 copy($filename, $this->target_dir_absolute . "/" . $this->file->getFileName());
                 $content = $this->target_dir_relative . "/" . $this->file->getFileName();
                 $this->xmlElement("Content", $attribs, $content);
             } elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_REST) {
                 $attribs = array('mode' => "REST");
                 include_once './Services/WebServices/Rest/classes/class.ilRestFileStorage.php';
                 $fs = new ilRestFileStorage();
                 $tmpname = $fs->storeFileForRest(base64_encode(@file_get_contents($filename)));
                 $this->xmlElement("Content", $attribs, $tmpname);
             } else {
                 $content = @file_get_contents($filename);
                 $attribs = array("mode" => "PLAIN");
                 if ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_ZLIB_ENCODED) {
                     $attribs["mode"] = "ZLIB";
                     $content = @gzcompress($content, 9);
                 } elseif ($this->attachFileContents == ilFileXMLWriter::$CONTENT_ATTACH_GZIP_ENCODED) {
                     $attribs["mode"] = "GZIP";
                     $content = @gzencode($content, 9);
                 }
                 $content = base64_encode($content);
                 $this->xmlElement("Content", $attribs, $content);
             }
         }
     }
     include_once "./Services/History/classes/class.ilHistory.php";
     $versions = ilHistory::_getEntriesForObject($this->file->getId(), $this->file->getType());
     if (count($versions)) {
         $this->xmlStartTag("Versions");
         foreach ($versions as $version) {
             $info_params = $version["info_params"];
             list($filename, $history_id) = split(",", $info_params);
             $attribs = array("id" => $history_id, "date" => ilUtil::date_mysql2time($version["date"]), "usr_id" => "il_" . IL_INST_ID . "_usr_" . $version["user_id"]);
             $this->xmlElement("Version", $attribs);
         }
         $this->xmlEndTag("Versions");
     }
     $this->xmlEndTag("File");
     $this->__buildFooter();
     return true;
 }
Пример #16
0
 function create($a_upload = false)
 {
     global $ilDB;
     // insert object data
     $this->setId($ilDB->nextId("lm_data"));
     $query = "INSERT INTO lm_data (obj_id, title, type, layout, lm_id, import_id, create_date) " . "VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($this->getTitle(), "text") . "," . $ilDB->quote($this->getType(), "text") . ", " . $ilDB->quote($this->getLayout(), "text") . ", " . $ilDB->quote($this->getLMId(), "integer") . "," . $ilDB->quote($this->getImportId(), "text") . ", " . $ilDB->now() . ")";
     $ilDB->manipulate($query);
     // create history entry
     include_once "./Services/History/classes/class.ilHistory.php";
     ilHistory::_createEntry($this->getId(), "create", "", $this->content_object->getType() . ":" . $this->getType());
     if (!$a_upload) {
         $this->createMetaData();
     }
 }
Пример #17
0
 /**
  * Creates a new version of the object.
  * Only objects which support versioning need to implement this method.
  */
 function createNewVersion()
 {
     $this->obj->setVersion($this->obj->getVersion() + 1);
     ilHistory::_createEntry($this->obj->getId(), "replace", $this->obj->getFileName() . "," . $this->obj->getVersion());
 }