ILIAS  release_8 Revision v8.24
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 8 of file class.ilSoapWebLinkAdministration.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapWebLinkAdministration::__construct ( )

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

11 {
13 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ 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 87 of file class.ilSoapWebLinkAdministration.php.

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

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

+ 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 18 of file class.ilSoapWebLinkAdministration.php.

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

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

+ 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

@noinspection PhpParamsInspection

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

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

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

+ Here is the call graph for this function:

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