ILIAS  release_4-3 Revision
 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  // begin-patch fm
317  include_once './Services/Search/classes/class.ilSearchSettings.php';
318  if(ilSearchSettings::getInstance()->enabledLucene()) {
319 
320  ilSearchSettings::getInstance()->setMaxHits(25);
321 
322  include_once './Services/Search/classes/Lucene/class.ilLuceneQueryParser.php';
323  $query_parser = new ilLuceneQueryParser($key);
324  $query_parser->parse();
325 
326  include_once './Services/Search/classes/Lucene/class.ilLuceneSearcher.php';
327  $searcher = ilLuceneSearcher::getInstance($query_parser);
328  $searcher->search();
329 
330  include_once './Services/Search/classes/Lucene/class.ilLuceneSearchResultFilter.php';
331  include_once './Services/Search/classes/Lucene/class.ilLucenePathFilter.php';
332  $filter = ilLuceneSearchResultFilter::getInstance($user_id);
333  $filter->setCandidates($searcher->getResult());
334  $filter->filter();
335 
336  $result_ids = $filter->getResults();
337  $objs = array();
338  $objs[ROOT_FOLDER_ID] = ilObjectFactory::getInstanceByRefId(ROOT_FOLDER_ID,false);
339  foreach ((array) $result_ids as $ref_id => $obj_id) {
340 
342  if($obj instanceof ilObject)
343  {
344  $objs[] = $obj;
345  }
346  }
347  include_once './Services/Search/classes/Lucene/class.ilLuceneHighlighterResultParser.php';
348  $highlighter = new ilLuceneHighlighterResultParser();
349  if($filter->getResultObjIds())
350  {
351  $highlighter = $searcher->highlight($filter->getResultObjIds());
352  }
353  }
354  else
355  {
356 
357  include_once './Services/Search/classes/class.ilQueryParser.php';
358 
359  $query_parser =& new ilQueryParser($key);
360  #$query_parser->setMinWordLength(3);
361  $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
362  $query_parser->parse();
363  if(!$query_parser->validate())
364  {
365  return $this->__raiseError($query_parser->getMessage(),
366  'Client');
367  }
368 
369  #include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
370  #$object_search =& ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
371 
372  include_once './Services/Search/classes/Like/class.ilLikeObjectSearch.php';
373  $object_search = new ilLikeObjectSearch($query_parser);
374 
375  $object_search->setFilter($types);
376 
377  $res =& $object_search->performSearch();
378  if($user_id)
379  {
380  $res->setUserId($user_id);
381  }
382  // begin-patch fm
383  $res->setMaxHits(100);
384  // begin-patch fm
385  $res->filter(ROOT_FOLDER_ID,$combination == 'and' ? true : false);
386 
387  $counter = 0;
388  $objs = array();
389  foreach($res->getUniqueResults() as $entry)
390  {
391  $obj = ilObjectFactory::getInstanceByRefId($entry['ref_id'],false);
392  if($obj instanceof ilObject)
393  {
394  $objs[] = $obj;
395  }
396  }
397  }
398 
399  if(!count($objs))
400  {
401  //rku: todo: das ist nicht soap konform! - hier muss ein XML zurück geliefert werden
402  return '';
403  }
404 
405  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
406 
407  $xml_writer = new ilObjectXMLWriter();
408 
409  // begin-patch fm
410  if(ilSearchSettings::getInstance()->enabledLucene())
411  {
412  $xml_writer->enableReferences(false);
413  $xml_writer->setMode(ilObjectXmlWriter::MODE_SEARCH_RESULT);
414  $xml_writer->setHighlighter($highlighter);
415  }
416 
417  $xml_writer->enablePermissionCheck(true);
418 
419  if($user_id)
420  {
421  $xml_writer->setUserId($user_id);
422  $xml_writer->enableOperations(true);
423  }
424 
425  $xml_writer->setObjects($objs);
426 
427  if($xml_writer->start())
428  {
429  #$GLOBALS['ilLog']->write(__METHOD__.': '.$xml_writer->xmlDumpMem(true));
430  return $xml_writer->getXML();
431  }
432 
433  return $this->__raiseError('Cannot create object xml !','Server');
434  }
435 
436  function getTreeChilds($sid,$ref_id,$types,$user_id)
437  {
438  $this->initAuth($sid);
439  $this->initIlias();
440 
441  if(!$this->__checkSession($sid))
442  {
443  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
444  }
445 
446  $all = false;
447 
448  global $tree;
449 
450  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($ref_id,false))
451  {
452  return $this->__raiseError('No valid reference id given.',
453  'Client');
454  }
455  if (intval($ref_id) == SYSTEM_FOLDER_ID) {
456  return $this->__raiseError('No valid reference id given.',
457  'Client');
458  }
459 
460  if(!$types)
461  {
462  $all = true;
463  }
464 
465  $objs = array();
466 
467  // begin-patch filemanager
468  include_once './Services/WebServices/FileManager/classes/class.ilFMSettings.php';
469  if(in_array('parent', (array) $types))
470  {
471  $objs[] = $target_obj;
472  }
473  // end-patch filemanager
474 
475  foreach($tree->getChilds($ref_id,'title') as $child)
476  {
477  if($all or in_array($child['type'],$types))
478  {
479  if($tmp = ilObjectFactory::getInstanceByRefId($child['ref_id'],false))
480  {
481  $objs[] = $tmp;
482  }
483  }
484  }
485 
486  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
487 
488  $xml_writer = new ilObjectXMLWriter();
489  // begin-patch filemanager
490  if(ilFMSettings::getInstance()->isEnabled())
491  {
492  $xml_writer->enableReferences(false);
493  }
494  // end-patch filemanager
495  $xml_writer->enablePermissionCheck(true);
496  $xml_writer->setObjects($objs);
497  $xml_writer->enableOperations(true);
498  if($user_id)
499  {
500  $xml_writer->setUserId($user_id);
501  }
502 
503  if ($xml_writer->start())
504  {
505  #$GLOBALS['ilLog']->write(__METHOD__.': '.$xml_writer->getXML());
506  return $xml_writer->getXML();
507  }
508 
509  return $this->__raiseError('Cannot create object xml !','Server');
510  }
511 
512  function getXMLTree($sid, $ref_id, $types, $user_id)
513  {
514  $this->initAuth($sid);
515  $this->initIlias();
516 
517  if(!$this->__checkSession($sid))
518  {
519  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
520  }
521 
522  global $tree;
523 
524  $nodedata = $tree->getNodeData($ref_id);
525  $nodearray = $tree->getSubTree($nodedata);
526 
527 
528  $filter = (array) $types;
529 
530  global $objDefinition;
531  foreach($nodearray as $node)
532  {
533  if(!$objDefinition->isAdministrationObject($node['type']) && !$objDefinition->isSystemObject($node['type']))
534  {
535  if(!in_array($node['type'], $filter))
536  {
537  if($tmp = ilObjectFactory::getInstanceByRefId($node['ref_id'], false))
538  {
539  $nodes[] = $tmp;
540  }
541  }
542  }
543  }
544 
545 
546  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
547 
548  $xml_writer = new ilObjectXMLWriter();
549  $xml_writer->enablePermissionCheck(true);
550  $xml_writer->setObjects($nodes);
551  $xml_writer->enableOperations(false);
552 
553  if($user_id)
554  {
555  $xml_writer->setUserId($user_id);
556  }
557 
558  if($xml_writer->start())
559  {
560  return $xml_writer->getXML();
561  }
562 
563  return $this->__raiseError('Cannot create object xml !', 'Server');
564  }
565 
566  function addObject($sid,$a_target_id,$a_xml)
567  {
568  $this->initAuth($sid);
569  $this->initIlias();
570 
571  if(!$this->__checkSession($sid))
572  {
573  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
574  }
575  if(!strlen($a_xml))
576  {
577  return $this->__raiseError('No valid xml string given.',
578  'Client');
579  }
580 
581  global $rbacsystem, $objDefinition,$ilUser, $lng, $ilObjDataCache;
582 
583  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
584  {
585  return $this->__raiseError('No valid target given.',
586  'Client');
587  }
588 
589  if(ilObject::_isInTrash($a_target_id))
590  {
591  return $this->__raiseError("Parent with ID $a_target_id has been deleted.", 'Client');
592  }
593 
594  $allowed_types = array('root','cat','grp','crs','fold');
595  if(!in_array($target_obj->getType(),$allowed_types))
596  {
597  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"',
598  'Client');
599  }
600 
601  $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
602 
603  foreach($allowed_subtypes as $row)
604  {
605  if($row['name'] != 'rolf')
606  {
607  $allowed[] = $row['name'];
608  }
609  }
610 
611  include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
612 
613  $xml_parser =& new ilObjectXMLParser($a_xml, true);
614  try {
615  $xml_parser->startParsing();
616  }
617  catch (ilSaxParserException $se){
618  return $this->__raiseError($se->getMessage(),'Client');
619  }
620  catch(ilObjectXMLException $e) {
621  return $this->__raiseError($e->getMessage(),'Client');
622  }
623 
624  foreach($xml_parser->getObjectData() as $object_data)
625  {
626  $res = $this->validateReferences('create',$object_data,$a_target_id);
627  if($this->isFault($res))
628  {
629  return $res;
630  }
631 
632  // Check possible subtype
633  if(!in_array($object_data['type'],$allowed))
634  {
635  return $this->__raiseError('Objects of type: '.$object_data['type'].' are not allowed to be subobjects of type '.
636  $target_obj->getType().'!',
637  'Client');
638  }
639  if(!$rbacsystem->checkAccess('create',$a_target_id,$object_data['type']))
640  {
641  return $this->__raiseError('No permission to create objects of type '.$object_data['type'].'!',
642  'Client');
643  }
644  // begin-patch fm
645  /*
646  if($object_data['type'] == 'crs')
647  {
648  return $this->__raiseError('Cannot create course objects. Use method addCourse() ',
649  'Client');
650  }
651  */
652  // end-patch fm
653 
654  // It's not possible to add objects with non unique import ids
655  if(strlen($object_data['import_id']) and ilObject::_lookupObjIdByImportId($object_data['import_id']))
656  {
657  return $this->__raiseError('An object with import id '.$object_data['import_id'].' already exists!',
658  'Server');
659  }
660 
661  // call gui object method
662  $class_name = $objDefinition->getClassName($object_data['type']);
663  $location = $objDefinition->getLocation($object_data['type']);
664 
665  $class_constr = "ilObj".$class_name;
666  require_once($location."/class.ilObj".$class_name.".php");
667 
668  $newObj = new $class_constr();
669 
670  if(isset($object_data['owner']) && strlen($object_data['owner']))
671  {
672  if((int)$object_data['owner'])
673  {
674  if(ilObject::_exists((int)$object_data['owner']) &&
675  $ilObjDataCache->lookupType((int)$object_data['owner']) == 'usr')
676  {
677  $newObj->setOwner((int)$object_data['owner']);
678  }
679  }
680  else
681  {
682  $usr_id = ilObjUser::_lookupId(trim($object_data['owner']));
683  if((int)$usr_id)
684  {
685  $newObj->setOwner((int)$usr_id);
686  }
687  }
688  }
689 
690  $newObj->setType($object_data['type']);
691  if(strlen($object_data['import_id']))
692  {
693  $newObj->setImportId($object_data['import_id']);
694  }
695  $newObj->setTitle($object_data['title']);
696  $newObj->setDescription($object_data['description']);
697  $newObj->create(); // true for upload
698  $newObj->createReference();
699  $newObj->putInTree($a_target_id);
700  $newObj->setPermissions($a_target_id);
701 
702  switch($object_data['type'])
703  {
704  case 'grp':
705  // Add member
706  $newObj->addMember($object_data['owner'] ? $object_data['owner'] : $ilUser->getId(),
707  $newObj->getDefaultAdminRole());
708  break;
709 
710  // begin-patch fm
711  case 'crs':
712  $newObj->getMemberObject()->add($ilUser->getId(),IL_CRS_ADMIN);
713  break;
714  // end-patch fm
715  case 'lm':
716  case 'dbk':
717  $newObj->createLMTree();
718  break;
719  case 'cat':
720  $newObj->addTranslation($object_data["title"],$object_data["description"], $lng->getLangKey(), $lng->getLangKey());
721  break;
722  }
723 
724  $this->addReferences($newObj,$object_data);
725 
726  }
727  $ref_id = $newObj->getRefId();
728  return $ref_id ? $ref_id : "0";
729  }
730 
731  function addReference($sid,$a_source_id,$a_target_id)
732  {
733  $this->initAuth($sid);
734  $this->initIlias();
735 
736  if(!$this->__checkSession($sid))
737  {
738  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
739  }
740  if(!is_numeric($a_source_id))
741  {
742  return $this->__raiseError('No source id given.',
743  'Client');
744  }
745  if(!is_numeric($a_target_id))
746  {
747  return $this->__raiseError('No target id given.',
748  'Client');
749  }
750 
751  global $objDefinition, $rbacsystem, $tree;
752 
753  if(!$source_obj =& ilObjectFactory::getInstanceByRefId($a_source_id,false))
754  {
755  return $this->__raiseError('No valid source id given.',
756  'Client');
757  }
758  if(!$target_obj =& ilObjectFactory::getInstanceByRefId($a_target_id,false))
759  {
760  return $this->__raiseError('No valid target id given.',
761  'Client');
762  }
763 
764  if(!$objDefinition->allowLink($source_obj->getType()) and
765  $source_obj->getType() != 'cat' and
766  $source_obj->getType() != 'crs')
767  {
768  return $this->__raiseError('Linking of object type: '.$source_obj->getType().' is not allowed',
769  'Client');
770  }
771 
772  $allowed_subtypes = $objDefinition->getSubObjects($target_obj->getType());
773  foreach($allowed_subtypes as $row)
774  {
775  if($row['name'] != 'rolf')
776  {
777  $allowed[] = $row['name'];
778  }
779  }
780  if(!in_array($source_obj->getType(),$allowed))
781  {
782  return $this->__raiseError('Objects of type: '.$source_obj->getType().' are not allowed to be subobjects of type '.
783  $target_obj->getType().'!',
784  'Client');
785  }
786 
787  // Permission checks
788  if(!$rbacsystem->checkAccess('create',$target_obj->getRefId(),$source_obj->getType()))
789  {
790  return $this->__raiseError('No permission to create objects of type '.$source_obj->getType().'!',
791  'Client');
792  }
793  if(!$rbacsystem->checkAccess('delete',$source_obj->getRefId()))
794  {
795  return $this->__raiseError('No permission to link object with id: '.$source_obj->getRefId().'!',
796  'Client');
797  }
798 
799 
800  if($source_obj->getType() != 'cat' and $source_obj->getType() != 'crs')
801  {
802  // check if object already linked to target
803  $possibleChilds = $tree->getChildsByType($target_obj->getRefId(), $source_obj->getType());
804  foreach ($possibleChilds as $child)
805  {
806  if ($child["obj_id"] == $source_obj->getId())
807  return $this->__raiseError("Object already linked to target.","Client");
808  }
809 
810  // Finally link it to target position
811 
812  $new_ref_id = $source_obj->createReference();
813  $source_obj->putInTree($target_obj->getRefId());
814  $source_obj->setPermissions($target_obj->getRefId());
815 
816  return $new_ref_id ? $new_ref_id : "0";
817  }
818  else
819  {
820  switch($source_obj->getType())
821  {
822  case 'cat':
823  include_once('./Modules/CategoryReference/classes/class.ilObjCategoryReference.php');
824  $new_ref = new ilObjCategoryReference();
825  break;
826 
827  case 'crs':
828  include_once('./Modules/CourseReference/classes/class.ilObjCourseReference.php');
829  $new_ref = new ilObjCourseReference();
830  break;
831  }
832  $new_ref->create();
833  $new_ref_id = $new_ref->createReference();
834 
835  $new_ref->putInTree($target_obj->getRefId());
836  $new_ref->setPermissions($target_obj->getRefId());
837 
838  $new_ref->setTargetId($source_obj->getId());
839  $new_ref->update();
840 
841  return $new_ref_id ? $new_ref_id : 0;
842  }
843  }
844 
845  function deleteObject($sid,$reference_id)
846  {
847  $this->initAuth($sid);
848  $this->initIlias();
849 
850  if(!$this->__checkSession($sid))
851  {
852  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
853  }
854  if(!is_numeric($reference_id))
855  {
856  return $this->__raiseError('No reference id given.',
857  'Client');
858  }
859  global $tree, $rbacsystem, $rbacadmin;
860 
861  if(!$del_obj =& ilObjectFactory::getInstanceByRefId($reference_id,false))
862  {
863  return $this->__raiseError('No valid reference id given.',
864  'Client');
865  }
866  if(!$rbacsystem->checkAccess('delete',$del_obj->getRefId()))
867  {
868  return $this->__raiseError('No permission to delete object with id: '.$del_obj->getRefId().'!',
869  'Client');
870  }
871 
872  // Delete tree
873  if($tree->isDeleted($reference_id))
874  {
875  return $this->__raiseError('Node already deleted','Server');
876  }
877 
878  if($del_obj->getType() == 'rolf')
879  {
880  return $this->__raiseError('Delete is not available for role folders.','Client');
881  }
882 
883  $subnodes = $tree->getSubtree($tree->getNodeData($reference_id));
884  foreach($subnodes as $subnode)
885  {
886  $rbacadmin->revokePermission($subnode["child"]);
887  // remove item from all user desktops
888  $affected_users = ilUtil::removeItemFromDesktops($subnode["child"]);
889  }
890  if(!$tree->saveSubTree($reference_id,true))
891  {
892  return $this->__raiseError('Node already deleted','Client');
893  }
894 
895  return true;
896  }
897 
898  function removeFromSystemByImportId($sid,$import_id)
899  {
900  $this->initAuth($sid);
901  $this->initIlias();
902 
903  if(!$this->__checkSession($sid))
904  {
905  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
906  }
907  if(!strlen($import_id))
908  {
909  return $this->__raiseError('No import id given. Aborting!',
910  'Client');
911  }
912  global $rbacsystem, $tree, $ilLog;
913 
914  // get obj_id
915  if(!$obj_id = ilObject::_lookupObjIdByImportId($import_id))
916  {
917  return $this->__raiseError('No object found with import id: '.$import_id,
918  'Client');
919  }
920 
921  // Check access
922  $permission_ok = false;
923  foreach($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id)
924  {
925  if($rbacsystem->checkAccess('delete',$ref_id))
926  {
927  $permission_ok = true;
928  break;
929  }
930  }
931  if(!$permission_ok)
932  {
933  return $this->__raiseError('No permission to delete the object with import id: '.$import_id,
934  'Server');
935  }
936 
937  // Delete all references (delete permssions and entries in object_reference)
938  foreach($ref_ids as $ref_id)
939  {
940  // All subnodes
941  $node_data = $tree->getNodeData($ref_id);
942  $subtree_nodes = $tree->getSubtree($node_data);
943 
944  foreach($subtree_nodes as $node)
945  {
946  $ilLog->write('Soap: removeFromSystemByImportId(). Deleting object with title id: '.$node['title']);
947  $tmp_obj = ilObjectFactory::getInstanceByRefId($node['ref_id']);
948  if(!is_object($tmp_obj))
949  {
950  return $this->__raiseError('Cannot create instance of reference id: '.$node['ref_id'],
951  'Server');
952  }
953  $tmp_obj->delete();
954  }
955  // Finally delete tree
956  $tree->deleteTree($node_data);
957 
958  }
959 
960  return true;
961  }
962 
963 
964  function updateObjects($sid,$a_xml)
965  {
966  $this->initAuth($sid);
967  $this->initIlias();
968 
969  if(!$this->__checkSession($sid))
970  {
971  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
972  }
973  if(!strlen($a_xml))
974  {
975  return $this->__raiseError('No valid xml string given.',
976  'Client');
977  }
978 
979  global $rbacreview, $rbacsystem, $lng,$ilAccess;
980 
981  include_once './webservice/soap/classes/class.ilObjectXMLParser.php';
982  $xml_parser =& new ilObjectXMLParser($a_xml, true);
983  try
984  {
985  $xml_parser->startParsing();
986  }
987  catch (ilSaxParserException $se){
988  return $this->__raiseError($se->getMessage(),'Client');
989  }
990  catch(ilObjectXMLException $e) {
991  return $this->__raiseError($e->getMessage(),'Client');
992  }
993 
994 
995  // Validate incoming data
996  $object_datas = $xml_parser->getObjectData();
997  foreach($object_datas as & $object_data)
998  {
999  $res = $this->validateReferences('update',$object_data);
1000  if($this->isFault($res))
1001  {
1002  return $res;
1003  }
1004 
1005 
1006  if(!$object_data["obj_id"])
1007  {
1008  return $this->__raiseError('No obj_id in xml found.', 'Client');
1009  }
1010  elseif ((int) $object_data["obj_id"] == -1 && count($object_data["references"])>0)
1011  {
1012  // object id might be unknown, resolve references instead to determine object id
1013  // all references should point to the same object, so using the first one is ok.
1014  foreach ($object_data["references"] as $refid)
1015  {
1016  if(ilObject::_isInTrash($refid))
1017  {
1018  continue;
1019  }
1020  break;
1021  }
1022 
1023  $obj_id_from_refid = ilObject::_lookupObjectId($object_data["references"][0], false);
1024  if (!$obj_id_from_refid)
1025  {
1026  return $this->__raiseError('No obj_id found for reference id '.$object_data["references"][0], 'CLIENT_OBJECT_NOT_FOUND');
1027  } else
1028  {
1029  $tmp_obj = ilObjectFactory::getInstanceByObjId($object_data['obj_id'], false);
1030  $object_data["obj_id"] = $obj_id_from_refid;
1031  }
1032  }
1033 
1034  $tmp_obj = ilObjectFactory::getInstanceByObjId($object_data['obj_id'], false);
1035  if ($tmp_obj == null)
1036  {
1037  return $this->__raiseError('No object for id '.$object_data['obj_id'].'!', 'CLIENT_OBJECT_NOT_FOUND');
1038  }
1039  else
1040  {
1041  $object_data["instance"] = $tmp_obj;
1042  }
1043 
1044  if($object_data['type'] == 'role')
1045  {
1046  $rolf_ids = $rbacreview->getFoldersAssignedToRole($object_data['obj_id'],true);
1047  $rolf_id = $rolf_ids[0];
1048 
1049  if(!$rbacsystem->checkAccess('write',$rolf_id))
1050  {
1051  return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!', 'Client');
1052  }
1053  }
1054  else
1055  {
1056  $permission_ok = false;
1057  foreach(ilObject::_getAllReferences($object_data['obj_id']) as $ref_id)
1058  {
1059  if($ilAccess->checkAccess('write','',$ref_id))
1060  {
1061  $permission_ok = true;
1062  break;
1063  }
1064  }
1065  if(!$permission_ok)
1066  {
1067  return $this->__raiseError('No write permission for object with id '.$object_data['obj_id'].'!', 'Client');
1068  }
1069  }
1070  }
1071  // perform update
1072  if (count ($object_datas) > 0)
1073  {
1074  foreach($object_datas as $object_data)
1075  {
1076  $this->updateReferences($object_data);
1077 
1078  $tmp_obj = $object_data["instance"];
1079  $tmp_obj->setTitle($object_data['title']);
1080  $tmp_obj->setDescription($object_data['description']);
1081 
1082  #$GLOBALS['ilLog']->write(__METHOD__.': type is '. $object_data['type']);
1083  #$GLOBALS['ilLog']->write(__METHOD__.': type is '. $a_xml);
1084 
1085 
1086  switch ($object_data['type'])
1087  {
1088  case 'cat':
1089  $tmp_obj->updateTranslation($object_data["title"],$object_data["description"], $lng->getLangKey(), $lng->getLangKey());
1090  break;
1091  }
1092  $tmp_obj->update();
1093  if(strlen($object_data['owner']) && is_numeric($object_data['owner']))
1094  {
1095  $tmp_obj->setOwner($object_data['owner']);
1096  $tmp_obj->updateOwner();
1097  }
1098 
1099  }
1100  return true;
1101  }
1102  return false;
1103  }
1104 
1105  function moveObject ($sid, $ref_id, $target_id)
1106  {
1107  $this->initAuth($sid);
1108  $this->initIlias();
1109 
1110  if(!$this->__checkSession($sid))
1111  {
1112  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1113  }
1114 
1115  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1116  global $rbacreview, $rbacadmin, $objDefinition, $rbacsystem, $lng, $ilUser, $tree;
1117 
1118  // does source object exist
1119  if(!$source_object_type = ilObjectFactory::getTypeByRefId($ref_id, false))
1120  {
1121  return $this->__raiseError('No valid source given.', 'Client');
1122  }
1123 
1124  // does target object exist
1125  if(!$target_object_type = ilObjectFactory::getTypeByRefId($target_id, false))
1126  {
1127  return $this->__raiseError('No valid target given.', 'Client');
1128  }
1129 
1130  // check for trash
1132  {
1133  return $this->__raiseError('Object is trashed.', 'Client');
1134  }
1135 
1137  {
1138  return $this->__raiseError('Object is trashed.', 'Client');
1139  }
1140 
1141  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1142  if ($this->isFault($canAddType))
1143  {
1144  return $canAddType;
1145  }
1146 
1147  // check if object already linked to target
1148  $possibleChilds = $tree->getChildsByType($target_id, $ref_id);
1149  foreach ($possibleChilds as $child)
1150  {
1151  if ($child["obj_id"] == $ref_id)
1152  return $this->__raiseError("Object already exists in target.","Client");
1153  }
1154 
1155  // CHECK IF PASTE OBJECT SHALL BE CHILD OF ITSELF
1156  if ($tree->isGrandChild($ref_id,$target_id))
1157  {
1158  return $this->__raiseError("Cannot move object into itself.","Client");
1159  }
1160 
1161  $old_parent = $tree->getParentId($ref_id);
1162  $tree->moveTree($ref_id,$target_id);
1163  $rbacadmin->adjustMovedObjectPermissions($ref_id,$old_parent);
1164 
1165  include_once('./Services/AccessControl/classes/class.ilConditionHandler.php');
1167  return true;
1168  }
1169 
1175  function copyObject($sid, $copy_settings_xml)
1176  {
1177  $this->initAuth($sid);
1178  $this->initIlias();
1179 
1180  if(!$this->__checkSession($sid))
1181  {
1182  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1183  }
1184 
1185 
1186  include_once './webservice/soap/classes/class.ilSoapUtils.php';
1187  global $rbacreview, $objDefinition, $rbacsystem, $lng, $ilUser;
1188 
1189  include_once './webservice/soap/classes/class.ilCopyWizardSettingsXMLParser.php';
1190  $xml_parser = new ilCopyWizardSettingsXMLParser($copy_settings_xml);
1191  try {
1192  $xml_parser->startParsing();
1193  } catch (ilSaxParserException $se){
1194  return $this->__raiseError($se->getMessage(), "Client");
1195  }
1196 
1197  // checking copy permissions, objects and create permissions
1198  if(!$rbacsystem->checkAccess('copy',$xml_parser->getSourceId()))
1199  {
1200  return $this->__raiseError("Missing copy permissions for object with reference id ".$xml_parser->getSourceId(), 'Client');
1201  }
1202 
1203  // checking copy permissions, objects and create permissions
1204  $source_id = $xml_parser->getSourceId();
1205  $target_id = $xml_parser->getTargetId();
1206 
1207 
1208  // does source object exist
1209  if(!$source_object_type = ilObjectFactory::getTypeByRefId($source_id, false))
1210  {
1211  return $this->__raiseError('No valid source given.', 'Client');
1212  }
1213 
1214  // does target object exist
1215  if(!$target_object_type = ilObjectFactory::getTypeByRefId($xml_parser->getTargetId(), false))
1216  {
1217  return $this->__raiseError('No valid target given.', 'Client');
1218  }
1219 
1220 
1221  $canAddType = $this->canAddType($source_object_type, $target_object_type, $target_id);
1222  if ($this->isFault($canAddType))
1223  {
1224  return $canAddType;
1225  }
1226 
1227  // if is container object than clone with sub items
1228  $options = $xml_parser->getOptions();
1229 // print_r($options);
1230  $source_object = ilObjectFactory::getInstanceByRefId($source_id);
1231  if ($source_object instanceof ilContainer) {
1232  // get client id from sid
1233  $clientid = substr($sid, strpos($sid, "::") + 2);
1234  $sessionid = str_replace("::".$clientid, "", $sid);
1235  // call container clone
1236  return $source_object->cloneAllObject($sessionid, $clientid,
1237  $source_object_type,
1238  $target_id,
1239  $source_id,
1240  $options, true);
1241 
1242  } else {
1243  // create copy wizard settings
1245  $wizard_options = ilCopyWizardOptions::_getInstance($copy_id);
1246  $wizard_options->saveOwner($ilUser->getId());
1247  $wizard_options->saveRoot($source_id);
1248 
1249  foreach($options as $source_id => $option)
1250  {
1251  $wizard_options->addEntry($source_id,$option);
1252  }
1253  $wizard_options->read();
1254 
1255  // call object clone
1256  $newObject = $source_object->cloneObject($xml_parser->getTargetId(), $copy_id);
1257  return is_object($newObject) ? $newObject->getRefId() : -1;
1258  }
1259  }
1260 
1261  function getPathForRefId($sid, $ref_id)
1262  {
1263  $this->initAuth($sid);
1264  $this->initIlias();
1265 
1266  if(!$this->__checkSession($sid))
1267  {
1268  return $this->__raiseError($this->__getMessage(),$this->__getMessageCode());
1269  }
1270 
1271  global $ilAccess, $objDefinition, $rbacsystem, $lng, $ilUser;
1272 
1273  if(!$rbacsystem->checkAccess('read', $ref_id))
1274  {
1275  return $this->__raiseError("Missing read permissions for object with reference id ".$ref_id, 'Client');
1276  }
1277 
1279  {
1280  return $this->__raiseError("Object is in Trash", 'Client');
1281  }
1282  global $tree, $lng;
1283  $items = $tree->getPathFull($ref_id);
1284 
1285  include_once 'webservice/soap/classes/class.ilXMLResultSet.php';
1286  include_once 'webservice/soap/classes/class.ilXMLResultSetWriter.php';
1287  include_once 'Modules/Course/classes/class.ilCourseXMLWriter.php';
1288 
1289  $xmlResultSet = new ilXMLResultSet();
1290  $xmlResultSet->addColumn("ref_id");
1291  $xmlResultSet->addColumn("type");
1292  $xmlResultSet->addColumn("title");
1293 
1294  $writer = new ilXMLResultSetWriter($xmlResultSet);
1295  foreach ($items as $item) {
1296  if ($item["ref_id"] == $ref_id)
1297  continue;
1298  if ($item["title"] == "ILIAS" && $item["type"] == "root")
1299  {
1300  $item["title"] = $lng->txt("repository");
1301  }
1302 
1303  $row = new ilXMLResultSetRow();
1304  $xmlResultSet->addRow($row);
1305  $row->setValue("ref_id", $item["ref_id"]);
1306  $row->setValue("type", $item["type"]);
1307  $row->setValue("title", $item["title"]);
1308  }
1309  $writer->start();
1310  return $writer->getXML();
1311  }
1312 
1313 
1314  private function canAddType ($type, $target_type, $target_id)
1315  {
1316  // checking for target subtypes. Can we add source to target
1317  global $objDefinition, $rbacsystem;
1318 
1319  $allowed_types = array('root','cat','grp','crs','fold');
1320  if(!in_array($target_type, $allowed_types))
1321  {
1322  return $this->__raiseError('No valid target type. Target must be reference id of "course, group, category or folder"', 'Client');
1323  }
1324 
1325  $allowed_subtypes = $objDefinition->getSubObjects($target_type);
1326  $allowed = array();
1327 
1328  foreach($allowed_subtypes as $row)
1329  {
1330  if($row['name'] != 'rolf')
1331  {
1332  $allowed[] = $row['name'];
1333  }
1334  }
1335 
1336  if(!in_array($type, $allowed))
1337  {
1338  return $this->__raiseError('Objects of type: '.$type.' are not allowed to be subobjects of type '.$target_type.'!','Client');
1339  }
1340  if(!$rbacsystem->checkAccess('create',$target_id, $type))
1341  {
1342  return $this->__raiseError('No permission to create objects of type '.$type.'!', 'Client');
1343  }
1344 
1345  return true;
1346  }
1347 
1348  private function validateReferences($a_action,$a_object_data,$a_target_id = 0)
1349  {
1350  global $ilAccess;
1351 
1352  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1353  {
1354  return true;
1355  }
1356  if($a_action == 'create')
1357  {
1358  if(count($a_object_data['references']) > 1)
1359  {
1360  if(in_array($a_object_data['type'],array('cat','crs','grp','fold')))
1361  {
1362  return $this->__raiseError("Cannot create references for type ".$a_object_data['type'],
1363  'Client');
1364  }
1365  }
1366  if(count($a_object_data['references']) == 1)
1367  {
1368  if($a_target_id != $a_object_data['references'][0]['parent_id'])
1369  {
1370  return $this->__raiseError("Cannot create references for type ".$a_object_data['type'],
1371  'Client');
1372  }
1373  }
1374 
1375  foreach($a_object_data['references'] as $ref_data)
1376  {
1377  if(!$ref_data['parent_id'])
1378  {
1379  return $this->__raiseError('Element References: No parent Id given!','Client');
1380  }
1381 
1382  $target_type = ilObject::_lookupType(ilObject::_lookupObjId($ref_data['parent_id']));
1383  $can_add_type = $this->canAddType($a_object_data['type'],$target_type,$ref_data['parent_id']);
1384  if($this->isFault($can_add_type))
1385  {
1386  return $can_add_type;
1387  }
1388  }
1389  return true;
1390  }
1391 
1392  if($a_action == 'update')
1393  {
1394  foreach($a_object_data['references'] as $ref_data)
1395  {
1396  if(!$ref_data['ref_id'])
1397  {
1398  return $this->__raiseError('Element References: No reference id given!','Client');
1399  }
1400  // check permissions
1401  if(!$ilAccess->checkAccess('write','',$ref_data['ref_id']))
1402  {
1403  return $this->__raiseError('No write permission for object with reference id '.$ref_data['ref_id'].'!', 'Client');
1404  }
1405  // TODO: check if all references belong to the same object
1406  }
1407  return true;
1408  }
1409  }
1410 
1411  private function updateReferences($a_object_data)
1412  {
1413  global $tree,$ilLog;
1414 
1415  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1416  {
1417  return true;
1418  }
1419 
1420  foreach($a_object_data['references'] as $ref_data)
1421  {
1422  if(isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($ref_data['ref_id'],'crs')) */)
1423  {
1424  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1425  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1426  $old = ilObjectActivation::getItem($ref_data['ref_id']);
1427 
1428  $items = new ilObjectActivation();
1429  $items->toggleChangeable(isset($ref_data['time_target']['changeable']) ? $ref_data['time_target']['changeable'] : $old['changeable']);
1430  $items->setTimingStart(isset($ref_data['time_target']['starting_time']) ? $ref_data['time_target']['starting_time'] : $old['timing_start']);
1431  $items->setTimingEnd(isset($ref_data['time_target']['ending_time']) ? $ref_data['time_target']['ending_time'] : $old['timing_end']);
1432  $items->toggleVisible(isset($ref_data['time_target']['timing_visibility']) ? $ref_data['time_target']['timing_visibility'] : $old['visible']);
1433  $items->setSuggestionStart(isset($ref_data['time_target']['suggestion_start']) ? $ref_data['time_target']['suggestion_start'] : $old['suggestion_start']);
1434  $items->setSuggestionEnd(isset($ref_data['time_target']['suggestion_end']) ? $ref_data['time_target']['suggestion_end'] : $old['suggestion_end']);
1435  $items->setEarliestStart(isset($ref_data['time_target']['earliest_start']) ? $ref_data['time_target']['earliest_start'] : $old['earliest_start']);
1436  $items->setLatestEnd(isset($ref_data['time_target']['latest_end']) ? $ref_data['time_target']['latest_end'] : $old['latest_end']);
1437 
1438  switch($ref_data['time_target']['timing_type'])
1439  {
1441  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_DEACTIVATED.' '.$ref_data['time_target']['timing_type']);
1442  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1443  break;
1444 
1446  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_ACTIVATION.' '.$ref_data['time_target']['timing_type']);
1447  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1448  break;
1449 
1451  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_PRESETTING.' '.$ref_data['time_target']['timing_type']);
1452  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1453  break;
1454  }
1455  $items->update($ref_data['ref_id']);
1456  }
1457  }
1458  return true;
1459  }
1460 
1461 
1462  private function addReferences($source,$a_object_data)
1463  {
1464  global $tree,$ilLog;
1465 
1466  if(!isset($a_object_data['references']) or !count($a_object_data['references']))
1467  {
1468  return true;
1469  }
1470 
1471  $original_id = $source->getRefId();
1472 
1473  foreach($a_object_data['references'] as $ref_data)
1474  {
1475  $new_ref_id = $ref_id = $original_id;
1476  if($tree->getParentId($original_id) != $ref_data['parent_id'])
1477  {
1478  // New reference requested => create it
1479  $new_ref_id = $source->createReference();
1480  $source->putInTree($ref_data['parent_id']);
1481  $source->setPermissions($ref_data['parent_id']);
1482  }
1483  if(isset($ref_data['time_target']) /* and ($crs_ref_id = $tree->checkForParentType($new_ref_id,'crs')) */)
1484  {
1485  include_once('./webservice/soap/classes/class.ilObjectXMLWriter.php');
1486  include_once('./Services/Object/classes/class.ilObjectActivation.php');
1487 
1488  if(!isset($ref_data['time_target']['starting_time']))
1489  {
1490  $ref_data['time_target']['starting_time'] = time();
1491  }
1492  if(!isset($ref_data['time_target']['ending_time']))
1493  {
1494  $ref_data['time_target']['ending_time'] = time();
1495  }
1496 
1497  $items = new ilObjectActivation();
1498  $items->toggleChangeable($ref_data['time_target']['changeable']);
1499  $items->setTimingStart($ref_data['time_target']['starting_time']);
1500  $items->setTimingEnd($ref_data['time_target']['ending_time']);
1501  $items->toggleVisible($ref_data['time_target']['timing_visibility']);
1502  $items->setSuggestionStart($ref_data['time_target']['suggestion_start']);
1503  $items->setSuggestionEnd($ref_data['time_target']['suggestion_end']);
1504  $items->setEarliestStart($ref_data['time_target']['earliest_start']);
1505  $items->setLatestEnd($ref_data['time_target']['latest_end']);
1506 
1507  switch($ref_data['time_target']['timing_type'])
1508  {
1510  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_DEACTIVATED.' '.$ref_data['time_target']['timing_type']);
1511  $items->setTimingType(ilObjectActivation::TIMINGS_DEACTIVATED);
1512  break;
1513 
1515  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_ACTIVATION.' '.$ref_data['time_target']['timing_type']);
1516  $items->setTimingType(ilObjectActivation::TIMINGS_ACTIVATION);
1517  break;
1518 
1520  $ilLog->write(__METHOD__.ilObjectActivation::TIMINGS_PRESETTING.' '.$ref_data['time_target']['timing_type']);
1521  $items->setTimingType(ilObjectActivation::TIMINGS_PRESETTING);
1522  break;
1523  }
1524  $items->update($new_ref_id);
1525  }
1526  }
1527 
1528  }
1529 
1530 
1531 
1532 }
1533 ?>