ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
 ilSoapAdministration ($use_nusoap=true)
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 
 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 105 of file class.ilSoapWebLinkAdministration.php.

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

References $ilLog, $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 {
36 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
37 }
38 if(!strlen($ref_id))
39 {
40 return $this->__raiseError('No ref id given. Aborting!',
41 'Client');
42 }
43 global $rbacsystem, $tree, $ilLog;
44
45 // get obj_id
47 {
48 return $this->__raiseError('No weblink found for id: '.$ref_id,
49 'Client');
50 }
51
53 {
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 {
62 if($rbacsystem->checkAccess('edit',$ref_id))
63 {
64 $write_permission_ok = true;
65 break;
66 }
67 if($rbacsystem->checkAccess('read',$ref_id))
68 {
69 $permission_ok = true;
70 break;
71 }
72
73 }
74
75 if(!$permission_ok && !$write_permission_ok)
76 {
77 return $this->__raiseError('No permission to edit the object with id: '.$ref_id,
78 'Server');
79 }
80
81 try
82 {
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);
89 }
90 catch(UnexpectedValueException $e)
91 {
92 return $this->__raiseError($e->getMessage(), 'Client');
93 }
94 }
static _lookupObjectId($a_ref_id)
lookup object id
static _getAllReferences($a_id)
get all reference ids of object
XML writer for weblinks.
$ref_id
Definition: sahs_server.php:39

References $ilLog, $ref_id, 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 179 of file class.ilSoapWebLinkAdministration.php.

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

References $ilLog, $ref_id, 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: