ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilSoapWebLinkAdministration Class Reference

Soap methods for adminstrating web links. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 readWebLink ($sid, $ref_id)
 Get Weblink xml. More...
 
 createWebLink ($sid, $target_id, $weblink_xml)
 add an exercise with id. More...
 
 updateWebLink ($sid, $ref_id, $weblink_xml)
 update a weblink with id. More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSoapWebLinkAdministration::__construct ( )

Constructor.

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

19 {
21 }
__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 (   $sid,
  $target_id,
  $weblink_xml 
)

add an exercise with id.

Parameters
string$session_idcurrent session
int$target_idrefid of parent in repository
string$weblink_xmlxml description of weblink
Returns
int reference id in the tree, 0 if not successful

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

104 {
105 $this->initAuth($sid);
106 $this->initIlias();
107
108 if (!$this->__checkSession($sid)) {
109 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
110 }
111 global $DIC;
112
113 $rbacsystem = $DIC['rbacsystem'];
114 $tree = $DIC['tree'];
115 $ilLog = $DIC['ilLog'];
116
117 if (!$target_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
118 return $this->__raiseError('No valid target given.', 'Client');
119 }
120
122 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
123 }
124
125 // Check access
126 // TODO: read from object definition
127 $allowed_types = array('cat','grp','crs','fold','root');
128 if (!in_array($target_obj->getType(), $allowed_types)) {
129 return $this->__raiseError('No valid target type. Target must be reference id of "course, group, root, category or folder"', 'Client');
130 }
131
132 if (!$rbacsystem->checkAccess('create', $target_id, "webr")) {
133 return $this->__raiseError('No permission to create weblink in target ' . $target_id . '!', 'Client');
134 }
135
136
137 // create object, put it into the tree and use the parser to update the settings
138 include_once './Modules/WebResource/classes/class.ilObjLinkResource.php';
139 include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
140
141 $webl = new ilObjLinkResource();
142 $webl->setTitle('XML Import');
143 $webl->create(true);
144 $webl->createReference();
145 $webl->putInTree($target_id);
146 $webl->setPermissions($target_id);
147
148 try {
149 $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
151 $parser->start();
152 } catch (ilSaxParserException $e) {
153 return $this->__raiseError($e->getMessage(), 'Client');
154 } catch (ilWebLinkXMLParserException $e) {
155 return $this->__raiseError($e->getMessage(), 'Client');
156 }
157
158 // Check if required
159 return $webl->getRefId();
160 }
$parser
Definition: BPMN2Parser.php:23
Class ilObjLinkResource.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _isInTrash($a_ref_id)
checks wether object is in trash
SaxParserException thrown by ilSaxParser if property throwException is set.
initAuth($sid)
Init authentication.
__raiseError($a_message, $a_code)
XML parser for weblink xml.
$target_id
Definition: goto.php:49
$DIC
Definition: xapitoken.php:46

References $DIC, Vendor\Package\$e, $ilLog, $parser, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilWebLinkXmlParser\MODE_CREATE.

+ Here is the call graph for this function:

◆ readWebLink()

ilSoapWebLinkAdministration::readWebLink (   $sid,
  $ref_id 
)

Get Weblink xml.

Parameters
string$a_sid
int$a_ref_id
Returns
string

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

30 {
31 $this->initAuth($sid);
32 $this->initIlias();
33
34 if (!$this->__checkSession($sid)) {
35 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
36 }
37 if (!strlen($ref_id)) {
38 return $this->__raiseError(
39 'No ref id given. Aborting!',
40 'Client'
41 );
42 }
43 global $DIC;
44
45 $rbacsystem = $DIC['rbacsystem'];
46 $tree = $DIC['tree'];
47 $ilLog = $DIC['ilLog'];
48
49 // get obj_id
50 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
51 return $this->__raiseError(
52 'No weblink found for id: ' . $ref_id,
53 'Client'
54 );
55 }
56
57 if (ilObject::_isInTrash($ref_id)) {
58 return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'Client');
59 }
60
61 // Check access
62 $permission_ok = false;
63 $write_permission_ok = false;
64 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
65 if ($rbacsystem->checkAccess('edit', $ref_id)) {
66 $write_permission_ok = true;
67 break;
68 }
69 if ($rbacsystem->checkAccess('read', $ref_id)) {
70 $permission_ok = true;
71 break;
72 }
73 }
74
75 if (!$permission_ok && !$write_permission_ok) {
76 return $this->__raiseError(
77 'No permission to edit the object with id: ' . $ref_id,
78 'Server'
79 );
80 }
81
82 try {
83 include_once './Modules/WebResource/classes/class.ilWebLinkXmlWriter.php';
84 $writer = new ilWebLinkXmlWriter();
85 $writer->setObjId($obj_id);
86 $writer->write();
87
88 return $writer->xmlDumpMem(true);
90 return $this->__raiseError($e->getMessage(), 'Client');
91 }
92 }
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
XML writer for weblinks.

References $DIC, Vendor\Package\$e, $ilLog, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ updateWebLink()

ilSoapWebLinkAdministration::updateWebLink (   $sid,
  $ref_id,
  $weblink_xml 
)

update a weblink with id.

Parameters
string$session_idcurrent session
int$ref_idrefid id of weblink in repository
string$weblink_xmlxml description
Returns
boolean true, if update successful, false otherwise

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

172 {
173 $this->initAuth($sid);
174 $this->initIlias();
175
176 if (!$this->__checkSession($sid)) {
177 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
178 }
179 global $DIC;
180
181 $rbacsystem = $DIC['rbacsystem'];
182 $tree = $DIC['tree'];
183 $ilLog = $DIC['ilLog'];
184
185 if (ilObject::_isInTrash($ref_id)) {
186 return $this->__raiseError('Cannot perform update since weblink has been deleted.', 'CLIENT_OBJECT_DELETED');
187 }
188 // get obj_id
189 if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
190 return $this->__raiseError(
191 'No weblink found for id: ' . $ref_id,
192 'CLIENT_OBJECT_NOT_FOUND'
193 );
194 }
195
196 // Check access
197 $permission_ok = false;
198 foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
199 if ($rbacsystem->checkAccess('edit', $ref_id)) {
200 $permission_ok = true;
201 break;
202 }
203 }
204
205 if (!$permission_ok) {
206 return $this->__raiseError(
207 'No permission to edit the weblink with id: ' . $ref_id,
208 'Server'
209 );
210 }
211
212 $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
213 if (!is_object($webl) or $webl->getType()!= "webr") {
214 return $this->__raiseError(
215 'Wrong obj id or type for weblink with id ' . $ref_id,
216 'Client'
217 );
218 }
219
220 try {
221 include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
222 $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
224 $parser->start();
225 } catch (ilSaxParserException $e) {
226 return $this->__raiseError($e->getMessage(), 'Client');
227 } catch (ilWebLinkXMLParserException $e) {
228 return $this->__raiseError($e->getMessage(), 'Client');
229 }
230
231 // Check if required
232 return true;
233 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $DIC, Vendor\Package\$e, $ilLog, $parser, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilObject\_lookupObjectId(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilWebLinkXmlParser\MODE_UPDATE.

+ Here is the call graph for this function:

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