ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSoapFileAdministration Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilSoapFileAdministration:
+ Collaboration diagram for ilSoapFileAdministration:

Public Member Functions

 addFile (string $sid, int $target_id, string $file_xml)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Additional Inherited Members

- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 
- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 checkObjectAccess (int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Soap file administration methods

Author
Roland Küstermann rolan.nosp@m.d@ku.nosp@m.ester.nosp@m.mann.nosp@m..com

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

Member Function Documentation

◆ addFile()

ilSoapFileAdministration::addFile ( string  $sid,
int  $target_id,
string  $file_xml 
)
Returns
int|soap_fault|SoapFault|null

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

References $DIC, ilFileException\$ID_MISMATCH, $ref_id, $requested_ref_id, ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

28  {
29  $this->initAuth($sid);
30  $this->initIlias();
31 
32  if (!$this->checkSession($sid)) {
33  return $this->raiseError($this->getMessage(), $this->getMessageCode());
34  }
35  global $DIC;
36 
37  $ilAccess = $DIC['ilAccess'];
38 
39  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
40  return $this->raiseError('No valid target given.', 'Client');
41  }
42 
43  if (ilObject::_isInTrash($target_id)) {
44  return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
45  }
46 
47  $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
48  if (!in_array($target_obj->getType(), $allowed_types)) {
49  return $this->raiseError(
50  'No valid target type. Target must be reference id of "course, group, category or folder"',
51  'Client'
52  );
53  }
54 
55  if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
56  return $this->raiseError('No permission to create Files in target ' . $target_id . '!', 'Client');
57  }
58 
59  // create object, put it into the tree and use the parser to update the settings
60 
61  $file = new ilObjFile();
62  try {
63  $fileXMLParser = new ilFileXMLParser($file, $file_xml);
64 
65  if ($fileXMLParser->start()) {
66  global $DIC;
67 
68  $ilLog = $DIC['ilLog'];
69 
70  $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
71 
72  $file->create();
73  $file->createReference();
74  $file->putInTree($target_id);
75  $file->setPermissions($target_id);
76 
77  // we now can save the file contents since we know the obj id now.
78  $fileXMLParser->setFileContents();
79  #$file->update();
80 
81  return $file->getRefId();
82  }
83 
84  return $this->raiseError("Could not add file", "Server");
85  } catch (ilFileException $exception) {
86  return $this->raiseError(
87  $exception->getMessage(),
88  $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server"
89  );
90  }
91  }
raiseError(string $a_message, $a_code)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObjFile.
global $DIC
Definition: shib_login.php:22
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

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