ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 26 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 59 of file class.ilAdvancedMDRecord.php.

60 {
61 global $DIC;
62
63 $this->db = $DIC->database();
64 $this->record_id = $a_record_id;
65
66 if ($this->getRecordId()) {
67 $this->read();
68 }
69 }
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

◆ __destruct()

ilAdvancedMDRecord::__destruct ( )

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

761 {
762 unset(self::$instances[$this->getRecordId()]);
763 }

Member Function Documentation

◆ _clone()

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

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

849 {
850 $new_obj = new self();
851 $new_obj->setActive($this->isActive());
852 $new_obj->setTitle($this->getTitle());
853 $new_obj->setDescription($this->getDescription());
854 $new_obj->setParentObject($a_parent_obj_id
855 ?: $this->getParentObject());
856 $new_obj->setAssignedObjectTypes($this->getAssignedObjectTypes());
857 $new_obj->setDefaultLanguage($this->getDefaultLanguage());
858 $new_obj->save();
859
860 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
861 $new_def = $definition->_clone($new_obj->getRecordId());
862 $a_fields_map[$definition->getFieldId()] = $new_def->getFieldId();
863 }
864
866 $record_translation->cloneRecord($new_obj->getRecordId());
867
868 return $new_obj;
869 }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.

References ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and setActive().

+ Here is the call graph for this function:

◆ _delete()

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

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

393 : void
394 {
395 global $DIC;
396
397 $ilDB = $DIC['ilDB'];
398
399 // Delete fields
400 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($a_record_id) as $field) {
401 $field->delete();
402 }
403
404 $query = "DELETE FROM adv_md_record " .
405 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
406 $res = $ilDB->manipulate($query);
407
408 $query = "DELETE FROM adv_md_record_objs " .
409 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
410 $res = $ilDB->manipulate($query);
411 }
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $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 184 of file class.ilAdvancedMDRecord.php.

184 : array
185 {
186 global $DIC;
187
188 $ilDB = $DIC['ilDB'];
189
190 $query = "SELECT DISTINCT(obj_type) FROM adv_md_record_objs amo " .
191 "JOIN adv_md_record amr ON amo.record_id = amr.record_id " .
192 "WHERE active = 1 ";
193 $res = $ilDB->query($query);
194 $obj_types = [];
195 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
196 $obj_types[] = (string) $row->obj_type;
197 }
198 return $obj_types;
199 }

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

Referenced by ilObjFileGUI\initSettingsTab().

+ 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 254 of file class.ilAdvancedMDRecord.php.

258 : array {
259 global $DIC;
260
261 $ilDB = $DIC['ilDB'];
262
263 if ($a_sub_type == "") {
264 $a_sub_type = "-";
265 }
266
267 $records = [];
268 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro " .
269 "JOIN adv_md_record amr ON amr.record_id = amro.record_id " .
270 "WHERE active = 1 " .
271 "AND obj_type = " . $ilDB->quote($a_obj_type, 'text') . " " .
272 "AND sub_type = " . $ilDB->quote($a_sub_type, 'text');
273
274 if ($a_only_optional) {
275 $query .= " AND optional =" . $ilDB->quote(1, 'integer');
276 }
277
278 // #16428
279 $query .= "ORDER by parent_obj DESC, record_id";
280
281 $res = $ilDB->query($query);
282 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
283 $records[] = self::_getInstanceByRecordId((int) $row->record_id);
284 }
285 return $records;
286 }
static _getInstanceByRecordId(int $a_record_id)

Referenced by ilExerciseExporter\getActiveAdvMDRecords(), ilCourseExporter\getActiveAdvMDRecords(), ilGlossaryExporter\getActiveAdvMDRecords(), ilGroupExporter\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 83 of file class.ilAdvancedMDRecord.php.

83 : array
84 {
85 global $DIC;
86
87 $ilDB = $DIC['ilDB'];
88
89 $query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr " .
90 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " .
91 "WHERE searchable = 1 AND active = 1 ";
92
93 $res = $ilDB->query($query);
94 $records = [];
95 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
96 $records[] = self::_getInstanceByRecordId((int) $row->record_id);
97 }
98 return $records;
99 }

References $DIC, $ilDB, $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 228 of file class.ilAdvancedMDRecord.php.

228 : array
229 {
230 global $DIC;
231
232 $ilDB = $DIC['ilDB'];
233
234 $records = [];
235 $query = "SELECT * FROM adv_md_record_objs WHERE sub_type=" . $ilDB->quote("-", "text");
236 $res = $ilDB->query($query);
237 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
238 $records[(string) $row->obj_type][] = self::_getInstanceByRecordId((int) $row->record_id);
239 }
240 // #13359 hide ecs if not configured
242 $filter = ilECSUtils::getPossibleRemoteTypes(false);
243 $filter[] = 'rtst';
244 $records = array_diff_key($records, array_flip($filter));
245 }
246
247 return $records;
248 }
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, $res, ilECSSetting\ecsConfigured(), ilDBConstants\FETCHMODE_OBJECT, and ilECSUtils\getPossibleRemoteTypes().

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

+ 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 141 of file class.ilAdvancedMDRecord.php.

141 : array
142 {
143 global $DIC;
144
145 $objDefinition = $DIC['objDefinition'];
146 $lng = $DIC['lng'];
147
148 $types = array();
149 $filter = array();
150 $amet_types = $objDefinition->getAdvancedMetaDataTypes();
151
153 $filter = array_merge($filter, ilECSUtils::getPossibleRemoteTypes(false));
154 $filter[] = 'rtst';
155 }
156
157 foreach ($amet_types as $at) {
158 if (in_array($at["obj_type"], $filter)) {
159 continue;
160 }
161
162 if ($a_include_text) {
163 $text = $lng->txt("obj_" . $at["obj_type"]);
164 if ($at["sub_type"] != "") {
165 $lng->loadLanguageModule($at["obj_type"]);
166 $text .= ": " . $lng->txt($at["obj_type"] . "_" . $at["sub_type"]);
167 } else {
168 $at["sub_type"] = "-";
169 }
170 $at["text"] = $text;
171 }
172
173 $types[] = $at;
174 }
175
176 sort($types);
177 return $types;
178 }
global $lng
Definition: privfeed.php:31

References $DIC, $lng, ilECSSetting\ecsConfigured(), ilECSUtils\getPossibleRemoteTypes(), and ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

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 208 of file class.ilAdvancedMDRecord.php.

208 : array
209 {
210 global $DIC;
211
212 $ilDB = $DIC['ilDB'];
213
214 $query = "SELECT record_id FROM adv_md_record ORDER BY gpos ";
215 $res = $ilDB->query($query);
216 $records = [];
217 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
218 $records[] = ilAdvancedMDRecord::_getInstanceByRecordId((int) $row->record_id);
219 }
220 return $records;
221 }

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

Referenced by 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 295 of file class.ilAdvancedMDRecord.php.

300 : array {
301 $records = array();
302
303 if ($a_sub_type == "") {
304 $a_sub_type = "-";
305 }
306
307 $a_obj_id = $is_ref_id
309 : $a_id;
310
311 // object-wide metadata configuration setting
312 $config_setting = ilContainer::_lookupContainerSetting(
313 $a_obj_id,
315 ''
316 );
317
318 $optional = array();
319 foreach (self::_getActivatedRecordsByObjectType($a_obj_type, $a_sub_type) as $record) {
320 // check scope
321 if ($is_ref_id && self::isFilteredByScope($a_id, $record->getScopes())) {
322 continue;
323 }
324 foreach ($record->getAssignedObjectTypes() as $item) {
325 if ($record->getParentObject()) {
326 // only matching local records
327 if ($record->getParentObject() != $a_obj_id) {
328 continue;
329 } // if object-wide setting is off, ignore local records
330 elseif (!$config_setting) {
331 continue;
332 }
333 }
334
335 if ($item['obj_type'] == $a_obj_type &&
336 $item['sub_type'] == $a_sub_type) {
337 if ($item['optional']) {
338 $optional[] = $record->getRecordId();
339 }
340 $records[$record->getRecordId()] = $record;
341 }
342 }
343 }
344
345 if ($optional) {
346 if (!$config_setting && !in_array($a_sub_type, array("orgu_type", "prg_type"))) { //#16925 + #17777
347 $selected = array();
348 } else {
349 $selected = self::getObjRecSelection($a_obj_id, $a_sub_type);
350 }
351 foreach ($optional as $record_id) {
352 if (!in_array($record_id, $selected)) {
353 unset($records[$record_id]);
354 }
355 }
356 }
357
358 $orderings = new ilAdvancedMDRecordObjectOrderings();
359 $records = $orderings->sortRecords($records, $a_obj_id);
360
361 return $records;
362 }
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 ilAdvancedMDRecordGUI\getActiveRecords(), ilGlossaryAdvMetaDataAdapter\getActiveRecords(), ilPCAMDFormGUI\getAdvRecords(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilObjectMetaDataGUI\getBlockHTML(), ILIAS\Wiki\Settings\SettingsGUI\getEditForm(), ilObjectMetaDataGUI\getKeyValueList(), ilWikiFunctionsBlockGUI\getLegacyContent(), ILIAS\AdvancedMetaData\Services\SubObjectModes\DataTable\Supplier\getRecordIds(), ILIAS\AdvancedMetaData\Services\SubObjectModes\Filter\Supplier\getRecordIds(), ilObjectMetaDataGUI\hasActiveRecords(), ilAdvancedMDValues\preloadedRead(), and ILIAS\Wiki\Settings\SettingsGUI\save().

+ Here is the caller graph for this function:

◆ _lookupRecordIdByImportId()

static ilAdvancedMDRecord::_lookupRecordIdByImportId ( string  $a_ilias_id)
static

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

121 : int
122 {
123 global $DIC;
124
125 $ilDB = $DIC['ilDB'];
126
127 $query = "SELECT record_id FROM adv_md_record " .
128 "WHERE import_id = " . $ilDB->quote($a_ilias_id, 'text') . " ";
129 $res = $ilDB->query($query);
130 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
131 return (int) $row->record_id;
132 }
133 return 0;
134 }

References $DIC, $ilDB, $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 101 of file class.ilAdvancedMDRecord.php.

101 : string
102 {
103 static $title_cache = array();
104
105 if (isset($title_cache[$a_record_id])) {
106 return $title_cache[$a_record_id];
107 }
108
109 global $DIC;
110
111 $ilDB = $DIC['ilDB'];
112
113 $query = "SELECT title FROM adv_md_record " .
114 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
115 $res = $ilDB->query($query);
116 $row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT);
117
118 return $title_cache[$a_record_id] = (string) $row->title;
119 }

References $DIC, $ilDB, $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 635 of file class.ilAdvancedMDRecord.php.

635 : void
636 {
637 $this->obj_types[] = array(
638 "obj_type" => $a_obj_type,
639 "sub_type" => $a_sub_type,
640 "optional" => $a_optional
641 );
642 }

◆ delete()

ilAdvancedMDRecord::delete ( )

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

431 : void
432 {
435 }
static deleteByRecordId(int $a_record_id)
static _delete($a_record_id)

References _delete(), and ilAdvancedMDRecordScope\deleteByRecordId().

+ 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 810 of file class.ilAdvancedMDRecord.php.

810 : void
811 {
812 global $DIC;
813
814 $ilDB = $DIC['ilDB'];
815
816 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
817 " obj_id = " . $ilDB->quote($a_obj_id, "integer"));
818 }

References $DIC, and $ilDB.

Referenced by ilAdvancedMDSettingsGUI\updateRecords().

+ Here is the caller graph for this function:

◆ enabledScope()

ilAdvancedMDRecord::enabledScope ( )

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

437 : bool
438 {
440 }

◆ enableScope()

ilAdvancedMDRecord::enableScope ( bool  $a_stat)

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

442 : void
443 {
444 $this->scope_enabled = $a_stat;
445 }

◆ generateImportId()

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

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

755 : string
756 {
757 return 'il_' . IL_INST_ID . '_adv_md_record_' . $this->getRecordId();
758 }
const IL_INST_ID
Definition: constants.php:40

References IL_INST_ID.

◆ getAssignedObjectTypes()

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

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

647 : array
648 {
649 return $this->obj_types;
650 }

◆ getDefaultLanguage()

ilAdvancedMDRecord::getDefaultLanguage ( )

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

426 : string
427 {
429 }

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

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

611 : string
612 {
613 return $this->description;
614 }

◆ getGlobalPosition()

ilAdvancedMDRecord::getGlobalPosition ( )

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

576 : int
577 {
579 }

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

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

621 : string
622 {
623 return $this->import_id;
624 }

◆ 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 826 of file class.ilAdvancedMDRecord.php.

826 : array
827 {
828 global $DIC;
829
830 $ilDB = $DIC['ilDB'];
831
832 if ($a_sub_type == "") {
833 $a_sub_type = "-";
834 }
835
836 $recs = array();
837 $set = $ilDB->query(
838 $r = "SELECT * FROM adv_md_obj_rec_select " .
839 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
840 " AND sub_type = " . $ilDB->quote($a_sub_type, "text")
841 );
842 while ($rec = $ilDB->fetchAssoc($set)) {
843 $recs[] = (int) $rec["rec_id"];
844 }
845 return $recs;
846 }

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

Referenced by 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 668 of file class.ilAdvancedMDRecord.php.

668 : int
669 {
670 return $this->parent_obj;
671 }

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

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

581 : int
582 {
583 return $this->record_id;
584 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getScopeRefIds()

ilAdvancedMDRecord::getScopeRefIds ( )
Returns
int[]

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

467 : array
468 {
469 $ref_ids = [];
470 foreach ($this->scopes as $scope) {
471 $ref_ids[] = $scope->getRefId();
472 }
473 return $ref_ids;
474 }
$scope
Definition: ltiregstart.php:51

References $scope.

◆ getScopes()

ilAdvancedMDRecord::getScopes ( )

Get scopes.

Returns
ilAdvancedMDRecordScope[]

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

459 : array
460 {
461 return $this->scopes;
462 }

References $scopes.

◆ getSharedRecords()

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

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

871 : array
872 {
873 $obj_type = ilObject::_lookupType($a_obj1_id);
874 $sel = array_intersect(
875 ilAdvancedMDRecord::getObjRecSelection($a_obj1_id, $a_sub_type),
876 ilAdvancedMDRecord::getObjRecSelection($a_obj2_id, $a_sub_type)
877 );
878
879 $res = array();
880
881 foreach (self::_getRecords() as $record) {
882 // local records cannot be shared
883 if ($record->getParentObject()) {
884 continue;
885 }
886
887 // :TODO: inactive records can be ignored?
888 if (!$record->isActive()) {
889 continue;
890 }
891
892 // parse assigned types
893 foreach ($record->getAssignedObjectTypes() as $item) {
894 if ($item["obj_type"] == $obj_type &&
895 $item["sub_type"] == $a_sub_type) {
896 // mandatory
897 if (!$item["optional"]) {
898 $res[] = $record->getRecordId();
899 } // optional
900 elseif (in_array($record->getRecordId(), $sel)) {
901 $res[] = $record->getRecordId();
902 }
903 }
904 }
905 }
906
907 return $res;
908 }
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 601 of file class.ilAdvancedMDRecord.php.

601 : string
602 {
603 return $this->title;
604 }

◆ isActive()

ilAdvancedMDRecord::isActive ( )

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

591 : bool
592 {
593 return $this->active;
594 }

◆ isAssignedObjectType()

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

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

652 : bool
653 {
654 foreach ($this->getAssignedObjectTypes() as $t) {
655 if ($t["obj_type"] == $a_obj_type &&
656 $t["sub_type"] == $a_sub_type) {
657 return true;
658 }
659 }
660 return false;
661 }

◆ 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 369 of file class.ilAdvancedMDRecord.php.

369 : bool
370 {
371 $tree = $GLOBALS['DIC']->repositoryTree();
372 $logger = $GLOBALS['DIC']->logger()->amet();
373
374 if (!count($scopes)) {
375 return false;
376 }
377 foreach ($scopes as $scope) {
378 $logger->debug('Comparing: ' . $a_ref_id . ' with: ' . $scope->getRefId());
379 if ($scope->getRefId() == $a_ref_id) {
380 $logger->debug('Elements are equal. No scope restrictions.');
381 return false;
382 }
383 if ($tree->getRelation($scope->getRefId(), $a_ref_id) == ilTree::RELATION_PARENT) {
384 $logger->debug('Node is child node. No scope restrictions.');
385 return false;
386 }
387 }
388 $logger->info('Scope filter matches.');
389
390 return true;
391 }
const RELATION_PARENT
$GLOBALS["DIC"]
Definition: wac.php:54

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 716 of file class.ilAdvancedMDRecord.php.

716 : void
717 {
718 $query = "SELECT * FROM adv_md_record " .
719 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
720 $res = $this->db->query($query);
721 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
722 $this->setImportId((string) $row->import_id);
723 $this->setActive((bool) $row->active);
724 $this->setTitle((string) $row->title);
725 $this->setDescription((string) $row->description);
726 $this->setParentObject((int) $row->parent_obj);
727 $this->setGlobalPosition((int) $row->gpos);
728 $this->setDefaultLanguage((string) $row->lang_default);
729 }
730 $query = "SELECT * FROM adv_md_record_objs " .
731 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
732 $res = $this->db->query($query);
733 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
734 $this->obj_types[] = array(
735 "obj_type" => (string) $row->obj_type,
736 "sub_type" => (string) $row->sub_type,
737 "optional" => (bool) $row->optional
738 );
739 }
740
741 $query = 'SELECT scope_id FROM adv_md_record_scope ' .
742 'WHERE record_id = ' . $this->db->quote($this->record_id, ilDBConstants::T_INTEGER);
743 $res = $this->db->query($query);
744 $this->scope_enabled = false;
745 $this->scopes = [];
746 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
747 $this->scope_enabled = true;
748 $this->scopes[] = new ilAdvancedMDRecordScope((int) $row->scope_id);
749 }
750 }
Scope restrictions for advanced md records.
setImportId(string $a_id_string)
setDescription(string $a_description)
setDefaultLanguage(string $language_code)

References $res, ilDBConstants\FETCHMODE_OBJECT, and ilDBConstants\T_INTEGER.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ save()

ilAdvancedMDRecord::save ( )

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

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

References $DIC, $ilDB, $res, $scope, ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), 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 773 of file class.ilAdvancedMDRecord.php.

778 : void {
779 global $DIC;
780
781 $ilDB = $DIC['ilDB'];
782
783 if ($a_sub_type == "") {
784 $a_sub_type = "-";
785 }
786
787 if ($a_delete_before) {
788 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
789 " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
790 " AND sub_type = " . $ilDB->quote($a_sub_type, "text"));
791 }
792
793 if (is_array($a_records)) {
794 foreach ($a_records as $r) {
795 if ($r > 0) {
796 $ilDB->manipulate("INSERT INTO adv_md_obj_rec_select " .
797 "(obj_id, rec_id, sub_type) VALUES (" .
798 $ilDB->quote($a_obj_id, "integer") . "," .
799 $ilDB->quote($r, "integer") . "," .
800 $ilDB->quote($a_sub_type, "text") .
801 ")");
802 }
803 }
804 }
805 }

Referenced by 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 586 of file class.ilAdvancedMDRecord.php.

586 : void
587 {
588 $this->active = $a_active;
589 }

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 630 of file class.ilAdvancedMDRecord.php.

630 : void
631 {
632 $this->obj_types = $a_obj_types;
633 }

◆ setDefaultLanguage()

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

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

421 : void
422 {
423 $this->language_default = $language_code;
424 }

◆ setDescription()

ilAdvancedMDRecord::setDescription ( string  $a_description)

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

606 : void
607 {
608 $this->description = $a_description;
609 }

◆ setGlobalPosition()

ilAdvancedMDRecord::setGlobalPosition ( int  $position)

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

571 : void
572 {
573 $this->global_position = $position;
574 }

◆ setImportId()

ilAdvancedMDRecord::setImportId ( string  $a_id_string)

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

616 : void
617 {
618 $this->import_id = $a_id_string;
619 }

◆ setParentObject()

ilAdvancedMDRecord::setParentObject ( int  $a_obj_id)

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

663 : void
664 {
665 $this->parent_obj = $a_obj_id;
666 }

◆ setRecordId()

ilAdvancedMDRecord::setRecordId ( int  $record_id)
protected

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

413 : void
414 {
415 $this->record_id = $record_id;
416 }

◆ setScopes()

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

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

450 : void
451 {
452 $this->scopes = $a_scopes;
453 }

◆ setTitle()

ilAdvancedMDRecord::setTitle ( string  $a_title)

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

596 : void
597 {
598 $this->title = $a_title;
599 }

◆ 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 678 of file class.ilAdvancedMDRecord.php.

678 : void
679 {
680 $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0,
681 'id' => $this->generateImportId()
682 ));
683 $writer->xmlElement('Title', null, $this->getTitle());
684 $writer->xmlElement('Description', null, $this->getDescription());
685
687 $translations->toXML($writer);
688
689 foreach ($this->getAssignedObjectTypes() as $obj_type) {
690 $optional = array("optional" => $obj_type["optional"]);
691 if ($obj_type["sub_type"] == "") {
692 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"]);
693 } else {
694 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"] . ":" . $obj_type["sub_type"]);
695 }
696 }
697
698 // scopes
699 if (count($this->getScopeRefIds())) {
700 $writer->xmlStartTag('Scope');
701 }
702 foreach ($this->getScopeRefIds() as $ref_id) {
704 $writer->xmlElement('ScopeEntry', ['id' => 'il_' . IL_INST_ID . '_' . $type . '_' . $ref_id]);
705 }
706 if (count($this->getScopeRefIds())) {
707 $writer->xmlEndTag('Scope');
708 }
709
710 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
711 $definition->toXML($writer);
712 }
713 $writer->xmlEndTag('Record');
714 }
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:66

References $ref_id, ilObject\_lookupObjId(), ilObject\_lookupType(), ilAdvancedMDRecordTranslations\getInstanceByRecordId(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), IL_INST_ID, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilAdvancedMDRecord::update ( )

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

525 : void
526 {
527 global $DIC;
528
529 $ilDB = $DIC['ilDB'];
530
531 $query = "UPDATE adv_md_record " .
532 "SET active = " . $this->db->quote($this->isActive(), 'integer') . ", " .
533 "title = " . $this->db->quote($this->getTitle(), 'text') . ", " .
534 "description = " . $this->db->quote($this->getDescription(), 'text') . ", " .
535 'gpos = ' . $this->db->quote($this->getGlobalPosition(), 'integer') . ', ' .
536 'lang_default = ' . $this->db->quote($this->getDefaultLanguage(), ilDBConstants::T_TEXT) . ' ' .
537 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
538 $res = $ilDB->manipulate($query);
539
540 // Delete assignments
541 $query = "DELETE FROM adv_md_record_objs " .
542 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
543 $res = $ilDB->manipulate($query);
544
545 // Insert assignments
546 foreach ($this->getAssignedObjectTypes() as $type) {
547 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
548 "VALUES ( " .
549 $this->db->quote($this->getRecordId(), 'integer') . ", " .
550 $this->db->quote($type["obj_type"], 'text') . ", " .
551 $this->db->quote($type["sub_type"], 'text') . ", " .
552 $this->db->quote($type["optional"], 'integer') . " " .
553 ")";
554 $res = $ilDB->manipulate($query);
555 }
557 foreach ($this->getScopes() as $scope) {
558 $scope->setRecordId($this->getRecordId());
559 $scope->save();
560 }
561 }

References $DIC, $ilDB, $res, $scope, ilAdvancedMDRecordScope\deleteByRecordId(), ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle(), and ilDBConstants\T_TEXT.

+ Here is the call graph for this function:

◆ validate()

ilAdvancedMDRecord::validate ( )

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

563 : bool
564 {
565 if (!strlen($this->getTitle())) {
566 return false;
567 }
568 return true;
569 }

References ILIAS\GlobalScreen\Scope\Footer\Factory\getTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $active

bool ilAdvancedMDRecord::$active = false
protected

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

◆ $db

ilDBInterface ilAdvancedMDRecord::$db
protected

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

◆ $description

string ilAdvancedMDRecord::$description = ''
protected

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

◆ $global_position

int ilAdvancedMDRecord::$global_position = 0
protected

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

◆ $import_id

string ilAdvancedMDRecord::$import_id = ''
protected

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

◆ $instances

ilAdvancedMDRecord::$instances = []
staticprivate

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

◆ $language_default

string ilAdvancedMDRecord::$language_default = ''
protected

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

◆ $obj_types

array ilAdvancedMDRecord::$obj_types = array()
protected

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

Referenced by _getActivatedObjTypes().

◆ $parent_obj

int ilAdvancedMDRecord::$parent_obj = 0
protected

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

◆ $record_id

int ilAdvancedMDRecord::$record_id
protected

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

◆ $scope_enabled

bool ilAdvancedMDRecord::$scope_enabled = false
protected

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

◆ $scopes

array ilAdvancedMDRecord::$scopes = []
protected

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

◆ $title

string ilAdvancedMDRecord::$title = ''
protected

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


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