ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSoapObjectAdministration.php
Go to the documentation of this file.
1 <?php
2  /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22  */
23 
24 
33 include_once './webservice/soap/classes/class.ilSoapAdministration.php';
34 
36 {
38  {
40  }
41 
42  function getObjIdByImportId($sid,$import_id)
43  {
44  $this->initAuth($sid);
45  $this->initIlias();
46 
47  if(!$this->__checkSession($sid))
48  {
49  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
50  }
51  if(!$import_id)
52  {
53  return $this->__raiseError('No import id given.',
54  'Client');
55  }
56 
57  global $ilLog;
58 
59  $obj_id = ilObject::_lookupObjIdByImportId($import_id);
60  $ilLog->write("SOAP getObjIdByImportId(): import_id = ".$import_id.' obj_id = '.$obj_id);
61 
62  return $obj_id ? $obj_id : "0";
63  }
64 
65  function getRefIdsByImportId($sid,$import_id)
66  {
67  $this->initAuth($sid);
68  $this->initIlias();
69 
70  if(!$this->__checkSession($sid))
71  {
72  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
73  }
74  if(!$import_id)
75  {
76  return $this->__raiseError('No import id given.',
77  'Client');
78  }
79 
80  global $tree;
81 
82  $obj_id = ilObject::_lookupObjIdByImportId($import_id);
83 
84 
85  $ref_ids = ilObject::_getAllReferences($obj_id);
86 
87  foreach($ref_ids as $ref_id)
88  {
89  // only get non deleted reference ids
90  if ($tree->isInTree($ref_id))
91  {
92  $new_refs[] = $ref_id;
93  }
94  }
95  return $new_refs ? $new_refs : array();
96  }
97 
98  function getRefIdsByObjId($sid,$obj_id)
99  {
100  $this->initAuth($sid);
101  $this->initIlias();
102 
103  if(!$this->__checkSession($sid))
104  {
105  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
106  }
107  if(!$obj_id)
108  {
109  return $this->__raiseError('No object id given.',
110  'Client');
111  }
112 
113  $ref_ids = ilObject::_getAllReferences($obj_id);
114  foreach($ref_ids as $ref_id)
115  {
116  $new_refs[] = $ref_id;
117  }
118  return $new_refs ? $new_refs : array();
119  }
120 
129  function getObjIdsByRefIds($sid, $ref_ids)
130  {
131  $this->initAuth($sid);
132  $this->initIlias();
133 
134  if(!$this->__checkSession($sid))
135  {
136  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
137  }
138 
139 
140  if(!count($ref_ids) || !is_array ($ref_ids))
141  {
142  return $this->__raiseError('No reference id(s) given.', 'Client');
143  }
144 
145  $obj_ids = array();
146  if (count($ref_ids)) {
147  foreach ($ref_ids as $ref_id)
148  {
149  $ref_id = trim($ref_id);
150  if (!is_numeric($ref_id)){
151  return $this->__raiseError('Reference ID has to be numeric. Value: '.$ref_id, 'Client');
152  }
153 
154  $obj_id = ilObject::_lookupObjectId($ref_id);
155  if (!$obj_id){
156  return $this->__raiseError('No object found for reference ID. Value: '.$ref_id, 'Client');
157  }
158  if (!ilObject::_hasUntrashedReference($obj_id)){
159  return $this->__raiseError('No untrashed reference found for reference ID. Value: '.$ref_id, 'Client');
160  }
161  $obj_ids[] = $obj_id;
162  }
163  }
164  return $obj_ids;
165  }
166 
167 
168 
169  function getObjectByReference($sid,$a_ref_id,$user_id)
170  {
171  $this->initAuth($sid);
172  $this->initIlias();
173 
174  if(!$this->__checkSession($sid))
175  {
176  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
177  }
178  if(!is_numeric($a_ref_id))
179  {
180  return $this->__raiseError('No valid reference id given. Please choose an existing reference id of an ILIAS object',
181  'Client');
182  }
183 
184  if(!$tmp_obj = ilObjectFactory::getInstanceByRefId($a_ref_id,false))
185  {
186  return $this->__raiseError('Cannot create object instance!','Server');
187  }
188 
189 
190  if(ilObject::_isInTrash($a_ref_id))
191  {
192  return $this->__raiseError("Object with ID $a_ref_id has been deleted.", 'Client');
193  }
194 
195  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
196 
197  $xml_writer = new ilObjectXMLWriter();
198  $xml_writer->enablePermissionCheck(true);
199  if($user_id)
200  {
201  $xml_writer->setUserId($user_id);
202  $xml_writer->enableOperations(true);
203  }
204  $xml_writer->setObjects(array($tmp_obj));
205  if($xml_writer->start())
206  {
207  return $xml_writer->getXML();
208  }
209 
210  return $this->__raiseError('Cannot create object xml !','Server');
211  }
212 
213  function getObjectsByTitle($sid,$a_title,$user_id)
214  {
215  $this->initAuth($sid);
216  $this->initIlias();
217 
218  if(!$this->__checkSession($sid))
219  {
220  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
221  }
222  if(!strlen($a_title))
223  {
224  return $this->__raiseError('No valid query string given.',
225  'Client');
226  }
227 
228  include_once './Services/Search/classes/class.ilQueryParser.php';
229 
230  $query_parser =& new ilQueryParser($a_title);
231  $query_parser->setMinWordLength(0,true);
232  $query_parser->setCombination(QP_COMBINATION_AND);
233  $query_parser->parse();
234  if(!$query_parser->validate())
235  {
236  return $this->__raiseError($query_parser->getMessage(),
237  'Client');
238  }
239 
240  include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
241 
242  include_once 'Services/Search/classes/Like/class.ilLikeObjectSearch.php';
243  $object_search = new ilLikeObjectSearch($query_parser);
244 
245  #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
246  $object_search->setFields(array('title'));
247  $object_search->appendToFilter('role');
248  $object_search->appendToFilter('rolt');
249  $res =& $object_search->performSearch();
250  if($user_id)
251  {
252  $res->setUserId($user_id);
253  }
254 
255  $res->filter(ROOT_FOLDER_ID,true);
256 
257  $objs = array();
258  foreach($res->getUniqueResults() as $entry)
259  {
260  if($entry['type'] == 'role' or $entry['type'] == 'rolt')
261  {
262  if($tmp = ilObjectFactory::getInstanceByObjId($entry['obj_id'],false))
263  {
264  $objs[] = $tmp;
265  }
266  continue;
267  }
268  if($tmp = ilObjectFactory::getInstanceByRefId($entry['ref_id'],false))
269  {
270  $objs[] = $tmp;
271  }
272  }
273  if(!count($objs))
274  {
275  return '';
276  }
277 
278  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
279 
280  $xml_writer = new ilObjectXMLWriter();
281  $xml_writer->enablePermissionCheck(true);
282  if($user_id)
283  {
284  $xml_writer->setUserId($user_id);
285  $xml_writer->enableOperations(true);
286  }
287  $xml_writer->setObjects($objs);
288  if($xml_writer->start())
289  {
290  return $xml_writer->getXML();
291  }
292 
293  return $this->__raiseError('Cannot create object xml !','Server');
294  }
295 
296  function searchObjects($sid,$types,$key,$combination,$user_id)
297  {
298  $this->initAuth($sid);
299  $this->initIlias();
300 
301  if(!$this->__checkSession($sid))
302  {
303  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
304  }
305  if(!is_array($types))
306  {
307  return $this->__raiseError('Types must be an array of object types.',
308  'Client');
309  }
310  if($combination != 'and' and $combination != 'or')
311  {
312  return $this->__raiseError('No valid combination given. Must be "and" or "or".',
313  'Client');
314  }
315 
316 
317  include_once './Services/Search/classes/class.ilQueryParser.php';
318 
319  $query_parser =& new ilQueryParser($key);
320  #$query_parser->setMinWordLength(3);
321  $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
322  $query_parser->parse();
323  if(!$query_parser->validate())
324  {
325  return $this->__raiseError($query_parser->getMessage(),
326  'Client');
327  }
328 
329  #include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
330  #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
331 
332  include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php';
333  $object_search = new ilLikeObjectSearch($query_parser);
334 
335  $object_search->setFilter($types);
336 
337  $res =& $object_search->performSearch();
338  if($user_id)
339  {
340  $res->setUserId($user_id);
341  }
342  $res->setMaxHits(999999);
343  $res->filter(ROOT_FOLDER_ID,$combination == 'and' ? true : false);
344 
345  $counter = 0;
346  $objs = array();
347 
348  foreach($res->getUniqueResults() as $entry)
349  {
350  $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'],false);
351  if (is_object($obj))
352  $objs[] = $obj; //ilObjectFactory::getInstanceByRefId($entry['ref_id'],false);
353  }
354  //todo: this is bad style
355  //todo: either throw exception or return valid return value (XML)
356  if(!count($objs))
357  {
358  return '';
359  }
360 
361  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
362 
363  $xml_writer = new ilObjectXMLWriter();
364  $xml_writer->enablePermissionCheck(true);
365 
366  if($user_id)
367  {
368  $xml_writer->setUserId($user_id);
369  $xml_writer->enableOperations(true);
370  }
371 
372  $xml_writer->setObjects($objs);
373  if($xml_writer->start())
374  {
375  return $xml_writer->getXML();
376  }
377 
378  return $this->__raiseError('Cannot create object xml !','Server');
379  }
380 
381  function getTreeChilds($sid,$ref_id,$types,$user_id)
382  {
383  $this->initAuth($sid);
384  $this->initIlias();
385 
386  if(!$this->__checkSession($sid))
387  {
388  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
389  }
390 
391  $all = false;
392 
393  global $tree;
394 
395  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
396  {
397  return $this->__raiseError('No valid reference id given.',
398  'Client');
399  }
400  if (intval($ref_id) == SYSTEM_FOLDER_ID) {
401  return $this->__raiseError('No valid reference id given.',
402  'Client');
403  }
404 
405  if(!$types)
406  {
407  $all = true;
408  }
409  $filter = is_array($types) ? $types : array();
410 
411  $objs = array();
412  foreach($tree->getChilds($ref_id,'title') as $child)
413  {
414  if($all or in_array($child['type'],$types))
415  {
416  if($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'],false))
417  {
418  $objs[] = $tmp;
419  }
420  }
421  }
422 
423  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
424 
425  $xml_writer = new ilObjectXMLWriter();
426  $xml_writer->enablePermissionCheck(true);
427  $xml_writer->setObjects($objs);
428  $xml_writer->enableOperations(true);
429  if($user_id)
430  {
431  $xml_writer->setUserId($user_id);
432  }
433 
434  if ($xml_writer->start())
435  {
436  return $xml_writer->getXML();
437  }
438 
439  return $this->__raiseError('Cannot create object xml !','Server');
440  }
441 
442  function getXMLTree($sid, $ref_id, $types, $user_id)
443  {
444  $this->initAuth($sid);
445  $this->initIlias();
446 
447  if (!$this->__checkSession($sid))
448  {
449  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
450  }
451 
452  global $tree;
453 
454  $nodedata = $tree->getNodeData($ref_id);
455 
456  $nodearray = $tree->getSubTree($nodedata);
457 
458  $filter = is_array($types)?$types: array ("0"=>"root", "adm", "lngf", "mail",
459  "usrf", "rolf", "taxf", "trac", "pays",
460  "auth", "chac", "objf", "recf", "assf",
461  "stys", "seas", "extt");
462 
463  foreach ($nodearray as $node)
464  {
465  if (!in_array($node['type'], $filter))
466  {
467  if ($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))
468  {
469  $nodes[] = $tmp;
470  }
471  }
472  }
473 
474 
475  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
476 
477  $xml_writer = new ilObjectXMLWriter();
478  $xml_writer->enablePermissionCheck(true);
479  $xml_writer->setObjects($nodes);
480  $xml_writer->enableOperations(false);
481 
482  if ($user_id)
483  {
484  $xml_writer->setUserId($user_id);
485  }
486 
487  if ($xml_writer->start())
488  {
489  return $xml_writer->getXML();
490  }
491 
492  return $this->__raiseError('Cannot create object xml !', 'Server');
493  }
494 
495 
496  function addObject($sid,$a_target_id,$a_xml)
497  {
498  $this->initAuth($sid);
499  $this->initIlias();
500 
501  if(!$this->__checkSession($sid))
502  {
503  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
504  }
505  if(!strlen($a_xml))
506  {
507  return $this->__raiseError('No valid xml string given.',
508  'Client');
509  }
510 
511  global $rbacsystem, $objDefinition,$ilUser, $lng, $ilObjDataCache;
512 
513  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
514  {
515  return $this->__raiseError('No valid target given.',
516  'Client');
517  }
518 
519  if(ilObject::_isInTrash($a_target_id))
520  {
521  return $this->__raiseError("Parent with ID $a_target_id has been deleted.", 'Client');
522  }
523 
524  $allowed_types = array('root','cat','grp','crs','fold');
525  if(!in_array($target_obj->getType(),$allowed_types))
526  {
527  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"',
528  'Client');
529  }
530 
531  $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
532 
533  foreach($allowed_subtypes as $row)
534  {
535  if($row['name'] != 'rolf')
536  {
537  $allowed[] = $row['name'];
538  }
539  }
540 
541  include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
542 
543  $xml_parser =& new ilObjectXMLParser($a_xml, true);
544  try {
545  $xml_parser->startParsing();
546  }
547  catch (ilSaxParserException $se){
548  return $this->__raiseError($se->getMessage(),'Client');
549  }
550  catch(ilObjectXMLException $e) {
551  return $this->__raiseError($e->getMessage(),'Client');
552  }
553 
554  foreach($xml_parser->getObjectData() as $object_data)
555  {
556  $res = $this->validateReferences('create',$object_data,$a_target_id);
557  if($this->isFault($res))
558  {
559  return $res;
560  }
561 
562  // Check possible subtype
563  if(!in_array($object_data['type'],$allowed))
564  {
565  return $this->__raiseError('Objects of type: '.$object_data['type'].' are not allowed to be subobjects of type '.
566  $target_obj->getType().'!',
567  'Client');
568  }
569  if(!$rbacsystem->checkAccess('create',$a_target_id,$object_data['type']))
570  {
571  return $this->__raiseError('No permission to create objects of type '.$object_data['type'].'!',
572  'Client');
573  }
574  if($object_data['type'] == 'crs')
575  {
576  return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
577  'Client');
578  }
579 
580  // It's not possible to add objects with non unique import ids
581  if(strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id']))
582  {
583  return $this->__raiseError('An object with import id '.$object_data['import_id'].' already exists!',
584  'Server');
585  }
586 
587  // call gui object method
588  $class_name = $objDefinition->getClassName($object_data['type']);
589  $location = $objDefinition->getLocation($object_data['type']);
590 
591  $class_constr = "ilObj".$class_name;
592  require_once($location."/class.ilObj".$class_name.".php");
593 
594  $newObj = new $class_constr();
595 
596  if(isset($object_data['owner']) && strlen($object_data['owner']))
597  {
598  if((int)$object_data['owner'])
599  {
600  if(ilObject::_exists((int)$object_data['owner']) &&
601  $ilObjDataCache->lookupType((int)$object_data['owner']) == 'usr')
602  {
603  $newObj->setOwner((int)$object_data['owner']);
604  }
605  }
606  else
607  {
608  $usr_id = ilObjUser::_lookupId(trim($object_data['owner']));
609  if((int)$usr_id)
610  {
611  $newObj->setOwner((int)$usr_id);
612  }
613  }
614  }
615 
616  $newObj->setType($object_data['type']);
617  if(strlen($object_data['import_id']))
618  {
619  $newObj->setImportId($object_data['import_id']);
620  }
621  $newObj->setTitle($object_data['title']);
622  $newObj->setDescription($object_data['description']);
623  $newObj->create(); // true for upload
624  $newObj->createReference();
625  $newObj->putInTree($a_target_id);
626  $newObj->setPermissions($a_target_id);
627  $newObj->initDefaultRoles();
628 
629  switch($object_data['type'])
630  {
631  case 'grp':
632  // Add member
633  $newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(),
634  $newObj->getDefaultAdminRole());
635  break;
636 
637  case 'lm':
638  case 'dbk':
639  $newObj->createLMTree();
640  break;
641  case 'cat':
642  $newObj->addTranslation($object_data["title"],$object_data["description"], $lng->getLangKey(), $lng->getLangKey());
643  break;
644  }
645 
646  $this->addReferences($newObj,$object_data);
647 
648  }
649  $ref_id = $newObj->getRefId();
650  return $ref_id ? $ref_id : "0";
651  }
652 
653  function addReference($sid,$a_source_id,$a_target_id)
654  {
655  $this->initAuth($sid);
656  $this->initIlias();
657 
658  if(!$this->__checkSession($sid))
659  {
660  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
661  }
662  if(!is_numeric($a_source_id))
663  {
664  return $this->__raiseError('No source id given.',
665  'Client');
666  }
667  if(!is_numeric($a_target_id))
668  {
669  return $this->__raiseError('No target id given.',
670  'Client');
671  }
672 
673  global $objDefinition, $rbacsystem, $tree;
674 
675  if(!$source_obj =& ilObjectFactory::getInstanceByRefId($a_source_id,false))
676  {
677  return $this->__raiseError('No valid source id given.',
678  'Client');
679  }
680  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
681  {
682  return $this->__raiseError('No valid target id given.',
683  'Client');
684  }
685 
686  if(!$objDefinition->allowLink($source_obj->getType()) and
687  $source_obj->getType() != 'cat' and
688  $source_obj->getType() != 'crs')
689  {
690  return $this->__raiseError('Linking of object type: '.$source_obj->getType().' is not allowed',
691  'Client');
692  }
693 
694  $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
695  foreach($allowed_subtypes as $row)
696  {
697  if($row['name'] != 'rolf')
698  {
699  $allowed[] = $row['name'];
700  }
701  }
702  if(!in_array($source_obj->getType(),$allowed))
703  {
704  return $this->__raiseError('Objects of type: '.$source_obj->getType().' are not allowed to be subobjects of type '.
705  $target_obj->getType().'!',
706  'Client');
707  }
708 
709  // Permission checks
710  if(!$rbacsystem->checkAccess('create',$target_obj->getRefId(),$source_obj->getType()))
711  {
712  return $this->__raiseError('No permission to create objects of type '.$source_obj->getType().'!',
713  'Client');
714  }
715  if(!$rbacsystem->checkAccess('delete',$source_obj->getRefId()))
716  {
717  return $this->__raiseError('No permission to link object with id: '.$source_obj->getRefId().'!',
718  'Client');
719  }
720 
721 
722  if($source_obj->getType() != 'cat' and $source_obj->getType() != 'crs')
723  {
724  // check if object already linked to target
725  $possibleChilds = $tree->getChildsByType($target_obj->getRefId(), $source_obj->getType());
726  foreach ($possibleChilds as $child)
727  {
728  if ($child["obj_id"] == $source_obj->getId())
729  return $this->__raiseError("Object already linked to target.","Client");
730  }
731 
732  // Finally link it to target position
733 
734  $new_ref_id = $source_obj->createReference();
735  $source_obj->putInTree($target_obj->getRefId());
736  $source_obj->setPermissions($target_obj->getRefId());
737  $source_obj->initDefaultRoles();
738 
739  if($tree->checkForParentType($target_obj->getRefId(), 'crs'))
740  {
741  // Update crs_items
742  include_once './Modules/Course/classes/class.ilCourseItems.php';
743  new ilCourseItems($target_obj,$target_obj->getRefId());
744  }
745 
746  return $new_ref_id ? $new_ref_id : "0";
747  }
748  else
749  {
750  switch($source_obj->getType())
751  {
752  case 'cat':
753  include_once('./Modules/CategoryReference/classes/class.ilObjCategoryReference.php');
754  $new_ref = new ilObjCategoryReference();
755  break;
756 
757  case 'crs':
758  include_once('./Modules/CourseReference/classes/class.ilObjCourseReference.php');
759  $new_ref = new ilObjCourseReference();
760  break;
761  }
762  $new_ref->create();
763  $new_ref_id = $new_ref->createReference();
764 
765  $new_ref->putInTree($target_obj->getRefId());
766  $new_ref->setPermissions($target_obj->getRefId());
767  $new_ref->initDefaultRoles();
768 
769  $new_ref->setTargetId($source_obj->getId());
770  $new_ref->update();
771 
772  return $new_ref_id ? $new_ref_id : 0;
773  }
774  }
775 
776  function deleteObject($sid,$reference_id)
777  {
778  $this->initAuth($sid);
779  $this->initIlias();
780 
781  if(!$this->__checkSession($sid))
782  {
783  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
784  }
785  if(!is_numeric($reference_id))
786  {
787  return $this->__raiseError('No reference id given.',
788  'Client');
789  }
790  global $tree, $rbacsystem, $rbacadmin;
791 
792  if(!$del_obj =& ilObjectFactory::getInstanceByRefId($reference_id,false))
793  {
794  return $this->__raiseError('No valid reference id given.',
795  'Client');
796  }
797  if(!$rbacsystem->checkAccess('delete',$del_obj->getRefId()))
798  {
799  return $this->__raiseError('No permission to delete object with id: '.$del_obj->getRefId().'!',
800  'Client');
801  }
802 
803  // Delete tree
804  if($tree->isDeleted($reference_id))
805  {
806  return $this->__raiseError('Node already deleted','Server');
807  }
808 
809  if($del_obj->getType() == 'rolf')
810  {
811  return $this->__raiseError('Delete is not available for role folders.','Client');
812  }
813 
814  $subnodes = $tree->getSubtree($tree->getNodeData($reference_id));
815  foreach($subnodes as $subnode)
816  {
817  $rbacadmin->revokePermission($subnode["child"]);
818  // remove item from all user desktops
819  $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
820  }
821  if(!$tree->saveSubTree($reference_id))
822  {
823  return $this->__raiseError('Node already deleted','Client');
824  }
825 
826  return true;
827  }
828 
829  function removeFromSystemByImportId($sid,$import_id)
830  {
831  $this->initAuth($sid);
832  $this->initIlias();
833 
834  if(!$this->__checkSession($sid))
835  {
836  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
837  }
838  if(!strlen($import_id))
839  {
840  return $this->__raiseError('No import id given. Aborting!',
841  'Client');
842  }
843  global $rbacsystem, $tree, $ilLog;
844 
845  // get obj_id
846  if(!$obj_id = ilObject::_lookupObjIdByImportId($import_id))
847  {
848  return $this->__raiseError('No object found with import id: '.$import_id,
849  'Client');
850  }
851 
852  // Check access
853  $permission_ok = false;
854  foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
855  {
856  if($rbacsystem->checkAccess('delete',$ref_id))
857  {
858  $permission_ok = true;
859  break;
860  }
861  }
862  if(!$permission_ok)
863  {
864  return $this->__raiseError('No permission to delete the object with import id: '.$import_id,
865  'Server');
866  }
867 
868  // Delete all references (delete permssions and entries in object_reference)
869  foreach($ref_ids as $ref_id)
870  {
871  // All subnodes
872  $node_data = $tree->getNodeData($ref_id);
873  $subtree_nodes = $tree->getSubtree($node_data);
874 
875  foreach($subtree_nodes as $node)
876  {
877  $ilLog->write('Soap: removeFromSystemByImportId(). Deleting object with title id: '.$node['title']);
878  $tmp_obj = ilObjectFactory::getInstanceByRefId($node['ref_id']);
879  if(!is_object($tmp_obj))
880  {
881  return $this->__raiseError('Cannot create instance of reference id: '.$node['ref_id'],
882  'Server');
883  }
884  $tmp_obj->delete();
885  }
886  // Finally delete tree
887  $tree->deleteTree($node_data);
888 
889  }
890 
891  return true;
892  }
893 
894 
895  function updateObjects($sid,$a_xml)
896  {
897  $this->initAuth($sid);
898  $this->initIlias();
899 
900  if(!$this->__checkSession($sid))
901  {
902  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
903  }
904  if(!strlen($a_xml))
905  {
906  return $this->__raiseError('No valid xml string given.',
907  'Client');
908  }
909 
910  global $rbacreview, $rbacsystem, $lng,$ilAccess;
911 
912  include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
913  $xml_parser =& new ilObjectXMLParser($a_xml, true);
914  try
915  {
916  $xml_parser->startParsing();
917  }
918  catch (ilSaxParserException $se){
919  return $this->__raiseError($se->getMessage(),'Client');
920  }
921  catch(ilObjectXMLException $e) {
922  return $this->__raiseError($e->getMessage(),'Client');
923  }
924 
925 
926  // Validate incoming data
927  $object_datas = $xml_parser->getObjectData();
928  foreach($object_datas as & $object_data)
929  {
930  $res = $this->validateReferences('update',$object_data);
931  if($this->isFault($res))
932  {
933  return $res;
934  }
935 
936 
937  if(!$object_data["obj_id"])
938  {
939  return $this->__raiseError('No obj_id in xml found.', 'Client');
940  }
941  elseif ((int) $object_data["obj_id"] == -1 && count($object_data["references"])>0)
942  {
943  // object id might be unknown, resolve references instead to determine object id
944  // all references should point to the same object, so using the first one is ok.
945  foreach ($object_data["references"] as $refid)
946  {
947  if(ilObject::_isInTrash($refid))
948  {
949  continue;
950  }
951  break;
952  }
953 
954  $obj_id_from_refid = ilObject::_lookupObjectId($object_data["references"][0], false);
955  if (!$obj_id_from_refid)
956  {
957  return $this->__raiseError('No obj_id found for reference id '.$object_data["references"][0], 'CLIENT_OBJECT_NOT_FOUND');
958  } else
959  {
960  $tmp_obj = ilObjectFactory::getInstanceByObjId($object_data['obj_id'], false);
961  $object_data["obj_id"] = $obj_id_from_refid;
962  }
963  }
964 
965  $tmp_obj = ilObjectFactory::getInstanceByObjId($object_data['obj_id'], false);
966  if ($tmp_obj == null)
967  {
968  return $this->__raiseError('No object for id '.$object_data['obj_id'].'!', 'CLIENT_OBJECT_NOT_FOUND');
969  }
970  else
971  {
972  $object_data["instance"] = $tmp_obj;
973  }
974 
975  if($object_data['type'] == 'role')
976  {
977  $rolf_ids = $rbacreview->getFoldersAssignedToRole($object_data['obj_id'],true);
978  $rolf_id = $rolf_ids[0];
979 
980  if(!$rbacsystem->checkAccess('write',$rolf_id))
981  {
982  return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!', 'Client');
983  }
984  }
985  else
986  {
987  $permission_ok = false;
988  foreach(ilObject::_getAllReferences($object_data['obj_id']) as $ref_id)
989  {
990  if($rbacsystem->checkAccess('write',$object_data['obj_id']))
991  {
992  $permission_ok = true;
993  break;
994  }
995  }
996  if(!$permission_ok)
997  {
998  return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!', 'Client');
999  }
1000  }
1001  }
1002  // perform update
1003  if (count ($object_datas) > 0)
1004  {
1005  foreach($object_datas as $object_data)
1006  {
1007  $this->updateReferences($object_data);
1008 
1009  $tmp_obj = $object_data["instance"];
1010  $tmp_obj->setTitle($object_data['title']);
1011  $tmp_obj->setDescription($object_data['description']);
1012  switch ($object_data['type'])
1013  {
1014  case 'cat':
1015  $tmp_obj->updateTranslation($object_data["title"],$object_data["description"], $lng->getLangKey(), $lng->getLangKey());
1016  break;
1017  }
1018  $tmp_obj->update();
1019  if(strlen($object_data['owner']) && is_numeric($object_data['owner']))
1020  {
1021  $tmp_obj->setOwner($object_data['owner']);
1022  $tmp_obj->updateOwner();
1023  }
1024 
1025  }
1026  return true;
1027  }
1028  return false;
1029  }
1030 
1031  function moveObject ($sid, $ref_id, $target_id)
1032  {
1033  $this->initAuth($sid);
1034  $this->initIlias();
1035 
1036  if(!$this->__checkSession($sid))
1037  {
1038  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1039  }
1040 
1041  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1042  global $rbacreview, $rbacadmin, $objDefinition, $rbacsystem, $lng, $ilUser, $tree;
1043 
1044  // does source object exist
1045  if(!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false))
1046  {
1047  return $this->__raiseError('No valid source given.', 'Client');
1048  }
1049 
1050  // does target object exist
1051  if(!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false))
1052  {
1053  return $this->__raiseError('No valid target given.', 'Client');
1054  }
1055 
1056  // check for trash
1058  {
1059  return $this->__raiseError('Object is trashed.', 'Client');
1060  }
1061 
1063  {
1064  return $this->__raiseError('Object is trashed.', 'Client');
1065  }
1066 
1067  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1068  if ($this->isFault($canAddType))
1069  {
1070  return $canAddType;
1071  }
1072 
1073  // check if object already linked to target
1074  $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1075  foreach ($possibleChilds as $child)
1076  {
1077  if ($child["obj_id"] == $ref_id)
1078  return $this->__raiseError("Object already exists in target.","Client");
1079  }
1080 
1081  // GET COMPLETE NODE_DATA OF ALL SUBTREE NODES
1082  $node_data = $tree->getNodeData($ref_id);
1083  $subtree_nodes = $tree->getSubTree($node_data);
1084 
1085  $all_node_data[] = $node_data;
1086  $all_subtree_nodes[] = $subtree_nodes;
1087 
1088  // CHECK DELETE PERMISSION OF ALL OBJECTS IN ACTUAL SUBTREE
1089  foreach ($subtree_nodes as $node)
1090  {
1091  if($node['type'] == 'rolf')
1092  {
1093  continue;
1094  }
1095 
1096  if (!$rbacsystem->checkAccess('delete',$node["ref_id"]))
1097  {
1098  $no_cut[] = $node["ref_id"];
1099  }
1100  }
1101 
1102  // IF THERE IS ANY OBJECT WITH NO PERMISSION TO 'delete'
1103  if (count($no_cut))
1104  {
1105  return $this->__raiseError("Object contains references which you are not allowed to delete.","Client");
1106  }
1107 
1108  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1109  if ($tree->isGrandChild($ref_id,$target_id))
1110  {
1111  return $this->__raiseError("Cannot move object into itself.","Client");
1112  }
1113 
1114  $old_parent = $tree->getParentId($ref_id);
1115  $tree->moveTree($ref_id,$target_id);
1116  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
1117 
1118  include_once('classes/class.ilConditionHandler.php');
1120  return true;
1121  }
1122 
1128  function copyObject($sid, $copy_settings_xml)
1129  {
1130  $this->initAuth($sid);
1131  $this->initIlias();
1132 
1133  if(!$this->__checkSession($sid))
1134  {
1135  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1136  }
1137 
1138 
1139  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1140  global $rbacreview, $objDefinition, $rbacsystem, $lng, $ilUser;
1141 
1142  include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
1143  $xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
1144  try {
1145  $xml_parser->startParsing();
1146  } catch (ilSaxParserException $se){
1147  return $this->__raiseError($se->getMessage(), "Client");
1148  }
1149 
1150  // checking copy permissions, objects and create permissions
1151  if(!$rbacsystem->checkAccess('copy',$xml_parser->getSourceId()))
1152  {
1153  return $this->__raiseError("Missing copy permissions for object with reference id ".$xml_parser->getSourceId(), 'Client');
1154  }
1155 
1156  // checking copy permissions, objects and create permissions
1157  $source_id = $xml_parser->getSourceId();
1158  $target_id = $xml_parser->getTargetId();
1159 
1160 
1161  // does source object exist
1162  if(!$source_object_type = ilObjectFactory::getTypeByRefId($source_id, false))
1163  {
1164  return $this->__raiseError('No valid source given.', 'Client');
1165  }
1166 
1167  // does target object exist
1168  if(!$target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false))
1169  {
1170  return $this->__raiseError('No valid target given.', 'Client');
1171  }
1172 
1173 
1174  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1175  if ($this->isFault($canAddType))
1176  {
1177  return $canAddType;
1178  }
1179 
1180  // if is container object than clone with sub items
1181  $options = $xml_parser->getOptions();
1182 // print_r($options);
1183  $source_object = ilObjectFactory::getInstanceByRefId($source_id);
1184  if ($source_object instanceof ilContainer) {
1185  // get client id from sid
1186  $clientid = substr($sid, strpos($sid, "::") + 2);
1187  $sessionid = str_replace("::".$clientid, "", $sid);
1188  // call container clone
1189  return $source_object->cloneAllObject($sessionid, $clientid,
1190  $source_object_type,
1191  $target_id,
1192  $source_id,
1193  $options, true);
1194 
1195  } else {
1196  // create copy wizard settings
1198  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1199  $wizard_options->saveOwner($ilUser->getId());
1200  $wizard_options->saveRoot($source_id);
1201 
1202  foreach($options as $source_id => $option)
1203  {
1204  $wizard_options->addEntry($source_id,$option);
1205  }
1206  $wizard_options->read();
1207 
1208  // call object clone
1209  $newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
1210  return is_object($newObject) ? $newObject->getRefId() : -1;
1211  }
1212  }
1213 
1214  function getPathForRefId($sid, $ref_id)
1215  {
1216  $this->initAuth($sid);
1217  $this->initIlias();
1218 
1219  if(!$this->__checkSession($sid))
1220  {
1221  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1222  }
1223 
1224  global $ilAccess, $objDefinition, $rbacsystem, $lng, $ilUser;
1225 
1226  if(!$rbacsystem->checkAccess('read', $ref_id))
1227  {
1228  return $this->__raiseError("Missing read permissions for object with reference id ".$ref_id, 'Client');
1229  }
1230 
1232  {
1233  return $this->__raiseError("Object is in Trash", 'Client');
1234  }
1235  global $tree, $lng;
1236  $items = $tree->getPathFull($ref_id);
1237 
1238  include_once 'webservice/soap/classes/class.ilXMLResultSet.php';
1239  include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
1240  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
1241 
1242  $xmlResultSet = new ilXMLResultSet();
1243  $xmlResultSet->addColumn("ref_id");
1244  $xmlResultSet->addColumn("type");
1245  $xmlResultSet->addColumn("title");
1246 
1247  $writer = new ilXMLResultSetWriter($xmlResultSet);
1248  foreach ($items as $item) {
1249  if ($item["ref_id"] == $ref_id)
1250  continue;
1251  if ($item["title"] == "ILIAS" && $item["type"] == "root")
1252  {
1253  $item["title"] = $lng->txt("repository");
1254  }
1255 
1256  $row = new ilXMLResultSetRow();
1257  $xmlResultSet->addRow($row);
1258  $row->setValue("ref_id", $item["ref_id"]);
1259  $row->setValue("type", $item["type"]);
1260  $row->setValue("title", $item["title"]);
1261  }
1262  $writer->start();
1263  return $writer->getXML();
1264  }
1265 
1266 
1267  private function canAddType ($type, $target_type, $target_id)
1268  {
1269  // checking for target subtypes. Can we add source to target
1270  global $objDefinition, $rbacsystem;
1271 
1272  $allowed_types = array('root','cat','grp','crs','fold');
1273  if(!in_array($target_type, $allowed_types))
1274  {
1275  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
1276  }
1277 
1278  $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1279  $allowed = array();
1280 
1281  foreach($allowed_subtypes as $row)
1282  {
1283  if($row['name'] != 'rolf')
1284  {
1285  $allowed[] = $row['name'];
1286  }
1287  }
1288 
1289  if(!in_array($type, $allowed))
1290  {
1291  return $this->__raiseError('Objects of type: '.$type.' are not allowed to be subobjects of type '.$target_type.'!','Client');
1292  }
1293  if(!$rbacsystem->checkAccess('create',$target_id, $type))
1294  {
1295  return $this->__raiseError('No permission to create objects of type '.$type.'!', 'Client');
1296  }
1297 
1298  return true;
1299  }
1300 
1301  private function validateReferences($a_action,$a_object_data,$a_target_id = 0)
1302  {
1303  global $ilAccess;
1304 
1305  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1306  {
1307  return true;
1308  }
1309  if($a_action == 'create')
1310  {
1311  if(count($a_object_data['references']) > 1)
1312  {
1313  if(in_array($a_object_data['type'],array('cat','crs','grp','fold')))
1314  {
1315  return $this->__raiseError("Cannot create references for type ".$a_object_data['type'],
1316  'Client');
1317  }
1318  }
1319  if(count($a_object_data['references']) == 1)
1320  {
1321  if($a_target_id != $a_object_data['references'][0]['parent_id'])
1322  {
1323  return $this->__raiseError("Cannot create references for type ".$a_object_data['type'],
1324  'Client');
1325  }
1326  }
1327 
1328  foreach($a_object_data['references'] as $ref_data)
1329  {
1330  if(!$ref_data['parent_id'])
1331  {
1332  return $this->__raiseError('Element References: No parent Id given!','Client');
1333  }
1334 
1335  $target_type = ilObject::_lookupType(ilObject::_lookupObjId($ref_data['parent_id']));
1336  $can_add_type = $this->canAddType($a_object_data['type'],$target_type,$ref_data['parent_id']);
1337  if($this->isFault($can_add_type))
1338  {
1339  return $can_add_type;
1340  }
1341  }
1342  return true;
1343  }
1344 
1345  if($a_action == 'update')
1346  {
1347  foreach($a_object_data['references'] as $ref_data)
1348  {
1349  if(!$ref_data['ref_id'])
1350  {
1351  return $this->__raiseError('Element References: No reference id given!','Client');
1352  }
1353  // check permissions
1354  if(!$ilAccess->checkAccess('write','',$ref_data['ref_id']))
1355  {
1356  return $this->__raiseError('No write permission for object with reference id '.$ref_data['ref_id'].'!', 'Client');
1357  }
1358  // TODO: check if all references belong to the same object
1359  }
1360  return true;
1361  }
1362  }
1363 
1364  private function updateReferences($a_object_data)
1365  {
1366  global $tree,$ilLog;
1367 
1368  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1369  {
1370  return true;
1371  }
1372 
1373  foreach($a_object_data['references'] as $ref_data)
1374  {
1375  if(isset($ref_data['time_target']) and ($crs_ref_id = $tree->checkForParentType($ref_data['ref_id'],'crs')))
1376  {
1377  $crs_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id,false);
1378  include_once('./Modules/Course/classes/class.ilCourseItems.php');
1379  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1380 
1381 
1382  $items = new ilCourseItems($crs_obj,$ref_data['parent_id']);
1383  $old = $items->getItem($ref_data['ref_id']);
1384 
1385  $items->toggleChangeable(isset($ref_data['time_target']['changeable']) ? $ref_data['time_target']['changeable'] : $old['changeable']);
1386  $items->setTimingStart(isset($ref_data['time_target']['starting_time']) ? $ref_data['time_target']['starting_time'] : $old['timing_start']);
1387  $items->setTimingEnd(isset($ref_data['time_target']['ending_time']) ? $ref_data['time_target']['ending_time'] : $old['timing_end']);
1388  $items->toggleVisible(isset($ref_data['time_target']['timing_visibility']) ? $ref_data['time_target']['timing_visibility'] : $old['visible']);
1389  $items->setSuggestionStart(isset($ref_data['time_target']['suggestion_start']) ? $ref_data['time_target']['suggestion_start'] : $old['suggestion_start']);
1390  $items->setSuggestionEnd(isset($ref_data['time_target']['suggestion_end']) ? $ref_data['time_target']['suggestion_end'] : $old['suggestion_end']);
1391  $items->setEarliestStart(isset($ref_data['time_target']['earliest_start']) ? $ref_data['time_target']['earliest_start'] : $old['earliest_start']);
1392  $items->setLatestEnd(isset($ref_data['time_target']['latest_end']) ? $ref_data['time_target']['latest_end'] : $old['latest_end']);
1393 
1394  switch($ref_data['time_target']['timing_type'])
1395  {
1397  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_DEACTIVATED.' '.$ref_data['time_target']['timing_type']);
1398  $items->setTimingType(IL_CRS_TIMINGS_DEACTIVATED);
1399  break;
1400 
1402  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_ACTIVATION.' '.$ref_data['time_target']['timing_type']);
1403  $items->setTimingType(IL_CRS_TIMINGS_ACTIVATION);
1404  break;
1405 
1407  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_PRESETTING.' '.$ref_data['time_target']['timing_type']);
1408  $items->setTimingType(IL_CRS_TIMINGS_PRESETTING);
1409  break;
1410  }
1411  $items->update($ref_data['ref_id']);
1412  }
1413  }
1414  return true;
1415  }
1416 
1417 
1418  private function addReferences($source,$a_object_data)
1419  {
1420  global $tree,$ilLog;
1421 
1422  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1423  {
1424  return true;
1425  }
1426 
1427  $original_id = $source->getRefId();
1428 
1429  foreach($a_object_data['references'] as $ref_data)
1430  {
1431  $new_ref_id = $ref_id = $original_id;
1432  if($tree->getParentId($original_id) != $ref_data['parent_id'])
1433  {
1434  // New reference requested => create it
1435  $new_ref_id = $source->createReference();
1436  $source->putInTree($ref_data['parent_id']);
1437  $source->setPermissions($ref_data['parent_id']);
1438  $source->initDefaultRoles();
1439  }
1440  if(isset($ref_data['time_target']) and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')))
1441  {
1442 
1443  $crs_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id,false);
1444  include_once('./Modules/Course/classes/class.ilCourseItems.php');
1445  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1446 
1447  $items = new ilCourseItems($crs_obj,$ref_data['parent_id']);
1448 
1449  if(!isset($ref_data['time_target']['starting_time']))
1450  {
1451  $ref_data['time_target']['starting_time'] = time();
1452  }
1453  if(!isset($ref_data['time_target']['ending_time']))
1454  {
1455  $ref_data['time_target']['ending_time'] = time();
1456  }
1457 
1458  $items->toggleChangeable($ref_data['time_target']['changeable']);
1459  $items->setTimingStart($ref_data['time_target']['starting_time']);
1460  $items->setTimingEnd($ref_data['time_target']['ending_time']);
1461  $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1462  $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1463  $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1464  $items->setEarliestStart($ref_data['time_target']['earliest_start']);
1465  $items->setLatestEnd($ref_data['time_target']['latest_end']);
1466 
1467  switch($ref_data['time_target']['timing_type'])
1468  {
1470  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_DEACTIVATED.' '.$ref_data['time_target']['timing_type']);
1471  $items->setTimingType(IL_CRS_TIMINGS_DEACTIVATED);
1472  break;
1473 
1475  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_ACTIVATION.' '.$ref_data['time_target']['timing_type']);
1476  $items->setTimingType(IL_CRS_TIMINGS_ACTIVATION);
1477  break;
1478 
1480  $ilLog->write(__METHOD__.IL_CRS_TIMINGS_PRESETTING.' '.$ref_data['time_target']['timing_type']);
1481  $items->setTimingType(IL_CRS_TIMINGS_PRESETTING);
1482  break;
1483  }
1484  $items->update($new_ref_id);
1485  }
1486  }
1487 
1488  }
1489 
1490 
1491 
1492 }
1493 ?>