ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSoapGroupAdministration Class Reference
+ Inheritance diagram for ilSoapGroupAdministration:
+ Collaboration diagram for ilSoapGroupAdministration:

Public Member Functions

 addGroup ($sid, $target_id, $grp_xml)
 
 updateGroup ($sid, $ref_id, $grp_xml)
 
 groupExists ($sid, $title)
 
 getGroup ($sid, $ref_id)
 
 assignGroupMember ($sid, $group_id, $user_id, $type)
 
 excludeGroupMember ($sid, $group_id, $user_id)
 
 isAssignedToGroup ($sid, $group_id, $user_id)
 
 getGroupsForUser ($sid, $parameters)
 get groups which belong to a specific user, fullilling the status 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)
 

Data Fields

const MEMBER = 1
 
const ADMIN = 2
 
const OWNER = 4
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 

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...
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

Definition at line 35 of file class.ilSoapGroupAdministration.php.

Member Function Documentation

◆ addGroup()

ilSoapGroupAdministration::addGroup (   $sid,
  $target_id,
  $grp_xml 
)

Definition at line 44 of file class.ilSoapGroupAdministration.php.

45 {
46 $this->initAuth($sid);
47 $this->initIlias();
48
49 if(!$this->__checkSession($sid))
50 {
51 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
52 }
53
54 if(!is_numeric($target_id))
55 {
56 return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category or group',
57 'Client');
58 }
59
60 global $rbacsystem;
61
62 if(!$rbacsystem->checkAccess('create',$target_id,'grp'))
63 {
64 return $this->__raiseError('Check access failed. No permission to create groups','Server');
65 }
66
68 {
69 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
70 }
71
72
73 // Start import
74 include_once("./Modules/Group/classes/class.ilObjGroup.php");
75 include_once 'Modules/Group/classes/class.ilGroupXMLParser.php';
76 $xml_parser = new ilGroupXMLParser($grp_xml,$target_id);
77 $new_ref_id = $xml_parser->startParsing();
78
79 return $new_ref_id ? $new_ref_id : "0";
80 }
Group Import Parser.
static _isInTrash($a_ref_id)
checks wether object is in trash
initAuth($sid)
Init authentication.
__raiseError($a_message, $a_code)
$target_id
Definition: goto.php:51

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

+ Here is the call graph for this function:

◆ assignGroupMember()

ilSoapGroupAdministration::assignGroupMember (   $sid,
  $group_id,
  $user_id,
  $type 
)

Definition at line 192 of file class.ilSoapGroupAdministration.php.

193 {
194 $this->initAuth($sid);
195 $this->initIlias();
196
197 if(!$this->__checkSession($sid))
198 {
199 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
200 }
201
202 if(!is_numeric($group_id))
203 {
204 return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
205 'Client');
206 }
207
208 global $rbacsystem;
209
210 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
211 {
212 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
213 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
214 {
215 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
216 }
217 }
218
219 if(!$rbacsystem->checkAccess('write',$group_id))
220 {
221 return $this->__raiseError('Check access failed. No permission to write to group','Server');
222 }
223
224
225 if(ilObject::_lookupType($user_id) != 'usr')
226 {
227 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
228 }
229 if($type != 'Admin' and
230 $type != 'Member')
231 {
232 return $this->__raiseError('Invalid type '.$type.' given. Parameter "type" must be "Admin","Member"','Client');
233 }
234
235 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
236 {
237 return $this->__raiseError('Cannot create group instance!','Server');
238 }
239
240 if(!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false))
241 {
242 return $this->__raiseError('Cannot create user instance!','Server');
243 }
244
245
246 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
247 $group_members = ilGroupParticipants::_getInstanceByObjId($tmp_group->getId());
248
249 switch($type)
250 {
251 case 'Admin':
252 $group_members->add($tmp_user->getId(),IL_GRP_ADMIN);
253 break;
254
255 case 'Member':
256 $group_members->add($tmp_user->getId(),IL_GRP_MEMBER);
257 break;
258 }
259 return true;
260 }
const IL_GRP_MEMBER
const IL_GRP_ADMIN
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilGroupParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), IL_GRP_ADMIN, IL_GRP_MEMBER, ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ excludeGroupMember()

ilSoapGroupAdministration::excludeGroupMember (   $sid,
  $group_id,
  $user_id 
)

Definition at line 262 of file class.ilSoapGroupAdministration.php.

263 {
264 $this->initAuth($sid);
265 $this->initIlias();
266
267 if(!$this->__checkSession($sid))
268 {
269 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
270 }
271 if(!is_numeric($group_id))
272 {
273 return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
274 'Client');
275 }
276
277 global $rbacsystem;
278
279 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
280 {
281 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
282 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
283 {
284 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
285 }
286 }
287
288 if(ilObject::_lookupType($user_id) != 'usr')
289 {
290 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
291 }
292
293 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
294 {
295 return $this->__raiseError('Cannot create group instance!','Server');
296 }
297
298 if(!$rbacsystem->checkAccess('write',$group_id))
299 {
300 return $this->__raiseError('Check access failed. No permission to write to group','Server');
301 }
302
303 $tmp_group->leave($user_id);
304 return true;
305 }

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ getGroup()

ilSoapGroupAdministration::getGroup (   $sid,
  $ref_id 
)

Definition at line 158 of file class.ilSoapGroupAdministration.php.

159 {
160 $this->initAuth($sid);
161 $this->initIlias();
162
163 if(!$this->__checkSession($sid))
164 {
165 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
166 }
167
169 {
170 return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'CLIENT_OBJECT_DELETED');
171 }
172
173
174 if(!$grp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
175 {
176 return $this->__raiseError('No valid reference id given.',
177 'Client');
178 }
179
180
181 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
182
183 $xml_writer = new ilGroupXMLWriter($grp_obj);
184 $xml_writer->start();
185
186 $xml = $xml_writer->getXML();
187
188 return strlen($xml) ? $xml : '';
189 }
$ref_id
Definition: sahs_server.php:39

References $ref_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ getGroupsForUser()

ilSoapGroupAdministration::getGroupsForUser (   $sid,
  $parameters 
)

get groups which belong to a specific user, fullilling the status

Parameters
string$sid
string$parametersfollowing xmlresultset, columns (user_id, status with values 1 = "MEMBER", 2 = "TUTOR", 4 = "ADMIN", 8 = "OWNER" and any xor operation e.g. 1 + 4 = 5 = ADMIN and TUTOR, 7 = ADMIN and TUTOR and MEMBER)
stringXMLResultSet, columns (ref_id, xml, parent_ref_id)

Definition at line 371 of file class.ilSoapGroupAdministration.php.

371 {
372
373 $this->initAuth($sid);
374 $this->initIlias();
375
376 if(!$this->__checkSession($sid))
377 {
378 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
379 }
380 global $rbacreview, $ilObjDataCache, $tree;
381
382 include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
383 $parser = new ilXMLResultSetParser($parameters);
384 try {
385 $parser->startParsing();
386 } catch (ilSaxParserException $exception) {
387 return $this->__raiseError($exception->getMessage(), "Client");
388 }
389 $xmlResultSet = $parser->getXMLResultSet();
390
391 if (!$xmlResultSet->hasColumn ("user_id"))
392 return $this->__raiseError("parameter user_id is missing", "Client");
393
394 if (!$xmlResultSet->hasColumn ("status"))
395 return $this->__raiseError("parameter status is missing", "Client");
396
397 $user_id = (int) $xmlResultSet->getValue (0, "user_id");
398 $status = (int) $xmlResultSet->getValue (0, "status");
399
400 $ref_ids = array();
401
402 // get roles
403#var_dump($xmlResultSet);
404#echo "uid:".$user_id;
405#echo "status:".$status;
408 foreach($rbacreview->assignedRoles($user_id) as $role_id)
409 {
410 if($role = ilObjectFactory::getInstanceByObjId($role_id,false))
411 {
412 #echo $role->getType();
413 if ($role->getType() != "role")
414 continue;
415
416 if ($role->getParent() == ROLE_FOLDER_ID)
417 {
418 continue;
419 }
420 $role_title = $role->getTitle();
421
422 if ($ref_id = ilUtil::__extractRefId($role_title))
423 {
425 continue;
426
427 #echo $role_title;
428 if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos($role_title, "member") !== false)
429 {
430 $ref_ids [] = $ref_id;
431 } elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos($role_title, "admin") !== false)
432 {
433 $ref_ids [] = $ref_id;
434 }
435 }
436 }
437 }
438
440 {
441 $owned_objects = ilObjectFactory::getObjectsForOwner("grp", $user_id);
442 foreach ($owned_objects as $obj_id) {
443 $allrefs = ilObject::_getAllReferences($obj_id);
444 $refs = array();
445 foreach($allrefs as $r)
446 {
447 if($tree->isDeleted($r))
448 {
449 continue;
450 }
451 if ($tree->isInTree($r))
452 {
453 $refs[] = $r;
454 }
455 }
456 if (count($refs) > 0)
457 $ref_ids[] = array_pop($refs);
458 }
459 }
460 $ref_ids = array_unique($ref_ids);
461
462
463#print_r($ref_ids);
464 include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
465 include_once 'Modules/Group/classes/class.ilObjGroup.php';
466 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
467
468 $xmlResultSet = new ilXMLResultSet();
469 $xmlResultSet->addColumn("ref_id");
470 $xmlResultSet->addColumn("xml");
471 $xmlResultSet->addColumn("parent_ref_id");
472
473 foreach ($ref_ids as $group_id) {
474 $group_obj = $this->checkObjectAccess($group_id,"grp","write", true);
475 if ($group_obj instanceof ilObjGroup) {
476 $row = new ilXMLResultSetRow();
477 $row->setValue("ref_id", $group_id);
478 $xmlWriter = new ilGroupXMLWriter($group_obj);
479 $xmlWriter->setAttachUsers(false);
480 $xmlWriter->start();
481 $row->setValue("xml", $xmlWriter->getXML());
482 $row->setValue("parent_ref_id", $tree->getParentId($group_id));
483 $xmlResultSet->addRow($row);
484 }
485 }
486 $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
487 $xmlResultSetWriter->start();
488 return $xmlResultSetWriter->getXML();
489 }
$parser
Definition: BPMN2Parser.php:24
Class ilObjGroup.
getObjectsForOwner($object_type, $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
SaxParserException thrown by ilSaxParser if property throwException is set.
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true
static __extractRefId($role_title)
extract ref id from role title, e.g.
XML Writer for XMLResultSet.
$r
Definition: example_031.php:79

References $parser, $r, $ref_id, $row, ilUtil\__extractRefId(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_exists(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ADMIN, ilSoapAdministration\checkObjectAccess(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getObjectsForOwner(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), MEMBER, and OWNER.

+ Here is the call graph for this function:

◆ groupExists()

ilSoapGroupAdministration::groupExists (   $sid,
  $title 
)

Definition at line 139 of file class.ilSoapGroupAdministration.php.

140 {
141 $this->initAuth($sid);
142 $this->initIlias();
143
144 if(!$this->__checkSession($sid))
145 {
146 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
147 }
148
149 if(!$title)
150 {
151 return $this->__raiseError('No title given. Please choose an title for the group in question.',
152 'Client');
153 }
154
156 }
static groupNameExists($a_group_name, $a_id=0)
checks if group name already exists.

References $title, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilUtil\groupNameExists(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ isAssignedToGroup()

ilSoapGroupAdministration::isAssignedToGroup (   $sid,
  $group_id,
  $user_id 
)

Definition at line 308 of file class.ilSoapGroupAdministration.php.

309 {
310 $this->initAuth($sid);
311 $this->initIlias();
312
313 if(!$this->__checkSession($sid))
314 {
315 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
316 }
317 if(!is_numeric($group_id))
318 {
319 return $this->__raiseError('No valid group id given. Please choose an existing id of an ILIAS group',
320 'Client');
321 }
322 global $rbacsystem;
323
324 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
325 {
326 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
327 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
328 {
329 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
330 }
331 }
332
333 if(ilObject::_lookupType($user_id) != 'usr')
334 {
335 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
336 }
337
338 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
339 {
340 return $this->__raiseError('Cannot create group instance!','Server');
341 }
342
343 if(!$rbacsystem->checkAccess('read',$group_id))
344 {
345 return $this->__raiseError('Check access failed. No permission to read group data','Server');
346 }
347
348 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
350
351 if($participants->isAdmin($user_id))
352 {
353 return 1;
354 }
355 if($participants->isMember($user_id))
356 {
357 return 2;
358 }
359 return 0;
360 }

References ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilGroupParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

◆ updateGroup()

ilSoapGroupAdministration::updateGroup (   $sid,
  $ref_id,
  $grp_xml 
)

Definition at line 83 of file class.ilSoapGroupAdministration.php.

84 {
85 $this->initAuth($sid);
86 $this->initIlias();
87
88
89 if(!$this->__checkSession($sid))
90 {
91 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
92 }
93
94
95
96 if(!is_numeric($ref_id))
97 {
98 return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category or group',
99 'Client');
100 }
101
102 global $rbacsystem;
103
104 if(!$rbacsystem->checkAccess('write',$ref_id,'grp'))
105 {
106 return $this->__raiseError('Check access failed. No permission to edit groups','Server');
107 }
108
109 // Start import
110 include_once("./Modules/Group/classes/class.ilObjGroup.php");
111
113 {
114 return $this->__raiseError('Cannot create group instance!','CLIENT_OBJECT_NOT_FOUND');
115 }
116
118 {
119 return $this->__raiseError("Object with ID $ref_id has been deleted.", 'CLIENT_OBJECT_DELETED');
120 }
121
122
123 if (ilObjectFactory::getTypeByRefId($ref_id, false) !="grp")
124 {
125 return $this->__raiseError('Reference id does not point to a group!','CLIENT_WRONG_TYPE');
126 }
127
128
129 include_once 'Modules/Group/classes/class.ilGroupXMLParser.php';
130 $xml_parser = new ilGroupXMLParser($grp_xml, -1);
131 $xml_parser->setMode(ilGroupXMLParser::$UPDATE);
132 $xml_parser->setGroup($grp);
133 $new_ref_id = $xml_parser->startParsing();
134
135 return $new_ref_id ? $new_ref_id : "0";
136 }
static getTypeByRefId($a_ref_id, $stop_on_error=true)
get object type by reference id

References $ref_id, ilGroupXMLParser\$UPDATE, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilObjectFactory\getTypeByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

+ Here is the call graph for this function:

Field Documentation

◆ ADMIN

const ilSoapGroupAdministration::ADMIN = 2

Definition at line 38 of file class.ilSoapGroupAdministration.php.

Referenced by getGroupsForUser().

◆ MEMBER

const ilSoapGroupAdministration::MEMBER = 1

Definition at line 37 of file class.ilSoapGroupAdministration.php.

Referenced by getGroupsForUser().

◆ OWNER

const ilSoapGroupAdministration::OWNER = 4

Definition at line 39 of file class.ilSoapGroupAdministration.php.

Referenced by getGroupsForUser().


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