ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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(), ilCourseXMLParser\MODE_SOAP, 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 
59  if (ilObject::_isInTrash($target_id)) {
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->setMode(ilCourseXMLParser::MODE_SOAP);
82  $xml_parser->setXMLContent($crs_xml);
83  $xml_parser->startParsing();
84  return $newObj->getRefId() ?: "0";
85  }
raiseError(string $a_message, $a_code)
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 144 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().

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

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

References $DIC, 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(), ilCourseXMLParser\MODE_SOAP, and ilSoapAdministration\raiseError().

222  {
223  $this->initAuth($sid);
224  $this->initIlias();
225 
226  if (!$this->checkSession($sid)) {
227  return $this->raiseError($this->getMessage(), $this->getMessageCode());
228  }
229 
230  global $DIC;
231 
232  $rbacsystem = $DIC['rbacsystem'];
233 
234  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
235  $ref_ids = ilObject::_getAllReferences($course_id);
236  $course_id = end($ref_ids);
237  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) !== 'crs') {
238  return $this->raiseError(
239  'Invalid course id. Object with id "' . $course_id . '" is not of type "course"',
240  'Client'
241  );
242  }
243  }
244 
245  if (ilObject::_lookupType($user_id) !== 'usr') {
246  return $this->raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
247  }
248 
249  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
250  return $this->raiseError('Cannot create course instance!', 'Server');
251  }
252 
253  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
254  return $this->raiseError('Check access failed. No permission to write to course', 'Server');
255  }
256 
257  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
258 
259  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
260  if (!$course_members->checkLastAdmin(array($user_id))) {
261  return $this->raiseError('Cannot deassign last administrator from course', 'Server');
262  }
263  $course_members->delete($user_id);
264  return true;
265  }
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 412 of file class.ilSoapCourseAdministration.php.

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

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