ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilSoapCourseAdministration Class Reference
+ Inheritance diagram for ilSoapCourseAdministration:
+ Collaboration diagram for ilSoapCourseAdministration:

Public Member Functions

 addCourse (string $sid, int $target_id, string $crs_xml)
 
 deleteCourse (string $sid, int $course_id)
 
 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)
 
 getCoursesForUser (string $sid, string $parameters)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Data Fields

const int MEMBER = 1
 
const int TUTOR = 2
 
const int ADMIN = 4
 
const int OWNER = 8
 
- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 

Additional Inherited Members

- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 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 More...
 
- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

Definition at line 25 of file class.ilSoapCourseAdministration.php.

Member Function Documentation

◆ addCourse()

ilSoapCourseAdministration::addCourse ( string  $sid,
int  $target_id,
string  $crs_xml 
)
Returns
int|soap_fault|SoapFault|string|null

Definition at line 35 of file class.ilSoapCourseAdministration.php.

36 {
37 $this->initAuth($sid);
38 $this->initIlias();
39
40 if (!$this->checkSession($sid)) {
41 return $this->raiseError($this->getMessage(), $this->getMessageCode());
42 }
43
44 global $DIC;
45
46 $rbacsystem = $DIC['rbacsystem'];
47
48 if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
49 return $this->raiseError('No valid target given.', 'Client');
50 }
51
52 if (ilObject::_isInTrash($target_id)) {
53 return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
54 }
55
56 if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) {
57 return $this->raiseError('Check access failed. No permission to create courses', 'Server');
58 }
59
60 $newObj = new ilObjCourse();
61 $newObj->setType('crs');
62 $newObj->setTitle('dummy');
63 $newObj->setDescription("");
64 $newObj->create(); // true for upload
65 $newObj->createReference();
66 $newObj->putInTree($target_id);
67 $newObj->setPermissions($target_id);
68
69 $xml_parser = new ilCourseXMLParser($newObj);
70 $xml_parser->setMode(ilCourseXMLParser::MODE_SOAP);
71 $xml_parser->setXMLContent($crs_xml);
72 $xml_parser->startParsing();
73 return $newObj->getRefId() ?: "0";
74 }
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 _isInTrash(int $ref_id)
raiseError(string $a_message, $a_code)
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\_isInTrash(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilCourseXMLParser\MODE_SOAP, and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ assignCourseMember()

ilSoapCourseAdministration::assignCourseMember ( string  $sid,
int  $course_id,
int  $user_id,
string  $type,
?bool  $notification = null,
?bool  $contact_person = null,
?bool  $blocked = null 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 132 of file class.ilSoapCourseAdministration.php.

140 {
141 $this->initAuth($sid);
142 $this->initIlias();
143
144 if (!$this->checkSession($sid)) {
145 return $this->raiseError($this->getMessage(), $this->getMessageCode());
146 }
147
148 global $DIC;
149
150 $rbacsystem = $DIC['rbacsystem'];
151
152 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
153 $ref_ids = ilObject::_getAllReferences($course_id);
154 $course_id = end($ref_ids);
155 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
156 return $this->raiseError(
157 'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
158 'Client'
159 );
160 }
161 }
162
163 if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
164 return $this->raiseError('Check access failed. No permission to write to course', 'Server');
165 }
166
167 if (ilObject::_lookupType($user_id) !== 'usr') {
168 return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
169 }
170 $valid_roles = [
174 ];
175 if (!isset($valid_roles[$type])) {
176 return $this->raiseError('Invalid type. Must be "Admin", "Tutor", or "Member"', 'Client');
177 }
178
179 if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
180 return $this->raiseError('Cannot create course instance!', 'Server');
181 }
182
183 if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
184 return $this->raiseError('Cannot create user instance!', 'Server');
185 }
186
187 $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
188
189 $course_members->add($tmp_user->getId(), $valid_roles[$type]);
190
191 $course_members->sendNotification(
193 $tmp_user->getId()
194 );
195
196 if ($type === 'Admin' || $type === 'Tutor') {
197 if ($notification !== null) {
198 $course_members->updateNotification($tmp_user->getId(), $notification);
199 }
200
201 if ($contact_person !== null) {
202 $course_members->updateContact($tmp_user->getId(), $contact_person);
203 }
204 } elseif ($type === "Member" && $blocked !== null) {
205 $course_members->updateBlocked($tmp_user->getId(), $blocked);
206 }
207 return true;
208 }
static _getInstanceByObjId(int $a_obj_id)
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 _lookupObjId(int $ref_id)

References $DIC, $user_id, ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilParticipants\IL_CRS_ADMIN, ilParticipants\IL_CRS_MEMBER, ilParticipants\IL_CRS_TUTOR, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), and ilCourseMembershipMailNotification\TYPE_ADMISSION_MEMBER.

+ Here is the call graph for this function:

◆ deleteCourse()

ilSoapCourseAdministration::deleteCourse ( string  $sid,
int  $course_id 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 79 of file class.ilSoapCourseAdministration.php.

80 {
81 $this->initAuth($sid);
82 $this->initIlias();
83
84 if (!$this->checkSession($sid)) {
85 return $this->raiseError($this->getMessage(), $this->getMessageCode());
86 }
87
88 global $DIC;
89
90 $rbacsystem = $DIC['rbacsystem'];
91
92 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
93 $ref_ids = ilObject::_getAllReferences($course_id);
94 $course_id = end($ref_ids);
95 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
96 return $this->raiseError(
97 'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
98 'Client'
99 );
100 }
101 }
102
103 if (!$rbacsystem->checkAccess('delete', $course_id)) {
104 return $this->raiseError('Check access failed. No permission to delete course', 'Server');
105 }
106
107 global $DIC;
108 $tree = $DIC->repositoryTree();
109 $user = $DIC->user();
110 $rbacadmin = $DIC['rbacadmin'];
111 $log = $DIC['log'];
112
113 if ($tree->isDeleted($course_id)) {
114 return $this->raiseError('Node already deleted', 'Server');
115 }
116
117 $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
118 foreach ($subnodes as $subnode) {
119 $rbacadmin->revokePermission($subnode["child"]);
120 }
121 if (!$tree->moveToTrash($course_id, true, $user->getId())) {
122 return $this->raiseError('Node already deleted', 'Client');
123 }
124
125 $log->write("SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id . " to trash");
126 return true;
127 }
$log
Definition: ltiresult.php:34

References $DIC, $log, ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ excludeCourseMember()

ilSoapCourseAdministration::excludeCourseMember ( string  $sid,
int  $course_id,
int  $user_id 
)
Returns
bool|soap_fault|SoapFault|null

Definition at line 213 of file class.ilSoapCourseAdministration.php.

214 {
215 $this->initAuth($sid);
216 $this->initIlias();
217
218 if (!$this->checkSession($sid)) {
219 return $this->raiseError($this->getMessage(), $this->getMessageCode());
220 }
221
222 global $DIC;
223
224 $rbacsystem = $DIC['rbacsystem'];
225
226 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
227 $ref_ids = ilObject::_getAllReferences($course_id);
228 $course_id = end($ref_ids);
229 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
230 return $this->raiseError(
231 'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
232 'Client'
233 );
234 }
235 }
236
237 if (ilObject::_lookupType($user_id) !== 'usr') {
238 return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
239 }
240
241 if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
242 return $this->raiseError('Cannot create course instance!', 'Server');
243 }
244
245 if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
246 return $this->raiseError('Check access failed. No permission to write to course', 'Server');
247 }
248
249 $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
250 if (!$course_members->checkLastAdmin(array($user_id))) {
251 return $this->raiseError('Cannot deassign last administrator from course', 'Server');
252 }
253 $course_members->delete($user_id);
254 return true;
255 }

References $DIC, $user_id, ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getCoursesForUser()

ilSoapCourseAdministration::getCoursesForUser ( string  $sid,
string  $parameters 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 391 of file class.ilSoapCourseAdministration.php.

392 {
393 $this->initAuth($sid);
394 $this->initIlias();
395
396 if (!$this->checkSession($sid)) {
397 return $this->raiseError($this->getMessage(), $this->getMessageCode());
398 }
399
400 global $DIC;
401
402 $rbacreview = $DIC['rbacreview'];
403 $ilObjDataCache = $DIC['ilObjDataCache'];
404 $tree = $DIC['tree'];
405
406 $parser = new ilXMLResultSetParser($parameters);
407 try {
408 $parser->startParsing();
409 } catch (ilSaxParserException $exception) {
410 return $this->raiseError($exception->getMessage(), "Client");
411 }
412 $xmlResultSet = $parser->getXMLResultSet();
413
414 if (!$xmlResultSet->hasColumn("user_id")) {
415 return $this->raiseError("parameter user_id is missing", "Client");
416 }
417
418 if (!$xmlResultSet->hasColumn("status")) {
419 return $this->raiseError("parameter status is missing", "Client");
420 }
421
422 $user_id = (int) $xmlResultSet->getValue(0, "user_id");
423 $status = (int) $xmlResultSet->getValue(0, "status");
424
425 $ref_ids = array();
426
427 if (
428 self::MEMBER == ($status & self::MEMBER) ||
429 self::TUTOR == ($status & self::TUTOR) ||
430 self::ADMIN == ($status & self::ADMIN)
431 ) {
432 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
433 if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
434 #echo $role->getType();
435 if ($role->getType() !== "role") {
436 continue;
437 }
438 if ($role->getParent() == ROLE_FOLDER_ID) {
439 continue;
440 }
441 $role_title = $role->getTitle();
442
443 if ($ref_id = ilUtil::__extractRefId($role_title)) {
445 continue;
446 }
447
448 if (
449 self::MEMBER == ($status & self::MEMBER) && strpos(
450 $role_title,
451 "member"
452 ) !== false
453 ) {
454 $ref_ids[] = $ref_id;
455 } elseif (
456 self::TUTOR == ($status & self::TUTOR) && strpos(
457 $role_title,
458 "tutor"
459 ) !== false
460 ) {
461 $ref_ids[] = $ref_id;
462 } elseif (
463 self::ADMIN == ($status & self::ADMIN) && strpos(
464 $role_title,
465 "admin"
466 ) !== false
467 ) {
468 $ref_ids[] = $ref_id;
469 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($ref_id)) == $user_id) {
470 $ref_ids[] = $ref_id;
471 }
472 }
473 }
474 }
475 }
476 if (($status & self::OWNER) == self::OWNER) {
477 $owned_objects = ilObjectFactory::getObjectsForOwner("crs", $user_id);
478 $refs = [];
479 foreach ($owned_objects as $obj_id) {
480 $allrefs = ilObject::_getAllReferences($obj_id);
481 foreach ($allrefs as $r) {
482 if ($tree->isDeleted($r)) {
483 continue;
484 }
485 if ($tree->isInTree($r)) {
486 $refs[] = $r;
487 }
488 }
489 if (count($refs) > 0) {
490 $ref_ids[] = array_pop($refs);
491 }
492 }
493 }
494 $ref_ids = array_unique($ref_ids);
495
496 $ref_ids = array_unique($ref_ids);
497
498 $xmlResultSet = new ilXMLResultSet();
499 $xmlResultSet->addColumn("ref_id");
500 $xmlResultSet->addColumn("xml");
501 $xmlResultSet->addColumn("parent_ref_id");
502
503 global $DIC;
504
505 $ilUser = $DIC['ilUser'];
506 //#18004
507 // Enable to see own participations by reducing the needed permissions
508 $permission = $user_id === $ilUser->getId() ? 'read' : 'write';
509
510 foreach ($ref_ids as $course_id) {
511 $course_obj = $this->checkObjectAccess($course_id, ['crs'], $permission, true);
512 if ($course_obj instanceof ilObjCourse) {
513 $row = new ilXMLResultSetRow();
514 $row->setValue("ref_id", $course_id);
515 $xmlWriter = new ilCourseXMLWriter($course_obj);
516 $xmlWriter->setAttachUsers(false);
517 $xmlWriter->start();
518 $row->setValue("xml", $xmlWriter->getXML());
519 $row->setValue("parent_ref_id", $tree->getParentId($course_id));
520 $xmlResultSet->addRow($row);
521 }
522 }
523 $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
524 $xmlResultSetWriter->start();
525 return $xmlResultSetWriter->getXML();
526 }
XML writer class Class to simplify manual writing of xml documents.
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 __extractRefId(string $role_title)
extract ref id from role title, e.g.
Row Class for XMLResultSet.
XML Writer for XMLResultSet.
const ROLE_FOLDER_ID
Definition: constants.php:34
$ref_id
Definition: ltiauth.php:66

References $DIC, $ref_id, $user_id, ilUtil\__extractRefId(), ilObject\_exists(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ilSoapAdministration\checkObjectAccess(), ilSoapAdministration\checkSession(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilObjectFactory\getObjectsForOwner(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ILIAS\Repository\int(), ilSoapAdministration\raiseError(), and ROLE_FOLDER_ID.

+ Here is the call graph for this function:

Field Documentation

◆ ADMIN

const int ilSoapCourseAdministration::ADMIN = 4

Definition at line 29 of file class.ilSoapCourseAdministration.php.

◆ MEMBER

const int ilSoapCourseAdministration::MEMBER = 1

Definition at line 27 of file class.ilSoapCourseAdministration.php.

◆ OWNER

const int ilSoapCourseAdministration::OWNER = 8

Definition at line 30 of file class.ilSoapCourseAdministration.php.

◆ TUTOR

const int ilSoapCourseAdministration::TUTOR = 2

Definition at line 28 of file class.ilSoapCourseAdministration.php.


The documentation for this class was generated from the following file: