00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
00034
00035 class ilSoapCourseAdministration extends ilSoapAdministration
00036 {
00037 function ilSoapCourseAdministration()
00038 {
00039 parent::ilSoapAdministration();
00040 }
00041
00042
00043
00044 function addCourse($sid,$target_id,$crs_xml)
00045 {
00046 if(!$this->__checkSession($sid))
00047 {
00048 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00049 }
00050
00051 if(!is_numeric($target_id))
00052 {
00053 return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category',
00054 'Client');
00055 }
00056
00057
00058 include_once './include/inc.header.php';
00059 global $rbacsystem;
00060
00061 if(!$target_obj =& ilObjectFactory::getInstanceByRefId($target_id, false))
00062 {
00063 return $this->__raiseError('No valid target given.', 'Client');
00064 }
00065
00066 if(ilObject::_isInTrash($target_id))
00067 {
00068 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
00069 }
00070
00071 if(!$rbacsystem->checkAccess('create',$target_id,'crs'))
00072 {
00073 return $this->__raiseError('Check access failed. No permission to create courses','Server');
00074 }
00075
00076
00077 include_once("Modules/Course/classes/class.ilObjCourse.php");
00078
00079 $newObj = new ilObjCourse();
00080 $newObj->setType('crs');
00081 $newObj->setTitle('dummy');
00082 $newObj->setDescription("");
00083 $newObj->create(true);
00084 $newObj->createReference();
00085 $newObj->putInTree($target_id);
00086 $newObj->setPermissions($target_id);
00087 $newObj->initDefaultRoles();
00088
00089 include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
00090
00091 $xml_parser = new ilCourseXMLParser($newObj);
00092 $xml_parser->setXMLContent($crs_xml);
00093
00094 $xml_parser->startParsing();
00095
00096 $newObj->MDUpdateListener('General');
00097
00098 return $newObj->getRefId() ? $newObj->getRefId() : "0";
00099
00100 }
00101
00102 function deleteCourse($sid,$course_id)
00103 {
00104 if(!$this->__checkSession($sid))
00105 {
00106 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00107 }
00108
00109 if(!is_numeric($course_id))
00110 {
00111 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00112 'Client');
00113 }
00114
00115
00116 include_once './include/inc.header.php';
00117 include_once "./Services/Utilities/classes/class.ilUtil.php";
00118 global $rbacsystem;
00119
00120 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00121 {
00122 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00123 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00124 {
00125 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00126 }
00127 }
00128
00129 if(!$rbacsystem->checkAccess('delete',$course_id))
00130 {
00131 return $this->__raiseError('Check access failed. No permission to delete course','Server');
00132 }
00133
00134
00135 global $tree,$rbacadmin,$log;
00136
00137 if($tree->isDeleted($course_id))
00138 {
00139 return $this->__raiseError('Node already deleted','Server');
00140 }
00141
00142 $subnodes = $tree->getSubtree($tree->getNodeData($course_id));
00143 foreach ($subnodes as $subnode)
00144 {
00145 $rbacadmin->revokePermission($subnode["child"]);
00146
00147
00148 $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00149
00150 }
00151 if(!$tree->saveSubTree($course_id))
00152 {
00153 return $this->__raiseError('Node already deleted','Client');
00154 }
00155
00156
00157 $log->write("SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$course_id." to trash");
00158
00159
00160 $affected_users = ilUtil::removeItemFromDesktops($course_id);
00161
00162 return true;
00163 }
00164
00165 function assignCourseMember($sid,$course_id,$user_id,$type)
00166 {
00167 if(!$this->__checkSession($sid))
00168 {
00169 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00170 }
00171
00172 if(!is_numeric($course_id))
00173 {
00174 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00175 'Client');
00176 }
00177
00178
00179 include_once './include/inc.header.php';
00180
00181 global $rbacsystem;
00182
00183 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00184 {
00185 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00186 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00187 {
00188 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00189 }
00190 }
00191
00192 if(!$rbacsystem->checkAccess('write',$course_id))
00193 {
00194 return $this->__raiseError('Check access failed. No permission to write to course','Server');
00195 }
00196
00197
00198 if(ilObject::_lookupType($user_id) != 'usr')
00199 {
00200 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00201 }
00202 if($type != 'Admin' and
00203 $type != 'Tutor' and
00204 $type != 'Member')
00205 {
00206 return $this->__raiseError('Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"','Client');
00207 }
00208
00209 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00210 {
00211 return $this->__raiseError('Cannot create course instance!','Server');
00212 }
00213
00214 if(!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false))
00215 {
00216 return $this->__raiseError('Cannot create user instance!','Server');
00217 }
00218
00219 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00220
00221 $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
00222
00223 switch($type)
00224 {
00225 case 'Admin':
00226 $course_members->add($tmp_user->getId(),IL_CRS_ADMIN);
00227 $course_members->updateNotification($tmp_user->getId(),1);
00228 break;
00229
00230 case 'Tutor':
00231 $course_members->add($tmp_user->getId(),IL_CRS_TUTOR);
00232 break;
00233
00234 case 'Member':
00235 $course_members->add($tmp_user->getId(),IL_CRS_MEMBER);
00236 break;
00237 }
00238
00239 return true;
00240 }
00241
00242 function excludeCourseMember($sid,$course_id,$user_id)
00243 {
00244 if(!$this->__checkSession($sid))
00245 {
00246 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00247 }
00248 if(!is_numeric($course_id))
00249 {
00250 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00251 'Client');
00252 }
00253
00254
00255 include_once './include/inc.header.php';
00256 global $rbacsystem;
00257
00258 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00259 {
00260 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00261 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00262 {
00263 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00264 }
00265 }
00266
00267 if(ilObject::_lookupType($user_id) != 'usr')
00268 {
00269 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00270 }
00271
00272 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00273 {
00274 return $this->__raiseError('Cannot create course instance!','Server');
00275 }
00276
00277 if(!$rbacsystem->checkAccess('write',$course_id))
00278 {
00279 return $this->__raiseError('Check access failed. No permission to write to course','Server');
00280 }
00281
00282 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00283
00284 $course_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
00285 if(!$course_members->checkLastAdmin(array($user_id)))
00286 {
00287 return $this->__raiseError('Cannot deassign last administrator from course','Server');
00288 }
00289
00290 $course_members->delete($user_id);
00291
00292 return true;
00293 }
00294
00295
00296 function isAssignedToCourse($sid,$course_id,$user_id)
00297 {
00298 if(!$this->__checkSession($sid))
00299 {
00300 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00301 }
00302 if(!is_numeric($course_id))
00303 {
00304 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00305 'Client');
00306 }
00307
00308 include_once './include/inc.header.php';
00309 global $rbacsystem;
00310
00311 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00312 {
00313 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00314 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00315 {
00316 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00317 }
00318 }
00319
00320 if(ilObject::_lookupType($user_id) != 'usr')
00321 {
00322 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00323 }
00324
00325 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00326 {
00327 return $this->__raiseError('Cannot create course instance!','Server');
00328 }
00329
00330 if(!$rbacsystem->checkAccess('write',$course_id))
00331 {
00332 return $this->__raiseError('Check access failed. No permission to write to course','Server');
00333 }
00334
00335 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
00336 $crs_members = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId());
00337
00338 if($crs_members->isAdmin($user_id))
00339 {
00340 return IL_CRS_ADMIN;
00341 }
00342 if($crs_members->isTutor($user_id))
00343 {
00344 return IL_CRS_TUTOR;
00345 }
00346 if($crs_members->isMember($user_id))
00347 {
00348 return IL_CRS_MEMBER;
00349 }
00350
00351 return "0";
00352 }
00353
00354
00355 function getCourseXML($sid,$course_id)
00356 {
00357 if(!$this->__checkSession($sid))
00358 {
00359 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00360 }
00361 if(!is_numeric($course_id))
00362 {
00363 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00364 'Client');
00365 }
00366
00367
00368 include_once './include/inc.header.php';
00369
00370 global $rbacsystem;
00371
00372 if(ilObject::_isInTrash($course_id))
00373 {
00374 return $this->__raiseError("Course with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
00375 }
00376
00377 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00378 {
00379 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00380 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00381 {
00382 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00383 }
00384 }
00385
00386 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00387 {
00388 return $this->__raiseError('Cannot create course instance!','Server');
00389 }
00390
00391 if(!$rbacsystem->checkAccess('read',$course_id))
00392 {
00393 return $this->__raiseError('Check access failed. No permission to read course','Server');
00394 }
00395
00396 include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
00397
00398 $xml_writer = new ilCourseXMLWriter($tmp_course);
00399 $xml_writer->start();
00400
00401 return $xml_writer->getXML();
00402 }
00403
00404 function updateCourse($sid,$course_id,$xml)
00405 {
00406 if(!$this->__checkSession($sid))
00407 {
00408 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00409 }
00410
00411 if(!is_numeric($course_id))
00412 {
00413 return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00414 'Client');
00415 }
00416
00417
00418 include_once './include/inc.header.php';
00419
00420 global $rbacsystem;
00421
00422 if(ilObject::_isInTrash($course_id))
00423 {
00424 return $this->__raiseError("Course with ID $target_id has been deleted.", 'CLIENT_OBJECT_DELETED');
00425 }
00426
00427 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00428 {
00429 $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00430 if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00431 {
00432 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00433 }
00434 }
00435
00436 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00437 {
00438 return $this->__raiseError('Cannot create course instance!','Server');
00439 }
00440
00441 if(!$rbacsystem->checkAccess('write',$course_id))
00442 {
00443 return $this->__raiseError('Check access failed. No permission to write course','Server');
00444 }
00445
00446
00447
00448 include_once 'Services/MetaData/classes/class.ilMD.php';
00449
00450 $md = new ilMD($tmp_course->getId(),0,'crs');
00451 $md->deleteAll();
00452
00453 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
00454 ilCourseParticipants::_deleteAllEntries($tmp_course->getId());
00455
00456
00457 include_once 'Modules/Course/classes/class.ilCourseWaitingList.php';
00458 ilCourseWaitingList::_deleteAll($tmp_course->getId());
00459
00460 include_once 'Modules/Course/classes/class.ilCourseXMLParser.php';
00461
00462 $xml_parser = new ilCourseXMLParser($tmp_course);
00463 $xml_parser->setXMLContent($xml);
00464
00465 $xml_parser->startParsing();
00466
00467 $tmp_course->MDUpdateListener('General');
00468
00469 return true;
00470 }
00471
00472
00473
00474 }
00475 ?>