ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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\GlobalScreen\Provider\__construct().

13  {
15  }
__construct(Container $dic, ilPlugin $plugin)
+ 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 88 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().

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

148  {
149  $this->initAuth($sid);
150  $this->initIlias();
151 
152  if (!$this->checkSession($sid)) {
153  return $this->raiseError($this->getMessage(), $this->getMessageCode());
154  }
155  global $DIC;
156 
157  $rbacsystem = $DIC['rbacsystem'];
158  $tree = $DIC['tree'];
159  $ilLog = $DIC['ilLog'];
160 
161  if (ilObject::_isInTrash($request_ref_id)) {
162  return $this->raiseError(
163  'Cannot perform update since weblink has been deleted.',
164  'CLIENT_OBJECT_DELETED'
165  );
166  }
167  // get obj_id
168  if (!$obj_id = ilObject::_lookupObjectId($request_ref_id)) {
169  return $this->raiseError(
170  'No weblink found for id: ' . $request_ref_id,
171  'CLIENT_OBJECT_NOT_FOUND'
172  );
173  }
174 
175  // Check access
176  $permission_ok = false;
177  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
178  if ($rbacsystem->checkAccess('edit', $ref_id)) {
179  $permission_ok = true;
180  break;
181  }
182  }
183 
184  if (!$permission_ok) {
185  return $this->raiseError(
186  'No permission to edit the weblink with id: ' . $request_ref_id,
187  'Server'
188  );
189  }
190 
191  $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
192  if (!$webl instanceof ilObjLinkResource) {
193  return $this->raiseError(
194  'Wrong obj id or type for weblink with id ' . $request_ref_id,
195  'Client'
196  );
197  }
198 
199  try {
201  $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
202  $parser->setMode(ilWebLinkXmlParser::MODE_UPDATE);
203  $parser->start();
205  return $this->raiseError($e->getMessage(), 'Client');
206  }
207 
208  // Check if required
209  return true;
210  }
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.
$ref_id
Definition: ltiauth.php:66
static _isInTrash(int $ref_id)
global $DIC
Definition: shib_login.php:25
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: