34 public function addFile(
string $sid,
int $target_id,
string $file_xml)
44 $ilAccess = $DIC[
'ilAccess'];
47 return $this->
raiseError(
'No valid target given.',
'Client');
51 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
54 $allowed_types = array(
'cat',
'grp',
'crs',
'fold',
'root');
55 if (!in_array($target_obj->getType(), $allowed_types)) {
57 'No valid target type. Target must be reference id of "course, group, category or folder"',
62 if (!$ilAccess->checkAccess(
'create',
'', $target_id,
"file")) {
63 return $this->
raiseError(
'No permission to create Files in target ' . $target_id .
'!',
'Client');
72 if ($fileXMLParser->start()) {
75 $ilLog = $DIC[
'ilLog'];
77 $ilLog->write(__METHOD__ .
': File type: ' . $file->getFileType());
80 $file->createReference();
81 $file->putInTree($target_id);
82 $file->setPermissions($target_id);
85 $fileXMLParser->setFileContents();
88 return $file->getRefId();
91 return $this->
raiseError(
"Could not add file",
"Server");
94 $exception->getMessage(),
113 $rbacsystem = $DIC[
'rbacsystem'];
114 $tree = $DIC[
'tree'];
115 $ilLog = $DIC[
'ilLog'];
116 $ilAccess = $DIC[
'ilAccess'];
119 return $this->
raiseError(
'Cannot perform update since file has been deleted.',
'CLIENT_OBJECT_DELETED');
124 'No File found for id: ' . $requested_ref_id,
129 $permission_ok =
false;
131 if ($ilAccess->checkAccess(
'write',
'', $ref_id)) {
132 $permission_ok =
true;
137 if (!$permission_ok) {
139 'No permission to edit the File with id: ' . $requested_ref_id,
147 if (!is_object($file) || $file->getType() !==
"file") {
149 'Wrong obj id or type for File with id ' . $requested_ref_id,
157 if ($fileXMLParser->start()) {
158 $fileXMLParser->updateFileContents();
160 return $file->update();
164 $exception->getMessage(),
174 public function getFileXML(
string $sid,
int $requested_ref_id,
int $attachFileContentsMode)
183 if (!($requested_ref_id > 0)) {
185 'No ref id given. Aborting!',
192 $rbacsystem = $DIC[
'rbacsystem'];
193 $tree = $DIC[
'tree'];
194 $ilLog = $DIC[
'ilLog'];
195 $ilAccess = $DIC[
'ilAccess'];
199 'No File found for id: ' . $requested_ref_id,
205 return $this->
raiseError(
"Object with ID $requested_ref_id has been deleted.",
'Client');
208 $permission_ok =
false;
210 if ($ilAccess->checkAccess(
'read',
'', $ref_id)) {
211 $permission_ok =
true;
216 if (!$permission_ok) {
218 'No permission to edit the object with id: ' . $requested_ref_id,
226 if (!is_object($file) || $file->getType() !==
"file") {
228 'Wrong obj id or type for File with id ' . $requested_ref_id,
235 $xmlWriter->setFile($file);
236 $xmlWriter->setAttachFileContents($attachFileContentsMode);
239 return $xmlWriter->getXML();
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
Soap file administration methods.
checkSession(string $sid)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjectId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
addFile(string $sid, int $target_id, string $file_xml)