ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 
 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 
)
Returns
bool|soap_fault|SoapFault|null

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

133 {
134 $this->initAuth($sid);
135 $this->initIlias();
136
137 if (!$this->checkSession($sid)) {
138 return $this->raiseError($this->getMessage(), $this->getMessageCode());
139 }
140
141 global $DIC;
142
143 $rbacsystem = $DIC['rbacsystem'];
144
145 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
146 $ref_ids = ilObject::_getAllReferences($course_id);
147 $course_id = end($ref_ids);
148 if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
149 return $this->raiseError(
150 'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
151 'Client'
152 );
153 }
154 }
155
156 if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
157 return $this->raiseError('Check access failed. No permission to write to course', 'Server');
158 }
159
160 if (ilObject::_lookupType($user_id) !== 'usr') {
161 return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
162 }
163 if ($type !== 'Admin' &&
164 $type !== 'Tutor' &&
165 $type !== 'Member') {
166 return $this->raiseError(
167 'Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"',
168 'Client'
169 );
170 }
171
172 if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
173 return $this->raiseError('Cannot create course instance!', 'Server');
174 }
175
176 if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
177 return $this->raiseError('Cannot create user instance!', 'Server');
178 }
179
180 $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
181
182 switch ($type) {
183 case 'Admin':
184 $settings = new ilSetting();
185 $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_ADMIN);
186 $course_members->updateNotification(
187 $tmp_user->getId(),
188 (bool) $settings->get('mail_crs_admin_notification', "1")
189 );
190 break;
191
192 case 'Tutor':
193 $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_TUTOR);
194 break;
195
196 case 'Member':
197 $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_MEMBER);
198 break;
199 }
200 return true;
201 }
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)
ILIAS Setting Class.

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(), and ilSoapAdministration\raiseError().

+ 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 206 of file class.ilSoapCourseAdministration.php.

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

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 384 of file class.ilSoapCourseAdministration.php.

385 {
386 $this->initAuth($sid);
387 $this->initIlias();
388
389 if (!$this->checkSession($sid)) {
390 return $this->raiseError($this->getMessage(), $this->getMessageCode());
391 }
392
393 global $DIC;
394
395 $rbacreview = $DIC['rbacreview'];
396 $ilObjDataCache = $DIC['ilObjDataCache'];
397 $tree = $DIC['tree'];
398
399 $parser = new ilXMLResultSetParser($parameters);
400 try {
401 $parser->startParsing();
402 } catch (ilSaxParserException $exception) {
403 return $this->raiseError($exception->getMessage(), "Client");
404 }
405 $xmlResultSet = $parser->getXMLResultSet();
406
407 if (!$xmlResultSet->hasColumn("user_id")) {
408 return $this->raiseError("parameter user_id is missing", "Client");
409 }
410
411 if (!$xmlResultSet->hasColumn("status")) {
412 return $this->raiseError("parameter status is missing", "Client");
413 }
414
415 $user_id = (int) $xmlResultSet->getValue(0, "user_id");
416 $status = (int) $xmlResultSet->getValue(0, "status");
417
418 $ref_ids = array();
419
420 if (self::MEMBER == ($status & self::MEMBER) ||
421 self::TUTOR == ($status & self::TUTOR) ||
422 self::ADMIN == ($status & self::ADMIN)) {
423 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
424 if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
425 #echo $role->getType();
426 if ($role->getType() !== "role") {
427 continue;
428 }
429 if ($role->getParent() == ROLE_FOLDER_ID) {
430 continue;
431 }
432 $role_title = $role->getTitle();
433
434 if ($ref_id = ilUtil::__extractRefId($role_title)) {
436 continue;
437 }
438
439 if (self::MEMBER == ($status & self::MEMBER) && strpos(
440 $role_title,
441 "member"
442 ) !== false) {
443 $ref_ids [] = $ref_id;
444 } elseif (self::TUTOR == ($status & self::TUTOR) && strpos(
445 $role_title,
446 "tutor"
447 ) !== false) {
448 $ref_ids [] = $ref_id;
449 } elseif (self::ADMIN == ($status & self::ADMIN) && strpos(
450 $role_title,
451 "admin"
452 ) !== false) {
453 $ref_ids [] = $ref_id;
454 } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($ref_id)) == $user_id) {
455 $ref_ids [] = $ref_id;
456 }
457 }
458 }
459 }
460 }
461 if (($status & self::OWNER) == self::OWNER) {
462 $owned_objects = ilObjectFactory::getObjectsForOwner("crs", $user_id);
463 $refs = [];
464 foreach ($owned_objects as $obj_id) {
465 $allrefs = ilObject::_getAllReferences($obj_id);
466 foreach ($allrefs as $r) {
467 if ($tree->isDeleted($r)) {
468 continue;
469 }
470 if ($tree->isInTree($r)) {
471 $refs[] = $r;
472 }
473 }
474 if (count($refs) > 0) {
475 $ref_ids[] = array_pop($refs);
476 }
477 }
478 }
479 $ref_ids = array_unique($ref_ids);
480
481 $ref_ids = array_unique($ref_ids);
482
483 $xmlResultSet = new ilXMLResultSet();
484 $xmlResultSet->addColumn("ref_id");
485 $xmlResultSet->addColumn("xml");
486 $xmlResultSet->addColumn("parent_ref_id");
487
488 global $DIC;
489
490 $ilUser = $DIC['ilUser'];
491 //#18004
492 // Enable to see own participations by reducing the needed permissions
493 $permission = $user_id === $ilUser->getId() ? 'read' : 'write';
494
495 foreach ($ref_ids as $course_id) {
496 $course_obj = $this->checkObjectAccess($course_id, ['crs'], $permission, true);
497 if ($course_obj instanceof ilObjCourse) {
498 $row = new ilXMLResultSetRow();
499 $row->setValue("ref_id", $course_id);
500 $xmlWriter = new ilCourseXMLWriter($course_obj);
501 $xmlWriter->setAttachUsers(false);
502 $xmlWriter->start();
503 $row->setValue("xml", $xmlWriter->getXML());
504 $row->setValue("parent_ref_id", $tree->getParentId($course_id));
505 $xmlResultSet->addRow($row);
506 }
507 }
508 $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
509 $xmlResultSetWriter->start();
510 return $xmlResultSetWriter->getXML();
511 }
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: