ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 24 of file class.ilSoapWebLinkAdministration.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapWebLinkAdministration::__construct ( )

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

27 {
29 }
__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 102 of file class.ilSoapWebLinkAdministration.php.

103 {
104 $this->initAuth($sid);
105 $this->initIlias();
106
107 if (!$this->checkSession($sid)) {
108 return $this->raiseError($this->getMessage(), $this->getMessageCode());
109 }
110 global $DIC;
111
112 $rbacsystem = $DIC['rbacsystem'];
113 $tree = $DIC['tree'];
114 $ilLog = $DIC['ilLog'];
115
116 if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
117 return $this->raiseError('No valid target given.', 'Client');
118 }
119
120 if (ilObject::_isInTrash($target_id)) {
121 return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
122 }
123
124 // Check access
125 // TODO: read from object definition
126 $allowed_types = array('cat', 'grp', 'crs', 'fold', 'root');
127 if (!in_array($target_obj->getType(), $allowed_types)) {
128 return $this->raiseError(
129 'No valid target type. Target must be reference id of "course, group, root, category or folder"',
130 'Client'
131 );
132 }
133
134 if (!$rbacsystem->checkAccess('create', $target_id, "webr")) {
135 return $this->raiseError('No permission to create weblink in target ' . $target_id . '!', 'Client');
136 }
137
138 // create object, put it into the tree and use the parser to update the settings
139 $webl = new ilObjLinkResource();
140 $webl->setTitle('XML Import');
141 $webl->create();
142 $webl->createReference();
143 $webl->putInTree($target_id);
144 $webl->setPermissions($target_id);
145
146 try {
147 $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
148 $parser->setMode(ilWebLinkXmlParser::MODE_CREATE);
149 $parser->start();
151 return $this->raiseError($e->getMessage(), 'Client');
152 }
153
154 // Check if required
155 return $webl->getRefId();
156 }
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
raiseError(string $a_message, $a_code)
global $DIC
Definition: shib_login.php:26

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

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

35 {
36 $this->initAuth($sid);
37 $this->initIlias();
38
39 if (!$this->checkSession($sid)) {
40 return $this->raiseError($this->getMessage(), $this->getMessageCode());
41 }
42 if (!$request_ref_id) {
43 return $this->raiseError(
44 'No ref id given. Aborting!',
45 'Client'
46 );
47 }
48 global $DIC;
49
50 $rbacsystem = $DIC['rbacsystem'];
51 $tree = $DIC['tree'];
52 $ilLog = $DIC['ilLog'];
53
54 // get obj_id
55 if (!$obj_id = ilObject::_lookupObjectId($request_ref_id)) {
56 return $this->raiseError(
57 'No weblink found for id: ' . $request_ref_id,
58 'Client'
59 );
60 }
61
62 if (ilObject::_isInTrash($request_ref_id)) {
63 return $this->raiseError("Parent with ID $request_ref_id has been deleted.", 'Client');
64 }
65
66 // Check access
67 $permission_ok = false;
68 $write_permission_ok = false;
69 $ref_ids = ilObject::_getAllReferences($obj_id);
70 foreach ($ref_ids as $ref_id) {
71 if ($rbacsystem->checkAccess('edit', $ref_id)) {
72 $write_permission_ok = true;
73 break;
74 }
75 if ($rbacsystem->checkAccess('read', $ref_id)) {
76 $permission_ok = true;
77 break;
78 }
79 }
80
81 if (!$permission_ok && !$write_permission_ok) {
82 return $this->raiseError(
83 'No permission to edit the object with id: ' . $request_ref_id,
84 'Server'
85 );
86 }
87
88 try {
89 $writer = new ilWebLinkXmlWriter(true);
90 $writer->setObjId($obj_id);
91 $writer->write();
92
93 return $writer->xmlDumpMem(true);
94 } catch (UnexpectedValueException $e) {
95 return $this->raiseError($e->getMessage(), 'Client');
96 }
97 }
static _lookupObjectId(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66

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

162 {
163 $this->initAuth($sid);
164 $this->initIlias();
165
166 if (!$this->checkSession($sid)) {
167 return $this->raiseError($this->getMessage(), $this->getMessageCode());
168 }
169 global $DIC;
170
171 $rbacsystem = $DIC['rbacsystem'];
172 $tree = $DIC['tree'];
173 $ilLog = $DIC['ilLog'];
174
175 if (ilObject::_isInTrash($request_ref_id)) {
176 return $this->raiseError(
177 'Cannot perform update since weblink has been deleted.',
178 'CLIENT_OBJECT_DELETED'
179 );
180 }
181 // get obj_id
182 if (!$obj_id = ilObject::_lookupObjectId($request_ref_id)) {
183 return $this->raiseError(
184 'No weblink found for id: ' . $request_ref_id,
185 'CLIENT_OBJECT_NOT_FOUND'
186 );
187 }
188
189 // Check access
190 $permission_ok = false;
191 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
192 if ($rbacsystem->checkAccess('edit', $ref_id)) {
193 $permission_ok = true;
194 break;
195 }
196 }
197
198 if (!$permission_ok) {
199 return $this->raiseError(
200 'No permission to edit the weblink with id: ' . $request_ref_id,
201 'Server'
202 );
203 }
204
205 $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
206 if (!$webl instanceof ilObjLinkResource) {
207 return $this->raiseError(
208 'Wrong obj id or type for weblink with id ' . $request_ref_id,
209 'Client'
210 );
211 }
212
213 try {
215 $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
216 $parser->setMode(ilWebLinkXmlParser::MODE_UPDATE);
217 $parser->start();
219 return $this->raiseError($e->getMessage(), 'Client');
220 }
221
222 // Check if required
223 return true;
224 }
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: