ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

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

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

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

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

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: