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 if(ilObject::_isInTrash($target_id))
00068 {
00069 return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
00070 }
00071
00072
00073
00074 include_once("classes/class.ilObjGroup.php");
00075 include_once 'classes/class.ilGroupImportParser.php';
00076 $xml_parser = new ilGroupImportParser($grp_xml,$target_id);
00077 $new_ref_id = $xml_parser->startParsing();
00078
00079 return $new_ref_id ? $new_ref_id : "0";
00080 }
00081
00082
00083 function updateGroup($sid,$ref_id,$grp_xml)
00084 {
00085
00086 if(!$this->__checkSession($sid))
00087 {
00088 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00089 }
00090
00091
00092
00093 if(!is_numeric($ref_id))
00094 {
00095 return $this->__raiseError('No valid target id given. Please choose an existing reference id of an ILIAS category or course',
00096 'Client');
00097 }
00098
00099
00100 include_once './include/inc.header.php';
00101 global $rbacsystem;
00102
00103 if(!$rbacsystem->checkAccess('write',$ref_id,'grp'))
00104 {
00105 return $this->__raiseError('Check access failed. No permission to edit groups','Server');
00106 }
00107
00108
00109 include_once("classes/class.ilObjGroup.php");
00110
00111 if(!$grp = ilObjectFactory::getInstanceByRefId($ref_id, false))
00112 {
00113 return $this->__raiseError('Cannot create group instance!','CLIENT_OBJECT_NOT_FOUND');
00114 }
00115
00116 if(ilObject::_isInTrash($ref_id))
00117 {
00118 return $this->__raiseError("Object with ID $ref_id has been deleted.", 'CLIENT_OBJECT_DELETED');
00119 }
00120
00121
00122 if (ilObjectFactory::getTypeByRefId($ref_id, false) !="grp")
00123 {
00124 return $this->__raiseError('Reference id does not point to a group!','CLIENT_WRONG_TYPE');
00125 }
00126
00127
00128 include_once 'classes/class.ilGroupImportParser.php';
00129 $xml_parser = new ilGroupImportParser($grp_xml, -1);
00130 $xml_parser->setMode(ilGroupImportParser::$UPDATE);
00131 $xml_parser->setGroup($grp);
00132 $new_ref_id = $xml_parser->startParsing();
00133
00134 return $new_ref_id ? $new_ref_id : "0";
00135 }
00136
00137
00138 function groupExists($sid,$title)
00139 {
00140 if(!$this->__checkSession($sid))
00141 {
00142 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00143 }
00144
00145 if(!$title)
00146 {
00147 return $this->__raiseError('No title given. Please choose an title for the group in question.',
00148 'Client');
00149 }
00150
00151
00152 include_once './include/inc.header.php';
00153
00154 return ilUtil::groupNameExists($title);
00155 }
00156
00157 function getGroup($sid,$ref_id)
00158 {
00159 if(!$this->__checkSession($sid))
00160 {
00161 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00162 }
00163
00164
00165 include_once './include/inc.header.php';
00166
00167 if(ilObject::_isInTrash($ref_id))
00168 {
00169 return $this->__raiseError("Parent with ID $ref_id has been deleted.", 'CLIENT_OBJECT_DELETED');
00170 }
00171
00172
00173 if(!$grp_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
00174 {
00175 return $this->__raiseError('No valid reference id given.',
00176 'Client');
00177 }
00178
00179
00180 include_once 'classes/class.ilGroupXMLWriter.php';
00181
00182 $xml_writer = new ilGroupXMLWriter($grp_obj);
00183 $xml_writer->start();
00184
00185 $xml = $xml_writer->getXML();
00186
00187 return strlen($xml) ? $xml : '';
00188 }
00189
00190
00191 function assignGroupMember($sid,$group_id,$user_id,$type)
00192 {
00193 if(!$this->__checkSession($sid))
00194 {
00195 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00196 }
00197
00198 if(!is_numeric($group_id))
00199 {
00200 return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
00201 'Client');
00202 }
00203
00204
00205 include_once './include/inc.header.php';
00206 global $rbacsystem;
00207
00208 if(($obj_type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00209 {
00210 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00211 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00212 {
00213 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00214 }
00215 }
00216
00217 if(!$rbacsystem->checkAccess('write',$group_id))
00218 {
00219 return $this->__raiseError('Check access failed. No permission to write to group','Server');
00220 }
00221
00222
00223 if(ilObject::_lookupType($user_id) != 'usr')
00224 {
00225 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00226 }
00227 if($type != 'Admin' and
00228 $type != 'Member')
00229 {
00230 return $this->__raiseError('Invalid type '.$type.' given. Parameter "type" must be "Admin","Member"','Client');
00231 }
00232
00233 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00234 {
00235 return $this->__raiseError('Cannot create group instance!','Server');
00236 }
00237
00238 if(!$tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false))
00239 {
00240 return $this->__raiseError('Cannot create user instance!','Server');
00241 }
00242
00243
00244 switch($type)
00245 {
00246 case 'Admin':
00247 return $tmp_group->addMember($user_id,$tmp_group->getDefaultAdminRole());
00248
00249 case 'Member':
00250 return $tmp_group->addMember($user_id,$tmp_group->getDefaultMemberRole());
00251 break;
00252 }
00253
00254 return true;
00255 }
00256
00257 function excludeGroupMember($sid,$group_id,$user_id)
00258 {
00259 if(!$this->__checkSession($sid))
00260 {
00261 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00262 }
00263 if(!is_numeric($group_id))
00264 {
00265 return $this->__raiseError('No valid group id given. Please choose an existing reference id of an ILIAS group',
00266 'Client');
00267 }
00268
00269
00270 include_once './include/inc.header.php';
00271 global $rbacsystem;
00272
00273 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00274 {
00275 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00276 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00277 {
00278 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00279 }
00280 }
00281
00282 if(ilObject::_lookupType($user_id) != 'usr')
00283 {
00284 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00285 }
00286
00287 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00288 {
00289 return $this->__raiseError('Cannot create group instance!','Server');
00290 }
00291
00292 if(!$rbacsystem->checkAccess('write',$group_id))
00293 {
00294 return $this->__raiseError('Check access failed. No permission to write to group','Server');
00295 }
00296
00297 $tmp_group->leave($user_id);
00298 return true;
00299 }
00300
00301
00302 function isAssignedToGroup($sid,$group_id,$user_id)
00303 {
00304 if(!$this->__checkSession($sid))
00305 {
00306 return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00307 }
00308 if(!is_numeric($group_id))
00309 {
00310 return $this->__raiseError('No valid group id given. Please choose an existing id of an ILIAS group',
00311 'Client');
00312 }
00313
00314 include_once './include/inc.header.php';
00315 global $rbacsystem;
00316
00317 if(($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp')
00318 {
00319 $group_id = end($ref_ids = ilObject::_getAllReferences($group_id));
00320 if(ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp')
00321 {
00322 return $this->__raiseError('Invalid group id. Object with id "'. $group_id.'" is not of type "group"','Client');
00323 }
00324 }
00325
00326 if(ilObject::_lookupType($user_id) != 'usr')
00327 {
00328 return $this->__raiseError('Invalid user id. User with id "'. $user_id.' does not exist','Client');
00329 }
00330
00331 if(!$tmp_group = ilObjectFactory::getInstanceByRefId($group_id,false))
00332 {
00333 return $this->__raiseError('Cannot create group instance!','Server');
00334 }
00335
00336 if(!$rbacsystem->checkAccess('read',$group_id))
00337 {
00338 return $this->__raiseError('Check access failed. No permission to read group data','Server');
00339 }
00340
00341
00342 if($tmp_group->isAdmin($user_id))
00343 {
00344 return 1;
00345 }
00346 if($tmp_group->isMember($user_id))
00347 {
00348 return 2;
00349 }
00350 return "0";
00351 }
00352
00353
00354
00355 }
00356 ?>