ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
51 }
52
53 if (!is_numeric($target_id)) {
54 return $this->__raiseError(
55 'No valid target id given. Please choose an existing reference id of an ILIAS category or group',
56 'Client'
57 );
58 }
59
60 global $rbacsystem;
61
62 if (!$rbacsystem->checkAccess('create', $target_id, 'grp')) {
63 return $this->__raiseError('Check access failed. No permission to create groups', 'Server');
64 }
65
67 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
68 }
69
70
71 // Start import
72 include_once("./Modules/Group/classes/class.ilObjGroup.php");
73 include_once 'Modules/Group/classes/class.ilGroupXMLParser.php';
74 $xml_parser = new ilGroupXMLParser($grp_xml, $target_id);
75 $new_ref_id = $xml_parser->startParsing();
76
77 return $new_ref_id ? $new_ref_id : "0";
78 }
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:49

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

186 {
187 $this->initAuth($sid);
188 $this->initIlias();
189
190 if (!$this->__checkSession($sid)) {
191 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
192 }
193
194 if (!is_numeric($group_id)) {
195 return $this->__raiseError(
196 'No valid group id given. Please choose an existing reference id of an ILIAS group',
197 'Client'
198 );
199 }
200
201 global $rbacsystem;
202
203 if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp') {
204 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
205 if (ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp') {
206 return $this->__raiseError('Invalid group id. Object with id "' . $group_id . '" is not of type "group"', 'Client');
207 }
208 }
209
210 if (!$rbacsystem->checkAccess('manage_members', $group_id)) {
211 return $this->__raiseError('Check access failed. No permission to write to group', 'Server');
212 }
213
214
215 if (ilObject::_lookupType($user_id) != 'usr') {
216 return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
217 }
218 if ($type != 'Admin' and
219 $type != 'Member') {
220 return $this->__raiseError('Invalid type ' . $type . ' given. Parameter "type" must be "Admin","Member"', 'Client');
221 }
222
223 if (!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id, false)) {
224 return $this->__raiseError('Cannot create group instance!', 'Server');
225 }
226
227 if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
228 return $this->__raiseError('Cannot create user instance!', 'Server');
229 }
230
231
232 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
233 $group_members = ilGroupParticipants::_getInstanceByObjId($tmp_group->getId());
234
235 switch ($type) {
236 case 'Admin':
237 $group_members->add($tmp_user->getId(), IL_GRP_ADMIN);
238 break;
239
240 case 'Member':
241 $group_members->add($tmp_user->getId(), IL_GRP_MEMBER);
242 break;
243 }
244 return true;
245 }
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
$type

References $type, 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 247 of file class.ilSoapGroupAdministration.php.

248 {
249 $this->initAuth($sid);
250 $this->initIlias();
251
252 if (!$this->__checkSession($sid)) {
253 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
254 }
255 if (!is_numeric($group_id)) {
256 return $this->__raiseError(
257 'No valid group id given. Please choose an existing reference id of an ILIAS group',
258 'Client'
259 );
260 }
261
262 global $rbacsystem;
263
264 if (($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp') {
265 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
266 if (ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp') {
267 return $this->__raiseError('Invalid group id. Object with id "' . $group_id . '" is not of type "group"', 'Client');
268 }
269 }
270
271 if (ilObject::_lookupType($user_id) != 'usr') {
272 return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
273 }
274
275 if (!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id, false)) {
276 return $this->__raiseError('Cannot create group instance!', 'Server');
277 }
278
279 if (!$rbacsystem->checkAccess('manage_members', $group_id)) {
280 return $this->__raiseError('Check access failed. No permission to write to group', 'Server');
281 }
282
283 $tmp_group->leave($user_id);
284 return true;
285 }

References $type, 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 152 of file class.ilSoapGroupAdministration.php.

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

References $xml, 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 344 of file class.ilSoapGroupAdministration.php.

345 {
346 $this->initAuth($sid);
347 $this->initIlias();
348
349 if (!$this->__checkSession($sid)) {
350 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
351 }
352 global $rbacreview, $ilObjDataCache, $tree;
353
354 include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
355 $parser = new ilXMLResultSetParser($parameters);
356 try {
357 $parser->startParsing();
358 } catch (ilSaxParserException $exception) {
359 return $this->__raiseError($exception->getMessage(), "Client");
360 }
361 $xmlResultSet = $parser->getXMLResultSet();
362
363 if (!$xmlResultSet->hasColumn("user_id")) {
364 return $this->__raiseError("parameter user_id is missing", "Client");
365 }
366
367 if (!$xmlResultSet->hasColumn("status")) {
368 return $this->__raiseError("parameter status is missing", "Client");
369 }
370
371 $user_id = (int) $xmlResultSet->getValue(0, "user_id");
372 $status = (int) $xmlResultSet->getValue(0, "status");
373
374 $ref_ids = array();
375
376 // get roles
377 #var_dump($xmlResultSet);
378 #echo "uid:".$user_id;
379 #echo "status:".$status;
382 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
383 if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
384 #echo $role->getType();
385 if ($role->getType() != "role") {
386 continue;
387 }
388
389 if ($role->getParent() == ROLE_FOLDER_ID) {
390 continue;
391 }
392 $role_title = $role->getTitle();
393
394 if ($ref_id = ilUtil::__extractRefId($role_title)) {
395 if (!ilObject::_exists($ref_id, true) || ilObject::_isInTrash($ref_id)) {
396 continue;
397 }
398
399 #echo $role_title;
400 if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos($role_title, "member") !== false) {
401 $ref_ids [] = $ref_id;
402 } elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos($role_title, "admin") !== false) {
403 $ref_ids [] = $ref_id;
404 }
405 }
406 }
407 }
408 }
409
411 $owned_objects = ilObjectFactory::getObjectsForOwner("grp", $user_id);
412 foreach ($owned_objects as $obj_id) {
413 $allrefs = ilObject::_getAllReferences($obj_id);
414 $refs = array();
415 foreach ($allrefs as $r) {
416 if ($tree->isDeleted($r)) {
417 continue;
418 }
419 if ($tree->isInTree($r)) {
420 $refs[] = $r;
421 }
422 }
423 if (count($refs) > 0) {
424 $ref_ids[] = array_pop($refs);
425 }
426 }
427 }
428 $ref_ids = array_unique($ref_ids);
429
430
431 #print_r($ref_ids);
432 include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
433 include_once 'Modules/Group/classes/class.ilObjGroup.php';
434 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
435
436 $xmlResultSet = new ilXMLResultSet();
437 $xmlResultSet->addColumn("ref_id");
438 $xmlResultSet->addColumn("xml");
439 $xmlResultSet->addColumn("parent_ref_id");
440
441 foreach ($ref_ids as $group_id) {
442 $group_obj = $this->checkObjectAccess($group_id, "grp", "write", true);
443 if ($group_obj instanceof ilObjGroup) {
444 $row = new ilXMLResultSetRow();
445 $row->setValue("ref_id", $group_id);
446 $xmlWriter = new ilGroupXMLWriter($group_obj);
447 $xmlWriter->setAttachUsers(false);
448 $xmlWriter->start();
449 $row->setValue("xml", $xmlWriter->getXML());
450 $row->setValue("parent_ref_id", $tree->getParentId($group_id));
451 $xmlResultSet->addRow($row);
452 }
453 }
454 $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
455 $xmlResultSetWriter->start();
456 return $xmlResultSetWriter->getXML();
457 }
$parser
Definition: BPMN2Parser.php:23
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, $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 133 of file class.ilSoapGroupAdministration.php.

134 {
135 $this->initAuth($sid);
136 $this->initIlias();
137
138 if (!$this->__checkSession($sid)) {
139 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
140 }
141
142 if (!$title) {
143 return $this->__raiseError(
144 'No title given. Please choose an title for the group in question.',
145 'Client'
146 );
147 }
148
150 }
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 288 of file class.ilSoapGroupAdministration.php.

289 {
290 $this->initAuth($sid);
291 $this->initIlias();
292
293 if (!$this->__checkSession($sid)) {
294 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
295 }
296 if (!is_numeric($group_id)) {
297 return $this->__raiseError(
298 'No valid group id given. Please choose an existing id of an ILIAS group',
299 'Client'
300 );
301 }
302 global $rbacsystem;
303
304 if (($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp') {
305 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
306 if (ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp') {
307 return $this->__raiseError('Invalid group id. Object with id "' . $group_id . '" is not of type "group"', 'Client');
308 }
309 }
310
311 if (ilObject::_lookupType($user_id) != 'usr') {
312 return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
313 }
314
315 if (!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id, false)) {
316 return $this->__raiseError('Cannot create group instance!', 'Server');
317 }
318
319 if (!$rbacsystem->checkAccess('read', $group_id)) {
320 return $this->__raiseError('Check access failed. No permission to read group data', 'Server');
321 }
322
323 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
325
326 if ($participants->isAdmin($user_id)) {
327 return 1;
328 }
329 if ($participants->isMember($user_id)) {
330 return 2;
331 }
332 return 0;
333 }

References $type, 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 81 of file class.ilSoapGroupAdministration.php.

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

References 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: