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