ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 213 of file class.ilSoapFileAdministration.php.

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

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: