ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAdvancedMDRecord Class Reference
+ Collaboration diagram for ilAdvancedMDRecord:

Public Member Functions

 __construct ($a_record_id=0)
 Singleton constructor To create an array of new records (without saving them) call the constructor directly. More...
 
 delete ()
 Delete. More...
 
 enabledScope ()
 Is scope enabled. More...
 
 enableScope ($a_stat)
 Enable scope restrictions. More...
 
 setScopes (array $a_scopes)
 Set scopes. More...
 
 getScopes ()
 Get scopes. More...
 
 getScopeRefIds ()
 Get scope gef_ids. More...
 
 save ()
 save More...
 
 update ()
 update More...
 
 validate ()
 Validate settings. More...
 
 getRecordId ()
 Get record id. More...
 
 setActive ($a_active)
 Set active. More...
 
 isActive ()
 Check if record is active. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 get title More...
 
 setDescription ($a_description)
 set description More...
 
 getDescription ()
 get description More...
 
 setImportId ($a_id_string)
 set import id More...
 
 getImportId ()
 get import id More...
 
 setAssignedObjectTypes ($a_obj_types)
 Set assigned object types. More...
 
 appendAssignedObjectType ($a_obj_type, $a_sub_type, $a_optional=false)
 append assigned object types More...
 
 getAssignedObjectTypes ()
 Get assigned object types. More...
 
 isAssignedObjectType ($a_obj_type, $a_sub_type)
 Is assigned object type? More...
 
 setParentObject ($a_obj_id)
 
 getParentObject ()
 
 toXML (ilXmlWriter $writer)
 To Xml. More...
 
 __destruct ()
 Destructor. More...
 
 _clone (array &$a_fields_map, $a_parent_obj_id=null)
 Clone record. More...
 

Static Public Member Functions

static _getInstanceByRecordId ($a_record_id)
 Get instance by record id. More...
 
static _getActiveSearchableRecords ()
 Get active searchable records. More...
 
static _lookupTitle ($a_record_id)
 Lookup title. More...
 
static _lookupRecordIdByImportId ($a_ilias_id)
 Lookup record Id by import id. More...
 
static _getAssignableObjectTypes ($a_include_text=false)
 Get assignable object type. More...
 
static _getActivatedObjTypes ()
 get activated obj types More...
 
static _getRecords ()
 Get records. More...
 
static _getAllRecordsByObjectType ()
 Get records by obj_type Note: this returns only records with no sub types! @access public. More...
 
static _getActivatedRecordsByObjectType ($a_obj_type, $a_sub_type="", $a_only_optional=false)
 Get activated records by object type. More...
 
static _getSelectedRecordsByObject ($a_obj_type, $a_ref_id, $a_sub_type="")
 Get selected records by object. More...
 
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)
 Delete record and all related data. More...
 
static saveObjRecSelection ($a_obj_id, $a_sub_type="", array $a_records=null, $a_delete_before=true)
 Save repository object record selection. More...
 
static getObjRecSelection ($a_obj_id, $a_sub_type="")
 Get repository object record selection. More...
 
static getSharedRecords ($a_obj1_id, $a_obj2_id, $a_sub_type="-")
 Get shared records. More...
 

Protected Member Functions

 generateImportId ()
 generate unique record id More...
 

Protected Attributes

 $record_id
 
 $import_id
 
 $active
 
 $title
 
 $description
 
 $obj_types = array()
 
 $db = null
 
 $parent_obj
 
 $scope_enabled = false
 
 $scopes = []
 

Private Member Functions

 read ()
 read record and assiged object types More...
 

Static Private Attributes

static $instances = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDRecord::__construct (   $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 46 of file class.ilAdvancedMDRecord.php.

47 {
48 global $ilDB;
49
50 $this->record_id = $a_record_id;
51 $this->db = $ilDB;
52
53 if ($this->getRecordId()) {
54 $this->read();
55 }
56 }
read()
read record and assiged object types
global $ilDB

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

+ Here is the call graph for this function:

◆ __destruct()

ilAdvancedMDRecord::__destruct ( )

Destructor.

@access public

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

853 {
854 unset(self::$instances[$this->getRecordId()]);
855 }

References getRecordId().

+ Here is the call graph for this function:

Member Function Documentation

◆ _clone()

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

Clone record.

Parameters
array&$a_fields_map
type$a_parent_obj_id
Returns
self

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

925 {
926 $new_obj = new self();
927 $new_obj->setActive($this->isActive());
928 $new_obj->setTitle($this->getTitle());
929 $new_obj->setDescription($this->getDescription());
930 $new_obj->setParentObject($a_parent_obj_id
931 ? $a_parent_obj_id
932 : $this->getParentObject());
933 $new_obj->setAssignedObjectTypes($this->getAssignedObjectTypes());
934 $new_obj->save();
935
936 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
937 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
938 $new_def = $definition->_clone($new_obj->getRecordId());
939 $a_fields_map[$definition->getFieldId()] = $new_def->getFieldId();
940 }
941
942 return $new_obj;
943 }
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.
isActive()
Check if record is active.
getAssignedObjectTypes()
Get assigned object types.

References getAssignedObjectTypes(), getDescription(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getParentObject(), getRecordId(), getTitle(), and isActive().

+ Here is the call graph for this function:

◆ _delete()

static ilAdvancedMDRecord::_delete (   $a_record_id)
static

Delete record and all related data.

@access public

Parameters
intrecord id

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

393 {
394 global $ilDB;
395
396 // Delete fields
397 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($a_record_id) as $field) {
398 $field->delete();
399 }
400
401 $query = "DELETE FROM adv_md_record " .
402 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
403 $res = $ilDB->manipulate($query);
404
405 $query = "DELETE FROM adv_md_record_objs " .
406 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
407 $res = $ilDB->manipulate($query);
408 }
$query
foreach($_POST as $key=> $value) $res

References $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

@access public

Parameters
stringobj types

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

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

References $ilDB, $obj_types, $query, $res, $row, 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 (   $a_obj_type,
  $a_sub_type = "",
  $a_only_optional = false 
)
static

Get activated records by object type.

@access public

Parameters
stringobj_type
Returns
ilAdvancedMDRecord[]

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

251 {
252 global $ilDB;
253
254 $records = array();
255
256 if ($a_sub_type == "") {
257 $a_sub_type = "-";
258 }
259
260 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro " .
261 "JOIN adv_md_record amr ON amr.record_id = amro.record_id " .
262 "WHERE active = 1 " .
263 "AND obj_type = " . $ilDB->quote($a_obj_type, 'text') . " " .
264 "AND sub_type = " . $ilDB->quote($a_sub_type, 'text');
265
266 if ($a_only_optional) {
267 $query .= " AND optional =" . $ilDB->quote(1, 'integer');
268 }
269
270 // #16428
271 $query .= "ORDER by parent_obj DESC, record_id";
272
273 $res = $ilDB->query($query);
274 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
276 }
277
278 return $records;
279 }
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
$records
Definition: simple_test.php:22

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

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilGlossaryExporter\getActiveAdvMDRecords(), ilSessionExporter\getActiveAdvMDRecords(), ilWikiExporter\getActiveAdvMDRecords(), ilOrgUnitType\getAvailableAdvancedMDRecords(), ilStudyProgrammeType\getAvailableAdvancedMDRecords(), ilSoapAdministration\getNIC(), and ilAdvancedMDRecordGUI\parseRecordSelection().

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

◆ _getActiveSearchableRecords()

static ilAdvancedMDRecord::_getActiveSearchableRecords ( )
static

Get active searchable records.

@access public

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

83 {
84 global $ilDB;
85
86 $query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr " .
87 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " .
88 "WHERE searchable = 1 AND active = 1 ";
89
90 $res = $ilDB->query($query);
91 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
93 }
94 return $records ? $records : array();
95 }

References $ilDB, $query, $records, $res, $row, _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! @access public.

Parameters

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

228 {
229 global $ilDB;
230
231 $records = array();
232
233 $query = "SELECT * FROM adv_md_record_objs WHERE sub_type=" . $ilDB->quote("-", "text");
234 $res = $ilDB->query($query);
235 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
236 $records[$row->obj_type][] = self::_getInstanceByRecordId($row->record_id);
237 }
238 return $records;
239 }

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

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 (   $a_include_text = false)
static

Get assignable object type.

@access public

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

151 {
152 global $objDefinition, $lng;
153
154 $types = array();
155 $amet_types = $objDefinition->getAdvancedMetaDataTypes();
156
157 foreach ($amet_types as $at) {
158 if ($a_include_text) {
159 $text = $lng->txt("obj_" . $at["obj_type"]);
160 if ($at["sub_type"] != "") {
161 $lng->loadLanguageModule($at["obj_type"]);
162 $text.= ": " . $lng->txt($at["obj_type"] . "_" . $at["sub_type"]);
163 } else {
164 $at["sub_type"] = "-";
165 }
166 $at["text"] = $text;
167 }
168
169 $types[] = $at;
170 }
171
172 sort($types);
173 return $types;
174 }
global $lng
Definition: privfeed.php:17
$text
Definition: errorreport.php:18

References $lng, and $text.

Referenced by ilSoapInstallationInfoXMLWriter\__buildClient(), ilAdvancedMDRecordTableGUI\fillRow(), ilSoapAdministration\getNIC(), ilAdvancedMDSettingsGUI\initForm(), and ilObjectMetaDataGUI\isAdvMDAvailable().

+ Here is the caller graph for this function:

◆ _getInstanceByRecordId()

static ilAdvancedMDRecord::_getInstanceByRecordId (   $a_record_id)
static

Get instance by record id.

@access public

Parameters
intrecord id
Returns
ilAdvancedMDRecord

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

68 {
69 if (isset(self::$instances[$a_record_id])) {
70 return self::$instances[$a_record_id];
71 }
72 return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
73 }

Referenced by _getActivatedRecordsByObjectType(), _getActiveSearchableRecords(), _getAllRecordsByObjectType(), _getRecords(), ilAdvancedMDSettingsGUI\confirmDeleteRecords(), ilAdvancedMDSettingsGUI\deleteRecords(), ilAdvancedMDSettingsGUI\exportRecords(), ilAdvancedMDRecordTableGUI\fillRow(), ilAdvancedMDRecordParser\initRecordObject(), ilAdvancedMDSettingsGUI\initRecordObject(), and ilAdvancedMDSettingsGUI\updateRecords().

+ Here is the caller graph for this function:

◆ _getRecords()

static ilAdvancedMDRecord::_getRecords ( )
static

Get records.

@access public

Parameters
arrayarray of record objects
Returns
ilAdvancedMDRecord[]

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

208 {
209 global $ilDB;
210
211 $query = "SELECT record_id FROM adv_md_record ";
212 $res = $ilDB->query($query);
213 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
215 }
216 return $records ? $records : array();
217 }

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

Referenced by ilAdvancedMDValues\_cloneValues(), 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 (   $a_obj_type,
  $a_ref_id,
  $a_sub_type = "" 
)
static

Get selected records by object.

Parameters
string$a_obj_typeobject type
string$a_ref_idreference id
string$a_sub_typesub type

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

289 {
290 $records = array();
291 // ilUtil::printBacktrace(10);
292 // var_dump($a_obj_type."-".$a_ref_id."-".$a_sub_type); exit;
293 if ($a_sub_type == "") {
294 $a_sub_type = "-";
295 }
296
297 $a_obj_id = ilObject::_lookupObjId($a_ref_id);
298
299 // object-wide metadata configuration setting
300 include_once 'Services/Container/classes/class.ilContainer.php';
301 include_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
302 $config_setting = ilContainer::_lookupContainerSetting(
303 $a_obj_id,
305 false
306 );
307
308 $optional = array();
309 foreach (self::_getActivatedRecordsByObjectType($a_obj_type, $a_sub_type) as $record) {
310 // check scope
311 if (self::isFilteredByScope($a_ref_id, $record->getScopes())) {
312 continue;
313 }
314
315 foreach ($record->getAssignedObjectTypes() as $item) {
316 if ($record->getParentObject()) {
317 // only matching local records
318 if ($record->getParentObject() != $a_obj_id) {
319 continue;
320 }
321 // if object-wide setting is off, ignore local records
322 elseif (!$config_setting) {
323 continue;
324 }
325 }
326
327 if ($item['obj_type'] == $a_obj_type &&
328 $item['sub_type'] == $a_sub_type) {
329 if ($item['optional']) {
330 $optional[] = $record->getRecordId();
331 }
332 $records[$record->getRecordId()] = $record;
333 }
334 }
335 }
336
337 if ($optional) {
338 if (!$config_setting && !in_array($a_sub_type, array("orgu_type", "prg_type"))) { //#16925 + #17777
339 $selected = array();
340 } else {
341 $selected = self::getObjRecSelection($a_obj_id, $a_sub_type);
342 }
343 foreach ($optional as $record_id) {
344 if (!in_array($record_id, $selected)) {
345 unset($records[$record_id]);
346 }
347 }
348 }
349
350 return $records;
351 }
static getObjRecSelection($a_obj_id, $a_sub_type="")
Get repository object record selection.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static _lookupObjId($a_id)

References $record_id, $records, ilContainer\_lookupContainerSetting(), ilObject\_lookupObjId(), ilObjectServiceSettingsGUI\CUSTOM_METADATA, and getObjRecSelection().

Referenced by ilGlossaryTerm\_copyTerm(), ilWikiFunctionsBlockGUI\fillDataSection(), ilPCAMDPageList\findPages(), ilAdvancedMDRecordGUI\getActiveRecords(), ilObjBookingPool\getAdvancedMDFields(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilObjectMetaDataGUI\getBlockHTML(), ilAdvancedMDValues\getInstancesForObjectId(), ilObjectMetaDataGUI\getKeyValueList(), ilObjectMetaDataGUI\hasActiveRecords(), ilObjWikiGUI\initSettingsForm(), ilAdvancedMDValues\preloadedRead(), and ilAdvancedMDValues\queryForRecords().

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

◆ _lookupRecordIdByImportId()

static ilAdvancedMDRecord::_lookupRecordIdByImportId (   $a_ilias_id)
static

Lookup record Id by import id.

@access public

Parameters
stringilias id

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

132 {
133 global $ilDB;
134
135 $query = "SELECT record_id FROM adv_md_record " .
136 "WHERE import_id = " . $ilDB->quote($a_ilias_id, 'text') . " ";
137 $res = $ilDB->query($query);
138 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
139 return $row->record_id;
140 }
141 return 0;
142 }

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

Referenced by ilAdvancedMDRecordParser\extractRecordId().

+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilAdvancedMDRecord::_lookupTitle (   $a_record_id)
static

Lookup title.

@access public

Parameters
intrecord_id

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

106 {
107 static $title_cache = array();
108
109 if (isset($title_cache[$a_record_id])) {
110 return $title_cache[$a_record_id];
111 }
112
113 global $ilDB;
114
115 $query = "SELECT title FROM adv_md_record " .
116 "WHERE record_id = " . $ilDB->quote($a_record_id, 'integer') . " ";
117 $res = $ilDB->query($query);
119
120 return $title_cache[$a_record_id] = $row->title;
121 }

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

Referenced by ilAdvancedMDSettingsGUI\initFormSubstitutions(), ilAdvancedMDRecordGUI\parseInfoPage(), ilECSSettingsGUI\prepareFieldSelection(), and ilLuceneAdvancedSearchFields\readSections().

+ Here is the caller graph for this function:

◆ appendAssignedObjectType()

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

append assigned object types

@access public

Parameters
stringilias object type

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

701 {
702 $this->obj_types[] = array(
703 "obj_type"=>$a_obj_type,
704 "sub_type"=>$a_sub_type,
705 "optional"=>(bool) $a_optional
706 );
707 }

◆ delete()

ilAdvancedMDRecord::delete ( )

Delete.

@access public

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

418 {
421 }
static deleteByRecordI($a_record_id)
delete by record id
static _delete($a_record_id)
Delete record and all related data.

References _delete(), ilAdvancedMDRecordScope\deleteByRecordI(), and getRecordId().

+ Here is the call graph for this function:

◆ enabledScope()

ilAdvancedMDRecord::enabledScope ( )

Is scope enabled.

Returns
scope

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

References $scope_enabled.

◆ enableScope()

ilAdvancedMDRecord::enableScope (   $a_stat)

Enable scope restrictions.

Parameters
bool$a_stat

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

437 {
438 $this->scope_enabled = $a_stat;
439 }

◆ generateImportId()

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

@access protected

Returns

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

842 {
843 return 'il_' . IL_INST_ID . '_adv_md_record_' . $this->getRecordId();
844 }

References getRecordId().

Referenced by save(), and toXML().

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

◆ getAssignedObjectTypes()

ilAdvancedMDRecord::getAssignedObjectTypes ( )

Get assigned object types.

@access public

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

716 {
717 return $this->obj_types ? $this->obj_types : array();
718 }

Referenced by _clone(), isAssignedObjectType(), save(), toXML(), and update().

+ Here is the caller graph for this function:

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

get description

@access public

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

References $description.

Referenced by _clone(), save(), toXML(), and update().

+ Here is the caller graph for this function:

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

get import id

@access public

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

References $import_id.

Referenced by save().

+ Here is the caller graph for this function:

◆ getObjRecSelection()

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

Get repository object record selection.

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

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

898 {
899 global $ilDB;
900
901 if ($a_sub_type == "") {
902 $a_sub_type = "-";
903 }
904
905 $recs = array();
906 $set = $ilDB->query(
907 $r = "SELECT * FROM adv_md_obj_rec_select " .
908 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
909 " AND sub_type = " . $ilDB->quote($a_sub_type, "text")
910 );
911 while ($rec = $ilDB->fetchAssoc($set)) {
912 $recs[] = $rec["rec_id"];
913 }
914 return $recs;
915 }
$r
Definition: example_031.php:79

References $ilDB, and $r.

Referenced by ilAdvancedMDValues\_cloneValues(), _getSelectedRecordsByObject(), ilGlossaryExporter\getActiveAdvMDRecords(), ilWikiExporter\getActiveAdvMDRecords(), ilAdvancedMDSettingsGUI\getParsedRecordObjects(), getSharedRecords(), and ilAdvancedMDRecordGUI\parseRecordSelection().

+ Here is the caller graph for this function:

◆ getParentObject()

ilAdvancedMDRecord::getParentObject ( )

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

References $parent_obj.

Referenced by _clone(), and save().

+ Here is the caller graph for this function:

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

Get record id.

@access public

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

585 {
586 return $this->record_id;
587 }

References $record_id.

Referenced by __construct(), __destruct(), _clone(), delete(), generateImportId(), read(), save(), toXML(), and update().

+ Here is the caller graph for this function:

◆ getScopeRefIds()

ilAdvancedMDRecord::getScopeRefIds ( )

Get scope gef_ids.

Returns
type

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

464 {
465 $ref_ids = [];
466 foreach ($this->scopes as $scope) {
467 $ref_ids[] = $scope->getRefId();
468 }
469 return $ref_ids;
470 }

Referenced by toXML().

+ Here is the caller graph for this function:

◆ getScopes()

ilAdvancedMDRecord::getScopes ( )

Get scopes.

Returns
ilAdvancedMDRecordScope[]

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

References $scopes.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ getSharedRecords()

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

Get shared records.

Parameters
int$a_obj1_id
int$a_obj2_id
string$a_sub_type
Returns
array

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

954 {
955 $obj_type = ilObject::_lookupType($a_obj1_id);
956 $sel = array_intersect(
957 ilAdvancedMDRecord::getObjRecSelection($a_obj1_id, $a_sub_type),
958 ilAdvancedMDRecord::getObjRecSelection($a_obj2_id, $a_sub_type)
959 );
960
961 $res = array();
962
963 foreach (self::_getRecords() as $record) {
964 // local records cannot be shared
965 if ($record->getParentObject()) {
966 continue;
967 }
968
969 // :TODO: inactive records can be ignored?
970 if (!$record->isActive()) {
971 continue;
972 }
973
974 // parse assigned types
975 foreach ($record->getAssignedObjectTypes() as $item) {
976 if ($item["obj_type"] == $obj_type &&
977 $item["sub_type"] == $a_sub_type) {
978 // mandatory
979 if (!$item["optional"]) {
980 $res[] = $record->getRecordId();
981 }
982 // optional
983 elseif (in_array($record->getRecordId(), $sel)) {
984 $res[] = $record->getRecordId();
985 }
986 }
987 }
988 }
989
990 return $res;
991 }
static _lookupType($a_id, $a_reference=false)
lookup object type

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

+ Here is the call graph for this function:

◆ getTitle()

ilAdvancedMDRecord::getTitle ( )

get title

@access public

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

References $title.

Referenced by _clone(), save(), toXML(), update(), and validate().

+ Here is the caller graph for this function:

◆ isActive()

ilAdvancedMDRecord::isActive ( )

Check if record is active.

@access public

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

608 {
609 return (bool) $this->active;
610 }

References $active.

Referenced by _clone(), save(), toXML(), and update().

+ Here is the caller graph for this function:

◆ isAssignedObjectType()

ilAdvancedMDRecord::isAssignedObjectType (   $a_obj_type,
  $a_sub_type 
)

Is assigned object type?

Parameters

return

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

727 {
728 foreach ($this->getAssignedObjectTypes() as $t) {
729 if ($t["obj_type"] == $a_obj_type &&
730 $t["sub_type"] == $a_sub_type) {
731 return true;
732 }
733 }
734 return false;
735 }

References $t, and getAssignedObjectTypes().

+ Here is the call graph for this function:

◆ isFilteredByScope()

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

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

Parameters
type$a_ref_id
ilAdvancedMDRecordScope[]$scopes

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

359 {
360 $tree = $GLOBALS['DIC']->repositoryTree();
361 $logger = $GLOBALS['DIC']->logger()->amet();
362
363 if (!count($scopes)) {
364 $logger->debug('No md scope restrictions.');
365 return false;
366 }
367 foreach ($scopes as $scope) {
368 $logger->debug('Comparing: ' . $a_ref_id . ' with: ' . $scope->getRefId());
369 if ($scope->getRefId() == $a_ref_id) {
370 $logger->debug('Elements are equal. No scope restrictions.');
371 return false;
372 }
373 if ($tree->getRelation($scope->getRefId(), $a_ref_id) == ilTree::RELATION_PARENT) {
374 $logger->debug('Node is child node. No scope restrictions.');
375 return false;
376 }
377 }
378 $logger->info('Scope filter matches.');
379
380 return true;
381 }
const RELATION_PARENT
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

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

Referenced by ilAdvancedMDSettingsGUI\getParsedRecordObjects().

+ Here is the caller graph for this function:

◆ read()

ilAdvancedMDRecord::read ( )
private

read record and assiged object types

@access private

Parameters

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

800 {
801 global $ilDB;
802
803 $query = "SELECT * FROM adv_md_record " .
804 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
805 $res = $this->db->query($query);
806 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
807 $this->setImportId($row->import_id);
808 $this->setActive($row->active);
809 $this->setTitle($row->title);
810 $this->setDescription($row->description);
811 $this->setParentObject($row->parent_obj);
812 }
813 $query = "SELECT * FROM adv_md_record_objs " .
814 "WHERE record_id = " . $this->db->quote($this->getRecordId(), 'integer') . " ";
815 $res = $this->db->query($query);
816 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
817 $this->obj_types[] = array(
818 "obj_type" => $row->obj_type,
819 "sub_type" => $row->sub_type,
820 "optional" => (bool) $row->optional
821 );
822 }
823
824 $query = 'SELECT scope_id FROM adv_md_record_scope ' .
825 'WHERE record_id = ' . $ilDB->quote($this->record_id);
826 $res = $ilDB->query($query);
827 $this->scope_enabled = false;
828 $this->scopes = [];
829 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
830 $this->scope_enabled = true;
831 $this->scopes[] = new ilAdvancedMDRecordScope($row->scope_id);
832 }
833 }
Scope restrictions for advanced md records.
setTitle($a_title)
Set title.
setDescription($a_description)
set description
setActive($a_active)
Set active.
setImportId($a_id_string)
set import id

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, getRecordId(), setActive(), setDescription(), setImportId(), setParentObject(), and setTitle().

Referenced by __construct().

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

◆ save()

ilAdvancedMDRecord::save ( )

save

@access public

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

479 {
480 global $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) " .
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 ")";
494 $res = $ilDB->manipulate($query);
495 $this->record_id = $next_id;
496
497 if (!strlen($this->getImportId())) {
498 // set import id to default value
499 $query = "UPDATE adv_md_record " .
500 "SET import_id = " . $this->db->quote($this->generateImportId(), 'text') . " " .
501 "WHERE record_id = " . $this->db->quote($this->record_id, 'integer') . " ";
502 $res = $ilDB->manipulate($query);
503 }
504
505 foreach ($this->getAssignedObjectTypes() as $type) {
506 global $ilDB;
507
508 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) " .
509 "VALUES( " .
510 $this->db->quote($this->getRecordId(), 'integer') . ", " .
511 $this->db->quote($type["obj_type"], 'text') . ", " .
512 $this->db->quote($type["sub_type"], 'text') . ", " .
513 $this->db->quote($type["optional"], 'integer') . " " .
514 ")";
515 $res = $ilDB->manipulate($query);
516 }
517
518 foreach ($this->getScopes() as $scope) {
519 $scope->setRecordId($this->getRecordId());
520 $scope->save();
521 }
522 }
generateImportId()
generate unique record id
$type

References $ilDB, $query, $res, $type, generateImportId(), getAssignedObjectTypes(), getDescription(), getImportId(), getParentObject(), getRecordId(), getScopes(), getTitle(), and isActive().

+ Here is the call graph for this function:

◆ saveObjRecSelection()

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

Save repository object record selection.

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

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

864 {
865 global $ilDB;
866
867 if ($a_sub_type == "") {
868 $a_sub_type = "-";
869 }
870
871 if ((bool) $a_delete_before) {
872 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE " .
873 " obj_id = " . $ilDB->quote($a_obj_id, "integer") .
874 " AND sub_type = " . $ilDB->quote($a_sub_type, "text"));
875 }
876
877 if (is_array($a_records)) {
878 foreach ($a_records as $r) {
879 if ($r > 0) {
880 $ilDB->manipulate("INSERT INTO adv_md_obj_rec_select " .
881 "(obj_id, rec_id, sub_type) VALUES (" .
882 $ilDB->quote($a_obj_id, "integer") . "," .
883 $ilDB->quote($r, "integer") . "," .
884 $ilDB->quote($a_sub_type, "text") .
885 ")");
886 }
887 }
888 }
889 }

References $ilDB, and $r.

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

+ Here is the caller graph for this function:

◆ setActive()

ilAdvancedMDRecord::setActive (   $a_active)

Set active.

@access public

Parameters

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

597 {
598 $this->active = $a_active;
599 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setAssignedObjectTypes()

ilAdvancedMDRecord::setAssignedObjectTypes (   $a_obj_types)

Set assigned object types.

@access public

Parameters
arrayarray(string) array of object types. E.g array('crs','crsl')

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

689 {
690 $this->obj_types = $a_obj_types;
691 }

◆ setDescription()

ilAdvancedMDRecord::setDescription (   $a_description)

set description

@access public

Parameters
stringdescription

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

643 {
644 $this->description = $a_description;
645 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setImportId()

ilAdvancedMDRecord::setImportId (   $a_id_string)

set import id

@access public

Parameters
stringimport id

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

666 {
667 $this->import_id = $a_id_string;
668 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setParentObject()

ilAdvancedMDRecord::setParentObject (   $a_obj_id)

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

738 {
739 $this->parent_obj = $a_obj_id;
740 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setScopes()

ilAdvancedMDRecord::setScopes ( array  $a_scopes)

Set scopes.

Parameters
array$a_scopes

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

446 {
447 $this->scopes = $a_scopes;
448 }

◆ setTitle()

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

@access public

Parameters
stringtitle

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

620 {
621 $this->title = $a_title;
622 }

Referenced by read().

+ Here is the caller graph for this function:

◆ 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.

@access public

Parameters
objectilXmlWriter

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

757 {
758 $writer->xmlStartTag('Record', array('active' => $this->isActive() ? 1 : 0,
759 'id' => $this->generateImportId()));
760 $writer->xmlElement('Title', null, $this->getTitle());
761 $writer->xmlElement('Description', null, $this->getDescription());
762
763 foreach ($this->getAssignedObjectTypes() as $obj_type) {
764 $optional = array("optional"=>$obj_type["optional"]);
765 if ($obj_type["sub_type"] == "") {
766 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"]);
767 } else {
768 $writer->xmlElement('ObjectType', $optional, $obj_type["obj_type"] . ":" . $obj_type["sub_type"]);
769 }
770 }
771
772 // scopes
773 if (count($this->getScopeRefIds())) {
774 $writer->xmlStartTag('Scope');
775 }
776 foreach ($this->getScopeRefIds() as $ref_id) {
778 $writer->xmlElement('ScopeEntry', ['id' => 'il_' . IL_INST_ID . '_' . $type . '_' . $ref_id]);
779 }
780 if (count($this->getScopeRefIds())) {
781 $writer->xmlEndTag('Scope');
782 }
783
784
785 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
786 foreach (ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->getRecordId()) as $definition) {
787 $definition->toXML($writer);
788 }
789 $writer->xmlEndTag('Record');
790 }
getScopeRefIds()
Get scope gef_ids.
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.

References $type, ilObject\_lookupObjId(), ilObject\_lookupType(), generateImportId(), getAssignedObjectTypes(), getDescription(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getRecordId(), getScopeRefIds(), getTitle(), isActive(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilAdvancedMDRecord::update ( )

update

@access public

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

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

References $ilDB, $query, $res, $type, ilAdvancedMDRecordScope\deleteByRecordI(), getAssignedObjectTypes(), getDescription(), getRecordId(), getScopes(), getTitle(), and isActive().

+ Here is the call graph for this function:

◆ validate()

ilAdvancedMDRecord::validate ( )

Validate settings.

@access public

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

571 {
572 if (!strlen($this->getTitle())) {
573 return false;
574 }
575 return true;
576 }

References getTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $active

ilAdvancedMDRecord::$active
protected

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

Referenced by isActive().

◆ $db

ilAdvancedMDRecord::$db = null
protected

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

◆ $description

ilAdvancedMDRecord::$description
protected

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

Referenced by getDescription().

◆ $import_id

ilAdvancedMDRecord::$import_id
protected

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

Referenced by getImportId().

◆ $instances

ilAdvancedMDRecord::$instances = array()
staticprivate

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

◆ $obj_types

ilAdvancedMDRecord::$obj_types = array()
protected

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

Referenced by _getActivatedObjTypes().

◆ $parent_obj

ilAdvancedMDRecord::$parent_obj
protected

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

Referenced by getParentObject().

◆ $record_id

ilAdvancedMDRecord::$record_id
protected

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

Referenced by _getSelectedRecordsByObject(), and getRecordId().

◆ $scope_enabled

ilAdvancedMDRecord::$scope_enabled = false
protected

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

Referenced by enabledScope().

◆ $scopes

ilAdvancedMDRecord::$scopes = []
protected

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

Referenced by getScopes(), and isFilteredByScope().

◆ $title

ilAdvancedMDRecord::$title
protected

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

Referenced by getTitle().


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