ILIAS  release_8 Revision v8.24
ilAdvancedMDRecord Class Reference
+ Collaboration diagram for ilAdvancedMDRecord:

Public Member Functions

 __construct (int $a_record_id=0)
 Singleton constructor To create an array of new records (without saving them) call the constructor directly. More...
 
 setDefaultLanguage (string $language_code)
 
 getDefaultLanguage ()
 
 delete ()
 
 enabledScope ()
 
 enableScope (bool $a_stat)
 
 setScopes (array $a_scopes)
 
 getScopes ()
 Get scopes. More...
 
 getScopeRefIds ()
 
 save ()
 
 update ()
 
 validate ()
 
 setGlobalPosition (int $position)
 
 getGlobalPosition ()
 
 getRecordId ()
 
 setActive (bool $a_active)
 
 isActive ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setDescription (string $a_description)
 
 getDescription ()
 
 setImportId (string $a_id_string)
 
 getImportId ()
 
 setAssignedObjectTypes (array $a_obj_types)
 
 appendAssignedObjectType (string $a_obj_type, string $a_sub_type, bool $a_optional=false)
 
 getAssignedObjectTypes ()
 
 isAssignedObjectType (string $a_obj_type, string $a_sub_type)
 
 setParentObject (int $a_obj_id)
 
 getParentObject ()
 
 toXML (ilXmlWriter $writer)
 To Xml. More...
 
 __destruct ()
 
 _clone (array &$a_fields_map, int $a_parent_obj_id=null)
 

Static Public Member Functions

static _getInstanceByRecordId (int $a_record_id)
 
static _getActiveSearchableRecords ()
 Get active searchable records. More...
 
static _lookupTitle (int $a_record_id)
 
static _lookupRecordIdByImportId (string $a_ilias_id)
 
static _getAssignableObjectTypes (bool $a_include_text=false)
 Get assignable object type @access public. More...
 
static _getActivatedObjTypes ()
 get activated obj types More...
 
static _getRecords ()
 Get records @access public. More...
 
static _getAllRecordsByObjectType ()
 Get records by obj_type Note: this returns only records with no sub types! More...
 
static _getActivatedRecordsByObjectType (string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
 Get activated records by object type. More...
 
static _getSelectedRecordsByObject (string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
 
static isFilteredByScope ($a_ref_id, array $scopes)
 Check if a given ref id is not filtered by scope restriction. More...
 
static _delete ($a_record_id)
 
static saveObjRecSelection (int $a_obj_id, string $a_sub_type="", array $a_records=null, bool $a_delete_before=true)
 Save repository object record selection. More...
 
static deleteObjRecSelection (int $a_obj_id)
 Delete repository object record selection. More...
 
static getObjRecSelection (int $a_obj_id, string $a_sub_type="")
 Get repository object record selection. More...
 
static getSharedRecords (int $a_obj1_id, int $a_obj2_id, string $a_sub_type="-")
 

Protected Member Functions

 setRecordId (int $record_id)
 
 generateImportId ()
 generate unique record id More...
 

Protected Attributes

int $record_id
 
int $global_position = 0
 
string $import_id = ''
 
bool $active = false
 
string $title = ''
 
string $description = ''
 
string $language_default = ''
 
array $obj_types = array()
 
int $parent_obj = 0
 
bool $scope_enabled = false
 
array $scopes = []
 
ilDBInterface $db
 

Private Member Functions

 read ()
 

Static Private Attributes

static $instances = []
 

Detailed Description

Definition at line 12 of file class.ilAdvancedMDRecord.php.

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDRecord::__construct ( int  $a_record_id = 0)

Singleton constructor To create an array of new records (without saving them) call the constructor directly.

Otherwise call getInstance... @access public

Parameters
intrecord id

Definition at line 45 of file class.ilAdvancedMDRecord.php.

46 {
47 global $DIC;
48
49 $this->db = $DIC->database();
50 $this->record_id = $a_record_id;
51
52 if ($this->getRecordId()) {
53 $this->read();
54 }
55 }
global $DIC
Definition: feed.php:28

References $DIC, getRecordId(), and read().

+ Here is the call graph for this function:

◆ __destruct()

ilAdvancedMDRecord::__destruct ( )

Definition at line 746 of file class.ilAdvancedMDRecord.php.

747 {
748 unset(self::$instances[$this->getRecordId()]);
749 }

References ILIAS\LTI\ToolProvider\getRecordId().

+ Here is the call graph for this function:

Member Function Documentation

◆ _clone()

ilAdvancedMDRecord::_clone ( array &  $a_fields_map,
int  $a_parent_obj_id = null 
)

Definition at line 834 of file class.ilAdvancedMDRecord.php.

835 {
836 $new_obj = new self();
837 $new_obj->setActive($this->isActive());
838 $new_obj->setTitle($this->getTitle());
839 $new_obj->setDescription($this->getDescription());
840 $new_obj->setParentObject($a_parent_obj_id
841 ?: $this->getParentObject());
842 $new_obj->setAssignedObjectTypes($this->getAssignedObjectTypes());
843 $new_obj->setDefaultLanguage($this->getDefaultLanguage());
844 $new_obj->save();
845
846 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
847 $new_def = $definition->_clone($new_obj->getRecordId());
848 $a_fields_map[$definition->getFieldId()] = $new_def->getFieldId();
849 }
850
852 $record_translation->cloneRecord($new_obj->getRecordId());
853
854 return $new_obj;
855 }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.

References ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ILIAS\LTI\ToolProvider\getRecordId(), and setActive().

+ Here is the call graph for this function:

◆ _delete()

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

Definition at line 379 of file class.ilAdvancedMDRecord.php.

379 : void
380 {
381 global $DIC;
382
383 $ilDB = $DIC['ilDB'];
384
385 // Delete fields
386 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($a_record_id) as $field) {
387 $field->delete();
388 }
389
390 $query = "DELETE FROM adv_md_record " .
391 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
392 $res = $ilDB->manipulate($query);
393
394 $query = "DELETE FROM adv_md_record_objs " .
395 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
396 $res = $ilDB->manipulate($query);
397 }
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, $res, and ilAdvancedMDFieldDefinition\getInstancesByRecordId().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getActivatedObjTypes()

static ilAdvancedMDRecord::_getActivatedObjTypes ( )
static

get activated obj types

Returns
string[]

Definition at line 170 of file class.ilAdvancedMDRecord.php.

170 : array
171 {
172 global $DIC;
173
174 $ilDB = $DIC['ilDB'];
175
176 $query = "SELECT DISTINCT(obj_type) FROM adv_md_record_objs amo " .
177 "JOIN adv_md_record amr ON amo.record_id = amr.record_id " .
178 "WHERE active = 1 ";
179 $res = $ilDB->query($query);
180 $obj_types = [];
181 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
182 $obj_types[] = (string) $row->obj_type;
183 }
184 return $obj_types;
185 }

References $DIC, $ilDB, $obj_types, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAdvancedSearchGUI\__setSearchOptions(), ilAdvancedSearchGUI\initAdvancedMetaDataForm(), and ilAdvancedMDSettingsGUI\updateSubstitutions().

+ Here is the caller graph for this function:

◆ _getActivatedRecordsByObjectType()

static ilAdvancedMDRecord::_getActivatedRecordsByObjectType ( string  $a_obj_type,
string  $a_sub_type = "",
bool  $a_only_optional = false 
)
static

Get activated records by object type.

Returns
ilAdvancedMDRecord[]

Definition at line 240 of file class.ilAdvancedMDRecord.php.

244 : array {
245 global $DIC;
246
247 $ilDB = $DIC['ilDB'];
248
249 if ($a_sub_type == "") {
250 $a_sub_type = "-";
251 }
252
253 $records = [];
254 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro " .
255 "JOIN adv_md_record amr ON amr.record_id = amro.record_id " .
256 "WHERE active = 1 " .
257 "AND obj_type = " . $ilDB->quote($a_obj_type, 'text') . " " .
258 "AND sub_type = " . $ilDB->quote($a_sub_type, 'text');
259
260 if ($a_only_optional) {
261 $query .= " AND optional =" . $ilDB->quote(1, 'integer');
262 }
263
264 // #16428
265 $query .= "ORDER by parent_obj DESC, record_id";
266
267 $res = $ilDB->query($query);
268 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
269 $records[] = self::_getInstanceByRecordId((int) $row->record_id);
270 }
271 return $records;
272 }
static _getInstanceByRecordId(int $a_record_id)

Referenced by ilExerciseExporter\getActiveAdvMDRecords(), ilGlossaryExporter\getActiveAdvMDRecords(), ilSessionExporter\getActiveAdvMDRecords(), ilWikiExporter\getActiveAdvMDRecords(), ilStudyProgrammeTypeDBRepository\getAllAMDRecords(), ilOrgUnitType\getAvailableAdvancedMDRecords(), ilContainerFilterAdvMDAdapter\getAvailableRecordSets(), and ilAdvancedMDRecordGUI\parseRecordSelection().

+ Here is the caller graph for this function:

◆ _getActiveSearchableRecords()

static ilAdvancedMDRecord::_getActiveSearchableRecords ( )
static

Get active searchable records.

Returns
ilAdvancedMDRecord[]

Definition at line 69 of file class.ilAdvancedMDRecord.php.

69 : array
70 {
71 global $DIC;
72
73 $ilDB = $DIC['ilDB'];
74
75 $query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr " .
76 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " .
77 "WHERE searchable = 1 AND active = 1 ";
78
79 $res = $ilDB->query($query);
80 $records = [];
81 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
82 $records[] = self::_getInstanceByRecordId((int) $row->record_id);
83 }
84 return $records;
85 }

References $DIC, $ilDB, $query, $res, _getInstanceByRecordId(), and ilDBConstants\FETCHMODE_OBJECT.

+ Here is the call graph for this function:

◆ _getAllRecordsByObjectType()

static ilAdvancedMDRecord::_getAllRecordsByObjectType ( )
static

Get records by obj_type Note: this returns only records with no sub types!

Returns
array<string, array<int, ilAdvancedMDRecord>

Definition at line 214 of file class.ilAdvancedMDRecord.php.

214 : array
215 {
216 global $DIC;
217
218 $ilDB = $DIC['ilDB'];
219
220 $records = [];
221 $query = "SELECT * FROM adv_md_record_objs WHERE sub_type=" . $ilDB->quote("-", "text");
222 $res = $ilDB->query($query);
223 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
224 $records[(string) $row->obj_type][] = self::_getInstanceByRecordId((int) $row->record_id);
225 }
226 // #13359 hide ecs if not configured
228 $filter = ilECSUtils::getPossibleRemoteTypes(false);
229 $filter[] = 'rtst';
230 $records = array_diff_key($records, array_flip($filter));
231 }
232
233 return $records;
234 }
static ecsConfigured()
Checks if an ecs server is configured.
static getPossibleRemoteTypes(bool $a_with_captions=false)
Get all possible remote object types.

References $DIC, $ilDB, $query, $res, ilECSSetting\ecsConfigured(), ilDBConstants\FETCHMODE_OBJECT, and ilECSUtils\getPossibleRemoteTypes().

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), and ilAdvancedMDSettingsGUI\setSubTabs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAssignableObjectTypes()

static ilAdvancedMDRecord::_getAssignableObjectTypes ( bool  $a_include_text = false)
static

Get assignable object type @access public.

Definition at line 127 of file class.ilAdvancedMDRecord.php.

127 : array
128 {
129 global $DIC;
130
131 $objDefinition = $DIC['objDefinition'];
132 $lng = $DIC['lng'];
133
134 $types = array();
135 $filter = array();
136 $amet_types = $objDefinition->getAdvancedMetaDataTypes();
137
139 $filter = array_merge($filter, ilECSUtils::getPossibleRemoteTypes(false));
140 $filter[] = 'rtst';
141 }
142
143 foreach ($amet_types as $at) {
144 if (in_array($at["obj_type"], $filter)) {
145 continue;
146 }
147
148 if ($a_include_text) {
149 $text = $lng->txt("obj_" . $at["obj_type"]);
150 if ($at["sub_type"] != "") {
151 $lng->loadLanguageModule($at["obj_type"]);
152 $text .= ": " . $lng->txt($at["obj_type"] . "_" . $at["sub_type"]);
153 } else {
154 $at["sub_type"] = "-";
155 }
156 $at["text"] = $text;
157 }
158
159 $types[] = $at;
160 }
161
162 sort($types);
163 return $types;
164 }
$lng

References $DIC, $lng, ilECSSetting\ecsConfigured(), and ilECSUtils\getPossibleRemoteTypes().

Referenced by ilAdvancedMDRecordTableGUI\fillRow(), ilAdvancedMDSettingsGUI\initForm(), ilObjectMetaDataGUI\isAdvMDAvailable(), and ilAdvancedMDSettingsGUI\loadRecordFormData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getInstanceByRecordId()

◆ _getRecords()

static ilAdvancedMDRecord::_getRecords ( )
static

Get records @access public.

Parameters
arrayarray of record objects
Returns
ilAdvancedMDRecord[]

Definition at line 194 of file class.ilAdvancedMDRecord.php.

194 : array
195 {
196 global $DIC;
197
198 $ilDB = $DIC['ilDB'];
199
200 $query = "SELECT record_id FROM adv_md_record ORDER BY gpos ";
201 $res = $ilDB->query($query);
202 $records = [];
203 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
204 $records[] = ilAdvancedMDRecord::_getInstanceByRecordId((int) $row->record_id);
205 }
206 return $records;
207 }

References $DIC, $ilDB, $query, $res, _getInstanceByRecordId(), and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLuceneAdvancedSearchFields\getFields(), and ilAdvancedMDSettingsGUI\getParsedRecordObjects().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getSelectedRecordsByObject()

static ilAdvancedMDRecord::_getSelectedRecordsByObject ( string  $a_obj_type,
int  $a_id,
string  $a_sub_type = "",
bool  $is_ref_id = true 
)
static
Parameters
string$a_obj_type
int$a_id
string$a_sub_type
bool$is_ref_id
Returns
array<int, ilAdvancedMDRecord>

Definition at line 281 of file class.ilAdvancedMDRecord.php.

286 : array {
287 $records = array();
288
289 if ($a_sub_type == "") {
290 $a_sub_type = "-";
291 }
292
293 $a_obj_id = $is_ref_id
295 : $a_id;
296
297 // object-wide metadata configuration setting
298 $config_setting = ilContainer::_lookupContainerSetting(
299 $a_obj_id,
301 ''
302 );
303
304 $optional = array();
305 foreach (self::_getActivatedRecordsByObjectType($a_obj_type, $a_sub_type) as $record) {
306 // check scope
307 if ($is_ref_id && self::isFilteredByScope($a_id, $record->getScopes())) {
308 continue;
309 }
310 foreach ($record->getAssignedObjectTypes() as $item) {
311 if ($record->getParentObject()) {
312 // only matching local records
313 if ($record->getParentObject() != $a_obj_id) {
314 continue;
315 } // if object-wide setting is off, ignore local records
316 elseif (!$config_setting) {
317 continue;
318 }
319 }
320
321 if ($item['obj_type'] == $a_obj_type &&
322 $item['sub_type'] == $a_sub_type) {
323 if ($item['optional']) {
324 $optional[] = $record->getRecordId();
325 }
326 $records[$record->getRecordId()] = $record;
327 }
328 }
329 }
330
331 if ($optional) {
332 if (!$config_setting && !in_array($a_sub_type, array("orgu_type", "prg_type"))) { //#16925 + #17777
333 $selected = array();
334 } else {
335 $selected = self::getObjRecSelection($a_obj_id, $a_sub_type);
336 }
337 foreach ($optional as $record_id) {
338 if (!in_array($record_id, $selected)) {
339 unset($records[$record_id]);
340 }
341 }
342 }
343
344 $orderings = new ilAdvancedMDRecordObjectOrderings();
345 $records = $orderings->sortRecords($records, $a_obj_id);
346
347 return $records;
348 }
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static _lookupObjId(int $ref_id)

Referenced by ilObjEmployeeTalkSeriesGUI\copyTemplateValues(), ilAdvancedMDRecordGUI\getActiveRecords(), ilPCAMDFormGUI\getAdvRecords(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilObjectMetaDataGUI\getBlockHTML(), ilObjectMetaDataGUI\getKeyValueList(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilObjectMetaDataGUI\hasActiveRecords(), ilObjWikiGUI\initSettingsForm(), and ilAdvancedMDValues\preloadedRead().

+ Here is the caller graph for this function:

◆ _lookupRecordIdByImportId()

static ilAdvancedMDRecord::_lookupRecordIdByImportId ( string  $a_ilias_id)
static

Definition at line 107 of file class.ilAdvancedMDRecord.php.

107 : int
108 {
109 global $DIC;
110
111 $ilDB = $DIC['ilDB'];
112
113 $query = "SELECT record_id FROM adv_md_record " .
114 "WHERE import_id = " . $ilDB->quote($a_ilias_id, 'text') . " ";
115 $res = $ilDB->query($query);
116 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
117 return (int) $row->record_id;
118 }
119 return 0;
120 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAdvancedMDRecordParser\extractRecordId().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilAdvancedMDRecord::_lookupTitle ( int  $a_record_id)
static

Definition at line 87 of file class.ilAdvancedMDRecord.php.

87 : string
88 {
89 static $title_cache = array();
90
91 if (isset($title_cache[$a_record_id])) {
92 return $title_cache[$a_record_id];
93 }
94
95 global $DIC;
96
97 $ilDB = $DIC['ilDB'];
98
99 $query = "SELECT title FROM adv_md_record " .
100 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
101 $res = $ilDB->query($query);
102 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
103
104 return $title_cache[$a_record_id] = (string) $row->title;
105 }

References $DIC, $ilDB, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), and ilECSSettingsGUI\prepareFieldSelection().

+ Here is the caller graph for this function:

◆ appendAssignedObjectType()

ilAdvancedMDRecord::appendAssignedObjectType ( string  $a_obj_type,
string  $a_sub_type,
bool  $a_optional = false 
)

Definition at line 621 of file class.ilAdvancedMDRecord.php.

621 : void
622 {
623 $this->obj_types[] = array(
624 "obj_type" => $a_obj_type,
625 "sub_type" => $a_sub_type,
626 "optional" => $a_optional
627 );
628 }

◆ delete()

ilAdvancedMDRecord::delete ( )

Definition at line 417 of file class.ilAdvancedMDRecord.php.

417 : void
418 {
421 }
static deleteByRecordId(int $a_record_id)
static _delete($a_record_id)

References _delete(), ilAdvancedMDRecordScope\deleteByRecordId(), and ILIAS\LTI\ToolProvider\getRecordId().

+ Here is the call graph for this function:

◆ deleteObjRecSelection()

static ilAdvancedMDRecord::deleteObjRecSelection ( int  $a_obj_id)
static

Delete repository object record selection.

Definition at line 796 of file class.ilAdvancedMDRecord.php.

796 : void
797 {
798 global $DIC;
799
800 $ilDB = $DIC['ilDB'];
801
802 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
803 " obj_id = " . $ilDB->quote($a_obj_id, "integer"));
804 }

References $DIC, and $ilDB.

Referenced by ilAdvancedMDSettingsGUI\updateRecords().

+ Here is the caller graph for this function:

◆ enabledScope()

ilAdvancedMDRecord::enabledScope ( )

Definition at line 423 of file class.ilAdvancedMDRecord.php.

423 : bool
424 {
426 }

◆ enableScope()

ilAdvancedMDRecord::enableScope ( bool  $a_stat)

Definition at line 428 of file class.ilAdvancedMDRecord.php.

428 : void
429 {
430 $this->scope_enabled = $a_stat;
431 }

◆ generateImportId()

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

Definition at line 741 of file class.ilAdvancedMDRecord.php.

741 : string
742 {
743 return 'il_' . IL_INST_ID . '_adv_md_record_' . $this->getRecordId();
744 }
const IL_INST_ID
Definition: constants.php:40

References ILIAS\LTI\ToolProvider\getRecordId(), and IL_INST_ID.

+ Here is the call graph for this function:

◆ getAssignedObjectTypes()

ilAdvancedMDRecord::getAssignedObjectTypes ( )
Returns
array<int, array{obj_type: string, sub_type: string, optional: bool}>

Definition at line 633 of file class.ilAdvancedMDRecord.php.

633 : array
634 {
635 return $this->obj_types;
636 }

◆ getDefaultLanguage()

ilAdvancedMDRecord::getDefaultLanguage ( )

Definition at line 412 of file class.ilAdvancedMDRecord.php.

412 : string
413 {
415 }

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

Definition at line 597 of file class.ilAdvancedMDRecord.php.

597 : string
598 {
599 return $this->description;
600 }

◆ getGlobalPosition()

ilAdvancedMDRecord::getGlobalPosition ( )

Definition at line 562 of file class.ilAdvancedMDRecord.php.

562 : int
563 {
565 }

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

Definition at line 607 of file class.ilAdvancedMDRecord.php.

607 : string
608 {
609 return $this->import_id;
610 }

◆ getObjRecSelection()

static ilAdvancedMDRecord::getObjRecSelection ( int  $a_obj_id,
string  $a_sub_type = "" 
)
static

Get repository object record selection.

Parameters
int$a_obj_idobject id if repository object
array$a_recordsarray of record ids that are selected (in use) by the object
Returns
int[]

Definition at line 812 of file class.ilAdvancedMDRecord.php.

812 : array
813 {
814 global $DIC;
815
816 $ilDB = $DIC['ilDB'];
817
818 if ($a_sub_type == "") {
819 $a_sub_type = "-";
820 }
821
822 $recs = array();
823 $set = $ilDB->query(
824 $r = "SELECT * FROM adv_md_obj_rec_select " .
825 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
826 " AND sub_type = " . $ilDB->quote($a_sub_type, "text")
827 );
828 while ($rec = $ilDB->fetchAssoc($set)) {
829 $recs[] = (int) $rec["rec_id"];
830 }
831 return $recs;
832 }

References $DIC, $ilDB, and ILIAS\Repository\int().

Referenced by ilObjEmployeeTalkSeriesGUI\copyTemplateValues(), ilGlossaryExporter\getActiveAdvMDRecords(), ilWikiExporter\getActiveAdvMDRecords(), ilAdvancedMDSettingsGUI\getParsedRecordObjects(), getSharedRecords(), and ilAdvancedMDRecordGUI\parseRecordSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObject()

ilAdvancedMDRecord::getParentObject ( )

Definition at line 654 of file class.ilAdvancedMDRecord.php.

654 : int
655 {
656 return $this->parent_obj;
657 }

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

Definition at line 567 of file class.ilAdvancedMDRecord.php.

567 : int
568 {
569 return $this->record_id;
570 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getScopeRefIds()

ilAdvancedMDRecord::getScopeRefIds ( )
Returns
int[]

Definition at line 453 of file class.ilAdvancedMDRecord.php.

453 : array
454 {
455 $ref_ids = [];
456 foreach ($this->scopes as $scope) {
457 $ref_ids[] = $scope->getRefId();
458 }
459 return $ref_ids;
460 }
$scope
Definition: ltiregstart.php:53

References $scope.

◆ getScopes()

ilAdvancedMDRecord::getScopes ( )

Get scopes.

Returns
ilAdvancedMDRecordScope[]

Definition at line 445 of file class.ilAdvancedMDRecord.php.

445 : array
446 {
447 return $this->scopes;
448 }

References $scopes.

◆ getSharedRecords()

static ilAdvancedMDRecord::getSharedRecords ( int  $a_obj1_id,
int  $a_obj2_id,
string  $a_sub_type = "-" 
)
static

Definition at line 857 of file class.ilAdvancedMDRecord.php.

857 : array
858 {
859 $obj_type = ilObject::_lookupType($a_obj1_id);
860 $sel = array_intersect(
861 ilAdvancedMDRecord::getObjRecSelection($a_obj1_id, $a_sub_type),
862 ilAdvancedMDRecord::getObjRecSelection($a_obj2_id, $a_sub_type)
863 );
864
865 $res = array();
866
867 foreach (self::_getRecords() as $record) {
868 // local records cannot be shared
869 if ($record->getParentObject()) {
870 continue;
871 }
872
873 // :TODO: inactive records can be ignored?
874 if (!$record->isActive()) {
875 continue;
876 }
877
878 // parse assigned types
879 foreach ($record->getAssignedObjectTypes() as $item) {
880 if ($item["obj_type"] == $obj_type &&
881 $item["sub_type"] == $a_sub_type) {
882 // mandatory
883 if (!$item["optional"]) {
884 $res[] = $record->getRecordId();
885 } // optional
886 elseif (in_array($record->getRecordId(), $sel)) {
887 $res[] = $record->getRecordId();
888 }
889 }
890 }
891 }
892
893 return $res;
894 }
static _lookupType(int $id, bool $reference=false)

References $res, ilObject\_lookupType(), and getObjRecSelection().

+ Here is the call graph for this function:

◆ getTitle()

ilAdvancedMDRecord::getTitle ( )

Definition at line 587 of file class.ilAdvancedMDRecord.php.

587 : string
588 {
589 return $this->title;
590 }

◆ isActive()

ilAdvancedMDRecord::isActive ( )

Definition at line 577 of file class.ilAdvancedMDRecord.php.

577 : bool
578 {
579 return $this->active;
580 }

◆ isAssignedObjectType()

ilAdvancedMDRecord::isAssignedObjectType ( string  $a_obj_type,
string  $a_sub_type 
)

Definition at line 638 of file class.ilAdvancedMDRecord.php.

638 : bool
639 {
640 foreach ($this->getAssignedObjectTypes() as $t) {
641 if ($t["obj_type"] == $a_obj_type &&
642 $t["sub_type"] == $a_sub_type) {
643 return true;
644 }
645 }
646 return false;
647 }

◆ isFilteredByScope()

static ilAdvancedMDRecord::isFilteredByScope (   $a_ref_id,
array  $scopes 
)
static

Check if a given ref id is not filtered by scope restriction.

Parameters
int$a_ref_id
ilAdvancedMDRecordScope[]$scopes

Definition at line 355 of file class.ilAdvancedMDRecord.php.

355 : bool
356 {
357 $tree = $GLOBALS['DIC']->repositoryTree();
358 $logger = $GLOBALS['DIC']->logger()->amet();
359
360 if (!count($scopes)) {
361 return false;
362 }
363 foreach ($scopes as $scope) {
364 $logger->debug('Comparing: ' . $a_ref_id . ' with: ' . $scope->getRefId());
365 if ($scope->getRefId() == $a_ref_id) {
366 $logger->debug('Elements are equal. No scope restrictions.');
367 return false;
368 }
369 if ($tree->getRelation($scope->getRefId(), $a_ref_id) == ilTree::RELATION_PARENT) {
370 $logger->debug('Node is child node. No scope restrictions.');
371 return false;
372 }
373 }
374 $logger->info('Scope filter matches.');
375
376 return true;
377 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const RELATION_PARENT

References $GLOBALS, $scope, $scopes, and ilTree\RELATION_PARENT.

Referenced by ilAdvancedMDSettingsGUI\getParsedRecordObjects().

+ Here is the caller graph for this function:

◆ read()

ilAdvancedMDRecord::read ( )
private

Definition at line 702 of file class.ilAdvancedMDRecord.php.

702 : void
703 {
704 $query = "SELECT * FROM adv_md_record " .
705 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
706 $res = $this->db->query($query);
707 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
708 $this->setImportId((string) $row->import_id);
709 $this->setActive((bool) $row->active);
710 $this->setTitle((string) $row->title);
711 $this->setDescription((string) $row->description);
712 $this->setParentObject((int) $row->parent_obj);
713 $this->setGlobalPosition((int) $row->gpos);
714 $this->setDefaultLanguage((string) $row->lang_default);
715 }
716 $query = "SELECT * FROM adv_md_record_objs " .
717 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
718 $res = $this->db->query($query);
719 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
720 $this->obj_types[] = array(
721 "obj_type" => (string) $row->obj_type,
722 "sub_type" => (string) $row->sub_type,
723 "optional" => (bool) $row->optional
724 );
725 }
726
727 $query = 'SELECT scope_id FROM adv_md_record_scope ' .
728 'WHERE record_id = ' . $this->db->quote($this->record_id, ilDBConstants::T_INTEGER);
729 $res = $this->db->query($query);
730 $this->scope_enabled = false;
731 $this->scopes = [];
732 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
733 $this->scope_enabled = true;
734 $this->scopes[] = new ilAdvancedMDRecordScope((int) $row->scope_id);
735 }
736 }
Scope restrictions for advanced md records.
setImportId(string $a_id_string)
setDescription(string $a_description)
setDefaultLanguage(string $language_code)

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, ILIAS\LTI\ToolProvider\getRecordId(), and ilDBConstants\T_INTEGER.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDRecord::save ( )

Definition at line 462 of file class.ilAdvancedMDRecord.php.

462 : void
463 {
464 global $DIC;
465
466 $ilDB = $DIC['ilDB'];
467
468 // Save import id if given
469 $next_id = $ilDB->nextId('adv_md_record');
470
471 $query = "INSERT INTO adv_md_record (record_id,import_id,active,title,description,parent_obj,lang_default) " .
472 "VALUES(" .
473 $ilDB->quote($next_id, 'integer') . ", " .
474 $this->db->quote($this->getImportId(), 'text') . ", " .
475 $this->db->quote($this->isActive(), 'integer') . ", " .
476 $this->db->quote($this->getTitle(), 'text') . ", " .
477 $this->db->quote($this->getDescription(), 'text') . ", " .
478 $this->db->quote($this->getParentObject(), 'integer') . ", " .
479 $this->db->quote($this->getDefaultLanguage(), ilDBConstants::T_TEXT) .
480 ")";
481 $res = $ilDB->manipulate($query);
482 $this->record_id = $next_id;
483
484 if (!strlen($this->getImportId())) {
485 // set import id to default value
486 $query = "UPDATE adv_md_record " .
487 "SET import_id = " . $this->db->quote($this->generateImportId(), 'text') . " " .
488 "WHERE record_id = " . $this->db->quote($this->record_id, 'integer') . " ";
489 $res = $ilDB->manipulate($query);
490 }
491
492 foreach ($this->getAssignedObjectTypes() as $type) {
493 global $DIC;
494 $ilDB = $DIC['ilDB'];
495 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
496 "VALUES( " .
497 $this->db->quote($this->getRecordId(), 'integer') . ", " .
498 $this->db->quote($type["obj_type"], 'text') . ", " .
499 $this->db->quote($type["sub_type"], 'text') . ", " .
500 $this->db->quote($type["optional"], 'integer') . " " .
501 ")";
502 $res = $ilDB->manipulate($query);
503 }
504
505 foreach ($this->getScopes() as $scope) {
506 $scope->setRecordId($this->getRecordId());
507 $scope->save();
508 }
509 }
generateImportId()
generate unique record id
$type

References $DIC, $ilDB, $query, $res, $scope, $type, ILIAS\LTI\ToolProvider\getRecordId(), and ilDBConstants\T_TEXT.

+ Here is the call graph for this function:

◆ saveObjRecSelection()

static ilAdvancedMDRecord::saveObjRecSelection ( int  $a_obj_id,
string  $a_sub_type = "",
array  $a_records = null,
bool  $a_delete_before = true 
)
static

Save repository object record selection.

Parameters
int$a_obj_idobject id if repository object
string$a_sub_typesubtype
int[]$a_recordsarray of record ids that are selected (in use) by the object
bool$a_delete_beforedelete before update
Returns
void

Definition at line 759 of file class.ilAdvancedMDRecord.php.

764 : void {
765 global $DIC;
766
767 $ilDB = $DIC['ilDB'];
768
769 if ($a_sub_type == "") {
770 $a_sub_type = "-";
771 }
772
773 if ($a_delete_before) {
774 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
775 " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
776 " AND sub_type = " . $ilDB->quote($a_sub_type, "text"));
777 }
778
779 if (is_array($a_records)) {
780 foreach ($a_records as $r) {
781 if ($r > 0) {
782 $ilDB->manipulate("INSERT INTO adv_md_obj_rec_select " .
783 "(obj_id, rec_id, sub_type) VALUES (" .
784 $ilDB->quote($a_obj_id, "integer") . "," .
785 $ilDB->quote($r, "integer") . "," .
786 $ilDB->quote($a_sub_type, "text") .
787 ")");
788 }
789 }
790 }
791 }

Referenced by ilObjEmployeeTalkSeriesGUI\copyTemplateValues(), ilAdvancedMetaDataImporter\importXmlRepresentation(), ilAdvancedMDRecordGUI\saveSelection(), ilObjOrgUnit\update(), ilObjStudyProgramme\update(), and ilAdvancedMDSettingsGUI\updateRecords().

+ Here is the caller graph for this function:

◆ setActive()

ilAdvancedMDRecord::setActive ( bool  $a_active)

Definition at line 572 of file class.ilAdvancedMDRecord.php.

572 : void
573 {
574 $this->active = $a_active;
575 }

Referenced by _clone().

+ Here is the caller graph for this function:

◆ setAssignedObjectTypes()

ilAdvancedMDRecord::setAssignedObjectTypes ( array  $a_obj_types)
Parameters
string[]
Todo:
is this format of $a_obj_types correct?

Definition at line 616 of file class.ilAdvancedMDRecord.php.

616 : void
617 {
618 $this->obj_types = $a_obj_types;
619 }

◆ setDefaultLanguage()

ilAdvancedMDRecord::setDefaultLanguage ( string  $language_code)
Parameters
string$language_code

Definition at line 407 of file class.ilAdvancedMDRecord.php.

407 : void
408 {
409 $this->language_default = $language_code;
410 }

◆ setDescription()

ilAdvancedMDRecord::setDescription ( string  $a_description)

Definition at line 592 of file class.ilAdvancedMDRecord.php.

592 : void
593 {
594 $this->description = $a_description;
595 }

◆ setGlobalPosition()

ilAdvancedMDRecord::setGlobalPosition ( int  $position)

Definition at line 557 of file class.ilAdvancedMDRecord.php.

557 : void
558 {
559 $this->global_position = $position;
560 }

◆ setImportId()

ilAdvancedMDRecord::setImportId ( string  $a_id_string)

Definition at line 602 of file class.ilAdvancedMDRecord.php.

602 : void
603 {
604 $this->import_id = $a_id_string;
605 }

◆ setParentObject()

ilAdvancedMDRecord::setParentObject ( int  $a_obj_id)

Definition at line 649 of file class.ilAdvancedMDRecord.php.

649 : void
650 {
651 $this->parent_obj = $a_obj_id;
652 }

◆ setRecordId()

ilAdvancedMDRecord::setRecordId ( int  $record_id)
protected

Definition at line 399 of file class.ilAdvancedMDRecord.php.

399 : void
400 {
401 $this->record_id = $record_id;
402 }

◆ setScopes()

ilAdvancedMDRecord::setScopes ( array  $a_scopes)
Parameters
ilAdvancedMDRecordScope[]

Definition at line 436 of file class.ilAdvancedMDRecord.php.

436 : void
437 {
438 $this->scopes = $a_scopes;
439 }

◆ setTitle()

ilAdvancedMDRecord::setTitle ( string  $a_title)

Definition at line 582 of file class.ilAdvancedMDRecord.php.

582 : void
583 {
584 $this->title = $a_title;
585 }

◆ toXML()

ilAdvancedMDRecord::toXML ( ilXmlWriter  $writer)

To Xml.

This method writes only the subset Record (including all fields) Use class.ilAdvancedMDRecordXMLWriter to generate a complete xml presentation.

Definition at line 664 of file class.ilAdvancedMDRecord.php.

664 : void
665 {
666 $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0,
667 'id' => $this->generateImportId()
668 ));
669 $writer->xmlElement('Title', null, $this->getTitle());
670 $writer->xmlElement('Description', null, $this->getDescription());
671
673 $translations->toXML($writer);
674
675 foreach ($this->getAssignedObjectTypes() as $obj_type) {
676 $optional = array("optional" => $obj_type["optional"]);
677 if ($obj_type["sub_type"] == "") {
678 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"]);
679 } else {
680 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"] . ":" . $obj_type["sub_type"]);
681 }
682 }
683
684 // scopes
685 if (count($this->getScopeRefIds())) {
686 $writer->xmlStartTag('Scope');
687 }
688 foreach ($this->getScopeRefIds() as $ref_id) {
690 $writer->xmlElement('ScopeEntry', ['id' => 'il_' . IL_INST_ID . '_' . $type . '_' . $ref_id]);
691 }
692 if (count($this->getScopeRefIds())) {
693 $writer->xmlEndTag('Scope');
694 }
695
696 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
697 $definition->toXML($writer);
698 }
699 $writer->xmlEndTag('Record');
700 }
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
$ref_id
Definition: ltiauth.php:67

References $ref_id, $type, ilObject\_lookupObjId(), ilObject\_lookupType(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ILIAS\LTI\ToolProvider\getRecordId(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilAdvancedMDRecord::update ( )

Definition at line 511 of file class.ilAdvancedMDRecord.php.

511 : void
512 {
513 global $DIC;
514
515 $ilDB = $DIC['ilDB'];
516
517 $query = "UPDATE adv_md_record " .
518 "SET active = " . $this->db->quote($this->isActive(), 'integer') . ", " .
519 "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
520 "description = " . $this->db->quote($this->getDescription(), 'text') . ", " .
521 'gpos = ' . $this->db->quote($this->getGlobalPosition(), 'integer') . ', ' .
522 'lang_default = ' . $this->db->quote($this->getDefaultLanguage(), ilDBConstants::T_TEXT) . ' ' .
523 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
524 $res = $ilDB->manipulate($query);
525
526 // Delete assignments
527 $query = "DELETE FROM adv_md_record_objs " .
528 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
529 $res = $ilDB->manipulate($query);
530
531 // Insert assignments
532 foreach ($this->getAssignedObjectTypes() as $type) {
533 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
534 "VALUES ( " .
535 $this->db->quote($this->getRecordId(), 'integer') . ", " .
536 $this->db->quote($type["obj_type"], 'text') . ", " .
537 $this->db->quote($type["sub_type"], 'text') . ", " .
538 $this->db->quote($type["optional"], 'integer') . " " .
539 ")";
540 $res = $ilDB->manipulate($query);
541 }
543 foreach ($this->getScopes() as $scope) {
544 $scope->setRecordId($this->getRecordId());
545 $scope->save();
546 }
547 }

References $DIC, $ilDB, $query, $res, $scope, $type, ilAdvancedMDRecordScope\deleteByRecordId(), ILIAS\LTI\ToolProvider\getRecordId(), and ilDBConstants\T_TEXT.

+ Here is the call graph for this function:

◆ validate()

ilAdvancedMDRecord::validate ( )

Definition at line 549 of file class.ilAdvancedMDRecord.php.

549 : bool
550 {
551 if (!strlen($this->getTitle())) {
552 return false;
553 }
554 return true;
555 }

Field Documentation

◆ $active

bool ilAdvancedMDRecord::$active = false
protected

Definition at line 20 of file class.ilAdvancedMDRecord.php.

◆ $db

ilDBInterface ilAdvancedMDRecord::$db
protected

Definition at line 36 of file class.ilAdvancedMDRecord.php.

◆ $description

string ilAdvancedMDRecord::$description = ''
protected

Definition at line 22 of file class.ilAdvancedMDRecord.php.

◆ $global_position

int ilAdvancedMDRecord::$global_position = 0
protected

Definition at line 17 of file class.ilAdvancedMDRecord.php.

◆ $import_id

string ilAdvancedMDRecord::$import_id = ''
protected

Definition at line 19 of file class.ilAdvancedMDRecord.php.

◆ $instances

ilAdvancedMDRecord::$instances = []
staticprivate

Definition at line 14 of file class.ilAdvancedMDRecord.php.

◆ $language_default

string ilAdvancedMDRecord::$language_default = ''
protected

Definition at line 23 of file class.ilAdvancedMDRecord.php.

◆ $obj_types

array ilAdvancedMDRecord::$obj_types = array()
protected

Definition at line 28 of file class.ilAdvancedMDRecord.php.

Referenced by _getActivatedObjTypes().

◆ $parent_obj

int ilAdvancedMDRecord::$parent_obj = 0
protected

Definition at line 29 of file class.ilAdvancedMDRecord.php.

◆ $record_id

int ilAdvancedMDRecord::$record_id
protected

Definition at line 16 of file class.ilAdvancedMDRecord.php.

◆ $scope_enabled

bool ilAdvancedMDRecord::$scope_enabled = false
protected

Definition at line 30 of file class.ilAdvancedMDRecord.php.

◆ $scopes

array ilAdvancedMDRecord::$scopes = []
protected

Definition at line 34 of file class.ilAdvancedMDRecord.php.

◆ $title

string ilAdvancedMDRecord::$title = ''
protected

Definition at line 21 of file class.ilAdvancedMDRecord.php.


The documentation for this class was generated from the following file: