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