41 public function addCourse(
string $sid,
int $target_id,
string $crs_xml)
52 $rbacsystem = $DIC[
'rbacsystem'];
55 return $this->
raiseError(
'No valid target given.',
'Client');
59 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
62 if (!$rbacsystem->checkAccess(
'create', $target_id,
'crs')) {
63 return $this->
raiseError(
'Check access failed. No permission to create courses',
'Server');
67 $newObj->setType(
'crs');
68 $newObj->setTitle(
'dummy');
69 $newObj->setDescription(
"");
70 $newObj->create(
true);
71 $newObj->createReference();
72 $newObj->putInTree($target_id);
73 $newObj->setPermissions($target_id);
77 $xml_parser->setXMLContent($crs_xml);
78 $xml_parser->startParsing();
79 return $newObj->getRefId() ?:
"0";
96 $rbacsystem = $DIC[
'rbacsystem'];
100 $course_id = end($ref_ids);
103 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
109 if (!$rbacsystem->checkAccess(
'delete', $course_id)) {
110 return $this->
raiseError(
'Check access failed. No permission to delete course',
'Server');
114 $tree = $DIC->repositoryTree();
115 $user = $DIC->user();
116 $rbacadmin = $DIC[
'rbacadmin'];
119 if ($tree->isDeleted($course_id)) {
120 return $this->
raiseError(
'Node already deleted',
'Server');
123 $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
124 foreach ($subnodes as $subnode) {
125 $rbacadmin->revokePermission($subnode[
"child"]);
127 if (!$tree->moveToTrash($course_id,
true, $user->getId())) {
128 return $this->
raiseError(
'Node already deleted',
'Client');
131 $log->write(
"SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id .
" to trash");
149 $rbacsystem = $DIC[
'rbacsystem'];
153 $course_id = end($ref_ids);
156 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
162 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
163 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
167 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
169 if ($type !==
'Admin' &&
171 $type !==
'Member') {
173 'Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"',
179 return $this->
raiseError(
'Cannot create course instance!',
'Server');
183 return $this->
raiseError(
'Cannot create user instance!',
'Server');
192 $course_members->updateNotification(
194 (bool) $settings->get(
'mail_crs_admin_notification',
"1")
223 $rbacsystem = $DIC[
'rbacsystem'];
227 $course_id = end($ref_ids);
230 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
237 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
241 return $this->
raiseError(
'Cannot create course instance!',
'Server');
244 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
245 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
249 if (!$course_members->checkLastAdmin(array($user_id))) {
250 return $this->
raiseError(
'Cannot deassign last administrator from course',
'Server');
252 $course_members->delete($user_id);
259 public function isAssignedToCourse(
string $sid,
int $course_id,
int $user_id)
270 $rbacsystem = $DIC[
'rbacsystem'];
274 $course_id = end($ref_ids);
277 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
284 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
289 return $this->
raiseError(
'Cannot create course instance!',
'Server');
292 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
293 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
298 if ($crs_members->isAdmin($user_id)) {
301 if ($crs_members->isTutor($user_id)) {
304 if ($crs_members->isMember($user_id)) {
313 public function getCourseXML(
string $sid,
int $course_id)
324 $rbacsystem = $DIC[
'rbacsystem'];
328 if ($this->
isFault($tmp_course)) {
333 $xml_writer->start();
334 return $xml_writer->getXML();
340 public function updateCourse(
string $sid,
int $course_id,
string $xml)
351 $rbacsystem = $DIC[
'rbacsystem'];
355 $course_id = end($ref_ids);
358 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
366 return $this->
raiseError(
'Cannot create course instance!',
'Server');
369 if (!$rbacsystem->checkAccess(
'write', $course_id)) {
370 return $this->
raiseError(
'Check access failed. No permission to write course',
'Server');
375 $md =
new ilMD($tmp_course->getId(), 0,
'crs');
385 $xml_parser->setXMLContent($xml);
386 $xml_parser->startParsing();
387 $tmp_course->MDUpdateListener(
'General');
406 $rbacreview = $DIC[
'rbacreview'];
407 $ilObjDataCache = $DIC[
'ilObjDataCache'];
408 $tree = $DIC[
'tree'];
412 $parser->startParsing();
414 return $this->
raiseError($exception->getMessage(),
"Client");
416 $xmlResultSet = $parser->getXMLResultSet();
418 if (!$xmlResultSet->hasColumn(
"user_id")) {
419 return $this->
raiseError(
"parameter user_id is missing",
"Client");
422 if (!$xmlResultSet->hasColumn(
"status")) {
423 return $this->
raiseError(
"parameter status is missing",
"Client");
426 $user_id = (
int) $xmlResultSet->getValue(0,
"user_id");
427 $status = (
int) $xmlResultSet->getValue(0,
"status");
431 if (self::MEMBER == ($status & self::MEMBER) ||
432 self::TUTOR == ($status & self::TUTOR) ||
433 self::ADMIN == ($status & self::ADMIN)) {
434 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
436 #echo $role->getType(); 437 if ($role->getType() !==
"role") {
443 $role_title = $role->getTitle();
450 if (self::MEMBER == ($status & self::MEMBER) && strpos(
455 } elseif (self::TUTOR == ($status & self::TUTOR) && strpos(
460 } elseif (self::ADMIN == ($status & self::ADMIN) && strpos(
465 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId(
$ref_id)) == $user_id) {
472 if (($status & self::OWNER) == self::OWNER) {
475 foreach ($owned_objects as $obj_id) {
477 foreach ($allrefs as
$r) {
478 if ($tree->isDeleted($r)) {
481 if ($tree->isInTree($r)) {
485 if (count($refs) > 0) {
486 $ref_ids[] = array_pop($refs);
490 $ref_ids = array_unique($ref_ids);
492 $ref_ids = array_unique($ref_ids);
495 $xmlResultSet->addColumn(
"ref_id");
496 $xmlResultSet->addColumn(
"xml");
497 $xmlResultSet->addColumn(
"parent_ref_id");
501 $ilUser = $DIC[
'ilUser'];
504 $permission = $user_id === $ilUser->getId() ?
'read' :
'write';
506 foreach ($ref_ids as $course_id) {
510 $row->setValue(
"ref_id", $course_id);
512 $xmlWriter->setAttachUsers(
false);
514 $row->setValue(
"xml", $xmlWriter->getXML());
515 $row->setValue(
"parent_ref_id", $tree->getParentId($course_id));
516 $xmlResultSet->addRow($row);
520 $xmlResultSetWriter->start();
521 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.
SaxParserException thrown by ilSaxParser if property throwException is set.
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static __extractRefId(string $role_title)
extract ref id from role title, e.g.