ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSoapGroupAdministration Class Reference
+ Inheritance diagram for ilSoapGroupAdministration:
+ Collaboration diagram for ilSoapGroupAdministration:

Public Member Functions

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

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 49 of file class.ilSoapGroupAdministration.php.

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

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 197 of file class.ilSoapGroupAdministration.php.

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

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

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 163 of file class.ilSoapGroupAdministration.php.

164 {
165 $this->initAuth($sid);
166 $this->initIlias();
167
168 if(!$this->__checkSession($sid))
169 {
170 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
171 }
172
174 {
175 return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'CLIENT_OBJECT_DELETED');
176 }
177
178
179 if(!$grp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
180 {
181 return $this->__raiseError('No valid reference id given.',
182 'Client');
183 }
184
185
186 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
187
188 $xml_writer = new ilGroupXMLWriter($grp_obj);
189 $xml_writer->start();
190
191 $xml = $xml_writer->getXML();
192
193 return strlen($xml) ? $xml : '';
194 }
$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 376 of file class.ilSoapGroupAdministration.php.

376 {
377
378 $this->initAuth($sid);
379 $this->initIlias();
380
381 if(!$this->__checkSession($sid))
382 {
383 return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
384 }
385 global $rbacreview, $ilObjDataCache, $tree;
386
387 include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
388 $parser = new ilXMLResultSetParser($parameters);
389 try {
390 $parser->startParsing();
391 } catch (ilSaxParserException $exception) {
392 return $this->__raiseError($exception->getMessage(), "Client");
393 }
394 $xmlResultSet = $parser->getXMLResultSet();
395
396 if (!$xmlResultSet->hasColumn ("user_id"))
397 return $this->__raiseError("parameter user_id is missing", "Client");
398
399 if (!$xmlResultSet->hasColumn ("status"))
400 return $this->__raiseError("parameter status is missing", "Client");
401
402 $user_id = (int) $xmlResultSet->getValue (0, "user_id");
403 $status = (int) $xmlResultSet->getValue (0, "status");
404
405 $ref_ids = array();
406
407 // get roles
408#var_dump($xmlResultSet);
409#echo "uid:".$user_id;
410#echo "status:".$status;
413 foreach($rbacreview->assignedRoles($user_id) as $role_id)
414 {
415 if($role = ilObjectFactory::getInstanceByObjId($role_id,false))
416 {
417 #echo $role->getType();
418 if ($role->getType() != "role")
419 continue;
420
421 if ($role->getParent() == ROLE_FOLDER_ID)
422 {
423 continue;
424 }
425 $role_title = $role->getTitle();
426
427 if ($ref_id = ilUtil::__extractRefId($role_title))
428 {
430 continue;
431
432 #echo $role_title;
433 if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos($role_title, "member") !== false)
434 {
435 $ref_ids [] = $ref_id;
436 } elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos($role_title, "admin") !== false)
437 {
438 $ref_ids [] = $ref_id;
439 }
440 }
441 }
442 }
443
445 {
446 $owned_objects = ilObjectFactory::getObjectsForOwner("grp", $user_id);
447 foreach ($owned_objects as $obj_id) {
448 $allrefs = ilObject::_getAllReferences($obj_id);
449 $refs = array();
450 foreach($allrefs as $r)
451 {
452 if($tree->isDeleted($r))
453 {
454 continue;
455 }
456 if ($tree->isInTree($r))
457 {
458 $refs[] = $r;
459 }
460 }
461 if (count($refs) > 0)
462 $ref_ids[] = array_pop($refs);
463 }
464 }
465 $ref_ids = array_unique($ref_ids);
466
467
468#print_r($ref_ids);
469 include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
470 include_once 'Modules/Group/classes/class.ilObjGroup.php';
471 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
472
473 $xmlResultSet = new ilXMLResultSet();
474 $xmlResultSet->addColumn("ref_id");
475 $xmlResultSet->addColumn("xml");
476 $xmlResultSet->addColumn("parent_ref_id");
477
478 foreach ($ref_ids as $group_id) {
479 $group_obj = $this->checkObjectAccess($group_id,"grp","write", true);
480 if ($group_obj instanceof ilObjGroup) {
481 $row = new ilXMLResultSetRow();
482 $row->setValue("ref_id", $group_id);
483 $xmlWriter = new ilGroupXMLWriter($group_obj);
484 $xmlWriter->setAttachUsers(false);
485 $xmlWriter->start();
486 $row->setValue("xml", $xmlWriter->getXML());
487 $row->setValue("parent_ref_id", $tree->getParentId($group_id));
488 $xmlResultSet->addRow($row);
489 }
490 }
491 $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
492 $xmlResultSetWriter->start();
493 return $xmlResultSetWriter->getXML();
494 }
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 $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 144 of file class.ilSoapGroupAdministration.php.

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

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

+ Here is the call graph for this function:

◆ ilSoapGroupAdministration()

ilSoapGroupAdministration::ilSoapGroupAdministration ( )

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

43 {
44 parent::ilSoapAdministration();
45 }

◆ isAssignedToGroup()

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

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

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

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 88 of file class.ilSoapGroupAdministration.php.

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