30 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
53 $rbacsystem = $DIC[
'rbacsystem'];
56 return $this->
raiseError(
'No valid target given.',
'Client');
60 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_OBJECT_DELETED');
63 if (!$rbacsystem->checkAccess(
'create', $target_id,
'crs')) {
64 return $this->
raiseError(
'Check access failed. No permission to create courses',
'Server');
67 include_once(
"Modules/Course/classes/class.ilObjCourse.php");
70 $newObj->setType(
'crs');
71 $newObj->setTitle(
'dummy');
72 $newObj->setDescription(
"");
73 $newObj->create(
true);
74 $newObj->createReference();
75 $newObj->putInTree($target_id);
76 $newObj->setPermissions($target_id);
78 include_once
'Modules/Course/classes/class.ilCourseXMLParser.php';
81 $xml_parser->setXMLContent($crs_xml);
82 $xml_parser->startParsing();
83 return $newObj->getRefId() ?:
"0";
98 include_once
"./Services/Utilities/classes/class.ilUtil.php";
101 $rbacsystem = $DIC[
'rbacsystem'];
105 $course_id = end($ref_ids);
108 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
114 if (!$rbacsystem->checkAccess(
'delete', $course_id)) {
115 return $this->
raiseError(
'Check access failed. No permission to delete course',
'Server');
119 $tree = $DIC->repositoryTree();
120 $user = $DIC->user();
121 $rbacadmin = $DIC[
'rbacadmin'];
124 if ($tree->isDeleted($course_id)) {
125 return $this->
raiseError(
'Node already deleted',
'Server');
128 $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
129 foreach ($subnodes as $subnode) {
130 $rbacadmin->revokePermission($subnode[
"child"]);
132 if (!$tree->moveToTrash($course_id,
true, $user->getId())) {
133 return $this->
raiseError(
'Node already deleted',
'Client');
136 $log->write(
"SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id .
" to trash");
154 $rbacsystem = $DIC[
'rbacsystem'];
158 $course_id = end($ref_ids);
161 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
167 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
168 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
172 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
174 if ($type !==
'Admin' &&
176 $type !==
'Member') {
178 'Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"',
184 return $this->
raiseError(
'Cannot create course instance!',
'Server');
188 return $this->
raiseError(
'Cannot create user instance!',
'Server');
191 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
197 require_once(
"Services/Administration/classes/class.ilSetting.php");
200 $course_members->updateNotification(
202 (bool)
$settings->get(
'mail_crs_admin_notification',
"1")
231 $rbacsystem = $DIC[
'rbacsystem'];
235 $course_id = end($ref_ids);
238 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
245 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
249 return $this->
raiseError(
'Cannot create course instance!',
'Server');
252 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
253 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
256 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
259 if (!$course_members->checkLastAdmin(array($user_id))) {
260 return $this->
raiseError(
'Cannot deassign last administrator from course',
'Server');
262 $course_members->delete($user_id);
269 public function isAssignedToCourse(
string $sid,
int $course_id,
int $user_id)
280 $rbacsystem = $DIC[
'rbacsystem'];
284 $course_id = end($ref_ids);
287 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
294 return $this->
raiseError(
'Invalid user id. User with id "' . $user_id .
' does not exist',
'Client');
299 return $this->
raiseError(
'Cannot create course instance!',
'Server');
302 if (!$rbacsystem->checkAccess(
'manage_members', $course_id)) {
303 return $this->
raiseError(
'Check access failed. No permission to write to course',
'Server');
306 include_once
'./Modules/Course/classes/class.ilCourseParticipants.php';
309 if ($crs_members->isAdmin($user_id)) {
312 if ($crs_members->isTutor($user_id)) {
315 if ($crs_members->isMember($user_id)) {
324 public function getCourseXML(
string $sid,
int $course_id)
335 $rbacsystem = $DIC[
'rbacsystem'];
339 if ($this->
isFault($tmp_course)) {
343 include_once
'Modules/Course/classes/class.ilCourseXMLWriter.php';
345 $xml_writer->start();
346 return $xml_writer->getXML();
352 public function updateCourse(
string $sid,
int $course_id,
string $xml)
363 $rbacsystem = $DIC[
'rbacsystem'];
367 $course_id = end($ref_ids);
370 'Invalid course id. Object with id "' . $course_id .
'" is not of type "course"',
378 return $this->
raiseError(
'Cannot create course instance!',
'Server');
381 if (!$rbacsystem->checkAccess(
'write', $course_id)) {
382 return $this->
raiseError(
'Check access failed. No permission to write course',
'Server');
386 include_once
'Services/MetaData/classes/class.ilMD.php';
388 $md =
new ilMD($tmp_course->getId(), 0,
'crs');
391 include_once
'Modules/Course/classes/class.ilCourseParticipants.php';
394 include_once
'Modules/Course/classes/class.ilCourseWaitingList.php';
397 include_once
'Modules/Course/classes/class.ilCourseXMLParser.php';
400 $xml_parser->setXMLContent($xml);
401 $xml_parser->startParsing();
402 $tmp_course->MDUpdateListener(
'General');
421 $rbacreview = $DIC[
'rbacreview'];
422 $ilObjDataCache = $DIC[
'ilObjDataCache'];
423 $tree = $DIC[
'tree'];
425 include_once
'webservice/soap/classes/class.ilXMLResultSetParser.php';
428 $parser->startParsing();
430 return $this->
raiseError($exception->getMessage(),
"Client");
432 $xmlResultSet = $parser->getXMLResultSet();
434 if (!$xmlResultSet->hasColumn(
"user_id")) {
435 return $this->
raiseError(
"parameter user_id is missing",
"Client");
438 if (!$xmlResultSet->hasColumn(
"status")) {
439 return $this->
raiseError(
"parameter status is missing",
"Client");
442 $user_id = (
int) $xmlResultSet->getValue(0,
"user_id");
443 $status = (
int) $xmlResultSet->getValue(0,
"status");
447 if (self::MEMBER == ($status & self::MEMBER) ||
448 self::TUTOR == ($status & self::TUTOR) ||
449 self::ADMIN == ($status & self::ADMIN)) {
450 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
452 #echo $role->getType(); 453 if ($role->getType() !==
"role") {
459 $role_title = $role->getTitle();
466 if (self::MEMBER == ($status & self::MEMBER) && strpos(
471 } elseif (self::TUTOR == ($status & self::TUTOR) && strpos(
476 } elseif (self::ADMIN == ($status & self::ADMIN) && strpos(
481 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId(
$ref_id)) == $user_id) {
488 if (($status & self::OWNER) == self::OWNER) {
491 foreach ($owned_objects as $obj_id) {
493 foreach ($allrefs as $r) {
494 if ($tree->isDeleted($r)) {
497 if ($tree->isInTree($r)) {
501 if (count($refs) > 0) {
502 $ref_ids[] = array_pop($refs);
506 $ref_ids = array_unique($ref_ids);
508 $ref_ids = array_unique($ref_ids);
510 include_once
'webservice/soap/classes/class.ilXMLResultSetWriter.php';
511 include_once
'Modules/Course/classes/class.ilObjCourse.php';
512 include_once
'Modules/Course/classes/class.ilCourseXMLWriter.php';
515 $xmlResultSet->addColumn(
"ref_id");
516 $xmlResultSet->addColumn(
"xml");
517 $xmlResultSet->addColumn(
"parent_ref_id");
524 $permission = $user_id ===
$ilUser->getId() ?
'read' :
'write';
526 foreach ($ref_ids as $course_id) {
530 $row->setValue(
"ref_id", $course_id);
532 $xmlWriter->setAttachUsers(
false);
534 $row->setValue(
"xml", $xmlWriter->getXML());
535 $row->setValue(
"parent_ref_id", $tree->getParentId($course_id));
536 $xmlResultSet->addRow($row);
540 $xmlResultSetWriter->start();
541 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.