ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilSoapWebLinkAdministration Class Reference

Soap methods for adminstrating web links. More...

+ Inheritance diagram for ilSoapWebLinkAdministration:
+ Collaboration diagram for ilSoapWebLinkAdministration:

Public Member Functions

 __construct ()
 
 readWebLink (string $sid, int $request_ref_id)
 
 createWebLink (string $sid, int $target_id, string $weblink_xml)
 
 updateWebLink (string $sid, int $request_ref_id, string $weblink_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 methods for adminstrating web links.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 10 of file class.ilSoapWebLinkAdministration.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapWebLinkAdministration::__construct ( )

Definition at line 12 of file class.ilSoapWebLinkAdministration.php.

References ILIAS\MetaData\Repository\Validation\Data\__construct().

13  {
15  }
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ createWebLink()

ilSoapWebLinkAdministration::createWebLink ( string  $sid,
int  $target_id,
string  $weblink_xml 
)
Returns
int|soap_fault|SoapFault|null

Definition at line 89 of file class.ilSoapWebLinkAdministration.php.

References $DIC, Vendor\Package\$e, ilObject\_isInTrash(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilWebLinkXmlParser\MODE_CREATE, and ilSoapAdministration\raiseError().

90  {
91  $this->initAuth($sid);
92  $this->initIlias();
93 
94  if (!$this->checkSession($sid)) {
95  return $this->raiseError($this->getMessage(), $this->getMessageCode());
96  }
97  global $DIC;
98 
99  $rbacsystem = $DIC['rbacsystem'];
100  $tree = $DIC['tree'];
101  $ilLog = $DIC['ilLog'];
102 
103  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
104  return $this->raiseError('No valid target given.', 'Client');
105  }
106 
107  if (ilObject::_isInTrash($target_id)) {
108  return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
109  }
110 
111  // Check access
112  // TODO: read from object definition
113  $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
114  if (!in_array($target_obj->getType(), $allowed_types)) {
115  return $this->raiseError(
116  'No valid target type. Target must be reference id of "course, group, root, category or folder"',
117  'Client'
118  );
119  }
120 
121  if (!$rbacsystem->checkAccess('create', $target_id, "webr")) {
122  return $this->raiseError('No permission to create weblink in target ' . $target_id . '!', 'Client');
123  }
124 
125  // create object, put it into the tree and use the parser to update the settings
126  include_once './Modules/WebResource/classes/class.ilObjLinkResource.php';
127  include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
128 
129  $webl = new ilObjLinkResource();
130  $webl->setTitle('XML Import');
131  $webl->create(true);
132  $webl->createReference();
133  $webl->putInTree($target_id);
134  $webl->setPermissions($target_id);
135 
136  try {
137  $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
138  $parser->setMode(ilWebLinkXmlParser::MODE_CREATE);
139  $parser->start();
141  return $this->raiseError($e->getMessage(), 'Client');
142  }
143 
144  // Check if required
145  return $webl->getRefId();
146  }
XML parser for weblink xml.
raiseError(string $a_message, $a_code)
SaxParserException thrown by ilSaxParser if property throwException is set.
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 ilObjLinkResource.
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:

◆ readWebLink()

ilSoapWebLinkAdministration::readWebLink ( string  $sid,
int  $request_ref_id 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 20 of file class.ilSoapWebLinkAdministration.php.

References $DIC, Vendor\Package\$e, $ref_id, ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

21  {
22  $this->initAuth($sid);
23  $this->initIlias();
24 
25  if (!$this->checkSession($sid)) {
26  return $this->raiseError($this->getMessage(), $this->getMessageCode());
27  }
28  if (!$request_ref_id) {
29  return $this->raiseError(
30  'No ref id given. Aborting!',
31  'Client'
32  );
33  }
34  global $DIC;
35 
36  $rbacsystem = $DIC['rbacsystem'];
37  $tree = $DIC['tree'];
38  $ilLog = $DIC['ilLog'];
39 
40  // get obj_id
41  if (!$obj_id = ilObject::_lookupObjectId($request_ref_id)) {
42  return $this->raiseError(
43  'No weblink found for id: ' . $request_ref_id,
44  'Client'
45  );
46  }
47 
48  if (ilObject::_isInTrash($request_ref_id)) {
49  return $this->raiseError("Parent with ID $request_ref_id has been deleted.", 'Client');
50  }
51 
52  // Check access
53  $permission_ok = false;
54  $write_permission_ok = false;
55  $ref_ids = ilObject::_getAllReferences($obj_id);
56  foreach ($ref_ids as $ref_id) {
57  if ($rbacsystem->checkAccess('edit', $ref_id)) {
58  $write_permission_ok = true;
59  break;
60  }
61  if ($rbacsystem->checkAccess('read', $ref_id)) {
62  $permission_ok = true;
63  break;
64  }
65  }
66 
67  if (!$permission_ok && !$write_permission_ok) {
68  return $this->raiseError(
69  'No permission to edit the object with id: ' . $request_ref_id,
70  'Server'
71  );
72  }
73 
74  try {
75  include_once './Modules/WebResource/classes/class.ilWebLinkXmlWriter.php';
76  $writer = new ilWebLinkXmlWriter(true);
77  $writer->setObjId($obj_id);
78  $writer->write();
79 
80  return $writer->xmlDumpMem(true);
81  } catch (UnexpectedValueException $e) {
82  return $this->raiseError($e->getMessage(), 'Client');
83  }
84  }
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _isInTrash(int $ref_id)
static _lookupObjectId(int $ref_id)
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:

◆ updateWebLink()

ilSoapWebLinkAdministration::updateWebLink ( string  $sid,
int  $request_ref_id,
string  $weblink_xml 
)
Returns
bool|soap_fault|SoapFault|null

PhpParamsInspection

Definition at line 151 of file class.ilSoapWebLinkAdministration.php.

References $DIC, Vendor\Package\$e, $ref_id, ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilWebLinkXmlParser\MODE_UPDATE, and ilSoapAdministration\raiseError().

152  {
153  $this->initAuth($sid);
154  $this->initIlias();
155 
156  if (!$this->checkSession($sid)) {
157  return $this->raiseError($this->getMessage(), $this->getMessageCode());
158  }
159  global $DIC;
160 
161  $rbacsystem = $DIC['rbacsystem'];
162  $tree = $DIC['tree'];
163  $ilLog = $DIC['ilLog'];
164 
165  if (ilObject::_isInTrash($request_ref_id)) {
166  return $this->raiseError(
167  'Cannot perform update since weblink has been deleted.',
168  'CLIENT_OBJECT_DELETED'
169  );
170  }
171  // get obj_id
172  if (!$obj_id = ilObject::_lookupObjectId($request_ref_id)) {
173  return $this->raiseError(
174  'No weblink found for id: ' . $request_ref_id,
175  'CLIENT_OBJECT_NOT_FOUND'
176  );
177  }
178 
179  // Check access
180  $permission_ok = false;
181  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
182  if ($rbacsystem->checkAccess('edit', $ref_id)) {
183  $permission_ok = true;
184  break;
185  }
186  }
187 
188  if (!$permission_ok) {
189  return $this->raiseError(
190  'No permission to edit the weblink with id: ' . $request_ref_id,
191  'Server'
192  );
193  }
194 
195  $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
196  if (!$webl instanceof ilObjLinkResource) {
197  return $this->raiseError(
198  'Wrong obj id or type for weblink with id ' . $request_ref_id,
199  'Client'
200  );
201  }
202 
203  try {
204  include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
206  $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
207  $parser->setMode(ilWebLinkXmlParser::MODE_UPDATE);
208  $parser->start();
210  return $this->raiseError($e->getMessage(), 'Client');
211  }
212 
213  // Check if required
214  return true;
215  }
XML parser for weblink xml.
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
SaxParserException thrown by ilSaxParser if property throwException is set.
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
static _isInTrash(int $ref_id)
static _lookupObjectId(int $ref_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjLinkResource.
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: