ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 30 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 35 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().

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