34 public function addCourse(
string $sid,
int $target_id,
string $crs_xml)
45 $rbacsystem = $DIC[
'rbacsystem'];
48 return $this->
raiseError(
'No valid target given.',
'Client');
52 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
55 if (!$rbacsystem->checkAccess(
'create', $target_id,
'crs')) {
56 return $this->
raiseError(
'Check access failed. No permission to create courses',
'Server');
60 $newObj->setType(
'crs');
61 $newObj->setTitle(
'dummy');
62 $newObj->setDescription(
"");
63 $newObj->create(
true);
64 $newObj->createReference();
65 $newObj->putInTree($target_id);
66 $newObj->setPermissions($target_id);
70 $xml_parser->setXMLContent($crs_xml);
71 $xml_parser->startParsing();
72 return $newObj->getRefId() ?:
"0";
89 $rbacsystem = $DIC[
'rbacsystem'];
93 $course_id = end($ref_ids);
96 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
102 if (!$rbacsystem->checkAccess(
'delete', $course_id)) {
103 return $this->
raiseError(
'Check access failed. No permission to delete course',
'Server');
107 $tree = $DIC->repositoryTree();
108 $user = $DIC->user();
109 $rbacadmin = $DIC[
'rbacadmin'];
112 if ($tree->isDeleted($course_id)) {
113 return $this->
raiseError(
'Node already deleted',
'Server');
116 $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
117 foreach ($subnodes as $subnode) {
118 $rbacadmin->revokePermission($subnode[
"child"]);
120 if (!$tree->moveToTrash($course_id,
true, $user->getId())) {
121 return $this->
raiseError(
'Node already deleted',
'Client');
124 $log->write(
"SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id .
" to trash");
142 $rbacsystem = $DIC[
'rbacsystem'];
146 $course_id = end($ref_ids);
149 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
155 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
156 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
160 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
162 if ($type !==
'Admin' &&
164 $type !==
'Member') {
166 'Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"',
172 return $this->
raiseError(
'Cannot create course instance!',
'Server');
176 return $this->
raiseError(
'Cannot create user instance!',
'Server');
185 $course_members->updateNotification(
187 (bool) $settings->get(
'mail_crs_admin_notification',
"1")
216 $rbacsystem = $DIC[
'rbacsystem'];
220 $course_id = end($ref_ids);
223 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
230 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
234 return $this->
raiseError(
'Cannot create course instance!',
'Server');
237 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
238 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
242 if (!$course_members->checkLastAdmin(array($user_id))) {
243 return $this->
raiseError(
'Cannot deassign last administrator from course',
'Server');
245 $course_members->delete($user_id);
252 public function isAssignedToCourse(
string $sid,
int $course_id,
int $user_id)
263 $rbacsystem = $DIC[
'rbacsystem'];
267 $course_id = end($ref_ids);
270 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
277 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
282 return $this->
raiseError(
'Cannot create course instance!',
'Server');
285 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
286 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
291 if ($crs_members->isAdmin($user_id)) {
294 if ($crs_members->isTutor($user_id)) {
297 if ($crs_members->isMember($user_id)) {
306 public function getCourseXML(
string $sid,
int $course_id)
317 $rbacsystem = $DIC[
'rbacsystem'];
321 if ($this->
isFault($tmp_course)) {
326 $xml_writer->start();
327 return $xml_writer->getXML();
333 public function updateCourse(
string $sid,
int $course_id,
string $xml)
344 $rbacsystem = $DIC[
'rbacsystem'];
348 $course_id = end($ref_ids);
351 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
359 return $this->
raiseError(
'Cannot create course instance!',
'Server');
362 if (!$rbacsystem->checkAccess(
'write', $course_id)) {
363 return $this->
raiseError(
'Check access failed. No permission to write course',
'Server');
368 $md =
new ilMD($tmp_course->getId(), 0,
'crs');
378 $xml_parser->setXMLContent($xml);
379 $xml_parser->startParsing();
380 $tmp_course->MDUpdateListener(
'General');
399 $rbacreview = $DIC[
'rbacreview'];
400 $ilObjDataCache = $DIC[
'ilObjDataCache'];
401 $tree = $DIC[
'tree'];
405 $parser->startParsing();
407 return $this->
raiseError($exception->getMessage(),
"Client");
409 $xmlResultSet = $parser->getXMLResultSet();
411 if (!$xmlResultSet->hasColumn(
"user_id")) {
412 return $this->
raiseError(
"parameter user_id is missing",
"Client");
415 if (!$xmlResultSet->hasColumn(
"status")) {
416 return $this->
raiseError(
"parameter status is missing",
"Client");
419 $user_id = (
int) $xmlResultSet->getValue(0,
"user_id");
420 $status = (
int) $xmlResultSet->getValue(0,
"status");
424 if (self::MEMBER == ($status & self::MEMBER) ||
425 self::TUTOR == ($status & self::TUTOR) ||
426 self::ADMIN == ($status & self::ADMIN)) {
427 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
429 #echo $role->getType(); 430 if ($role->getType() !==
"role") {
436 $role_title = $role->getTitle();
443 if (self::MEMBER == ($status & self::MEMBER) && strpos(
448 } elseif (self::TUTOR == ($status & self::TUTOR) && strpos(
453 } elseif (self::ADMIN == ($status & self::ADMIN) && strpos(
458 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId(
$ref_id)) == $user_id) {
465 if (($status & self::OWNER) == self::OWNER) {
468 foreach ($owned_objects as $obj_id) {
470 foreach ($allrefs as
$r) {
471 if ($tree->isDeleted($r)) {
474 if ($tree->isInTree($r)) {
478 if (count($refs) > 0) {
479 $ref_ids[] = array_pop($refs);
483 $ref_ids = array_unique($ref_ids);
485 $ref_ids = array_unique($ref_ids);
488 $xmlResultSet->addColumn(
"ref_id");
489 $xmlResultSet->addColumn(
"xml");
490 $xmlResultSet->addColumn(
"parent_ref_id");
494 $ilUser = $DIC[
'ilUser'];
497 $permission = $user_id === $ilUser->getId() ?
'read' :
'write';
499 foreach ($ref_ids as $course_id) {
503 $row->setValue(
"ref_id", $course_id);
505 $xmlWriter->setAttachUsers(
false);
507 $row->setValue(
"xml", $xmlWriter->getXML());
508 $row->setValue(
"parent_ref_id", $tree->getParentId($course_id));
509 $xmlResultSet->addRow($row);
513 $xmlResultSetWriter->start();
514 return $xmlResultSetWriter->getXML();
addCourse(string $sid, int $target_id, string $crs_xml)
XML Writer for XMLResultSet.
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...
getCoursesForUser(string $sid, string $parameters)
static _lookupObjId(int $ref_id)
static _deleteAll(int $a_obj_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getInstanceByObjId(int $a_obj_id)
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
deleteCourse(string $sid, int $course_id)
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 ...
excludeCourseMember(string $sid, int $course_id, int $user_id)
assignCourseMember(string $sid, int $course_id, int $user_id, string $type)
static _deleteAllEntries(int $a_obj_id)
Delete all entries Normally called in case of object deletion.
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)
XML writer class Class to simplify manual writing of xml documents.
static __extractRefId(string $role_title)
extract ref id from role title, e.g.