ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  {
20  parent::__construct();
21  }

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

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

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

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

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 $rbacsystem, $tree, $ilLog;
44 
45  // get obj_id
46  if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
47  return $this->__raiseError(
48  'No weblink found for id: ' . $ref_id,
49  'Client'
50  );
51  }
52 
53  if (ilObject::_isInTrash($ref_id)) {
54  return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'Client');
55  }
56 
57  // Check access
58  $permission_ok = false;
59  $write_permission_ok = false;
60  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
61  if ($rbacsystem->checkAccess('edit', $ref_id)) {
62  $write_permission_ok = true;
63  break;
64  }
65  if ($rbacsystem->checkAccess('read', $ref_id)) {
66  $permission_ok = true;
67  break;
68  }
69  }
70 
71  if (!$permission_ok && !$write_permission_ok) {
72  return $this->__raiseError(
73  'No permission to edit the object with id: ' . $ref_id,
74  'Server'
75  );
76  }
77 
78  try {
79  include_once './Modules/WebResource/classes/class.ilWebLinkXmlWriter.php';
80  $writer = new ilWebLinkXmlWriter();
81  $writer->setObjId($obj_id);
82  $writer->write();
83 
84  return $writer->xmlDumpMem(true);
85  } catch (UnexpectedValueException $e) {
86  return $this->__raiseError($e->getMessage(), 'Client');
87  }
88  }
static _isInTrash($a_ref_id)
checks wether object is in trash
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
XML writer for weblinks.
+ 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 163 of file class.ilSoapWebLinkAdministration.php.

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

164  {
165  $this->initAuth($sid);
166  $this->initIlias();
167 
168  if (!$this->__checkSession($sid)) {
169  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
170  }
171  global $rbacsystem, $tree, $ilLog;
172 
173  if (ilObject::_isInTrash($ref_id)) {
174  return $this->__raiseError('Cannot perform update since weblink has been deleted.', 'CLIENT_OBJECT_DELETED');
175  }
176  // get obj_id
177  if (!$obj_id = ilObject::_lookupObjectId($ref_id)) {
178  return $this->__raiseError(
179  'No weblink found for id: ' . $ref_id,
180  'CLIENT_OBJECT_NOT_FOUND'
181  );
182  }
183 
184  // Check access
185  $permission_ok = false;
186  foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
187  if ($rbacsystem->checkAccess('edit', $ref_id)) {
188  $permission_ok = true;
189  break;
190  }
191  }
192 
193  if (!$permission_ok) {
194  return $this->__raiseError(
195  'No permission to edit the weblink with id: ' . $ref_id,
196  'Server'
197  );
198  }
199 
200  $webl = ilObjectFactory::getInstanceByObjId($obj_id, false);
201  if (!is_object($webl) or $webl->getType()!= "webr") {
202  return $this->__raiseError(
203  'Wrong obj id or type for weblink with id ' . $ref_id,
204  'Client'
205  );
206  }
207 
208  try {
209  include_once './Modules/WebResource/classes/class.ilWebLinkXmlParser.php';
210  $parser = new ilWebLinkXmlParser($webl, $weblink_xml);
212  $parser->start();
213  } catch (ilSaxParserException $e) {
214  return $this->__raiseError($e->getMessage(), 'Client');
215  } catch (ilWebLinkXMLParserException $e) {
216  return $this->__raiseError($e->getMessage(), 'Client');
217  }
218 
219  // Check if required
220  return true;
221  }
XML parser for weblink xml.
static _isInTrash($a_ref_id)
checks wether object is in trash
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjectId($a_ref_id)
lookup object id
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$parser
Definition: BPMN2Parser.php:23
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

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