ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $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 $rbacsystem;
61 
62  if (!$target_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
63  return $this->__raiseError('No valid target given.', 'Client');
64  }
65 
67  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
68  }
69 
70  if (!$rbacsystem->checkAccess('create', $target_id, 'crs')) {
71  return $this->__raiseError('Check access failed. No permission to create courses', 'Server');
72  }
73 
74 
75  // Start import
76  include_once("Modules/Course/classes/class.ilObjCourse.php");
77 
78  $newObj = new ilObjCourse();
79  $newObj->setType('crs');
80  $newObj->setTitle('dummy');
81  $newObj->setDescription("");
82  $newObj->create(true); // true for upload
83  $newObj->createReference();
84  $newObj->putInTree($target_id);
85  $newObj->setPermissions($target_id);
86 
87  include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
88 
89  $xml_parser = new ilCourseXMLParser($newObj);
90  $xml_parser->setXMLContent($crs_xml);
91  $xml_parser->startParsing();
92  return $newObj->getRefId() ? $newObj->getRefId() : "0";
93  }
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 152 of file class.ilSoapCourseAdministration.php.

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

153  {
154  $this->initAuth($sid);
155  $this->initIlias();
156 
157  if (!$this->__checkSession($sid)) {
158  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
159  }
160 
161  if (!is_numeric($course_id)) {
162  return $this->__raiseError(
163  'No valid course id given. Please choose an existing reference id of an ILIAS course',
164  'Client'
165  );
166  }
167 
168  global $rbacsystem;
169 
170  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
171  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
172  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
173  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
174  }
175  }
176 
177  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
178  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
179  }
180 
181 
182  if (ilObject::_lookupType($user_id) != 'usr') {
183  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
184  }
185  if ($type != 'Admin' and
186  $type != 'Tutor' and
187  $type != 'Member') {
188  return $this->__raiseError('Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"', 'Client');
189  }
190 
191  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
192  return $this->__raiseError('Cannot create course instance!', 'Server');
193  }
194 
195  if (!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id, false)) {
196  return $this->__raiseError('Cannot create user instance!', 'Server');
197  }
198 
199  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
200 
201  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
202 
203  switch ($type) {
204  case 'Admin':
205  require_once("Services/Administration/classes/class.ilSetting.php");
206  $settings = new ilSetting();
207  $course_members->add($tmp_user->getId(), IL_CRS_ADMIN);
208  $course_members->updateNotification($tmp_user->getId(), $settings->get('mail_crs_admin_notification', true));
209  break;
210 
211  case 'Tutor':
212  $course_members->add($tmp_user->getId(), IL_CRS_TUTOR);
213  break;
214 
215  case 'Member':
216  $course_members->add($tmp_user->getId(), IL_CRS_MEMBER);
217  break;
218  }
219 
220  return true;
221  }
$type
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 95 of file class.ilSoapCourseAdministration.php.

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

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

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

224  {
225  $this->initAuth($sid);
226  $this->initIlias();
227 
228  if (!$this->__checkSession($sid)) {
229  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
230  }
231  if (!is_numeric($course_id)) {
232  return $this->__raiseError(
233  'No valid course id given. Please choose an existing reference id of an ILIAS course',
234  'Client'
235  );
236  }
237 
238  global $rbacsystem;
239 
240  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
241  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
242  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
243  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
244  }
245  }
246 
247  if (ilObject::_lookupType($user_id) != 'usr') {
248  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
249  }
250 
251  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
252  return $this->__raiseError('Cannot create course instance!', 'Server');
253  }
254 
255  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
256  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
257  }
258 
259  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
260 
261  $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
262  if (!$course_members->checkLastAdmin(array($user_id))) {
263  return $this->__raiseError('Cannot deassign last administrator from course', 'Server');
264  }
265 
266  $course_members->delete($user_id);
267 
268  return true;
269  }
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)
Create styles array
The data for the language used.
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 441 of file class.ilSoapCourseAdministration.php.

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

442  {
443  $this->initAuth($sid);
444  $this->initIlias();
445 
446  if (!$this->__checkSession($sid)) {
447  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
448  }
449 
450  global $rbacreview, $ilObjDataCache, $tree;
451 
452  include_once 'webservice/soap/classes/class.ilXMLResultSetParser.php';
453  $parser = new ilXMLResultSetParser($parameters);
454  try {
455  $parser->startParsing();
456  } catch (ilSaxParserException $exception) {
457  return $this->__raiseError($exception->getMessage(), "Client");
458  }
459  $xmlResultSet = $parser->getXMLResultSet();
460 
461  if (!$xmlResultSet->hasColumn("user_id")) {
462  return $this->__raiseError("parameter user_id is missing", "Client");
463  }
464 
465  if (!$xmlResultSet->hasColumn("status")) {
466  return $this->__raiseError("parameter status is missing", "Client");
467  }
468 
469  $user_id = (int) $xmlResultSet->getValue(0, "user_id");
470  $status = (int) $xmlResultSet->getValue(0, "status");
471 
472  $ref_ids = array();
473 
474  // get roles
475  #var_dump($xmlResultSet);
476  #echo "uid:".$user_id;
477  #echo "status:".$status;
481  foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
482  if ($role = ilObjectFactory::getInstanceByObjId($role_id, false)) {
483  #echo $role->getType();
484  if ($role->getType() != "role") {
485  continue;
486  }
487  if ($role->getParent() == ROLE_FOLDER_ID) {
488  continue;
489  }
490  $role_title = $role->getTitle();
491 
492  if ($ref_id = ilUtil::__extractRefId($role_title)) {
493  if (!ilObject::_exists($ref_id, true) || ilObject::_isInTrash($ref_id)) {
494  continue;
495  }
496 
497  #echo $role_title;
498  if (ilSoapCourseAdministration::MEMBER == ($status & ilSoapCourseAdministration::MEMBER) && strpos($role_title, "member") !== false) {
499  $ref_ids [] = $ref_id;
500  } elseif (ilSoapCourseAdministration::TUTOR == ($status & ilSoapCourseAdministration::TUTOR) && strpos($role_title, "tutor") !== false) {
501  $ref_ids [] = $ref_id;
502  } elseif (ilSoapCourseAdministration::ADMIN == ($status & ilSoapCourseAdministration::ADMIN) && strpos($role_title, "admin") !== false) {
503  $ref_ids [] = $ref_id;
504  } elseif (($status & ilSoapCourseAdministration::OWNER) == ilSoapCourseAdministration::OWNER && $ilObjDataCache->lookupOwner($ilObjDataCache->lookupObjId($ref_id)) == $user_id) {
505  $ref_ids [] = $ref_id;
506  }
507  }
508  }
509  }
510  }
512  $owned_objects = ilObjectFactory::getObjectsForOwner("crs", $user_id);
513  foreach ($owned_objects as $obj_id) {
514  $allrefs = ilObject::_getAllReferences($obj_id);
515  foreach ($allrefs as $r) {
516  if ($tree->isDeleted($r)) {
517  continue;
518  }
519  if ($tree->isInTree($r)) {
520  $refs[] = $r;
521  }
522  }
523  if (count($refs) > 0) {
524  $ref_ids[] = array_pop($refs);
525  }
526  }
527  }
528  $ref_ids = array_unique($ref_ids);
529 
530 
531 
532  $ref_ids = array_unique($ref_ids);
533  #print_r($ref_ids);
534  include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
535  include_once 'Modules/Course/classes/class.ilObjCourse.php';
536  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
537 
538  $xmlResultSet = new ilXMLResultSet();
539  $xmlResultSet->addColumn("ref_id");
540  $xmlResultSet->addColumn("xml");
541  $xmlResultSet->addColumn("parent_ref_id");
542 
543  global $ilUser;
544  //#18004
545  // Enable to see own participations by reducing the needed permissions
546  $permission = $user_id == $ilUser->getId() ? 'read' : 'write';
547 
548  foreach ($ref_ids as $course_id) {
549  $course_obj = $this->checkObjectAccess($course_id, "crs", $permission, true);
550  if ($course_obj instanceof ilObjCourse) {
551  $row = new ilXMLResultSetRow();
552  $row->setValue("ref_id", $course_id);
553  $xmlWriter = new ilCourseXMLWriter($course_obj);
554  $xmlWriter->setAttachUsers(false);
555  $xmlWriter->start();
556  $row->setValue("xml", $xmlWriter->getXML());
557  $row->setValue("parent_ref_id", $tree->getParentId($course_id));
558  $xmlResultSet->addRow($row);
559  }
560  }
561  $xmlResultSetWriter = new ilXMLResultSetWriter($xmlResultSet);
562  $xmlResultSetWriter->start();
563  return $xmlResultSetWriter->getXML();
564  }
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 ...
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
Create styles array
The data for the language used.
$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 324 of file class.ilSoapCourseAdministration.php.

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

325  {
326  $this->initAuth($sid);
327  $this->initIlias();
328 
329  if (!$this->__checkSession($sid)) {
330  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
331  }
332  if (!is_numeric($course_id)) {
333  return $this->__raiseError(
334  'No valid course id given. Please choose an existing reference id of an ILIAS course',
335  'Client'
336  );
337  }
338 
339  global $rbacsystem;
340 
341  $tmp_course = $this->checkObjectAccess($course_id, "crs", "read", true);
342  if ($this->isFault($tmp_course)) {
343  return $tmp_course;
344  }
345 
346  /*if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
347  {
348  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
349  if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
350  {
351  return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
352  }
353  }
354 
355  if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
356  {
357  return $this->__raiseError('Cannot create course instance!','Server');
358  }
359 
360  if(!$rbacsystem->checkAccess('read',$course_id))
361  {
362  return $this->__raiseError('Check access failed. No permission to read course','Server');
363  }*/
364 
365  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
366 
367  $xml_writer = new ilCourseXMLWriter($tmp_course);
368  $xml_writer->start();
369 
370  return $xml_writer->getXML();
371  }
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true ...
__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 272 of file class.ilSoapCourseAdministration.php.

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

273  {
274  $this->initAuth($sid);
275  $this->initIlias();
276 
277  if (!$this->__checkSession($sid)) {
278  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
279  }
280  if (!is_numeric($course_id)) {
281  return $this->__raiseError(
282  'No valid course id given. Please choose an existing reference id of an ILIAS course',
283  'Client'
284  );
285  }
286  global $rbacsystem;
287 
288  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
289  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
290  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
291  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
292  }
293  }
294 
295  if (ilObject::_lookupType($user_id) != 'usr') {
296  return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client');
297  }
298 
299  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
300  return $this->__raiseError('Cannot create course instance!', 'Server');
301  }
302 
303  if (!$rbacsystem->checkAccess('manage_members', $course_id)) {
304  return $this->__raiseError('Check access failed. No permission to write to course', 'Server');
305  }
306 
307  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
308  $crs_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
309 
310  if ($crs_members->isAdmin($user_id)) {
311  return IL_CRS_ADMIN;
312  }
313  if ($crs_members->isTutor($user_id)) {
314  return IL_CRS_TUTOR;
315  }
316  if ($crs_members->isMember($user_id)) {
317  return IL_CRS_MEMBER;
318  }
319 
320  return "0";
321  }
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 373 of file class.ilSoapCourseAdministration.php.

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

374  {
375  $this->initAuth($sid);
376  $this->initIlias();
377 
378  if (!$this->__checkSession($sid)) {
379  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
380  }
381 
382  if (!is_numeric($course_id)) {
383  return $this->__raiseError(
384  'No valid course id given. Please choose an existing reference id of an ILIAS course',
385  'Client'
386  );
387  }
388 
389  global $rbacsystem;
390 
391  if (($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs') {
392  $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
393  if (ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs') {
394  return $this->__raiseError('Invalid course id. Object with id "' . $course_id . '" is not of type "course"', 'Client');
395  }
396  }
397 
398  if (!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id, false)) {
399  return $this->__raiseError('Cannot create course instance!', 'Server');
400  }
401 
402  if (!$rbacsystem->checkAccess('write', $course_id)) {
403  return $this->__raiseError('Check access failed. No permission to write course', 'Server');
404  }
405 
406 
407  // First delete old meta data
408  include_once 'Services/MetaData/classes/class.ilMD.php';
409 
410  $md = new ilMD($tmp_course->getId(), 0, 'crs');
411  $md->deleteAll();
412 
413  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
414  ilCourseParticipants::_deleteAllEntries($tmp_course->getId());
415 
416 
417  include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
418  ilCourseWaitingList::_deleteAll($tmp_course->getId());
419 
420  include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
421 
422  $xml_parser = new ilCourseXMLParser($tmp_course);
423  $xml_parser->setXMLContent($xml);
424 
425  $xml_parser->startParsing();
426 
427  $tmp_course->MDUpdateListener('General');
428 
429  return true;
430  }
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
deleteAll()
Definition: class.ilMD.php:347
static _getAllReferences($a_id)
get all reference ids of object
$xml
Definition: metadata.php:240
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: