33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
52 if (!$this->__checkSession($sid)) {
55 global $rbacsystem, $tree,
$ilLog, $ilAccess;
58 return $this->
__raiseError(
'No valid target given.',
'Client');
63 return $this->
__raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
67 $allowed_types =
array(
'cat',
'grp',
'crs',
'fold',
'root');
68 if (!in_array($target_obj->getType(), $allowed_types)) {
69 return $this->
__raiseError(
'No valid target type. Target must be reference id of "course, group, category or folder"',
'Client');
72 if (!$ilAccess->checkAccess(
'create',
'',
$target_id,
"file")) {
77 include_once
'./Modules/File/classes/class.ilFileXMLParser.php';
78 include_once
'./Modules/File/classes/class.ilFileException.php';
79 include_once
'./Modules/File/classes/class.ilObjFile.php';
85 if ($fileXMLParser->start()) {
88 $ilLog->write(__METHOD__ .
': File type: ' .
$file->getFileType());
91 $file->createReference();
96 $fileXMLParser->setFileContents();
99 return $file->getRefId();
101 return $this->
__raiseError(
"Could not add file",
"Server");
123 if (!$this->__checkSession($sid)) {
126 global $rbacsystem, $tree,
$ilLog, $ilAccess;
129 return $this->
__raiseError(
'Cannot perform update since file has been deleted.',
'CLIENT_OBJECT_DELETED');
134 'No File found for id: ' . $ref_id,
140 $permission_ok =
false;
142 if ($ilAccess->checkAccess(
'write',
'', $ref_id)) {
143 $permission_ok =
true;
148 if (!$permission_ok) {
150 'No permission to edit the File with id: ' . $ref_id,
158 if (!is_object(
$file) ||
$file->getType()!=
"file") {
160 'Wrong obj id or type for File with id ' . $ref_id,
165 include_once
'./Modules/File/classes/class.ilFileXMLParser.php';
166 include_once
'./Modules/File/classes/class.ilFileException.php';
170 if ($fileXMLParser->start()) {
171 $fileXMLParser->updateFileContents();
173 return $file->update();
177 $exception->getMessage(),
194 public function getFileXML($sid, $ref_id, $attachFileContentsMode)
199 if (!$this->__checkSession($sid)) {
202 if (!strlen($ref_id)) {
204 'No ref id given. Aborting!',
208 global $rbacsystem, $tree,
$ilLog, $ilAccess;
214 'No File found for id: ' . $ref_id,
220 return $this->
__raiseError(
"Object with ID $ref_id has been deleted.",
'Client');
224 $permission_ok =
false;
226 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
227 $permission_ok =
true;
232 if (!$permission_ok) {
234 'No permission to edit the object with id: ' . $ref_id,
241 if (!is_object(
$file) ||
$file->getType()!=
"file") {
243 'Wrong obj id or type for File with id ' . $ref_id,
248 include_once
'./Modules/File/classes/class.ilFileXMLWriter.php';
252 $xmlWriter->setFile(
$file);
253 $xmlWriter->setAttachFileContents($attachFileContentsMode);
256 return $xmlWriter->getXML();
addFile($sid, $target_id, $file_xml)
add an File with id.
static _isInTrash($a_ref_id)
checks wether object is in trash
Exercise XML Parser which completes/updates a given file by an xml string.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
updateFile($sid, $ref_id, $file_xml)
update a File with id.
__raiseError($a_message, $a_code)
Class to report exception.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
getFileXML($sid, $ref_id, $attachFileContentsMode)
get File xml
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file