ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

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 $DIC;
56 
57  $ilAccess = $DIC['ilAccess'];
58 
59  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
60  return $this->__raiseError('No valid target given.', 'Client');
61  }
62 
64  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
65  }
66 
67  // Check access
68  $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
69  if (!in_array($target_obj->getType(), $allowed_types)) {
70  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
71  }
72 
73  if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
74  return $this->__raiseError('No permission to create Files in target ' . $target_id . '!', 'Client');
75  }
76 
77  // create object, put it into the tree and use the parser to update the settings
78  include_once './Modules/File/classes/class.ilFileXMLParser.php';
79  include_once './Modules/File/classes/class.ilFileException.php';
80  include_once './Modules/File/classes/class.ilObjFile.php';
81 
82  $file = new ilObjFile();
83  try {
84  $fileXMLParser = new ilFileXMLParser($file, $file_xml);
85 
86  if ($fileXMLParser->start()) {
87  global $DIC;
88 
89  $ilLog = $DIC['ilLog'];
90 
91  $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
92 
93  $file->create();
94  $file->createReference();
95  $file->putInTree($target_id);
96  $file->setPermissions($target_id);
97 
98  // we now can save the file contents since we know the obj id now.
99  $fileXMLParser->setFileContents();
100  #$file->update();
101 
102  return $file->getRefId();
103  } else {
104  return $this->__raiseError("Could not add file", "Server");
105  }
106  } catch (ilFileException $exception) {
107  return $this->__raiseError($exception->getMessage(), $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server");
108  }
109  }
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
$target_id
Definition: goto.php:49
__raiseError($a_message, $a_code)
Class to report exception.
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ 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 202 of file class.ilSoapFileAdministration.php.

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

203  {
204  $this->initAuth($sid);
205  $this->initIlias();
206 
207  if (!$this->__checkSession($sid)) {
208  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
209  }
210  if (!strlen($ref_id)) {
211  return $this->__raiseError(
212  'No ref id given. Aborting!',
213  'Client'
214  );
215  }
216  global $DIC;
217 
218  $rbacsystem = $DIC['rbacsystem'];
219  $tree = $DIC['tree'];
220  $ilLog = $DIC['ilLog'];
221  $ilAccess = $DIC['ilAccess'];
222 
223 
224  // get obj_id
225  if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
226  return $this->__raiseError(
227  'No File found for id: ' . $ref_id,
228  'Client'
229  );
230  }
231 
232  if (ilObject::_isInTrash($ref_id)) {
233  return $this->__raiseError("Object with ID $ref_id has been deleted.", 'Client');
234  }
235 
236  // Check access
237  $permission_ok = false;
238  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
239  if ($ilAccess->checkAccess('read', '', $ref_id)) {
240  $permission_ok = true;
241  break;
242  }
243  }
244 
245  if (!$permission_ok) {
246  return $this->__raiseError(
247  'No permission to edit the object with id: ' . $ref_id,
248  'Server'
249  );
250  }
251 
252  $file = ilObjectFactory::getInstanceByObjId($obj_id, false);
253 
254  if (!is_object($file) || $file->getType()!= "file") {
255  return $this->__raiseError(
256  'Wrong obj id or type for File with id ' . $ref_id,
257  'Server'
258  );
259  }
260  // store into xml result set
261  include_once './Modules/File/classes/class.ilFileXMLWriter.php';
262 
263  // create writer
264  $xmlWriter = new ilFileXMLWriter();
265  $xmlWriter->setFile($file);
266  $xmlWriter->setAttachFileContents($attachFileContentsMode);
267  $xmlWriter->start();
268 
269  return $xmlWriter->getXML();
270  }
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
XML writer class.
initAuth($sid)
Init authentication.
+ 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 121 of file class.ilSoapFileAdministration.php.

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

122  {
123  $this->initAuth($sid);
124  $this->initIlias();
125 
126  if (!$this->__checkSession($sid)) {
127  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
128  }
129  global $DIC;
130 
131  $rbacsystem = $DIC['rbacsystem'];
132  $tree = $DIC['tree'];
133  $ilLog = $DIC['ilLog'];
134  $ilAccess = $DIC['ilAccess'];
135 
136  if (ilObject::_isInTrash($ref_id)) {
137  return $this->__raiseError('Cannot perform update since file has been deleted.', 'CLIENT_OBJECT_DELETED');
138  }
139  // get obj_id
140  if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
141  return $this->__raiseError(
142  'No File found for id: ' . $ref_id,
143  'Client'
144  );
145  }
146 
147  // Check access
148  $permission_ok = false;
149  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
150  if ($ilAccess->checkAccess('write', '', $ref_id)) {
151  $permission_ok = true;
152  break;
153  }
154  }
155 
156  if (!$permission_ok) {
157  return $this->__raiseError(
158  'No permission to edit the File with id: ' . $ref_id,
159  'Server'
160  );
161  }
162 
163 
164  $file = ilObjectFactory::getInstanceByObjId($obj_id, false);
165 
166  if (!is_object($file) || $file->getType()!= "file") {
167  return $this->__raiseError(
168  'Wrong obj id or type for File with id ' . $ref_id,
169  'Server'
170  );
171  }
172 
173  include_once './Modules/File/classes/class.ilFileXMLParser.php';
174  include_once './Modules/File/classes/class.ilFileException.php';
175  $fileXMLParser = new ilFileXMLParser($file, $file_xml, $obj_id);
176 
177  try {
178  if ($fileXMLParser->start()) {
179  $fileXMLParser->updateFileContents();
180 
181  return $file->update();
182  }
183  } catch (ilFileException $exception) {
184  return $this->__raiseError(
185  $exception->getMessage(),
186  $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server"
187  );
188  }
189  return false;
190  }
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
Class to report exception.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

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