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