ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilSoapFileAdministration Class Reference

Soap file administration methods. 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

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 29 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 34 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().

35  {
36  $this->initAuth($sid);
37  $this->initIlias();
38 
39  if (!$this->checkSession($sid)) {
40  return $this->raiseError($this->getMessage(), $this->getMessageCode());
41  }
42  global $DIC;
43 
44  $ilAccess = $DIC['ilAccess'];
45 
46  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
47  return $this->raiseError('No valid target given.', 'Client');
48  }
49 
50  if (ilObject::_isInTrash($target_id)) {
51  return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
52  }
53 
54  $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
55  if (!in_array($target_obj->getType(), $allowed_types)) {
56  return $this->raiseError(
57  'No valid target type. Target must be reference id of "course, group, category or folder"',
58  'Client'
59  );
60  }
61 
62  if (!$ilAccess->checkAccess('create', '', $target_id, "file")) {
63  return $this->raiseError('No permission to create Files in target ' . $target_id . '!', 'Client');
64  }
65 
66  // create object, put it into the tree and use the parser to update the settings
67 
68  $file = new ilObjFile();
69  try {
70  $fileXMLParser = new ilFileXMLParser($file, $file_xml);
71 
72  if ($fileXMLParser->start()) {
73  global $DIC;
74 
75  $ilLog = $DIC['ilLog'];
76 
77  $ilLog->write(__METHOD__ . ': File type: ' . $file->getFileType());
78 
79  $file->create();
80  $file->createReference();
81  $file->putInTree($target_id);
82  $file->setPermissions($target_id);
83 
84  // we now can save the file contents since we know the obj id now.
85  $fileXMLParser->setFileContents();
86  #$file->update();
87 
88  return $file->getRefId();
89  }
90 
91  return $this->raiseError("Could not add file", "Server");
92  } catch (ilFileException $exception) {
93  return $this->raiseError(
94  $exception->getMessage(),
95  $exception->getCode() == ilFileException::$ID_MISMATCH ? "Client" : "Server"
96  );
97  }
98  }
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:25
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: