• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

webservice/soap/classes/class.ilSoapCourseAdministration.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    +-----------------------------------------------------------------------------+
00004    | ILIAS open source                                                           |
00005    +-----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007    |                                                                             |
00008    | This program is free software; you can redistribute it and/or               |
00009    | modify it under the terms of the GNU General Public License                 |
00010    | as published by the Free Software Foundation; either version 2              |
00011    | of the License, or (at your option) any later version.                      |
00012    |                                                                             |
00013    | This program is distributed in the hope that it will be useful,             |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016    | GNU General Public License for more details.                                |
00017    |                                                                             |
00018    | You should have received a copy of the GNU General Public License           |
00019    | along with this program; if not, write to the Free Software                 |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
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         // Service methods
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                 // Include main header
00058                 include_once './include/inc.header.php';
00059 
00060                 if(!$rbacsystem->checkAccess('create',$target_id,'crs'))
00061                 {
00062                         return $this->__raiseError('Check access failed. No permission to create courses','Server');
00063                 }
00064 
00065                 // Start import
00066                 include_once("course/classes/class.ilObjCourse.php");
00067 
00068                 $newObj = new ilObjCourse();
00069                 $newObj->setType('crs');
00070                 $newObj->setTitle('dummy');
00071                 $newObj->setDescription("");
00072                 $newObj->create(true); // true for upload
00073                 $newObj->createReference();
00074                 $newObj->putInTree($target_id);
00075                 $newObj->setPermissions($target_id);
00076                 $newObj->initDefaultRoles();
00077 
00078                 include_once 'course/classes/class.ilCourseXMLParser.php';
00079 
00080                 $xml_parser = new ilCourseXMLParser($newObj);
00081                 $xml_parser->setXMLContent($crs_xml);
00082 
00083                 $xml_parser->startParsing();
00084 
00085                 $newObj->MDUpdateListener('General');
00086 
00087                 return $newObj->getRefId() ? $newObj->getRefId() : "0";
00088                 
00089         }
00090 
00091         function deleteCourse($sid,$course_id)
00092         {
00093                 if(!$this->__checkSession($sid))
00094                 {
00095                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00096                 }                       
00097 
00098                 if(!is_numeric($course_id))
00099                 {
00100                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00101                                                                            'Client');
00102                 }
00103 
00104                 // Include main header
00105                 include_once './include/inc.header.php';
00106                 include_once './classes/class.ilUtil.php';
00107 
00108                 global $rbacsystem;
00109 
00110                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00111                 {
00112                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00113                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00114                         {
00115                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00116                         }
00117                 }
00118 
00119                 if(!$rbacsystem->checkAccess('delete',$course_id))
00120                 {
00121                         return $this->__raiseError('Check access failed. No permission to delete course','Server');
00122                 }
00123 
00124 
00125                 global $tree,$rbacadmin,$log;
00126 
00127                 $subnodes = $tree->getSubtree($tree->getNodeData($course_id));
00128                         
00129                 foreach ($subnodes as $subnode)
00130                 {
00131                         $rbacadmin->revokePermission($subnode["child"]);
00132 
00133                         // remove item from all user desktops
00134                         $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00135                                 
00136                 }
00137                 $tree->saveSubTree($course_id);
00138                 $tree->deleteTree($tree->getNodeData($course_id));
00139                 
00140                 // write log entry
00141                 $log->write("SOAP ilObjectGUI::confirmedDeleteObject(), moved ref_id ".$course_id." to trash");
00142                 
00143                 // remove item from all user desktops
00144                 $affected_users = ilUtil::removeItemFromDesktops($course_id);
00145                 
00146                 return true;
00147         }
00148 
00149         function assignCourseMember($sid,$course_id,$user_id,$type)
00150         {
00151                 if(!$this->__checkSession($sid))
00152                 {
00153                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00154                 }
00155 
00156                 if(!is_numeric($course_id))
00157                 {
00158                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00159                                                                            'Client');
00160                 }
00161 
00162                 // Include main header
00163                 include_once './include/inc.header.php';
00164 
00165                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00166                 {
00167                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00168                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00169                         {
00170                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00171                         }
00172                 }
00173 
00174                 if(!$rbacsystem->checkAccess('write',$course_id))
00175                 {
00176                         return $this->__raiseError('Check access failed. No permission to write to course','Server');
00177                 }
00178 
00179                 
00180                 if(ilObject::_lookupType($user_id) != 'usr')
00181                 {
00182                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00183                 }
00184                 if($type != 'Admin' and
00185                    $type != 'Tutor' and
00186                    $type != 'Member')
00187                 {
00188                         return $this->__raiseError('Invalid type given. Parameter "type" must be "Admin", "Tutor" or "Member"','Client');
00189                 }
00190 
00191                 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00192                 {
00193                         return $this->__raiseError('Cannot create course instance!','Server');
00194                 }
00195 
00196                 if(!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false))
00197                 {
00198                         return $this->__raiseError('Cannot create user instance!','Server');
00199                 }
00200 
00201                 include_once 'course/classes/class.ilCourseMembers.php';
00202                 
00203                 $course_members = new ilCourseMembers($tmp_course);
00204 
00205                 switch($type)
00206                 {
00207                         case 'Admin':
00208                                 $course_members->add($tmp_user,$course_members->ROLE_ADMIN,$course_members->STATUS_NOTIFY,0);
00209                                 break;
00210 
00211                         case 'Tutor':
00212                                 $course_members->add($tmp_user,$course_members->ROLE_TUTOR,$course_members->STATUS_NO_NOTIFY,0);
00213                                 break;
00214 
00215                         case 'Member':
00216                                 $course_members->add($tmp_user,$course_members->ROLE_MEMBER,$course_members->STATUS_UNBLOCKED,0);
00217                                 break;
00218                 }
00219 
00220                 return true;
00221         }
00222 
00223         function excludeCourseMember($sid,$course_id,$user_id)
00224         {
00225                 if(!$this->__checkSession($sid))
00226                 {
00227                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00228                 }                       
00229                 if(!is_numeric($course_id))
00230                 {
00231                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00232                                                                            'Client');
00233                 }
00234 
00235                 // Include main header
00236                 include_once './include/inc.header.php';
00237 
00238                 global $rbacsystem;
00239 
00240                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00241                 {
00242                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00243                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00244                         {
00245                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00246                         }
00247                 }
00248 
00249                 if(ilObject::_lookupType($user_id) != 'usr')
00250                 {
00251                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00252                 }
00253 
00254                 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00255                 {
00256                         return $this->__raiseError('Cannot create course instance!','Server');
00257                 }
00258 
00259                 if(!$rbacsystem->checkAccess('write',$course_id))
00260                 {
00261                         return $this->__raiseError('Check access failed. No permission to write to course','Server');
00262                 }
00263 
00264                 include_once 'course/classes/class.ilCourseMembers.php';
00265                 
00266                 $course_members = new ilCourseMembers($tmp_course);
00267 
00268                 if(!$course_members->checkLastAdmin(array($user_id)))
00269                 {
00270                         return $this->__raiseError('Cannot deassign last administrator from course','Server');
00271                 }
00272 
00273                 $course_members->delete($user_id);
00274 
00275                 return true;
00276         }
00277 
00278         
00279         function isAssignedToCourse($sid,$course_id,$user_id)
00280         {
00281                 if(!$this->__checkSession($sid))
00282                 {
00283                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00284                 }                       
00285                 if(!is_numeric($course_id))
00286                 {
00287                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00288                                                                            'Client');
00289                 }
00290                 // Include main header
00291                 include_once './include/inc.header.php';
00292 
00293                 global $rbacsystem;
00294 
00295                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00296                 {
00297                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00298                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00299                         {
00300                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00301                         }
00302                 }
00303 
00304                 if(ilObject::_lookupType($user_id) != 'usr')
00305                 {
00306                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00307                 }
00308 
00309                 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00310                 {
00311                         return $this->__raiseError('Cannot create course instance!','Server');
00312                 }
00313 
00314                 if(!$rbacsystem->checkAccess('write',$course_id))
00315                 {
00316                         return $this->__raiseError('Check access failed. No permission to write to course','Server');
00317                 }
00318 
00319                 include_once './course/classes/class.ilCourseMembers.php';
00320 
00321                 $crs_members = new ilCourseMembers($tmp_course);
00322                 
00323                 if($crs_members->isAdmin($user_id))
00324                 {
00325                         return $crs_members->ROLE_ADMIN;
00326                 }
00327                 if($crs_members->isTutor($user_id))
00328                 {
00329                         return $crs_members->ROLE_TUTOR;
00330                 }
00331                 if($crs_members->isMember($user_id))
00332                 {
00333                         return $crs_members->ROLE_MEMBER;
00334                 }
00335 
00336                 return "0";
00337         }
00338 
00339 
00340         function getCourseXML($sid,$course_id)
00341         {
00342                 if(!$this->__checkSession($sid))
00343                 {
00344                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00345                 }                       
00346                 if(!is_numeric($course_id))
00347                 {
00348                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00349                                                                            'Client');
00350                 }
00351 
00352                 // Include main header
00353                 include_once './include/inc.header.php';
00354 
00355                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00356                 {
00357                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00358                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00359                         {
00360                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00361                         }
00362                 }
00363 
00364                 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00365                 {
00366                         return $this->__raiseError('Cannot create course instance!','Server');
00367                 }
00368 
00369                 if(!$rbacsystem->checkAccess('read',$course_id))
00370                 {
00371                         return $this->__raiseError('Check access failed. No permission to read course','Server');
00372                 }
00373 
00374                 include_once 'course/classes/class.ilCourseXMLWriter.php';
00375 
00376                 $xml_writer = new ilCourseXMLWriter($tmp_course);
00377                 $xml_writer->start();
00378                 
00379                 return $xml_writer->getXML();
00380         }
00381 
00382         function updateCourse($sid,$course_id,$xml)
00383         {
00384                 if(!$this->__checkSession($sid))
00385                 {
00386                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00387                 }                       
00388                 if(!is_numeric($course_id))
00389                 {
00390                         return $this->__raiseError('No valid course id given. Please choose an existing reference id of an ILIAS course',
00391                                                                            'Client');
00392                 }
00393 
00394                 // Include main header
00395                 include_once './include/inc.header.php';
00396 
00397                 global $rbacsystem;
00398 
00399                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($course_id))) != 'crs')
00400                 {
00401                         $course_id = end($ref_ids = ilObject::_getAllReferences($course_id));
00402                         if(ilObject::_lookupType(ilObject::_lookupObjId($course_id)) != 'crs')
00403                         {
00404                                 return $this->__raiseError('Invalid course id. Object with id "'. $course_id.'" is not of type "course"','Client');
00405                         }
00406                 }
00407 
00408                 if(!$tmp_course = ilObjectFactory::getInstanceByRefId($course_id,false))
00409                 {
00410                         return $this->__raiseError('Cannot create course instance!','Server');
00411                 }
00412 
00413                 if(!$rbacsystem->checkAccess('write',$course_id))
00414                 {
00415                         return $this->__raiseError('Check access failed. No permission to write course','Server');
00416                 }
00417 
00418 
00419                 // First delete old meta data
00420                 include_once 'Services/MetaData/classes/class.ilMD.php';
00421 
00422                 $md = new ilMD($tmp_course->getId(),0,'crs');
00423                 $md->deleteAll();
00424 
00425                 include_once 'course/classes/class.ilCourseMembers.php';
00426 
00427                 $crs_members = new ilCourseMembers($tmp_course);
00428                 $crs_members->deleteAllEntries();
00429 
00430                 include_once 'course/classes/class.ilCourseWaitingList.php';
00431 
00432                 ilCourseWaitingList::_deleteAll($tmp_course->getId());
00433 
00434                 include_once 'course/classes/class.ilCourseXMLParser.php';
00435 
00436                 $xml_parser = new ilCourseXMLParser($tmp_course);
00437                 $xml_parser->setXMLContent($xml);
00438 
00439                 $xml_parser->startParsing();
00440 
00441                 $tmp_course->MDUpdateListener('General');
00442 
00443                 return true;
00444         }
00445 
00446         // PRIVATE
00447 
00448 }
00449 ?>

Generated on Fri Dec 13 2013 11:58:04 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1