ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSoapFileAdministration Class Reference
+ Inheritance diagram for ilSoapFileAdministration:
+ Collaboration diagram for ilSoapFileAdministration:

Public Member Functions

 addFile ($sid, $target_id, $file_xml)
 add an File with id. More...
 
 updateFile ($sid, $ref_id, $file_xml)
 update a File with id. More...
 
 getFileXML ($sid, $ref_id, $attachFileContentsMode)
 get File xml More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

Definition at line 35 of file class.ilSoapFileAdministration.php.

Member Function Documentation

◆ addFile()

ilSoapFileAdministration::addFile (   $sid,
  $target_id,
  $file_xml 
)

add an File with id.

Parameters
string$session_idcurrent session
int$target_idrefid of parent in repository
string$file_xmlqti xml description of test
Returns
int reference id in the tree, 0 if not successful

Definition at line 47 of file class.ilSoapFileAdministration.php.

48 {
49 $this->initAuth($sid);
50 $this->initIlias();
51
52 if (!$this->__checkSession($sid)) {
53 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
54 }
55 global $rbacsystem, $tree, $ilLog, $ilAccess;
56
57 if (!$target_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
58 return $this->__raiseError('No valid target given.', 'Client');
59 }
60
61
63 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
64 }
65
66 // Check access
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');
70 }
71
72 if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
73 return $this->__raiseError('No permission to create Files in target ' . $target_id . '!', 'Client');
74 }
75
76 // create object, put it into the tree and use the parser to update the settings
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';
80
81 $file = new ilObjFile();
82 try {
83 $fileXMLParser = new ilFileXMLParser($file, $file_xml);
84
85 if ($fileXMLParser->start()) {
86 global $ilLog;
87
88 $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
89
90 $file->create();
91 $file->createReference();
92 $file->putInTree($target_id);
93 $file->setPermissions($target_id);
94
95 // we now can save the file contents since we know the obj id now.
96 $fileXMLParser->setFileContents();
97 #$file->update();
98
99 return $file->getRefId();
100 } else {
101 return $this->__raiseError("Could not add file", "Server");
102 }
103 } catch (ilFileException $exception) {
104 return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
105 }
106 }
Class to report exception.
Exercise XML Parser which completes/updates a given file by an xml string.
Class ilObjFile.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _isInTrash($a_ref_id)
checks wether object is in trash
initAuth($sid)
Init authentication.
__raiseError($a_message, $a_code)
$target_id
Definition: goto.php:49
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, ilFileException\$ID_MISMATCH, $ilLog, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ getFileXML()

ilSoapFileAdministration::getFileXML (   $sid,
  $ref_id,
  $attachFileContentsMode 
)

get File xml

Parameters
string$sid
int$ref_id
boolean$attachFileContentsMode
Returns
xml following ilias_file_x.dtd

Definition at line 194 of file class.ilSoapFileAdministration.php.

195 {
196 $this->initAuth($sid);
197 $this->initIlias();
198
199 if (!$this->__checkSession($sid)) {
200 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
201 }
202 if (!strlen($ref_id)) {
203 return $this->__raiseError(
204 'No ref id given. Aborting!',
205 'Client'
206 );
207 }
208 global $rbacsystem, $tree, $ilLog, $ilAccess;
209
210
211 // get obj_id
212 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
213 return $this->__raiseError(
214 'No File found for id: ' . $ref_id,
215 'Client'
216 );
217 }
218
219 if (ilObject::_isInTrash($ref_id)) {
220 return $this->__raiseError("Object with ID $ref_id has been deleted.", 'Client');
221 }
222
223 // Check access
224 $permission_ok = false;
225 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
226 if ($ilAccess->checkAccess('read', '', $ref_id)) {
227 $permission_ok = true;
228 break;
229 }
230 }
231
232 if (!$permission_ok) {
233 return $this->__raiseError(
234 'No permission to edit the object with id: ' . $ref_id,
235 'Server'
236 );
237 }
238
240
241 if (!is_object($file) || $file->getType()!= "file") {
242 return $this->__raiseError(
243 'Wrong obj id or type for File with id ' . $ref_id,
244 'Server'
245 );
246 }
247 // store into xml result set
248 include_once './Modules/File/classes/class.ilFileXMLWriter.php';
249
250 // create writer
251 $xmlWriter = new ilFileXMLWriter();
252 $xmlWriter->setFile($file);
253 $xmlWriter->setAttachFileContents($attachFileContentsMode);
254 $xmlWriter->start();
255
256 return $xmlWriter->getXML();
257 }
XML writer class.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object

References $file, $ilLog, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ updateFile()

ilSoapFileAdministration::updateFile (   $sid,
  $ref_id,
  $file_xml 
)

update a File with id.

Parameters
string$session_idcurrent session
int$ref_idrefid id of File in repository
string$file_xmlqti xml description of test
Returns
boolean true, if update successful, false otherwise

Definition at line 118 of file class.ilSoapFileAdministration.php.

119 {
120 $this->initAuth($sid);
121 $this->initIlias();
122
123 if (!$this->__checkSession($sid)) {
124 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
125 }
126 global $rbacsystem, $tree, $ilLog, $ilAccess;
127
128 if (ilObject::_isInTrash($ref_id)) {
129 return $this->__raiseError('Cannot perform update since file has been deleted.', 'CLIENT_OBJECT_DELETED');
130 }
131 // get obj_id
132 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
133 return $this->__raiseError(
134 'No File found for id: ' . $ref_id,
135 'Client'
136 );
137 }
138
139 // Check access
140 $permission_ok = false;
141 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
142 if ($ilAccess->checkAccess('write', '', $ref_id)) {
143 $permission_ok = true;
144 break;
145 }
146 }
147
148 if (!$permission_ok) {
149 return $this->__raiseError(
150 'No permission to edit the File with id: ' . $ref_id,
151 'Server'
152 );
153 }
154
155
157
158 if (!is_object($file) || $file->getType()!= "file") {
159 return $this->__raiseError(
160 'Wrong obj id or type for File with id ' . $ref_id,
161 'Server'
162 );
163 }
164
165 include_once './Modules/File/classes/class.ilFileXMLParser.php';
166 include_once './Modules/File/classes/class.ilFileException.php';
167 $fileXMLParser = new ilFileXMLParser($file, $file_xml, $obj_id);
168
169 try {
170 if ($fileXMLParser->start()) {
171 $fileXMLParser->updateFileContents();
172
173 return $file->update();
174 }
175 } catch (ilFileException $exception) {
176 return $this->__raiseError(
177 $exception->getMessage(),
178 $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server"
179 );
180 }
181 return false;
182 }

References $file, ilFileException\$ID_MISMATCH, $ilLog, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: