/** * 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(); }