/** * Get xml representation * * @param string entity * @param string target release * @param string id * @return string xml string */ public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) { include_once "./Modules/File/classes/class.ilObjFile.php"; include_once "./Modules/File/classes/class.ilFileXMLWriter.php"; if (ilObject::_lookupType($a_id) == "file") { $file = new ilObjFile($a_id, false); $writer = new ilFileXMLWriter(); $writer->setFile($file); $writer->setOmitHeader(true); $writer->setAttachFileContents(ilFileXMLWriter::$CONTENT_ATTACH_COPY); ilUtil::makeDirParents($this->getAbsoluteExportDirectory()); $writer->setFileTargetDirectories($this->getRelativeExportDirectory(), $this->getAbsoluteExportDirectory()); $writer->start(); $xml .= $writer->getXml(); } return $xml; }
/** * get File xml * * @param string $sid * @param int $ref_id * @param boolean $attachFileContentsMode * * @return xml following ilias_file_x.dtd */ function getFileXML($sid, $ref_id, $attachFileContentsMode) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } if (!strlen($ref_id)) { return $this->__raiseError('No ref id given. Aborting!', 'Client'); } global $rbacsystem, $tree, $ilLog, $ilAccess; // get obj_id if (!($obj_id = ilObject::_lookupObjectId($ref_id))) { return $this->__raiseError('No File found for id: ' . $ref_id, 'Client'); } if (ilObject::_isInTrash($ref_id)) { return $this->__raiseError("Object with ID {$ref_id} has been deleted.", 'Client'); } // Check access $permission_ok = false; foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) { if ($ilAccess->checkAccess('read', '', $ref_id)) { $permission_ok = true; break; } } if (!$permission_ok) { return $this->__raiseError('No permission to edit the object with id: ' . $ref_id, 'Server'); } $file = ilObjectFactory::getInstanceByObjId($obj_id, false); if (!is_object($file) || $file->getType() != "file") { return $this->__raiseError('Wrong obj id or type for File with id ' . $ref_id, 'Server'); } // store into xml result set include_once './Modules/File/classes/class.ilFileXMLWriter.php'; // create writer $xmlWriter = new ilFileXMLWriter(); $xmlWriter->setFile($file); $xmlWriter->setAttachFileContents($attachFileContentsMode); $xmlWriter->start(); return $xmlWriter->getXML(); }