ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 31 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 41 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().

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

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

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

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

References $DIC, $user_id, 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().

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

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

◆ MEMBER

const ilSoapCourseAdministration::MEMBER = 1

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

◆ OWNER

const ilSoapCourseAdministration::OWNER = 8

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

◆ TUTOR

const ilSoapCourseAdministration::TUTOR = 2

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


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