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

webservice/soap/classes/class.ilSoapObjectAdministration.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 ilSoapObjectAdministration extends ilSoapAdministration
00036 {
00037         function ilSoapObjectAdministration()
00038         {
00039                 parent::ilSoapAdministration();
00040         }
00041 
00042         function getObjIdByImportId($sid,$import_id)
00043         {
00044                 if(!$this->__checkSession($sid))
00045                 {
00046                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00047                 }                       
00048                 if(!$import_id)
00049                 {
00050                         return $this->__raiseError('No import id given.',
00051                                                                            'Client');
00052                 }
00053 
00054                 // Include main header
00055                 include_once './include/inc.header.php';
00056 
00057                 global $ilLog;
00058 
00059                 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
00060                 $ilLog->write("SOAP getObjIdByImportId(): import_id = ".$import_id.' obj_id = '.$obj_id);
00061 
00062                 return $obj_id ? $obj_id : "0";
00063         }
00064 
00065         function getRefIdsByImportId($sid,$import_id)
00066         {
00067                 global $tree;
00068                 
00069                 if(!$this->__checkSession($sid))
00070                 {
00071                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00072                 }                       
00073                 if(!$import_id)
00074                 {
00075                         return $this->__raiseError('No import id given.',
00076                                                                            'Client');
00077                 }
00078 
00079                 // Include main header
00080                 include_once './include/inc.header.php';
00081 
00082                 $obj_id = ilObject::_lookupObjIdByImportId($import_id);
00083 
00084                 
00085                 $ref_ids = ilObject::_getAllReferences($obj_id);
00086 
00087                 foreach($ref_ids as $ref_id)
00088                 {
00089                         // only get non deleted reference ids
00090                         if ($tree->isInTree($ref_id))
00091                         {
00092                                 $new_refs[] = $ref_id;
00093                         }
00094                 }
00095                 return $new_refs ? $new_refs : array();
00096         }
00097 
00098         function getRefIdsByObjId($sid,$obj_id)
00099         {
00100                 if(!$this->__checkSession($sid))
00101                 {
00102                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00103                 }                       
00104                 if(!$obj_id)
00105                 {
00106                         return $this->__raiseError('No object id given.',
00107                                                                            'Client');
00108                 }
00109 
00110                 // Include main header
00111                 include_once './include/inc.header.php';
00112 
00113                 $ref_ids = ilObject::_getAllReferences($obj_id);
00114                 foreach($ref_ids as $ref_id)
00115                 {
00116                         $new_refs[] = $ref_id;
00117                 }
00118                 return $new_refs ? $new_refs : array();
00119         }               
00120 
00121                 
00122         function getObjectByReference($sid,$a_ref_id,$user_id)
00123         {
00124                 if(!$this->__checkSession($sid))
00125                 {
00126                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00127                 }                       
00128                 if(!is_numeric($a_ref_id))
00129                 {
00130                         return $this->__raiseError('No valid reference id given. Please choose an existing reference id of an ILIAS object',
00131                                                                            'Client');
00132                 }
00133 
00134                 // Include main header
00135                 include_once './include/inc.header.php';
00136                 
00137                 if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id,false))
00138                 {
00139                         return $this->__raiseError('Cannot create object instance!','Server');
00140                 }
00141                 
00142                 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
00143 
00144                 $xml_writer = new ilObjectXMLWriter();
00145                 if($user_id)
00146                 {
00147                         $xml_writer->setUserId($user_id);
00148                         $xml_writer->enableOperations(true);
00149                 }
00150                 $xml_writer->setObjects(array($tmp_obj));
00151                 if($xml_writer->start())
00152                 {
00153                         return $xml_writer->getXML();
00154                 }
00155 
00156                 return $this->__raiseError('Cannot create object xml !','Server');
00157         }
00158 
00159         function getObjectsByTitle($sid,$a_title,$user_id)
00160         {
00161                 if(!$this->__checkSession($sid))
00162                 {
00163                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00164                 }                       
00165                 if(!strlen($a_title))
00166                 {
00167                         return $this->__raiseError('No valid query string given.',
00168                                                                            'Client');
00169                 }
00170 
00171                 // Include main header
00172                 include_once './include/inc.header.php';
00173 
00174                 include_once './Services/Search/classes/class.ilQueryParser.php';
00175 
00176                 $query_parser =& new ilQueryParser($a_title);
00177                 $query_parser->setMinWordLength(0);
00178                 $query_parser->setCombination(QP_COMBINATION_AND);
00179                 $query_parser->parse();
00180                 if(!$query_parser->validate())
00181                 {
00182                         return $this->__raiseError($query_parser->getMessage(),
00183                                                                            'Client');
00184                 }
00185                 
00186                 include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
00187 
00188                 $object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
00189                 $object_search->setFields(array('title'));
00190                 $object_search->appendToFilter('role');
00191                 $object_search->appendToFilter('rolt');
00192                 $res =& $object_search->performSearch();
00193                 if($user_id)
00194                 {
00195                         $res->setUserId($user_id);
00196                 }
00197 
00198                 $res->filter(ROOT_FOLDER_ID,true);
00199 
00200                 $objs = array();
00201                 foreach($res->getUniqueResults() as $entry)
00202                 {
00203                         $objs[] = ilObjectFactory::getInstanceByObjId($entry['obj_id'],false);
00204                 }
00205                 if(!count($objs))
00206                 {
00207                         return '';
00208                 }
00209 
00210                 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
00211 
00212                 $xml_writer = new ilObjectXMLWriter();
00213                 if($user_id)
00214                 {
00215                         $xml_writer->setUserId($user_id);
00216                         $xml_writer->enableOperations(true);
00217                 }
00218                 $xml_writer->setObjects($objs);
00219                 if($xml_writer->start())
00220                 {
00221                         return $xml_writer->getXML();
00222                 }
00223 
00224                 return $this->__raiseError('Cannot create object xml !','Server');
00225         }
00226 
00227         function searchObjects($sid,$types,$key,$combination,$user_id)
00228         {
00229                 if(!$this->__checkSession($sid))
00230                 {
00231                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00232                 }                       
00233                 if(!is_array($types))
00234                 {
00235                         return $this->__raiseError('Types must be an array of object types.',
00236                                                                            'Client');
00237                 }
00238                 if($combination != 'and' and $combination != 'or')
00239                 {
00240                         return $this->__raiseError('No valid combination given. Must be "and" or "or".',
00241                                                                            'Client');
00242                 }
00243                         
00244 
00245                 // Include main header
00246                 include_once './include/inc.header.php';
00247 
00248                 include_once './Services/Search/classes/class.ilQueryParser.php';
00249 
00250                 $query_parser =& new ilQueryParser($key);
00251                 $query_parser->setMinWordLength(3);
00252                 $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
00253                 $query_parser->parse();
00254                 if(!$query_parser->validate())
00255                 {
00256                         return $this->__raiseError($query_parser->getMessage(),
00257                                                                            'Client');
00258                 }
00259 
00260                 include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
00261 
00262                 $object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
00263                 $object_search->setFilter($types);
00264 
00265                 $res =& $object_search->performSearch();
00266                 if($user_id)
00267                 {
00268                         $res->setUserId($user_id);
00269                 }
00270                 $res->filter(ROOT_FOLDER_ID,$combination == 'and' ? true : false);
00271 
00272 
00273                 // Limit to 30 objects
00274                 $counter = 0;
00275                 $objs = array();
00276                 foreach($res->getUniqueResults() as $entry)
00277                 {
00278                         if(++$counter == 30)
00279                         {
00280                                 break;
00281                         }
00282                         $objs[] = ilObjectFactory::getInstanceByObjId($entry['obj_id'],false);
00283                 }
00284                 if(!count($objs))
00285                 {
00286                         return '';
00287                 }
00288 
00289                 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
00290 
00291                 $xml_writer = new ilObjectXMLWriter();
00292 
00293                 if($user_id)
00294                 {
00295                         $xml_writer->setUserId($user_id);
00296                         $xml_writer->enableOperations(true);
00297                 }
00298                 $xml_writer->setObjects($objs);
00299                 if($xml_writer->start())
00300                 {
00301                         return $xml_writer->getXML();
00302                 }
00303 
00304                 return $this->__raiseError('Cannot create object xml !','Server');
00305         }
00306 
00307         function getTreeChilds($sid,$ref_id,$types,$user_id)
00308         {
00309                 $all = false;
00310 
00311                 if(!$this->__checkSession($sid))
00312                 {
00313                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00314                 }                       
00315 
00316                 // Include main header
00317                 include_once './include/inc.header.php';
00318 
00319                 global $tree;
00320 
00321                 if(!$target_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
00322                 {
00323                         return $this->__raiseError('No valid reference id given.',
00324                                                                            'Client');
00325                 }
00326                 if(!$types)
00327                 {
00328                         $all = true;
00329                 }
00330                 $filter = is_array($types) ? $types : array();
00331 
00332                 foreach($tree->getChilds($ref_id,'title') as $child)
00333                 {
00334                         if($all or in_array($child['type'],$types))
00335                         {
00336                                 if($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'],false))
00337                                 {
00338                                         $objs[] = $tmp;
00339                                 }
00340                         }
00341                 }
00342 
00343                 if(!$objs)
00344                 {
00345                         return '';
00346                 }
00347 
00348                 include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
00349 
00350                 $xml_writer = new ilObjectXMLWriter();
00351                 $xml_writer->setObjects($objs);
00352                 $xml_writer->enableOperations(true);
00353                 if($user_id)
00354                 {
00355                         $xml_writer->setUserId($user_id);
00356                 }
00357 
00358                 if($xml_writer->start())
00359                 {
00360                         return $xml_writer->getXML();
00361                 }
00362 
00363                 return $this->__raiseError('Cannot create object xml !','Server');
00364         }
00365 
00366                 
00367                 
00368                         
00369         
00370 
00371         function addObject($sid,$a_target_id,$a_xml)
00372         {
00373                 if(!$this->__checkSession($sid))
00374                 {
00375                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00376                 }                       
00377                 if(!strlen($a_xml))
00378                 {
00379                         return $this->__raiseError('No valid xml string given.',
00380                                                                            'Client');
00381                 }
00382 
00383                 // Include main header
00384                 include_once './include/inc.header.php';
00385 
00386                 if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
00387                 {
00388                         return $this->__raiseError('No valid target given.',
00389                                                                            'Client');
00390                 }
00391                 $allowed_types = array('cat','grp','crs','fold');
00392                 if(!in_array($target_obj->getType(),$allowed_types))
00393                 {
00394                         return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"',
00395                                                                            'Client');
00396                 }
00397 
00398                 $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
00399 
00400                 foreach($allowed_subtypes as $row)
00401                 {
00402                         if($row['name'] != 'rolf')
00403                         {
00404                                 $allowed[] = $row['name'];
00405                         }
00406                 }
00407 
00408                 include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
00409 
00410                 $xml_parser =& new ilObjectXMLParser($a_xml);
00411                 $xml_parser->startParsing();
00412 
00413                 foreach($xml_parser->getObjectData() as $object_data)
00414                 {
00415                         // Check possible subtype
00416                         if(!in_array($object_data['type'],$allowed))
00417                         {
00418                                 return $this->__raiseError('Objects of type: '.$object_data['type'].' are not allowed to be subobjects of type '.
00419                                                                                    $target_obj->getType().'!',
00420                                                                                    'Client');
00421                         }
00422                         if(!$rbacsystem->checkAccess('create',$a_target_id,$object_data['type']))
00423                         {
00424                                 return $this->__raiseError('No permission to create objects of type '.$object_data['type'].'!',
00425                                                                                    'Client');
00426                         }
00427                         if($object_data['type'] == 'crs')
00428                         {
00429                                 return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
00430                                                                                    'Client');
00431                         }
00432 
00433                         // It's not possible to add objects with non unique import ids
00434                         if(strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id']))
00435                         {
00436                                 return $this->__raiseError('An object with import id '.$object_data['import_id'].' already exists!',
00437                                                                                    'Server');
00438                         }
00439 
00440                                 
00441 
00442                         // Check preconditions
00443                         switch($object_data['type'])
00444                         {
00445                                 case 'grp':
00446                                         if(ilUtil::groupNameExists($object_data['title']))
00447                                         {
00448                                                 return $this->__raiseError('A group with name '.$object_data['title'].' already exists!',
00449                                                                                                    'Client');
00450                                         }
00451                                         break;
00452                         }
00453 
00454 
00455                         // call gui object method
00456                         $class_name = $objDefinition->getClassName($object_data['type']);
00457                         $module = $objDefinition->getModule($object_data['type']);
00458                         $module_dir = ($module == "")
00459                                 ? ""
00460                                 : $module."/";
00461                         
00462                         $class_constr = "ilObj".$class_name;
00463                         require_once("./".$module_dir."classes/class.ilObj".$class_name.".php");
00464 
00465                         $newObj = new $class_constr();
00466 
00467                         $newObj->setType($object_data['type']);
00468                         if(strlen($object_data['import_id']))
00469                         {
00470                                 $newObj->setImportId($object_data['import_id']);
00471                         }
00472                         $newObj->setTitle($object_data['title']);
00473                         $newObj->setDescription($object_data['description']);
00474                         $newObj->create(); // true for upload
00475                         $newObj->createReference();
00476                         $newObj->putInTree($a_target_id);
00477                         $newObj->setPermissions($a_target_id);
00478                         $newObj->initDefaultRoles();
00479 
00480                         switch($object_data['type'])
00481                         {
00482                                 case 'grp':
00483                                         // Add member
00484                                         $newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(),
00485                                                                            $newObj->getDefaultAdminRole());
00486                                         break;
00487 
00488                                 case 'lm':
00489                                 case 'dbk':
00490                                         $newObj->createLMTree();
00491                                         break;
00492 
00493                         }                                       
00494 
00495                 }
00496                 $ref_id = $newObj->getRefId();
00497                 return  $ref_id  ? $ref_id : "0";
00498         }
00499 
00500         function addReference($sid,$a_source_id,$a_target_id)
00501         {
00502                 if(!$this->__checkSession($sid))
00503                 {
00504                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00505                 }                       
00506                 if(!is_numeric($a_source_id))
00507                 {
00508                         return $this->__raiseError('No source id given.',
00509                                                                            'Client');
00510                 }
00511                 if(!is_numeric($a_target_id))
00512                 {
00513                         return $this->__raiseError('No target id given.',
00514                                                                            'Client');
00515                 }
00516 
00517                 include_once './include/inc.header.php';
00518 
00519                 if(!$source_obj =& ilObjectFactory::getInstanceByRefId($a_source_id,false))
00520                 {
00521                         return $this->__raiseError('No valid source id given.',
00522                                                                            'Client');
00523                 }
00524                 if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
00525                 {
00526                         return $this->__raiseError('No valid target id given.',
00527                                                                            'Client');
00528                 }
00529 
00530                 if(!$objDefinition->allowLink($source_obj->getType()))
00531                 {
00532                         return $this->__raiseError('Linking of object type: '.$source_obj->getType().' is not allowed',
00533                                                                            'Client');
00534                 }
00535 
00536                 $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
00537                 foreach($allowed_subtypes as $row)
00538                 {
00539                         if($row['name'] != 'rolf')
00540                         {
00541                                 $allowed[] = $row['name'];
00542                         }
00543                 }
00544                 if(!in_array($source_obj->getType(),$allowed))
00545                 {
00546                         return $this->__raiseError('Objects of type: '.$source_obj->getType().' are not allowed to be subobjects of type '.
00547                                                                            $target_obj->getType().'!',
00548                                                                            'Client');
00549                 }
00550 
00551                 // Permission checks
00552                 if(!$rbacsystem->checkAccess('create',$target_obj->getRefId(),$source_obj->getType()))
00553                 {
00554                         return $this->__raiseError('No permission to create objects of type '.$source_obj->getType().'!',
00555                                                                            'Client');
00556                 }
00557                 if(!$rbacsystem->checkAccess('delete',$source_obj->getRefId()))
00558                 {
00559                         return $this->__raiseError('No permission to link object with id: '.$source_obj->getRefId().'!',
00560                                                                            'Client');
00561                 }
00562 
00563                 // Finally link it to target position
00564                 
00565                 $new_ref_id = $source_obj->createReference();
00566                 $source_obj->putInTree($target_obj->getRefId());
00567                 $source_obj->setPermissions($target_obj->getRefId());
00568                 $source_obj->initDefaultRoles();
00569                 
00570                 return $new_ref_id ? $new_ref_id : "0";
00571         }
00572 
00573         function deleteObject($sid,$reference_id)
00574         {
00575                 global $tree;
00576                 
00577                 if(!$this->__checkSession($sid))
00578                 {
00579                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00580                 }                       
00581                 if(!is_numeric($reference_id))
00582                 {
00583                         return $this->__raiseError('No reference id given.',
00584                                                                            'Client');
00585                 }
00586                 include_once './include/inc.header.php';
00587                 global $tree;
00588 
00589                 if(!$del_obj =& ilObjectFactory::getInstanceByRefId($reference_id,false))
00590                 {
00591                         return $this->__raiseError('No valid reference id given.',
00592                                                                            'Client');
00593                 }
00594                 if(!$rbacsystem->checkAccess('delete',$del_obj->getRefId()))
00595                 {
00596                         return $this->__raiseError('No permission to delete object with id: '.$del_obj->getRefId().'!',
00597                                                                            'Client');
00598                 }
00599 
00600                 // Delete tree
00601                 $subnodes = $tree->getSubtree($tree->getNodeData($reference_id));
00602                         
00603                 foreach($subnodes as $subnode)
00604                 {
00605                         $rbacadmin->revokePermission($subnode["child"]);
00606                         // remove item from all user desktops
00607                         $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
00608                 }
00609                 
00610                 $tree->saveSubTree($reference_id);
00611                 $tree->deleteTree($tree->getNodeData($reference_id));
00612                 
00613                 return true;
00614         }
00615 
00616         function removeFromSystemByImportId($sid,$import_id)
00617         {
00618                 if(!$this->__checkSession($sid))
00619                 {
00620                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00621                 }                       
00622                 if(!strlen($import_id))
00623                 {
00624                         return $this->__raiseError('No import id given. Aborting!',
00625                                                                            'Client');
00626                 }
00627                 include_once './include/inc.header.php';
00628 
00629                 // get obj_id
00630                 if(!$obj_id = ilObject::_lookupObjIdByImportId($import_id))
00631                 {
00632                         return $this->__raiseError('No object found with import id: '.$import_id,
00633                                                                            'Client');
00634                 }
00635 
00636                 // Check access
00637                 $permission_ok = false;
00638                 foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
00639                 {
00640                         if($rbacsystem->checkAccess('delete',$ref_id))
00641                         {
00642                                 $permission_ok = true;
00643                                 break;
00644                         }
00645                 }
00646                 if(!$permission_ok)
00647                 {
00648                         return $this->__raiseError('No permission to delete the object with import id: '.$import_id,
00649                                                                            'Server');
00650                 }
00651 
00652                 global $tree;
00653                 // Delete all references (delete permssions and entries in object_reference)
00654                 foreach($ref_ids as $ref_id)
00655                 {
00656                         // All subnodes
00657                         $node_data = $tree->getNodeData($ref_id);
00658                         $subtree_nodes = $tree->getSubtree($node_data);
00659 
00660                         foreach($subtree_nodes as $node)
00661                         {
00662                                 $ilLog->write('Soap: removeFromSystemByImportId(). Deleting object with title id: '.$node['title']);
00663                                 $tmp_obj = ilObjectFactory::getInstanceByRefId($node['ref_id']);
00664                                 if(!is_object($tmp_obj))
00665                                 {
00666                                         return $this->__raiseError('Cannot create instance of reference id: '.$node['ref_id'],
00667                                                                                            'Server');
00668                                 }
00669                                 $tmp_obj->delete();
00670                         }
00671                         // Finally delete tree
00672                         $tree->deleteTree($node_data);
00673                         
00674                 }                               
00675 
00676                 return true;
00677         }
00678                         
00679 
00680         function updateObjects($sid,$a_xml)
00681         {
00682                 if(!$this->__checkSession($sid))
00683                 {
00684                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00685                 }                       
00686                 if(!strlen($a_xml))
00687                 {
00688                         return $this->__raiseError('No valid xml string given.',
00689                                                                            'Client');
00690                 }
00691 
00692                 // Include main header
00693                 include_once './include/inc.header.php';
00694                 include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
00695 
00696                 $xml_parser =& new ilObjectXMLParser($a_xml);
00697                 $xml_parser->startParsing();
00698 
00699                 // Validate incoming data
00700                 foreach($xml_parser->getObjectData() as $object_data)
00701                 {
00702                         if(!$object_data["obj_id"])
00703                         {
00704                                 return $this->__raiseError('No obj_id in xml found.',
00705                                                                                    'Client');
00706                         }
00707 
00708                         if($object_data['type'] == 'role')
00709                         {
00710                                 $rolf_ids = $rbacreview->getFoldersAssignedToRole($object_data['obj_id'],true);
00711                                 $rolf_id = $rolf_ids[0];
00712 
00713                                 if(!$rbacsystem->checkAccess('write',$rolf_id))
00714                                 {
00715                                         return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!',
00716                                                                                            'Client');
00717                                 }
00718                         }
00719                         else
00720                         {
00721                                 $permission_ok = false;
00722                                 foreach(ilObject::_getAllReferences($object_data['obj_id']) as $ref_id)
00723                                 {
00724                                         if($rbacsystem->checkAccess('write',$object_data['obj_id']))
00725                                         {
00726                                                 $permission_ok = true;
00727                                                 break;
00728                                         }
00729                                 }
00730                                 if(!$permission_ok)
00731                                 {
00732                                         return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!',
00733                                                                                            'Client');
00734                                 }
00735                         }
00736                         
00737 
00738                         // Check preconditions
00739                         switch($object_data['type'])
00740                         {
00741                                 case 'grp':
00742                                         if(ilUtil::groupNameExists($object_data['title']))
00743                                         {
00744                                                 return $this->__raiseError('A group with name '.$object_data['title'].' already exists!',
00745                                                                                                    'Client');
00746                                         }
00747                                         break;
00748                         }
00749                 }
00750 
00751                 // perform update
00752                 foreach($xml_parser->getObjectData() as $object_data)
00753                 {
00754                         $tmp_obj = ilObjectFactory::getInstanceByObjId($object_data['obj_id'],false);
00755                         $tmp_obj->setTitle($object_data['title']);
00756                         $tmp_obj->setDescription($object_data['description']);
00757                         if(strlen($object_data['owner']))
00758                         {
00759                                 $tmp_obj->setOwner($object_data['owner']);
00760                         }
00761                         $tmp_obj->update();
00762                 }
00763                 return true;
00764 
00765         }
00766 
00767                 
00768 }
00769 ?>

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