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

webservice/soap/classes/class.ilSoapGroupAdministration.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 ilSoapGroupAdministration extends ilSoapAdministration
00036 {
00037         function ilSoapGroupAdministration()
00038         {
00039                 parent::ilSoapAdministration();
00040         }
00041                 
00042 
00043         // Service methods
00044         function addGroup($sid,$target_id,$grp_xml)
00045         {
00046                 
00047                 if(!$this->__checkSession($sid))
00048                 {
00049                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00050                 }                       
00051 
00052                 if(!is_numeric($target_id))
00053                 {
00054                         return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category or course',
00055                                                                            'Client');
00056                 }
00057 
00058                 // Include main header
00059                 include_once './include/inc.header.php';
00060 
00061                 if(!$rbacsystem->checkAccess('create',$target_id,'grp'))
00062                 {
00063                         return $this->__raiseError('Check access failed. No permission to create groups','Server');
00064                 }
00065 
00066                 // Start import
00067                 include_once("classes/class.ilObjGroup.php");
00068                 include_once 'classes/class.ilGroupImportParser.php';
00069                 $xml_parser = new ilGroupImportParser($grp_xml,$target_id);
00070                 $new_ref_id = $xml_parser->startParsing();
00071 
00072                 return $new_ref_id ? $new_ref_id : "0";
00073         }
00074 
00075         function groupExists($sid,$title)
00076         {
00077                 if(!$this->__checkSession($sid))
00078                 {
00079                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00080                 }                       
00081 
00082                 if(!$title)
00083                 {
00084                         return $this->__raiseError('No title given. Please choose an title for the group in question.',
00085                                                                            'Client');
00086                 }
00087 
00088                 // Include main header
00089                 include_once './include/inc.header.php';
00090 
00091                 return ilUtil::groupNameExists($title);
00092         }
00093 
00094         function getGroup($sid,$ref_id)
00095         {
00096                 if(!$this->__checkSession($sid))
00097                 {
00098                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00099                 }                       
00100 
00101                 // Include main header
00102                 include_once './include/inc.header.php';
00103 
00104                 if(!$grp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
00105                 {
00106                         return $this->__raiseError('No valid reference id given.',
00107                                                                            'Client');
00108                 }
00109 
00110                 include_once 'classes/class.ilGroupXMLWriter.php';
00111 
00112                 $xml_writer = new ilGroupXMLWriter($grp_obj);
00113                 $xml_writer->start();
00114                 
00115                 $xml = $xml_writer->getXML();
00116                 
00117                 return strlen($xml) ? $xml : '';
00118         }
00119 
00120 
00121         function assignGroupMember($sid,$group_id,$user_id,$type)
00122         {
00123                 if(!$this->__checkSession($sid))
00124                 {
00125                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00126                 }
00127 
00128                 if(!is_numeric($group_id))
00129                 {
00130                         return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
00131                                                                            'Client');
00132                 }
00133 
00134                 // Include main header
00135                 include_once './include/inc.header.php';
00136 
00137                 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00138                 {
00139                         $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00140                         if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00141                         {
00142                                 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00143                         }
00144                 }
00145 
00146                 if(!$rbacsystem->checkAccess('write',$group_id))
00147                 {
00148                         return $this->__raiseError('Check access failed. No permission to write to group','Server');
00149                 }
00150 
00151                 
00152                 if(ilObject::_lookupType($user_id) != 'usr')
00153                 {
00154                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00155                 }
00156                 if($type != 'Admin' and
00157                    $type != 'Member')
00158                 {
00159                         return $this->__raiseError('Invalid type '.$type.' given. Parameter "type" must be "Admin","Member"','Client');
00160                 }
00161 
00162                 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00163                 {
00164                         return $this->__raiseError('Cannot create group instance!','Server');
00165                 }
00166 
00167                 if(!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false))
00168                 {
00169                         return $this->__raiseError('Cannot create user instance!','Server');
00170                 }
00171 
00172 
00173                 switch($type)
00174                 {
00175                         case 'Admin':
00176                                 return $tmp_group->addMember($user_id,$tmp_group->getDefaultAdminRole());
00177 
00178                         case 'Member':
00179                                 return $tmp_group->addMember($user_id,$tmp_group->getDefaultMemberRole());
00180                                 break;
00181                 }
00182 
00183                 return true;
00184         }
00185 
00186         function excludeGroupMember($sid,$group_id,$user_id)
00187         {
00188                 if(!$this->__checkSession($sid))
00189                 {
00190                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00191                 }                       
00192                 if(!is_numeric($group_id))
00193                 {
00194                         return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
00195                                                                            'Client');
00196                 }
00197 
00198                 // Include main header
00199                 include_once './include/inc.header.php';
00200 
00201                 global $rbacsystem;
00202 
00203                 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00204                 {
00205                         $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00206                         if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00207                         {
00208                                 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00209                         }
00210                 }
00211 
00212                 if(ilObject::_lookupType($user_id) != 'usr')
00213                 {
00214                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00215                 }
00216 
00217                 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00218                 {
00219                         return $this->__raiseError('Cannot create group instance!','Server');
00220                 }
00221 
00222                 if(!$rbacsystem->checkAccess('write',$group_id))
00223                 {
00224                         return $this->__raiseError('Check access failed. No permission to write to group','Server');
00225                 }
00226 
00227                 $tmp_group->leave($user_id);
00228                 return true;
00229         }
00230 
00231         
00232         function isAssignedToGroup($sid,$group_id,$user_id)
00233         {
00234                 if(!$this->__checkSession($sid))
00235                 {
00236                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00237                 }                       
00238                 if(!is_numeric($group_id))
00239                 {
00240                         return $this->__raiseError('No valid group id given. Please choose an existing id of an ILIAS group',
00241                                                                            'Client');
00242                 }
00243                 // Include main header
00244                 include_once './include/inc.header.php';
00245 
00246                 global $rbacsystem;
00247 
00248                 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00249                 {
00250                         $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00251                         if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00252                         {
00253                                 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00254                         }
00255                 }
00256 
00257                 if(ilObject::_lookupType($user_id) != 'usr')
00258                 {
00259                         return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00260                 }
00261 
00262                 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00263                 {
00264                         return $this->__raiseError('Cannot create group instance!','Server');
00265                 }
00266 
00267                 if(!$rbacsystem->checkAccess('read',$group_id))
00268                 {
00269                         return $this->__raiseError('Check access failed. No permission to read group data','Server');
00270                 }
00271 
00272 
00273                 if($tmp_group->isAdmin($user_id))
00274                 {
00275                         return 1;
00276                 }
00277                 if($tmp_group->isMember($user_id))
00278                 {
00279                         return 2;
00280                 }
00281                 return "0";
00282         }
00283         
00284         // PRIVATE
00285 
00286 }
00287 ?>

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