ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 MEMBER = 1
 
const TUTOR = 2
 
const ADMIN = 4
 
const 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 32 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 42 of file class.ilSoapCourseAdministration.php.

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

43  {
44  $this->initAuth($sid);
45  $this->initIlias();
46 
47  if (!$this->checkSession($sid)) {
48  return $this->raiseError($this->getMessage(), $this->getMessageCode());
49  }
50 
51  global $DIC;
52 
53  $rbacsystem = $DIC['rbacsystem'];
54 
55  if (!$target_obj = ilObjectFactory::getInstanceByRefId($target_id, false)) {
56  return $this->raiseError('No valid target given.', 'Client');
57  }
58 
60  return $this->raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
61  }
62 
63  if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) {
64  return $this->raiseError('Check access failed. No permission to create courses', 'Server');
65  }
66 
67  include_once("Modules/Course/classes/class.ilObjCourse.php");
68 
69  $newObj = new ilObjCourse();
70  $newObj->setType('crs');
71  $newObj->setTitle('dummy');
72  $newObj->setDescription("");
73  $newObj->create(true); // true for upload
74  $newObj->createReference();
75  $newObj->putInTree($target_id);
76  $newObj->setPermissions($target_id);
77 
78  include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
79 
80  $xml_parser = new ilCourseXMLParser($newObj);
81  $xml_parser->setXMLContent($crs_xml);
82  $xml_parser->startParsing();
83  return $newObj->getRefId() ?: "0";
84  }
raiseError(string $a_message, $a_code)
$target_id
Definition: goto.php:52
global $DIC
Definition: feed.php:28
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 143 of file class.ilSoapCourseAdministration.php.

References $DIC, ILIAS\LTI\ToolProvider\$settings, 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().

144  {
145  $this->initAuth($sid);
146  $this->initIlias();
147 
148  if (!$this->checkSession($sid)) {
149  return $this->raiseError($this->getMessage(), $this->getMessageCode());
150  }
151 
152  global $DIC;
153 
154  $rbacsystem = $DIC['rbacsystem'];
155 
156  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
157  $ref_ids = ilObject::_getAllReferences($course_id);
158  $course_id = end($ref_ids);
159  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
160  return $this->raiseError(
161  'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
162  'Client'
163  );
164  }
165  }
166 
167  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
168  return $this->raiseError('Check access failed. No permission to write to course', 'Server');
169  }
170 
171  if (ilObject::_lookupType($user_id) !== 'usr') {
172  return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
173  }
174  if ($type !== 'Admin' &&
175  $type !== 'Tutor' &&
176  $type !== 'Member') {
177  return $this->raiseError(
178  'Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"',
179  'Client'
180  );
181  }
182 
183  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
184  return $this->raiseError('Cannot create course instance!', 'Server');
185  }
186 
187  if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
188  return $this->raiseError('Cannot create user instance!', 'Server');
189  }
190 
191  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
192 
193  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
194 
195  switch ($type) {
196  case 'Admin':
197  require_once("Services/Administration/classes/class.ilSetting.php");
198  $settings = new ilSetting();
199  $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_ADMIN);
200  $course_members->updateNotification(
201  $tmp_user->getId(),
202  (bool) $settings->get('mail_crs_admin_notification', "1")
203  );
204  break;
205 
206  case 'Tutor':
207  $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_TUTOR);
208  break;
209 
210  case 'Member':
211  $course_members->add($tmp_user->getId(), ilParticipants::IL_CRS_MEMBER);
212  break;
213  }
214  return true;
215  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$type
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static _getInstanceByObjId(int $a_obj_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference 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)
+ 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 89 of file class.ilSoapCourseAdministration.php.

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

90  {
91  $this->initAuth($sid);
92  $this->initIlias();
93 
94  if (!$this->checkSession($sid)) {
95  return $this->raiseError($this->getMessage(), $this->getMessageCode());
96  }
97 
98  include_once "./Services/Utilities/classes/class.ilUtil.php";
99  global $DIC;
100 
101  $rbacsystem = $DIC['rbacsystem'];
102 
103  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
104  $ref_ids = ilObject::_getAllReferences($course_id);
105  $course_id = end($ref_ids);
106  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
107  return $this->raiseError(
108  'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
109  'Client'
110  );
111  }
112  }
113 
114  if (!$rbacsystem->checkAccess('delete', $course_id)) {
115  return $this->raiseError('Check access failed. No permission to delete course', 'Server');
116  }
117 
118  global $DIC;
119  $tree = $DIC->repositoryTree();
120  $user = $DIC->user();
121  $rbacadmin = $DIC['rbacadmin'];
122  $log = $DIC['log'];
123 
124  if ($tree->isDeleted($course_id)) {
125  return $this->raiseError('Node already deleted', 'Server');
126  }
127 
128  $subnodes = $tree->getSubTree($tree->getNodeData($course_id));
129  foreach ($subnodes as $subnode) {
130  $rbacadmin->revokePermission($subnode["child"]);
131  }
132  if (!$tree->moveToTrash($course_id, true, $user->getId())) {
133  return $this->raiseError('Node already deleted', 'Client');
134  }
135 
136  $log->write("SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id . " to trash");
137  return true;
138  }
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
$log
Definition: result.php:33
static _lookupType(int $id, bool $reference=false)
+ 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 220 of file class.ilSoapCourseAdministration.php.

References $DIC, $xml, ilWaitingList\_deleteAll(), ilParticipants\_deleteAllEntries(), ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilSoapAdministration\checkObjectAccess(), ilSoapAdministration\checkSession(), ilMD\deleteAll(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilParticipants\IL_CRS_ADMIN, ilParticipants\IL_CRS_MEMBER, ilParticipants\IL_CRS_TUTOR, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), and ilSoapAdministration\raiseError().

221  {
222  $this->initAuth($sid);
223  $this->initIlias();
224 
225  if (!$this->checkSession($sid)) {
226  return $this->raiseError($this->getMessage(), $this->getMessageCode());
227  }
228 
229  global $DIC;
230 
231  $rbacsystem = $DIC['rbacsystem'];
232 
233  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
234  $ref_ids = ilObject::_getAllReferences($course_id);
235  $course_id = end($ref_ids);
236  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
237  return $this->raiseError(
238  'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
239  'Client'
240  );
241  }
242  }
243 
244  if (ilObject::_lookupType($user_id) !== 'usr') {
245  return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
246  }
247 
248  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
249  return $this->raiseError('Cannot create course instance!', 'Server');
250  }
251 
252  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
253  return $this->raiseError('Check access failed. No permission to write to course', 'Server');
254  }
255 
256  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
257 
258  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
259  if (!$course_members->checkLastAdmin(array($user_id))) {
260  return $this->raiseError('Cannot deassign last administrator from course', 'Server');
261  }
262  $course_members->delete($user_id);
263  return true;
264  }
static _getAllReferences(int $id)
get all reference ids for object ID
raiseError(string $a_message, $a_code)
static _lookupObjId(int $ref_id)
global $DIC
Definition: feed.php:28
static _getInstanceByObjId(int $a_obj_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getCoursesForUser()

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

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

References $DIC, $ilUser, $ref_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.

411  {
412  $this->initAuth($sid);
413  $this->initIlias();
414 
415  if (!$this->checkSession($sid)) {
416  return $this->raiseError($this->getMessage(), $this->getMessageCode());
417  }
418 
419  global $DIC;
420 
421  $rbacreview = $DIC['rbacreview'];
422  $ilObjDataCache = $DIC['ilObjDataCache'];
423  $tree = $DIC['tree'];
424 
425  include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
426  $parser = new ilXMLResultSetParser($parameters);
427  try {
428  $parser->startParsing();
429  } catch (ilSaxParserException $exception) {
430  return $this->raiseError($exception->getMessage(), "Client");
431  }
432  $xmlResultSet = $parser->getXMLResultSet();
433 
434  if (!$xmlResultSet->hasColumn("user_id")) {
435  return $this->raiseError("parameter user_id is missing", "Client");
436  }
437 
438  if (!$xmlResultSet->hasColumn("status")) {
439  return $this->raiseError("parameter status is missing", "Client");
440  }
441 
442  $user_id = (int) $xmlResultSet->getValue(0, "user_id");
443  $status = (int) $xmlResultSet->getValue(0, "status");
444 
445  $ref_ids = array();
446 
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) {
451  if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
452  #echo $role->getType();
453  if ($role->getType() !== "role") {
454  continue;
455  }
456  if ($role->getParent() == ROLE_FOLDER_ID) {
457  continue;
458  }
459  $role_title = $role->getTitle();
460 
461  if ($ref_id = ilUtil::__extractRefId($role_title)) {
463  continue;
464  }
465 
466  if (self::MEMBER == ($status & self::MEMBER) && strpos(
467  $role_title,
468  "member"
469  ) !== false) {
470  $ref_ids [] = $ref_id;
471  } elseif (self::TUTOR == ($status & self::TUTOR) && strpos(
472  $role_title,
473  "tutor"
474  ) !== false) {
475  $ref_ids [] = $ref_id;
476  } elseif (self::ADMIN == ($status & self::ADMIN) && strpos(
477  $role_title,
478  "admin"
479  ) !== false) {
480  $ref_ids [] = $ref_id;
481  } elseif (($status & self::OWNER) == self::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($ref_id)) == $user_id) {
482  $ref_ids [] = $ref_id;
483  }
484  }
485  }
486  }
487  }
488  if (($status & self::OWNER) == self::OWNER) {
489  $owned_objects = ilObjectFactory::getObjectsForOwner("crs", $user_id);
490  $refs = [];
491  foreach ($owned_objects as $obj_id) {
492  $allrefs = ilObject::_getAllReferences($obj_id);
493  foreach ($allrefs as $r) {
494  if ($tree->isDeleted($r)) {
495  continue;
496  }
497  if ($tree->isInTree($r)) {
498  $refs[] = $r;
499  }
500  }
501  if (count($refs) > 0) {
502  $ref_ids[] = array_pop($refs);
503  }
504  }
505  }
506  $ref_ids = array_unique($ref_ids);
507 
508  $ref_ids = array_unique($ref_ids);
509 
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';
513 
514  $xmlResultSet = new ilXMLResultSet();
515  $xmlResultSet->addColumn("ref_id");
516  $xmlResultSet->addColumn("xml");
517  $xmlResultSet->addColumn("parent_ref_id");
518 
519  global $DIC;
520 
521  $ilUser = $DIC['ilUser'];
522  //#18004
523  // Enable to see own participations by reducing the needed permissions
524  $permission = $user_id === $ilUser->getId() ? 'read' : 'write';
525 
526  foreach ($ref_ids as $course_id) {
527  $course_obj = $this->checkObjectAccess($course_id, ['crs'], $permission, true);
528  if ($course_obj instanceof ilObjCourse) {
529  $row = new ilXMLResultSetRow();
530  $row->setValue("ref_id", $course_id);
531  $xmlWriter = new ilCourseXMLWriter($course_obj);
532  $xmlWriter->setAttachUsers(false);
533  $xmlWriter->start();
534  $row->setValue("xml", $xmlWriter->getXML());
535  $row->setValue("parent_ref_id", $tree->getParentId($course_id));
536  $xmlResultSet->addRow($row);
537  }
538  }
539  $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
540  $xmlResultSetWriter->start();
541  return $xmlResultSetWriter->getXML();
542  }
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.
global $DIC
Definition: feed.php:28
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
$ref_id
Definition: ltiauth.php:67
static getObjectsForOwner(string $object_type, int $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
static _isInTrash(int $ref_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 ...
const ROLE_FOLDER_ID
Definition: constants.php:34
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
$ilUser
Definition: imgupload.php:34
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.
+ Here is the call graph for this function:

Field Documentation

◆ ADMIN

const ilSoapCourseAdministration::ADMIN = 4

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

◆ MEMBER

const ilSoapCourseAdministration::MEMBER = 1

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

◆ OWNER

const ilSoapCourseAdministration::OWNER = 8

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

◆ TUTOR

const ilSoapCourseAdministration::TUTOR = 2

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


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