ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAdvancedMDRecord.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once './Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordScope.php';
6
18{
19 private static $instances = array();
20
21 protected $record_id;
22
27
28 protected $import_id;
29 protected $active;
30 protected $title;
31 protected $description;
36 protected $obj_types = array();
37 protected $db = null;
38 protected $parent_obj; // [int]
39 protected $scope_enabled = false;
40
44 protected $scopes = [];
45
46
56 public function __construct($a_record_id = 0)
57 {
58 global $DIC;
59
60 $ilDB = $DIC['ilDB'];
61
62 $this->record_id = $a_record_id;
63 $this->db = $ilDB;
64
65 if ($this->getRecordId()) {
66 $this->read();
67 }
68 }
69
79 public static function _getInstanceByRecordId($a_record_id)
80 {
81 if (isset(self::$instances[$a_record_id])) {
82 return self::$instances[$a_record_id];
83 }
84 return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
85 }
86
94 public static function _getActiveSearchableRecords()
95 {
96 global $DIC;
97
98 $ilDB = $DIC['ilDB'];
99
100 $query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr " .
101 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " .
102 "WHERE searchable = 1 AND active = 1 ";
103
104 $res = $ilDB->query($query);
105 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
106 $records[] = self::_getInstanceByRecordId($row->record_id);
107 }
108 return $records ? $records : array();
109 }
110
119 public static function _lookupTitle($a_record_id)
120 {
121 static $title_cache = array();
122
123 if (isset($title_cache[$a_record_id])) {
124 return $title_cache[$a_record_id];
125 }
126
127 global $DIC;
128
129 $ilDB = $DIC['ilDB'];
130
131 $query = "SELECT title FROM adv_md_record " .
132 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
133 $res = $ilDB->query($query);
134 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
135
136 return $title_cache[$a_record_id] = $row->title;
137 }
138
147 public static function _lookupRecordIdByImportId($a_ilias_id)
148 {
149 global $DIC;
150
151 $ilDB = $DIC['ilDB'];
152
153 $query = "SELECT record_id FROM adv_md_record " .
154 "WHERE import_id = " . $ilDB->quote($a_ilias_id, 'text') . " ";
155 $res = $ilDB->query($query);
156 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
157 return $row->record_id;
158 }
159 return 0;
160 }
161
168 public static function _getAssignableObjectTypes($a_include_text = false)
169 {
170 global $DIC;
171
172 $objDefinition = $DIC['objDefinition'];
173 $lng = $DIC['lng'];
174
175 $types = array();
176 $filter = array();
177 $amet_types = $objDefinition->getAdvancedMetaDataTypes();
178
180 $filter = array_merge($filter, ilECSUtils::getPossibleRemoteTypes(false));
181 $filter[] = 'rtst';
182 }
183
184 foreach ($amet_types as $at) {
185 if (in_array($at["obj_type"], $filter)) {
186 continue;
187 }
188
189 if ($a_include_text) {
190 $text = $lng->txt("obj_" . $at["obj_type"]);
191 if ($at["sub_type"] != "") {
192 $lng->loadLanguageModule($at["obj_type"]);
193 $text .= ": " . $lng->txt($at["obj_type"] . "_" . $at["sub_type"]);
194 } else {
195 $at["sub_type"] = "-";
196 }
197 $at["text"] = $text;
198 }
199
200 $types[] = $at;
201 }
202
203 sort($types);
204 return $types;
205 }
206
215 public static function _getActivatedObjTypes()
216 {
217 global $DIC;
218
219 $ilDB = $DIC['ilDB'];
220
221 $query = "SELECT DISTINCT(obj_type) FROM adv_md_record_objs amo " .
222 "JOIN adv_md_record amr ON amo.record_id = amr.record_id " .
223 "WHERE active = 1 ";
224 $res = $ilDB->query($query);
225 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
226 $obj_types[] = $row->obj_type;
227 }
228 return $obj_types ? $obj_types : array();
229 }
230
240 public static function _getRecords()
241 {
242 global $DIC;
243
244 $ilDB = $DIC['ilDB'];
245
246 $query = "SELECT record_id FROM adv_md_record ORDER BY gpos ";
247 $res = $ilDB->query($query);
248 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
249 $records[] = ilAdvancedMDRecord::_getInstanceByRecordId($row->record_id);
250 }
251 return $records ? $records : array();
252 }
253
262 public static function _getAllRecordsByObjectType()
263 {
264 global $DIC;
265
266 $ilDB = $DIC['ilDB'];
267
268 $records = array();
269
270 $query = "SELECT * FROM adv_md_record_objs WHERE sub_type=" . $ilDB->quote("-", "text");
271 $res = $ilDB->query($query);
272 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
273 $records[$row->obj_type][] = self::_getInstanceByRecordId($row->record_id);
274 }
275 // #13359 hide ecs if not configured
277 $filter = ilECSUtils::getPossibleRemoteTypes(false);
278 $filter[] = 'rtst';
279 $records = array_diff_key($records, array_flip($filter));
280 }
281
282 return $records;
283 }
284
294 public static function _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type = "", $a_only_optional = false)
295 {
296 global $DIC;
297
298 $ilDB = $DIC['ilDB'];
299
300 $records = array();
301
302 if ($a_sub_type == "") {
303 $a_sub_type = "-";
304 }
305
306 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro " .
307 "JOIN adv_md_record amr ON amr.record_id = amro.record_id " .
308 "WHERE active = 1 " .
309 "AND obj_type = " . $ilDB->quote($a_obj_type, 'text') . " " .
310 "AND sub_type = " . $ilDB->quote($a_sub_type, 'text');
311
312 if ($a_only_optional) {
313 $query .= " AND optional =" . $ilDB->quote(1, 'integer');
314 }
315
316 // #16428
317 $query .= "ORDER by parent_obj DESC, record_id";
318
319 $res = $ilDB->query($query);
320 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
321 $records[] = self::_getInstanceByRecordId($row->record_id);
322 }
323
324 return $records;
325 }
326
334 public static function _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type = "")
335 {
336 $records = array();
337 // ilUtil::printBacktrace(10);
338 // var_dump($a_obj_type."-".$a_ref_id."-".$a_sub_type); exit;
339 if ($a_sub_type == "") {
340 $a_sub_type = "-";
341 }
342
343 $a_obj_id = ilObject::_lookupObjId($a_ref_id);
344
345 // object-wide metadata configuration setting
346 include_once 'Services/Container/classes/class.ilContainer.php';
347 include_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
348 $config_setting = ilContainer::_lookupContainerSetting(
349 $a_obj_id,
351 false
352 );
353
354 $optional = array();
355 foreach (self::_getActivatedRecordsByObjectType($a_obj_type, $a_sub_type) as $record) {
356 // check scope
357 if (self::isFilteredByScope($a_ref_id, $record->getScopes())) {
358 continue;
359 }
360
361 foreach ($record->getAssignedObjectTypes() as $item) {
362 if ($record->getParentObject()) {
363 // only matching local records
364 if ($record->getParentObject() != $a_obj_id) {
365 continue;
366 }
367 // if object-wide setting is off, ignore local records
368 elseif (!$config_setting) {
369 continue;
370 }
371 }
372
373 if ($item['obj_type'] == $a_obj_type &&
374 $item['sub_type'] == $a_sub_type) {
375 if ($item['optional']) {
376 $optional[] = $record->getRecordId();
377 }
378 $records[$record->getRecordId()] = $record;
379 }
380 }
381 }
382
383 if ($optional) {
384 if (!$config_setting && !in_array($a_sub_type, array("orgu_type", "prg_type"))) { //#16925 + #17777
385 $selected = array();
386 } else {
387 $selected = self::getObjRecSelection($a_obj_id, $a_sub_type);
388 }
389 foreach ($optional as $record_id) {
390 if (!in_array($record_id, $selected)) {
391 unset($records[$record_id]);
392 }
393 }
394 }
395
396
397 $orderings = new ilAdvancedMDRecordObjectOrderings();
398 $records = $orderings->sortRecords($records, $a_obj_id);
399
400 return $records;
401 }
402
408 public static function isFilteredByScope($a_ref_id, array $scopes)
409 {
410 $tree = $GLOBALS['DIC']->repositoryTree();
411 $logger = $GLOBALS['DIC']->logger()->amet();
412
413 if (!count($scopes)) {
414 return false;
415 }
416 foreach ($scopes as $scope) {
417 $logger->debug('Comparing: ' . $a_ref_id . ' with: ' . $scope->getRefId());
418 if ($scope->getRefId() == $a_ref_id) {
419 $logger->debug('Elements are equal. No scope restrictions.');
420 return false;
421 }
422 if ($tree->getRelation($scope->getRefId(), $a_ref_id) == ilTree::RELATION_PARENT) {
423 $logger->debug('Node is child node. No scope restrictions.');
424 return false;
425 }
426 }
427 $logger->info('Scope filter matches.');
428
429 return true;
430 }
431
432
441 public static function _delete($a_record_id)
442 {
443 global $DIC;
444
445 $ilDB = $DIC['ilDB'];
446
447 // Delete fields
448 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($a_record_id) as $field) {
449 $field->delete();
450 }
451
452 $query = "DELETE FROM adv_md_record " .
453 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
454 $res = $ilDB->manipulate($query);
455
456 $query = "DELETE FROM adv_md_record_objs " .
457 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
458 $res = $ilDB->manipulate($query);
459 }
460
464 public function setDefaultLanguage(string $language_code)
465 {
466 $this->language_default = $language_code;
467 }
468
469 public function getDefaultLanguage() :string
470 {
471 return (string) $this->language_default;
472 }
473
474
481 public function delete()
482 {
485 }
486
491 public function enabledScope()
492 {
494 }
495
500 public function enableScope($a_stat)
501 {
502 $this->scope_enabled = $a_stat;
503 }
504
509 public function setScopes(array $a_scopes)
510 {
511 $this->scopes = $a_scopes;
512 }
513
518 public function getScopes()
519 {
520 return $this->scopes;
521 }
522
527 public function getScopeRefIds()
528 {
529 $ref_ids = [];
530 foreach ($this->scopes as $scope) {
531 $ref_ids[] = $scope->getRefId();
532 }
533 return $ref_ids;
534 }
535
542 public function save()
543 {
544 global $DIC;
545
546 $ilDB = $DIC['ilDB'];
547
548 // Save import id if given
549 $next_id = $ilDB->nextId('adv_md_record');
550
551 $query = "INSERT INTO adv_md_record (record_id,import_id,active,title,description,parent_obj,lang_default) " .
552 "VALUES(" .
553 $ilDB->quote($next_id, 'integer') . ", " .
554 $this->db->quote($this->getImportId(), 'text') . ", " .
555 $this->db->quote($this->isActive(), 'integer') . ", " .
556 $this->db->quote($this->getTitle(), 'text') . ", " .
557 $this->db->quote($this->getDescription(), 'text') . ", " .
558 $this->db->quote($this->getParentObject(), 'integer') . ", " .
559 $this->db->quote((string) $this->getDefaultLanguage(), ilDBConstants::T_TEXT) .
560 ")";
561 $res = $ilDB->manipulate($query);
562 $this->record_id = $next_id;
563
564 if (!strlen($this->getImportId())) {
565 // set import id to default value
566 $query = "UPDATE adv_md_record " .
567 "SET import_id = " . $this->db->quote($this->generateImportId(), 'text') . " " .
568 "WHERE record_id = " . $this->db->quote($this->record_id, 'integer') . " ";
569 $res = $ilDB->manipulate($query);
570 }
571
572 foreach ($this->getAssignedObjectTypes() as $type) {
573 global $DIC;
574
575 $ilDB = $DIC['ilDB'];
576
577 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
578 "VALUES( " .
579 $this->db->quote($this->getRecordId(), 'integer') . ", " .
580 $this->db->quote($type["obj_type"], 'text') . ", " .
581 $this->db->quote($type["sub_type"], 'text') . ", " .
582 $this->db->quote($type["optional"], 'integer') . " " .
583 ")";
584 $res = $ilDB->manipulate($query);
585 }
586
587 foreach ($this->getScopes() as $scope) {
588 $scope->setRecordId($this->getRecordId());
589 $scope->save();
590 }
591 }
592
599 public function update()
600 {
601 global $DIC;
602
603 $ilDB = $DIC['ilDB'];
604
605 $query = "UPDATE adv_md_record " .
606 "SET active = " . $this->db->quote($this->isActive(), 'integer') . ", " .
607 "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
608 "description = " . $this->db->quote($this->getDescription(), 'text') . ", " .
609 'gpos = ' . $this->db->quote($this->getGlobalPosition(), 'integer') . ', ' .
610 'lang_default = ' . $this->db->quote($this->getDefaultLanguage(), ilDBConstants::T_TEXT) . ' ' .
611 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
612 $res = $ilDB->manipulate($query);
613
614 // Delete assignments
615 $query = "DELETE FROM adv_md_record_objs " .
616 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
617 $res = $ilDB->manipulate($query);
618
619 // Insert assignments
620 foreach ($this->getAssignedObjectTypes() as $type) {
621 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
622 "VALUES ( " .
623 $this->db->quote($this->getRecordId(), 'integer') . ", " .
624 $this->db->quote($type["obj_type"], 'text') . ", " .
625 $this->db->quote($type["sub_type"], 'text') . ", " .
626 $this->db->quote($type["optional"], 'integer') . " " .
627 ")";
628 $res = $ilDB->manipulate($query);
629 }
631 foreach ($this->getScopes() as $scope) {
632 $scope->setRecordId($this->getRecordId());
633 $scope->save();
634 }
635 }
636
643 public function validate()
644 {
645 if (!strlen($this->getTitle())) {
646 return false;
647 }
648 return true;
649 }
650
655 public function setGlobalPosition(int $position)
656 {
657 $this->global_position = $position;
658 }
659
663 public function getGlobalPosition() : int
664 {
666 }
667
668
675 public function getRecordId()
676 {
677 return $this->record_id;
678 }
679
687 public function setActive($a_active)
688 {
689 $this->active = $a_active;
690 }
691
698 public function isActive()
699 {
700 return (bool) $this->active;
701 }
702
710 public function setTitle($a_title)
711 {
712 $this->title = $a_title;
713 }
714
721 public function getTitle()
722 {
723 return $this->title;
724 }
725
733 public function setDescription($a_description)
734 {
735 $this->description = $a_description;
736 }
737
744 public function getDescription()
745 {
746 return $this->description;
747 }
748
756 public function setImportId($a_id_string)
757 {
758 $this->import_id = $a_id_string;
759 }
760
767 public function getImportId()
768 {
769 return $this->import_id;
770 }
771
779 public function setAssignedObjectTypes($a_obj_types)
780 {
781 $this->obj_types = $a_obj_types;
782 }
783
791 public function appendAssignedObjectType($a_obj_type, $a_sub_type, $a_optional = false)
792 {
793 $this->obj_types[] = array(
794 "obj_type" => $a_obj_type,
795 "sub_type" => $a_sub_type,
796 "optional" => (bool) $a_optional
797 );
798 }
799
806 public function getAssignedObjectTypes()
807 {
808 return $this->obj_types ? $this->obj_types : array();
809 }
810
817 public function isAssignedObjectType($a_obj_type, $a_sub_type)
818 {
819 foreach ($this->getAssignedObjectTypes() as $t) {
820 if ($t["obj_type"] == $a_obj_type &&
821 $t["sub_type"] == $a_sub_type) {
822 return true;
823 }
824 }
825 return false;
826 }
827
828 public function setParentObject($a_obj_id)
829 {
830 $this->parent_obj = $a_obj_id;
831 }
832
833 public function getParentObject()
834 {
835 return $this->parent_obj;
836 }
837
847 public function toXML(ilXmlWriter $writer)
848 {
849 $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0,
850 'id' => $this->generateImportId()));
851 $writer->xmlElement('Title', null, $this->getTitle());
852 $writer->xmlElement('Description', null, $this->getDescription());
853
855 $translations->toXML($writer);
856
857 foreach ($this->getAssignedObjectTypes() as $obj_type) {
858 $optional = array("optional" => $obj_type["optional"]);
859 if ($obj_type["sub_type"] == "") {
860 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"]);
861 } else {
862 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"] . ":" . $obj_type["sub_type"]);
863 }
864 }
865
866 // scopes
867 if (count($this->getScopeRefIds())) {
868 $writer->xmlStartTag('Scope');
869 }
870 foreach ($this->getScopeRefIds() as $ref_id) {
872 $writer->xmlElement('ScopeEntry', ['id' => 'il_' . IL_INST_ID . '_' . $type . '_' . $ref_id]);
873 }
874 if (count($this->getScopeRefIds())) {
875 $writer->xmlEndTag('Scope');
876 }
877
878
879 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
880 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
881 $definition->toXML($writer);
882 }
883 $writer->xmlEndTag('Record');
884 }
885
893 private function read()
894 {
895 global $DIC;
896
897 $ilDB = $DIC['ilDB'];
898
899 $query = "SELECT * FROM adv_md_record " .
900 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
901 $res = $this->db->query($query);
902 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
903 $this->setImportId($row->import_id);
904 $this->setActive($row->active);
905 $this->setTitle($row->title);
906 $this->setDescription($row->description);
907 $this->setParentObject($row->parent_obj);
908 $this->setGlobalPosition((int) $row->gpos);
909 $this->setDefaultLanguage((string) $row->lang_default);
910 }
911 $query = "SELECT * FROM adv_md_record_objs " .
912 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
913 $res = $this->db->query($query);
914 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
915 $this->obj_types[] = array(
916 "obj_type" => $row->obj_type,
917 "sub_type" => $row->sub_type,
918 "optional" => (bool) $row->optional
919 );
920 }
921
922 $query = 'SELECT scope_id FROM adv_md_record_scope ' .
923 'WHERE record_id = ' . $ilDB->quote($this->record_id);
924 $res = $ilDB->query($query);
925 $this->scope_enabled = false;
926 $this->scopes = [];
927 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
928 $this->scope_enabled = true;
929 $this->scopes[] = new ilAdvancedMDRecordScope($row->scope_id);
930 }
931 }
932
939 protected function generateImportId()
940 {
941 return 'il_' . IL_INST_ID . '_adv_md_record_' . $this->getRecordId();
942 }
943
950 public function __destruct()
951 {
952 unset(self::$instances[$this->getRecordId()]);
953 }
954
964 public static function saveObjRecSelection($a_obj_id, $a_sub_type = "", array $a_records = null, $a_delete_before = true)
965 {
966 global $DIC;
967
968 $ilDB = $DIC['ilDB'];
969
970 if ($a_sub_type == "") {
971 $a_sub_type = "-";
972 }
973
974 if ((bool) $a_delete_before) {
975 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
976 " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
977 " AND sub_type = " . $ilDB->quote($a_sub_type, "text"));
978 }
979
980 if (is_array($a_records)) {
981 foreach ($a_records as $r) {
982 if ($r > 0) {
983 $ilDB->manipulate("INSERT INTO adv_md_obj_rec_select " .
984 "(obj_id, rec_id, sub_type) VALUES (" .
985 $ilDB->quote($a_obj_id, "integer") . "," .
986 $ilDB->quote($r, "integer") . "," .
987 $ilDB->quote($a_sub_type, "text") .
988 ")");
989 }
990 }
991 }
992 }
993
1000 public static function getObjRecSelection($a_obj_id, $a_sub_type = "")
1001 {
1002 global $DIC;
1003
1004 $ilDB = $DIC['ilDB'];
1005
1006 if ($a_sub_type == "") {
1007 $a_sub_type = "-";
1008 }
1009
1010 $recs = array();
1011 $set = $ilDB->query(
1012 $r = "SELECT * FROM adv_md_obj_rec_select " .
1013 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
1014 " AND sub_type = " . $ilDB->quote($a_sub_type, "text")
1015 );
1016 while ($rec = $ilDB->fetchAssoc($set)) {
1017 $recs[] = $rec["rec_id"];
1018 }
1019 return $recs;
1020 }
1021
1029 public function _clone(array &$a_fields_map, $a_parent_obj_id = null)
1030 {
1031 $new_obj = new self();
1032 $new_obj->setActive($this->isActive());
1033 $new_obj->setTitle($this->getTitle());
1034 $new_obj->setDescription($this->getDescription());
1035 $new_obj->setParentObject($a_parent_obj_id
1036 ? $a_parent_obj_id
1037 : $this->getParentObject());
1038 $new_obj->setAssignedObjectTypes($this->getAssignedObjectTypes());
1039 $new_obj->setDefaultLanguage($this->getDefaultLanguage());
1040 $new_obj->save();
1041
1042 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
1043 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
1044 $new_def = $definition->_clone($new_obj->getRecordId());
1045 $a_fields_map[$definition->getFieldId()] = $new_def->getFieldId();
1046 }
1047
1049 $record_translation->cloneRecord($new_obj->getRecordId());
1050
1051 return $new_obj;
1052 }
1053
1062 public static function getSharedRecords($a_obj1_id, $a_obj2_id, $a_sub_type = "-")
1063 {
1064 $obj_type = ilObject::_lookupType($a_obj1_id);
1065 $sel = array_intersect(
1066 ilAdvancedMDRecord::getObjRecSelection($a_obj1_id, $a_sub_type),
1067 ilAdvancedMDRecord::getObjRecSelection($a_obj2_id, $a_sub_type)
1068 );
1069
1070 $res = array();
1071
1072 foreach (self::_getRecords() as $record) {
1073 // local records cannot be shared
1074 if ($record->getParentObject()) {
1075 continue;
1076 }
1077
1078 // :TODO: inactive records can be ignored?
1079 if (!$record->isActive()) {
1080 continue;
1081 }
1082
1083 // parse assigned types
1084 foreach ($record->getAssignedObjectTypes() as $item) {
1085 if ($item["obj_type"] == $obj_type &&
1086 $item["sub_type"] == $a_sub_type) {
1087 // mandatory
1088 if (!$item["optional"]) {
1089 $res[] = $record->getRecordId();
1090 }
1091 // optional
1092 elseif (in_array($record->getRecordId(), $sel)) {
1093 $res[] = $record->getRecordId();
1094 }
1095 }
1096 }
1097 }
1098
1099 return $res;
1100 }
1101}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
static getInstancesByRecordId($a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
Scope restrictions for advanced md records.
static deleteByRecordI($a_record_id)
delete by record id
static _lookupTitle($a_record_id)
Lookup title.
isAssignedObjectType($a_obj_type, $a_sub_type)
Is assigned object type?
static _getSelectedRecordsByObject($a_obj_type, $a_ref_id, $a_sub_type="")
Get selected records by object.
setTitle($a_title)
Set title.
static saveObjRecSelection($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
Save repository object record selection.
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
setDescription($a_description)
set description
static getSharedRecords($a_obj1_id, $a_obj2_id, $a_sub_type="-")
Get shared records.
appendAssignedObjectType($a_obj_type, $a_sub_type, $a_optional=false)
append assigned object types
isActive()
Check if record is active.
toXML(ilXmlWriter $writer)
To Xml.
generateImportId()
generate unique record id
static _getActivatedRecordsByObjectType($a_obj_type, $a_sub_type="", $a_only_optional=false)
Get activated records by object type.
static _getAllRecordsByObjectType()
Get records by obj_type Note: this returns only records with no sub types! @access public.
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
static _getActivatedObjTypes()
get activated obj types
setActive($a_active)
Set active.
read()
read record and assiged object types
static _delete($a_record_id)
Delete record and all related data.
validate()
Validate settings.
setDefaultLanguage(string $language_code)
getScopeRefIds()
Get scope gef_ids.
static _getRecords()
Get records.
setGlobalPosition(int $position)
Set global position.
enabledScope()
Is scope enabled.
setImportId($a_id_string)
set import id
getAssignedObjectTypes()
Get assigned object types.
static _getAssignableObjectTypes($a_include_text=false)
Get assignable object type.
enableScope($a_stat)
Enable scope restrictions.
_clone(array &$a_fields_map, $a_parent_obj_id=null)
Clone record.
__construct($a_record_id=0)
Singleton constructor To create an array of new records (without saving them) call the constructor di...
static isFilteredByScope($a_ref_id, array $scopes)
Check if a given ref id is not filtered by scope restriction.
setAssignedObjectTypes($a_obj_types)
Set assigned object types.
setScopes(array $a_scopes)
Set scopes.
static _lookupRecordIdByImportId($a_ilias_id)
Lookup record Id by import id.
static _getActiveSearchableRecords()
Get active searchable records.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static ecsConfigured()
Checks if an ecs server is configured.
static getPossibleRemoteTypes($a_with_captions=false)
Get all possible remote object types.
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
const RELATION_PARENT
XML writer class.
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
const IL_INST_ID
Definition: constants.php:38
global $DIC
Definition: goto.php:24
$query
$type
$lng
foreach($_POST as $key=> $value) $res
global $ilDB