33 public function addGroup(
string $sid,
int $target_id,
string $grp_xml)
44 $rbacsystem = $DIC[
'rbacsystem'];
46 if (!$rbacsystem->checkAccess(
'create', $target_id,
'grp')) {
47 return $this->
raiseError(
'Check access failed. No permission to create groups',
'Server');
51 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
55 $newObj->setTitle(
'dummy');
56 $newObj->setDescription(
"");
60 $xml_parser->startParsing();
61 $new_ref_id = $xml_parser->getObjectRefId();
63 return $new_ref_id ?:
"0";
69 public function updateGroup(
string $sid,
int $ref_id,
string $grp_xml)
80 $rbacsystem = $DIC[
'rbacsystem'];
82 if (!$rbacsystem->checkAccess(
'write', $ref_id,
'grp')) {
83 return $this->
raiseError(
'Check access failed. No permission to edit groups',
'Server');
88 return $this->
raiseError(
'Cannot create group instance!',
'CLIENT_OBJECT_NOT_FOUND');
92 return $this->
raiseError(
"Object with ID $ref_id has been deleted.",
'CLIENT_OBJECT_DELETED');
96 return $this->
raiseError(
'Reference id does not point to a group!',
'CLIENT_WRONG_TYPE');
101 $xml_parser->startParsing();
102 $new_ref_id = $xml_parser->getObjectRefId();
104 return $new_ref_id ?:
"0";
121 'No title given. Please choose an title for the group in question.',
132 public function getGroup(
string $sid,
int $ref_id)
142 return $this->
raiseError(
"Parent with ID $ref_id has been deleted.",
'CLIENT_OBJECT_DELETED');
148 'No valid reference id given.',
154 $xml_writer->start();
156 return $xml_writer->getXML();
162 public function assignGroupMember(
string $sid,
int $group_id,
int $user_id,
string $type)
173 $rbacsystem = $DIC[
'rbacsystem'];
177 $group_id = end($ref_ids);
180 'Invalid group id. Object with id "' . $group_id .
'" is not of type "group"',
186 if (!$rbacsystem->checkAccess(
'manage_members', $group_id)) {
187 return $this->
raiseError(
'Check access failed. No permission to write to group',
'Server');
191 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
193 if ($type !==
'Admin' &&
194 $type !==
'Member') {
196 'Invalid type ' . $type .
' given. Parameter "type" must be "Admin","Member"',
203 return $this->
raiseError(
'Cannot create group instance!',
'Server');
208 return $this->
raiseError(
'Cannot create user instance!',
'Server');
228 public function excludeGroupMember(
string $sid,
int $group_id,
int $user_id)
239 $rbacsystem = $DIC[
'rbacsystem'];
243 $group_id = end($ref_ids);
246 'Invalid group id. Object with id "' . $group_id .
'" is not of type "group"',
253 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
258 return $this->
raiseError(
'Cannot create group instance!',
'Server');
261 if (!$rbacsystem->checkAccess(
'manage_members', $group_id)) {
262 return $this->
raiseError(
'Check access failed. No permission to write to group',
'Server');
265 $tmp_group->leave($user_id);
272 public function isAssignedToGroup(
string $sid,
int $group_id,
int $user_id)
283 $rbacsystem = $DIC[
'rbacsystem'];
287 $group_id = end($ref_ids);
290 'Invalid group id. Object with id "' . $group_id .
'" is not of type "group"',
297 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
302 return $this->
raiseError(
'Cannot create group instance!',
'Server');
305 if (!$rbacsystem->checkAccess(
'read', $group_id)) {
306 return $this->
raiseError(
'Check access failed. No permission to read group data',
'Server');
311 if ($participants->isAdmin($user_id)) {
314 if ($participants->isMember($user_id)) {
333 $rbacreview = $DIC[
'rbacreview'];
334 $ilObjDataCache = $DIC[
'ilObjDataCache'];
335 $tree = $DIC[
'tree'];
339 $parser->startParsing();
341 return $this->
raiseError($exception->getMessage(),
"Client");
343 $xmlResultSet = $parser->getXMLResultSet();
345 if (!$xmlResultSet->hasColumn(
"user_id")) {
346 return $this->
raiseError(
"parameter user_id is missing",
"Client");
349 if (!$xmlResultSet->hasColumn(
"status")) {
350 return $this->
raiseError(
"parameter status is missing",
"Client");
353 $user_id = (
int) $xmlResultSet->getValue(0,
"user_id");
354 $status = (
int) $xmlResultSet->getValue(0,
"status");
360 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
362 #echo $role->getType(); 363 if ($role->getType() !==
"role") {
370 $role_title = $role->getTitle();
378 if (ilSoapGroupAdministration::MEMBER == ($status & ilSoapGroupAdministration::MEMBER) && strpos(
383 } elseif (ilSoapGroupAdministration::ADMIN == ($status & ilSoapGroupAdministration::ADMIN) && strpos(
396 foreach ($owned_objects as $obj_id) {
399 foreach ($allrefs as
$r) {
400 if ($tree->isDeleted($r)) {
403 if ($tree->isInTree($r)) {
407 if (count($refs) > 0) {
408 $ref_ids[] = array_pop($refs);
412 $ref_ids = array_unique($ref_ids);
415 $xmlResultSet->addColumn(
"ref_id");
416 $xmlResultSet->addColumn(
"xml");
417 $xmlResultSet->addColumn(
"parent_ref_id");
419 foreach ($ref_ids as $group_id) {
423 $row->setValue(
"ref_id", $group_id);
425 $xmlWriter->setAttachUsers(
false);
427 $row->setValue(
"xml", $xmlWriter->getXML());
428 $row->setValue(
"parent_ref_id", $tree->getParentId($group_id));
429 $xmlResultSet->addRow($row);
433 $xmlResultSetWriter->start();
434 return $xmlResultSetWriter->getXML();
XML Writer for XMLResultSet.
addGroup(string $sid, int $target_id, string $grp_xml)
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
Row Class for XMLResultSet.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTypeByRefId(int $ref_id, bool $stop_on_error=true)
get object type by reference id
static _lookupObjId(int $ref_id)
getGroupsForUser(string $sid, string $parameters)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
groupExists(string $sid, string $title)
checkSession(string $sid)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
checkObjectAccess(int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true ...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
static groupNameExists(string $a_group_name, ?int $a_id=null)
checks if group name already exists.
static _lookupType(int $id, bool $reference=false)
static __extractRefId(string $role_title)
extract ref id from role title, e.g.