ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $DIC;
61
62 $rbacsystem = $DIC['rbacsystem'];
63
64 if (!$rbacsystem->checkAccess('create', $target_id, 'grp')) {
65 return $this->__raiseError('Check access failed. No permission to create groups', 'Server');
66 }
67
69 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
70 }
71
72
73 $newObj = new ilObjGroup();
74 $newObj->setTitle('dummy');
75 $newObj->setDescription("");
76 $newObj->create(true); // true for upload
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($newObj, $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.
Class ilObjGroup.
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
$DIC
Definition: xapitoken.php:46

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

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

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

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

161 {
162 $this->initAuth($sid);
163 $this->initIlias();
164
165 if (!$this->__checkSession($sid)) {
166 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
167 }
168
169 if (ilObject::_isInTrash($ref_id)) {
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 return $this->__raiseError(
176 'No valid reference id given.',
177 'Client'
178 );
179 }
180
181
182 include_once 'Modules/Group/classes/class.ilGroupXMLWriter.php';
183
184 $xml_writer = new ilGroupXMLWriter($grp_obj);
185 $xml_writer->start();
186
187 $xml = $xml_writer->getXML();
188
189 return strlen($xml) ? $xml : '';
190 }
$xml
Definition: metadata.php:332

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

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

References $DIC, $parser, 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 141 of file class.ilSoapGroupAdministration.php.

142 {
143 $this->initAuth($sid);
144 $this->initIlias();
145
146 if (!$this->__checkSession($sid)) {
147 return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
148 }
149
150 if (!$title) {
151 return $this->__raiseError(
152 'No title given. Please choose an title for the group in question.',
153 'Client'
154 );
155 }
156
157 return ilUtil::groupNameExists($title);
158 }
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:

◆ isAssignedToGroup()

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

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

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

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

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

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