ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSoapCourseAdministration Class Reference
+ Inheritance diagram for ilSoapCourseAdministration:
+ Collaboration diagram for ilSoapCourseAdministration:

Public Member Functions

 addCourse ($sid, $target_id, $crs_xml)
 
 deleteCourse ($sid, $course_id)
 
 assignCourseMember ($sid, $course_id, $user_id, $type)
 
 excludeCourseMember ($sid, $course_id, $user_id)
 
 isAssignedToCourse ($sid, $course_id, $user_id)
 
 getCourseXML ($sid, $course_id)
 
 updateCourse ($sid, $course_id, $xml)
 
 getCoursesForUser ($sid, $parameters)
 get courses which belong to a specific user, fullilling the status More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Data Fields

const MEMBER = 1
 
const TUTOR = 2
 
const ADMIN = 4
 
const OWNER = 8
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

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

Member Function Documentation

◆ addCourse()

ilSoapCourseAdministration::addCourse (   $sid,
  $target_id,
  $crs_xml 
)

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

References $DIC, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

45  {
46  $this->initAuth($sid);
47  $this->initIlias();
48 
49  if (!$this->__checkSession($sid)) {
50  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
51  }
52 
53  if (!is_numeric($target_id)) {
54  return $this->__raiseError(
55  'No valid target id given. Please choose an existing reference id of an ILIAS category',
56  'Client'
57  );
58  }
59 
60  global $DIC;
61 
62  $rbacsystem = $DIC['rbacsystem'];
63 
64  if (!$target_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
65  return $this->__raiseError('No valid target given.', 'Client');
66  }
67 
69  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
70  }
71 
72  if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) {
73  return $this->__raiseError('Check access failed. No permission to create courses', 'Server');
74  }
75 
76 
77  // Start import
78  include_once("Modules/Course/classes/class.ilObjCourse.php");
79 
80  $newObj = new ilObjCourse();
81  $newObj->setType('crs');
82  $newObj->setTitle('dummy');
83  $newObj->setDescription("");
84  $newObj->create(true); // true for upload
85  $newObj->createReference();
86  $newObj->putInTree($target_id);
87  $newObj->setPermissions($target_id);
88 
89  include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
90 
91  $xml_parser = new ilCourseXMLParser($newObj);
92  $xml_parser->setXMLContent($crs_xml);
93  $xml_parser->startParsing();
94  return $newObj->getRefId() ? $newObj->getRefId() : "0";
95  }
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
$target_id
Definition: goto.php:49
Class ilObjCourse.
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ assignCourseMember()

ilSoapCourseAdministration::assignCourseMember (   $sid,
  $course_id,
  $user_id,
  $type 
)

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

References $DIC, $type, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

161  {
162  $this->initAuth($sid);
163  $this->initIlias();
164 
165  if (!$this->__checkSession($sid)) {
166  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
167  }
168 
169  if (!is_numeric($course_id)) {
170  return $this->__raiseError(
171  'No valid course id given. Please choose an existing reference id of an ILIAS course',
172  'Client'
173  );
174  }
175 
176  global $DIC;
177 
178  $rbacsystem = $DIC['rbacsystem'];
179 
180  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
181  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
182  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
183  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
184  }
185  }
186 
187  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
188  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
189  }
190 
191 
192  if (ilObject::_lookupType($user_id) != 'usr') {
193  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
194  }
195  if ($type != 'Admin' and
196  $type != 'Tutor' and
197  $type != 'Member') {
198  return $this->__raiseError('Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"', 'Client');
199  }
200 
201  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
202  return $this->__raiseError('Cannot create course instance!', 'Server');
203  }
204 
205  if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
206  return $this->__raiseError('Cannot create user instance!', 'Server');
207  }
208 
209  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
210 
211  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
212 
213  switch ($type) {
214  case 'Admin':
215  require_once("Services/Administration/classes/class.ilSetting.php");
216  $settings = new ilSetting();
217  $course_members->add($tmp_user->getId(), IL_CRS_ADMIN);
218  $course_members->updateNotification($tmp_user->getId(), $settings->get('mail_crs_admin_notification', true));
219  break;
220 
221  case 'Tutor':
222  $course_members->add($tmp_user->getId(), IL_CRS_TUTOR);
223  break;
224 
225  case 'Member':
226  $course_members->add($tmp_user->getId(), IL_CRS_MEMBER);
227  break;
228  }
229 
230  return true;
231  }
$type
global $DIC
Definition: saml.php:7
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
const IL_CRS_TUTOR
static _getAllReferences($a_id)
get all reference ids of object
const IL_CRS_MEMBER
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
const IL_CRS_ADMIN
Base class for course and group participants.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ deleteCourse()

ilSoapCourseAdministration::deleteCourse (   $sid,
  $course_id 
)

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

References $DIC, $log, $tree, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilUtil\removeItemFromDesktops().

98  {
99  $this->initAuth($sid);
100  $this->initIlias();
101 
102  if (!$this->__checkSession($sid)) {
103  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
104  }
105 
106  if (!is_numeric($course_id)) {
107  return $this->__raiseError(
108  'No valid course id given. Please choose an existing reference id of an ILIAS course',
109  'Client'
110  );
111  }
112 
113  include_once "./Services/Utilities/classes/class.ilUtil.php";
114  global $DIC;
115 
116  $rbacsystem = $DIC['rbacsystem'];
117 
118  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
119  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
120  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
121  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
122  }
123  }
124 
125  if (!$rbacsystem->checkAccess('delete', $course_id)) {
126  return $this->__raiseError('Check access failed. No permission to delete course', 'Server');
127  }
128 
129 
130  global $DIC;
131 
132  $tree = $DIC['tree'];
133  $rbacadmin = $DIC['rbacadmin'];
134  $log = $DIC['log'];
135 
136  if ($tree->isDeleted($course_id)) {
137  return $this->__raiseError('Node already deleted', 'Server');
138  }
139 
140  $subnodes = $tree->getSubtree($tree->getNodeData($course_id));
141  foreach ($subnodes as $subnode) {
142  $rbacadmin->revokePermission($subnode["child"]);
143 
144  // remove item from all user desktops
145  $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
146  }
147  if (!$tree->saveSubTree($course_id, true)) {
148  return $this->__raiseError('Node already deleted', 'Client');
149  }
150 
151  // write log entry
152  $log->write("SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id " . $course_id . " to trash");
153 
154  // remove item from all user desktops
155  $affected_users = ilUtil::removeItemFromDesktops($course_id);
156 
157  return true;
158  }
static removeItemFromDesktops($a_id)
removes object from all user's desktops public
global $DIC
Definition: saml.php:7
$log
Definition: sabredav.php:21
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ excludeCourseMember()

ilSoapCourseAdministration::excludeCourseMember (   $sid,
  $course_id,
  $user_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

234  {
235  $this->initAuth($sid);
236  $this->initIlias();
237 
238  if (!$this->__checkSession($sid)) {
239  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
240  }
241  if (!is_numeric($course_id)) {
242  return $this->__raiseError(
243  'No valid course id given. Please choose an existing reference id of an ILIAS course',
244  'Client'
245  );
246  }
247 
248  global $DIC;
249 
250  $rbacsystem = $DIC['rbacsystem'];
251 
252  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
253  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
254  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
255  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
256  }
257  }
258 
259  if (ilObject::_lookupType($user_id) != 'usr') {
260  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
261  }
262 
263  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
264  return $this->__raiseError('Cannot create course instance!', 'Server');
265  }
266 
267  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
268  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
269  }
270 
271  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
272 
273  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
274  if (!$course_members->checkLastAdmin(array($user_id))) {
275  return $this->__raiseError('Cannot deassign last administrator from course', 'Server');
276  }
277 
278  $course_members->delete($user_id);
279 
280  return true;
281  }
global $DIC
Definition: saml.php:7
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getCoursesForUser()

ilSoapCourseAdministration::getCoursesForUser (   $sid,
  $parameters 
)

get courses which belong to a specific user, fullilling the status

Parameters
string$sid
string$parametersfollowing xmlresultset, columns (user_id, status with values 1 = "MEMBER", 2 = "TUTOR", 4 = "ADMIN", 8 = "OWNER" and any xor operation e.g. 1 + 4 = 5 = ADMIN and TUTOR, 7 = ADMIN and TUTOR and MEMBER)
stringXMLResultSet, columns (ref_id, xml, parent_ref_id)

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

References $DIC, $ilUser, $parser, $r, $row, $tree, ilUtil\__extractRefId(), ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_exists(), ilObject\_getAllReferences(), ilObject\_isInTrash(), ADMIN, ilSoapAdministration\checkObjectAccess(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getObjectsForOwner(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), MEMBER, OWNER, and TUTOR.

460  {
461  $this->initAuth($sid);
462  $this->initIlias();
463 
464  if (!$this->__checkSession($sid)) {
465  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
466  }
467 
468  global $DIC;
469 
470  $rbacreview = $DIC['rbacreview'];
471  $ilObjDataCache = $DIC['ilObjDataCache'];
472  $tree = $DIC['tree'];
473 
474  include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
475  $parser = new ilXMLResultSetParser($parameters);
476  try {
477  $parser->startParsing();
478  } catch (ilSaxParserException $exception) {
479  return $this->__raiseError($exception->getMessage(), "Client");
480  }
481  $xmlResultSet = $parser->getXMLResultSet();
482 
483  if (!$xmlResultSet->hasColumn("user_id")) {
484  return $this->__raiseError("parameter user_id is missing", "Client");
485  }
486 
487  if (!$xmlResultSet->hasColumn("status")) {
488  return $this->__raiseError("parameter status is missing", "Client");
489  }
490 
491  $user_id = (int) $xmlResultSet->getValue(0, "user_id");
492  $status = (int) $xmlResultSet->getValue(0, "status");
493 
494  $ref_ids = array();
495 
496  // get roles
497  #var_dump($xmlResultSet);
498  #echo "uid:".$user_id;
499  #echo "status:".$status;
503  foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
504  if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
505  #echo $role->getType();
506  if ($role->getType() != "role") {
507  continue;
508  }
509  if ($role->getParent() == ROLE_FOLDER_ID) {
510  continue;
511  }
512  $role_title = $role->getTitle();
513 
514  if ($ref_id = ilUtil::__extractRefId($role_title)) {
515  if (!ilObject::_exists($ref_id, true) || ilObject::_isInTrash($ref_id)) {
516  continue;
517  }
518 
519  #echo $role_title;
520  if (ilSoapCourseAdministration::MEMBER == ($status & ilSoapCourseAdministration::MEMBER) && strpos($role_title, "member") !== false) {
521  $ref_ids [] = $ref_id;
522  } elseif (ilSoapCourseAdministration::TUTOR == ($status & ilSoapCourseAdministration::TUTOR) && strpos($role_title, "tutor") !== false) {
523  $ref_ids [] = $ref_id;
524  } elseif (ilSoapCourseAdministration::ADMIN == ($status & ilSoapCourseAdministration::ADMIN) && strpos($role_title, "admin") !== false) {
525  $ref_ids [] = $ref_id;
526  } elseif (($status & ilSoapCourseAdministration::OWNER) == ilSoapCourseAdministration::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($ref_id)) == $user_id) {
527  $ref_ids [] = $ref_id;
528  }
529  }
530  }
531  }
532  }
534  $owned_objects = ilObjectFactory::getObjectsForOwner("crs", $user_id);
535  foreach ($owned_objects as $obj_id) {
536  $allrefs = ilObject::_getAllReferences($obj_id);
537  foreach ($allrefs as $r) {
538  if ($tree->isDeleted($r)) {
539  continue;
540  }
541  if ($tree->isInTree($r)) {
542  $refs[] = $r;
543  }
544  }
545  if (count($refs) > 0) {
546  $ref_ids[] = array_pop($refs);
547  }
548  }
549  }
550  $ref_ids = array_unique($ref_ids);
551 
552 
553 
554  $ref_ids = array_unique($ref_ids);
555  #print_r($ref_ids);
556  include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
557  include_once 'Modules/Course/classes/class.ilObjCourse.php';
558  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
559 
560  $xmlResultSet = new ilXMLResultSet();
561  $xmlResultSet->addColumn("ref_id");
562  $xmlResultSet->addColumn("xml");
563  $xmlResultSet->addColumn("parent_ref_id");
564 
565  global $DIC;
566 
567  $ilUser = $DIC['ilUser'];
568  //#18004
569  // Enable to see own participations by reducing the needed permissions
570  $permission = $user_id == $ilUser->getId() ? 'read' : 'write';
571 
572  foreach ($ref_ids as $course_id) {
573  $course_obj = $this->checkObjectAccess($course_id, "crs", $permission, true);
574  if ($course_obj instanceof ilObjCourse) {
575  $row = new ilXMLResultSetRow();
576  $row->setValue("ref_id", $course_id);
577  $xmlWriter = new ilCourseXMLWriter($course_obj);
578  $xmlWriter->setAttachUsers(false);
579  $xmlWriter->start();
580  $row->setValue("xml", $xmlWriter->getXML());
581  $row->setValue("parent_ref_id", $tree->getParentId($course_id));
582  $xmlResultSet->addRow($row);
583  }
584  }
585  $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
586  $xmlResultSetWriter->start();
587  return $xmlResultSetWriter->getXML();
588  }
XML Writer for XMLResultSet.
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true ...
global $DIC
Definition: saml.php:7
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
static _isInTrash($a_ref_id)
checks wether object is in trash
SaxParserException thrown by ilSaxParser if property throwException is set.
static _getAllReferences($a_id)
get all reference ids of object
getObjectsForOwner($object_type, $owner_id)
returns all objects of an owner, filtered by type, objects are not deleted!
static __extractRefId($role_title)
extract ref id from role title, e.g.
$r
Definition: example_031.php:79
Class ilObjCourse.
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$row
$parser
Definition: BPMN2Parser.php:23
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getCourseXML()

ilSoapCourseAdministration::getCourseXML (   $sid,
  $course_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\checkObjectAccess(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\isFault().

339  {
340  $this->initAuth($sid);
341  $this->initIlias();
342 
343  if (!$this->__checkSession($sid)) {
344  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
345  }
346  if (!is_numeric($course_id)) {
347  return $this->__raiseError(
348  'No valid course id given. Please choose an existing reference id of an ILIAS course',
349  'Client'
350  );
351  }
352 
353  global $DIC;
354 
355  $rbacsystem = $DIC['rbacsystem'];
356 
357  $tmp_course = $this->checkObjectAccess($course_id, "crs", "read", true);
358  if ($this->isFault($tmp_course)) {
359  return $tmp_course;
360  }
361 
362  /*if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
363  {
364  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
365  if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
366  {
367  return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
368  }
369  }
370 
371  if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
372  {
373  return $this->__raiseError('Cannot create course instance!','Server');
374  }
375 
376  if(!$rbacsystem->checkAccess('read',$course_id))
377  {
378  return $this->__raiseError('Check access failed. No permission to read course','Server');
379  }*/
380 
381  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
382 
383  $xml_writer = new ilCourseXMLWriter($tmp_course);
384  $xml_writer->start();
385 
386  return $xml_writer->getXML();
387  }
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true ...
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ isAssignedToCourse()

ilSoapCourseAdministration::isAssignedToCourse (   $sid,
  $course_id,
  $user_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), IL_CRS_ADMIN, IL_CRS_MEMBER, IL_CRS_TUTOR, ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

285  {
286  $this->initAuth($sid);
287  $this->initIlias();
288 
289  if (!$this->__checkSession($sid)) {
290  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
291  }
292  if (!is_numeric($course_id)) {
293  return $this->__raiseError(
294  'No valid course id given. Please choose an existing reference id of an ILIAS course',
295  'Client'
296  );
297  }
298  global $DIC;
299 
300  $rbacsystem = $DIC['rbacsystem'];
301 
302  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
303  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
304  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
305  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
306  }
307  }
308 
309  if (ilObject::_lookupType($user_id) != 'usr') {
310  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
311  }
312 
313  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
314  return $this->__raiseError('Cannot create course instance!', 'Server');
315  }
316 
317  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
318  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
319  }
320 
321  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
322  $crs_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
323 
324  if ($crs_members->isAdmin($user_id)) {
325  return IL_CRS_ADMIN;
326  }
327  if ($crs_members->isTutor($user_id)) {
328  return IL_CRS_TUTOR;
329  }
330  if ($crs_members->isMember($user_id)) {
331  return IL_CRS_MEMBER;
332  }
333 
334  return "0";
335  }
global $DIC
Definition: saml.php:7
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
const IL_CRS_TUTOR
static _getAllReferences($a_id)
get all reference ids of object
const IL_CRS_MEMBER
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
const IL_CRS_ADMIN
Base class for course and group participants.
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ updateCourse()

ilSoapCourseAdministration::updateCourse (   $sid,
  $course_id,
  $xml 
)

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

References $DIC, $xml, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilWaitingList\_deleteAll(), ilParticipants\_deleteAllEntries(), ilObject\_getAllReferences(), ilObject\_lookupObjId(), ilObject\_lookupType(), ilMD\deleteAll(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

390  {
391  $this->initAuth($sid);
392  $this->initIlias();
393 
394  if (!$this->__checkSession($sid)) {
395  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
396  }
397 
398  if (!is_numeric($course_id)) {
399  return $this->__raiseError(
400  'No valid course id given. Please choose an existing reference id of an ILIAS course',
401  'Client'
402  );
403  }
404 
405  global $DIC;
406 
407  $rbacsystem = $DIC['rbacsystem'];
408 
409  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
410  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
411  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
412  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
413  }
414  }
415 
416  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
417  return $this->__raiseError('Cannot create course instance!', 'Server');
418  }
419 
420  if (!$rbacsystem->checkAccess('write', $course_id)) {
421  return $this->__raiseError('Check access failed. No permission to write course', 'Server');
422  }
423 
424 
425  // First delete old meta data
426  include_once 'Services/MetaData/classes/class.ilMD.php';
427 
428  $md = new ilMD($tmp_course->getId(), 0, 'crs');
429  $md->deleteAll();
430 
431  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
432  ilCourseParticipants::_deleteAllEntries($tmp_course->getId());
433 
434 
435  include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
436  ilCourseWaitingList::_deleteAll($tmp_course->getId());
437 
438  include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
439 
440  $xml_parser = new ilCourseXMLParser($tmp_course);
441  $xml_parser->setXMLContent($xml);
442 
443  $xml_parser->startParsing();
444 
445  $tmp_course->MDUpdateListener('General');
446 
447  return true;
448  }
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
global $DIC
Definition: saml.php:7
deleteAll()
Definition: class.ilMD.php:357
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _deleteAll($a_obj_id)
delete all
+ Here is the call graph for this function:

Field Documentation

◆ ADMIN

const ilSoapCourseAdministration::ADMIN = 4

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

Referenced by getCoursesForUser().

◆ MEMBER

const ilSoapCourseAdministration::MEMBER = 1

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

Referenced by getCoursesForUser().

◆ OWNER

const ilSoapCourseAdministration::OWNER = 8

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

Referenced by getCoursesForUser().

◆ TUTOR

const ilSoapCourseAdministration::TUTOR = 2

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

Referenced by getCoursesForUser().


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