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; }
/** * 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(); }
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; }
/** * Gets the file versions for this object. * * @param array $version_ids The file versions to get. If not specified all versions are returned. * @return The file versions. */ public function getVersions($version_ids = null) { include_once "./Services/History/classes/class.ilHistory.php"; $versions = ilHistory::_getEntriesForObject($this->getId(), $this->getType()); if ($version_ids != null && count($version_ids) > 0) { foreach ($versions as $index => $version) { if (!in_array($version["hist_entry_id"], $version_ids, true)) { unset($versions[$index]); } } } // add custom entries foreach ($versions as $index => $version) { $params = $this->parseInfoParams($version); $versions[$index] = array_merge($version, $params); } // sort by version number (hist_entry_id will do for that) usort($versions, array($this, "compareVersions")); return $versions; }
/** * Get data and put it into an array */ public function getDataFromDb() { $entries = ilHistory::_getEntriesForObject($this->getObjId(), $this->getObjType()); $this->setData($entries); }
/** * 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); }