ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSoapFileAdministration Class Reference
+ Inheritance diagram for ilSoapFileAdministration:
+ Collaboration diagram for ilSoapFileAdministration:

Public Member Functions

 ilSoapFileAdministration ()
 
 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
 ilSoapAdministration ($use_nusoap=true)
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 
 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 51 of file class.ilSoapFileAdministration.php.

51 {
52
53 $this->initAuth($sid);
54 $this->initIlias();
55
56 if(!$this->__checkSession($sid))
57 {
58 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
59 }
60 global $rbacsystem, $tree, $ilLog, $ilAccess;
61
62 if(!$target_obj =& ilObjectFactory::getInstanceByRefId($target_id,false))
63 {
64 return $this->__raiseError('No valid target given.', 'Client');
65 }
66
67
69 {
70 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
71 }
72
73 // Check access
74 $allowed_types = array('cat','grp','crs','fold','root');
75 if(!in_array($target_obj->getType(), $allowed_types))
76 {
77 return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
78 }
79
80 if(!$ilAccess->checkAccess('create','',$target_id,"file"))
81 {
82 return $this->__raiseError('No permission to create Files in target '.$target_id.'!', 'Client');
83 }
84
85 // create object, put it into the tree and use the parser to update the settings
86 include_once './Modules/File/classes/class.ilFileXMLParser.php';
87 include_once './Modules/File/classes/class.ilFileException.php';
88 include_once './Modules/File/classes/class.ilObjFile.php';
89
90 $file = new ilObjFile();
91 try
92 {
93
94 $fileXMLParser = new ilFileXMLParser($file, $file_xml);
95
96 if ($fileXMLParser->start())
97 {
98 global $ilLog;
99
100 $ilLog->write(__METHOD__.': File type: '.$file->getFileType());
101
102 $file->create();
103 $file->createReference();
104 $file->putInTree($target_id);
105 $file->setPermissions($target_id);
106
107 // we now can save the file contents since we know the obj id now.
108 $fileXMLParser->setFileContents();
109 #$file->update();
110
111 return $file->getRefId();
112 }
113 else
114 {
115 return $this->__raiseError("Could not add file", "Server");
116 }
117 }
118 catch(ilFileException $exception) {
119 return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
120 }
121 }
print $file
Class to report exception.
Exercise XML Parser which completes/updates a given file by an xml string.
Class ilObjFile.
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
_isInTrash($a_ref_id)
checks wether object is in trash
__raiseError($a_message, $a_code)
$target_id
Definition: goto.php:88

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 214 of file class.ilSoapFileAdministration.php.

215 {
216 $this->initAuth($sid);
217 $this->initIlias();
218
219 if(!$this->__checkSession($sid))
220 {
221 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
222 }
223 if(!strlen($ref_id))
224 {
225 return $this->__raiseError('No ref id given. Aborting!',
226 'Client');
227 }
228 global $rbacsystem, $tree, $ilLog, $ilAccess;
229
230
231 // get obj_id
232 if(!$obj_id = ilObject::_lookupObjectId($ref_id))
233 {
234 return $this->__raiseError('No File found for id: '.$ref_id,
235 'Client');
236 }
237
239 {
240 return $this->__raiseError("Object with ID $ref_id has been deleted.", 'Client');
241 }
242
243 // Check access
244 $permission_ok = false;
245 foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
246 {
247 if($ilAccess->checkAccess('read','',$ref_id))
248 {
249 $permission_ok = true;
250 break;
251 }
252 }
253
254 if(!$permission_ok)
255 {
256 return $this->__raiseError('No permission to edit the object with id: '.$ref_id,
257 'Server');
258 }
259
261
262 if (!is_object($file) || $file->getType()!= "file")
263 {
264 return $this->__raiseError('Wrong obj id or type for File with id '.$ref_id,
265 'Server');
266 }
267 // store into xml result set
268 include_once './Modules/File/classes/class.ilFileXMLWriter.php';
269
270 // create writer
271 $xmlWriter = new ilFileXMLWriter();
272 $xmlWriter->setFile($file);
273 $xmlWriter->setAttachFileContents($attachFileContentsMode);
274 $xmlWriter->start();
275
276 return $xmlWriter->getXML();
277 }
XML writer class.
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
$ref_id
Definition: sahs_server.php:39

References $file, $ilLog, $ref_id, 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:

◆ ilSoapFileAdministration()

ilSoapFileAdministration::ilSoapFileAdministration ( )

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

38 {
39 parent::ilSoapAdministration();
40 }

◆ 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 133 of file class.ilSoapFileAdministration.php.

134 {
135 $this->initAuth($sid);
136 $this->initIlias();
137
138 if(!$this->__checkSession($sid))
139 {
140 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
141 }
142 global $rbacsystem, $tree, $ilLog, $ilAccess;
143
145 {
146 return $this->__raiseError('Cannot perform update since file has been deleted.', 'CLIENT_OBJECT_DELETED');
147 }
148 // get obj_id
149 if(!$obj_id = ilObject::_lookupObjectId($ref_id))
150 {
151 return $this->__raiseError('No File found for id: '.$ref_id,
152 'Client');
153 }
154
155 // Check access
156 $permission_ok = false;
157 foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
158 {
159 if($ilAccess->checkAccess('write','',$ref_id))
160 {
161 $permission_ok = true;
162 break;
163 }
164 }
165
166 if(!$permission_ok)
167 {
168 return $this->__raiseError('No permission to edit the File with id: '.$ref_id,
169 'Server');
170 }
171
172
174
175 if (!is_object($file) || $file->getType()!= "file")
176 {
177 return $this->__raiseError('Wrong obj id or type for File with id '.$ref_id,
178 'Server');
179 }
180
181 include_once './Modules/File/classes/class.ilFileXMLParser.php';
182 include_once './Modules/File/classes/class.ilFileException.php';
183 $fileXMLParser = new ilFileXMLParser($file, $file_xml, $obj_id);
184
185 try
186 {
187
188 if ($fileXMLParser->start())
189 {
190 $file->setVersion($file->getVersion() + 1);
191 $fileXMLParser->updateFileContents();
192
193 return $file->update();
194 }
195 }
196 catch(ilFileException $exception)
197 {
198 return $this->__raiseError($exception->getMessage(),
199 $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
200 }
201 return false;
202 }

References $file, ilFileException\$ID_MISMATCH, $ilLog, $ref_id, 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: