35 public function addCourse(
string $sid,
int $target_id,
string $crs_xml)
46 $rbacsystem =
$DIC[
'rbacsystem'];
49 return $this->
raiseError(
'No valid target given.',
'Client');
53 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
56 if (!$rbacsystem->checkAccess(
'create', $target_id,
'crs')) {
57 return $this->
raiseError(
'Check access failed. No permission to create courses',
'Server');
61 $newObj->setType(
'crs');
62 $newObj->setTitle(
'dummy');
63 $newObj->setDescription(
"");
65 $newObj->createReference();
66 $newObj->putInTree($target_id);
67 $newObj->setPermissions($target_id);
71 $xml_parser->setXMLContent($crs_xml);
72 $xml_parser->startParsing();
73 return $newObj->getRefId() ?:
"0";
90 $rbacsystem =
$DIC[
'rbacsystem'];
94 $course_id = end($ref_ids);
97 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
103 if (!$rbacsystem->checkAccess(
'delete', $course_id)) {
104 return $this->
raiseError(
'Check access failed. No permission to delete course',
'Server');
108 $tree =
$DIC->repositoryTree();
109 $user =
$DIC->user();
110 $rbacadmin =
$DIC[
'rbacadmin'];
113 if ($tree->isDeleted($course_id)) {
114 return $this->
raiseError(
'Node already deleted',
'Server');
117 $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
118 foreach ($subnodes as $subnode) {
119 $rbacadmin->revokePermission($subnode[
"child"]);
121 if (!$tree->moveToTrash($course_id,
true, $user->getId())) {
122 return $this->
raiseError(
'Node already deleted',
'Client');
125 $log->write(
"SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id .
" to trash");
137 ?
bool $notification =
null,
138 ?
bool $contact_person =
null,
139 ?
bool $blocked =
null
150 $rbacsystem =
$DIC[
'rbacsystem'];
154 $course_id = end($ref_ids);
157 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
163 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
164 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
168 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
175 if (!isset($valid_roles[$type])) {
176 return $this->
raiseError(
'Invalid type. Must be "Admin", "Tutor", or "Member"',
'Client');
180 return $this->
raiseError(
'Cannot create course instance!',
'Server');
184 return $this->
raiseError(
'Cannot create user instance!',
'Server');
189 $course_members->add($tmp_user->getId(), $valid_roles[$type]);
191 $course_members->sendNotification(
196 if ($type ===
'Admin' || $type ===
'Tutor') {
197 if ($notification !==
null) {
198 $course_members->updateNotification($tmp_user->getId(), $notification);
201 if ($contact_person !==
null) {
202 $course_members->updateContact($tmp_user->getId(), $contact_person);
204 } elseif ($type ===
"Member" && $blocked !==
null) {
205 $course_members->updateBlocked($tmp_user->getId(), $blocked);
224 $rbacsystem =
$DIC[
'rbacsystem'];
228 $course_id = end($ref_ids);
231 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
238 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
242 return $this->
raiseError(
'Cannot create course instance!',
'Server');
245 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
246 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
250 if (!$course_members->checkLastAdmin(array(
$user_id))) {
251 return $this->
raiseError(
'Cannot deassign last administrator from course',
'Server');
260 public function isAssignedToCourse(
string $sid,
int $course_id,
int $user_id)
271 $rbacsystem =
$DIC[
'rbacsystem'];
275 $course_id = end($ref_ids);
278 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
285 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
290 return $this->
raiseError(
'Cannot create course instance!',
'Server');
293 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
294 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
299 if ($crs_members->isAdmin(
$user_id)) {
302 if ($crs_members->isTutor(
$user_id)) {
305 if ($crs_members->isMember(
$user_id)) {
314 public function getCourseXML(
string $sid,
int $course_id)
325 $rbacsystem =
$DIC[
'rbacsystem'];
329 if ($this->
isFault($tmp_course)) {
334 $xml_writer->start();
335 return $xml_writer->getXML();
341 public function updateCourse(
string $sid,
int $course_id,
string $xml)
352 $rbacsystem =
$DIC[
'rbacsystem'];
356 $course_id = end($ref_ids);
359 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
367 return $this->
raiseError(
'Cannot create course instance!',
'Server');
370 if (!$rbacsystem->checkAccess(
'write', $course_id)) {
371 return $this->
raiseError(
'Check access failed. No permission to write course',
'Server');
381 $xml_parser->setXMLContent($xml);
382 $xml_parser->startParsing();
383 $tmp_course->MDUpdateListener(
'General');
402 $rbacreview =
$DIC[
'rbacreview'];
403 $ilObjDataCache =
$DIC[
'ilObjDataCache'];
404 $tree =
$DIC[
'tree'];
408 $parser->startParsing();
410 return $this->
raiseError($exception->getMessage(),
"Client");
412 $xmlResultSet = $parser->getXMLResultSet();
414 if (!$xmlResultSet->hasColumn(
"user_id")) {
415 return $this->
raiseError(
"parameter user_id is missing",
"Client");
418 if (!$xmlResultSet->hasColumn(
"status")) {
419 return $this->
raiseError(
"parameter status is missing",
"Client");
422 $user_id = (
int) $xmlResultSet->getValue(0,
"user_id");
423 $status = (
int) $xmlResultSet->getValue(0,
"status");
428 self::MEMBER == ($status & self::MEMBER) ||
429 self::TUTOR == ($status & self::TUTOR) ||
430 self::ADMIN == ($status & self::ADMIN)
432 foreach ($rbacreview->assignedRoles(
$user_id) as $role_id) {
434 #echo $role->getType();
435 if ($role->getType() !==
"role") {
441 $role_title = $role->getTitle();
449 self::MEMBER == ($status & self::MEMBER) && strpos(
456 self::TUTOR == ($status & self::TUTOR) && strpos(
463 self::ADMIN == ($status & self::ADMIN) && strpos(
469 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId(
$ref_id)) ==
$user_id) {
476 if (($status & self::OWNER) == self::OWNER) {
479 foreach ($owned_objects as $obj_id) {
481 foreach ($allrefs as $r) {
482 if ($tree->isDeleted($r)) {
485 if ($tree->isInTree($r)) {
489 if (count($refs) > 0) {
490 $ref_ids[] = array_pop($refs);
494 $ref_ids = array_unique($ref_ids);
496 $ref_ids = array_unique($ref_ids);
499 $xmlResultSet->addColumn(
"ref_id");
500 $xmlResultSet->addColumn(
"xml");
501 $xmlResultSet->addColumn(
"parent_ref_id");
505 $ilUser =
$DIC[
'ilUser'];
508 $permission =
$user_id === $ilUser->getId() ?
'read' :
'write';
510 foreach ($ref_ids as $course_id) {
514 $row->setValue(
"ref_id", $course_id);
516 $xmlWriter->setAttachUsers(
false);
518 $row->setValue(
"xml", $xmlWriter->getXML());
519 $row->setValue(
"parent_ref_id", $tree->getParentId($course_id));
520 $xmlResultSet->addRow($row);
524 $xmlResultSetWriter->start();
525 return $xmlResultSetWriter->getXML();
const TYPE_ADMISSION_MEMBER
static _getInstanceByObjId(int $a_obj_id)
XML writer class Class to simplify manual writing of xml documents.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _isInTrash(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _deleteAllEntries(int $a_obj_id)
Delete all entries Normally called in case of object deletion.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
raiseError(string $a_message, $a_code)
checkSession(string $sid)
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
addCourse(string $sid, int $target_id, string $crs_xml)
deleteCourse(string $sid, int $course_id)
getCoursesForUser(string $sid, string $parameters)
assignCourseMember(string $sid, int $course_id, int $user_id, string $type, ?bool $notification=null, ?bool $contact_person=null, ?bool $blocked=null)
excludeCourseMember(string $sid, int $course_id, int $user_id)
static __extractRefId(string $role_title)
extract ref id from role title, e.g.
static _deleteAll(int $a_obj_id)
Row Class for XMLResultSet.
XML Writer for XMLResultSet.