ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 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_obj_id, $a_sub_type="")
 Get selected records by object. 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
 

Private Member Functions

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

Static Private Attributes

static $instances = array()
 

Detailed Description

Definition at line 15 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 37 of file class.ilAdvancedMDRecord.php.

38 {
39 global $ilDB;
40
41 $this->record_id = $a_record_id;
42 $this->db = $ilDB;
43
44 if($this->getRecordId())
45 {
46 $this->read();
47 }
48 }
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 779 of file class.ilAdvancedMDRecord.php.

780 {
781 unset(self::$instances[$this->getRecordId()]);
782 }

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

858 {
859 $new_obj = new self();
860 $new_obj->setActive($this->isActive());
861 $new_obj->setTitle($this->getTitle());
862 $new_obj->setDescription($this->getDescription());
863 $new_obj->setParentObject($a_parent_obj_id
864 ? $a_parent_obj_id
865 : $this->getParentObject());
866 $new_obj->setAssignedObjectTypes($this->getAssignedObjectTypes());
867 $new_obj->save();
868
869 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
871 {
872 $new_def = $definition->_clone($new_obj->getRecordId());
873 $a_fields_map[$definition->getFieldId()] = $new_def->getFieldId();
874 }
875
876 return $new_obj;
877 }
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 388 of file class.ilAdvancedMDRecord.php.

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

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 {
194 $obj_types[] = $row->obj_type;
195 }
196 return $obj_types ? $obj_types : array();
197 }

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

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

252 {
253 global $ilDB;
254
255 $records = array();
256
257 if ($a_sub_type == "")
258 {
259 $a_sub_type = "-";
260 }
261
262 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro ".
263 "JOIN adv_md_record amr ON amr.record_id = amro.record_id ".
264 "WHERE active = 1 ".
265 "AND obj_type = ".$ilDB->quote($a_obj_type ,'text')." ".
266 "AND sub_type = ".$ilDB->quote($a_sub_type ,'text');
267
268 if($a_only_optional)
269 {
270 $query .= " AND optional =".$ilDB->quote(1, 'integer');
271 }
272
273 // #16428
274 $query .= "ORDER by parent_obj DESC, record_id";
275
276 $res = $ilDB->query($query);
277 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
278 {
280 }
281
282 return $records;
283 }
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(), 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 74 of file class.ilAdvancedMDRecord.php.

75 {
76 global $ilDB;
77
78 $query = "SELECT DISTINCT(amr.record_id) FROM adv_md_record amr ".
79 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
80 "WHERE searchable = 1 AND active = 1 ";
81
82 $res = $ilDB->query($query);
83 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
84 {
86 }
87 return $records ? $records : array();
88 }

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

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

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

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

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

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

59 {
60 if(isset(self::$instances[$a_record_id]))
61 {
62 return self::$instances[$a_record_id];
63 }
64 return self::$instances[$a_record_id] = new ilAdvancedMDRecord($a_record_id);
65 }

Referenced by _getActivatedRecordsByObjectType(), _getActiveSearchableRecords(), _getAllRecordsByObjectType(), _getRecords(), ilAdvancedMDSettingsGUI\confirmDeleteRecords(), ilAdvancedMDSettingsGUI\deleteRecords(), ilAdvancedMDSettingsGUI\exportRecords(), 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

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))
214 {
216 }
217 return $records ? $records : array();
218 }

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_obj_id,
  $a_sub_type = "" 
)
static

Get selected records by object.

Parameters
string$a_obj_typeobject type
string$a_obj_idobject id
string$a_sub_typesub type

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

293 {
294 $records = array();
295
296 if ($a_sub_type == "")
297 {
298 $a_sub_type = "-";
299 }
300
301 // object-wide metadata configuration setting
302 include_once 'Services/Container/classes/class.ilContainer.php';
303 include_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
304 $config_setting = ilContainer::_lookupContainerSetting(
305 $a_obj_id,
307 false);
308
309 $optional = array();
310 foreach(self::_getActivatedRecordsByObjectType($a_obj_type, $a_sub_type) as $record)
311 {
312 foreach($record->getAssignedObjectTypes() as $item)
313 {
314 if($record->getParentObject())
315 {
316 // only matching local records
317 if($record->getParentObject() != $a_obj_id)
318 {
319 continue;
320 }
321 // if object-wide setting is off, ignore local records
322 else if(!$config_setting)
323 {
324 continue;
325 }
326 }
327
328 if($item['obj_type'] == $a_obj_type &&
329 $item['sub_type'] == $a_sub_type)
330 {
331 if($item['optional'])
332 {
333 $optional[] = $record->getRecordId();
334 }
335 $records[$record->getRecordId()] = $record;
336 }
337 }
338 }
339
340 if($optional)
341 {
342 if(!$config_setting && !in_array($a_sub_type, array("orgu_type", "prg_type"))) //#16925 + #17777
343 {
344 $selected = array();
345 }
346 else
347 {
348 $selected = self::getObjRecSelection($a_obj_id, $a_sub_type);
349 }
350 foreach($optional as $record_id)
351 {
352 if(!in_array($record_id, $selected))
353 {
354 unset($records[$record_id]);
355 }
356 }
357 }
358
359 /* v1 obsolete
360 $query = "SELECT amro.record_id record_id FROM adv_md_record_objs amro ".
361 "JOIN adv_md_record amr ON (amr.record_id = amro.record_id) ".
362 "JOIN adv_md_obj_rec_select os ON (amr.record_id = os.rec_id AND amro.sub_type = os.sub_type) ".
363 "WHERE active = 1 ".
364 "AND amro.obj_type = ".$ilDB->quote($a_obj_type ,'text')." ".
365 "AND amro.sub_type = ".$ilDB->quote($a_sub_type ,'text')." ".
366 "AND os.obj_id = ".$ilDB->quote($a_obj_id ,'integer')
367 ;
368
369 $res = $ilDB->query($query);
370 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
371 {
372 $records[] = self::_getInstanceByRecordId($row->record_id);
373 }
374 */
375
376 return $records;
377 }
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.

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

Referenced by ilGlossaryTerm\_copyTerm(), ilWikiFunctionsBlockGUI\fillDataSection(), ilPCAMDPageList\findPages(), ilGlossaryExporter\getActiveAdvMDRecords(), 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 125 of file class.ilAdvancedMDRecord.php.

126 {
127 global $ilDB;
128
129 $query = "SELECT record_id FROM adv_md_record ".
130 "WHERE import_id = ".$ilDB->quote($a_ilias_id ,'text')." ";
131 $res = $ilDB->query($query);
132 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
133 {
134 return $row->record_id;
135 }
136 return 0;
137 }

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

99 {
100 static $title_cache = array();
101
102 if(isset($title_cache[$a_record_id]))
103 {
104 return $title_cache[$a_record_id];
105 }
106
107 global $ilDB;
108
109 $query = "SELECT title FROM adv_md_record ".
110 "WHERE record_id = ".$ilDB->quote($a_record_id ,'integer')." ";
111 $res = $ilDB->query($query);
113
114 return $title_cache[$a_record_id] = $row->title;
115 }

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

642 {
643 $this->obj_types[] = array(
644 "obj_type"=>$a_obj_type,
645 "sub_type"=>$a_sub_type,
646 "optional"=>(bool)$a_optional
647 );
648 }

◆ delete()

ilAdvancedMDRecord::delete ( )

Delete.

@access public

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

415 {
417 }
static _delete($a_record_id)
Delete record and all related data.

References _delete(), and getRecordId().

+ Here is the call graph for this function:

◆ generateImportId()

ilAdvancedMDRecord::generateImportId ( )
protected

generate unique record id

@access protected

Returns

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

769 {
770 return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
771 }

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

657 {
658 return $this->obj_types ? $this->obj_types : array();
659 }

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 594 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 617 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 829 of file class.ilAdvancedMDRecord.php.

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

References $ilDB, and $r.

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

+ Here is the caller graph for this function:

◆ getParentObject()

ilAdvancedMDRecord::getParentObject ( )

Definition at line 685 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 525 of file class.ilAdvancedMDRecord.php.

526 {
527 return $this->record_id;
528 }

References $record_id.

Referenced by __construct(), __destruct(), _clone(), delete(), generateImportId(), read(), save(), toXML(), 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 887 of file class.ilAdvancedMDRecord.php.

888 {
889 $obj_type = ilObject::_lookupType($a_obj1_id);
890 $sel = array_intersect(
891 ilAdvancedMDRecord::getObjRecSelection($a_obj1_id, $a_sub_type),
892 ilAdvancedMDRecord::getObjRecSelection($a_obj2_id, $a_sub_type)
893 );
894
895 $res = array();
896
897 foreach(self::_getRecords() as $record)
898 {
899 // local records cannot be shared
900 if($record->getParentObject())
901 {
902 continue;
903 }
904
905 // :TODO: inactive records can be ignored?
906 if(!$record->isActive())
907 {
908 continue;
909 }
910
911 // parse assigned types
912 foreach($record->getAssignedObjectTypes() as $item)
913 {
914 if($item["obj_type"] == $obj_type &&
915 $item["sub_type"] == $a_sub_type)
916 {
917 // mandatory
918 if(!$item["optional"])
919 {
920 $res[] = $record->getRecordId();
921 }
922 // optional
923 else if(in_array($record->getRecordId(), $sel))
924 {
925 $res[] = $record->getRecordId();
926 }
927 }
928 }
929 }
930
931 return $res;
932 }
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 571 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 548 of file class.ilAdvancedMDRecord.php.

549 {
550 return (bool) $this->active;
551 }

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

668 {
669 foreach ($this->getAssignedObjectTypes() as $t)
670 {
671 if ($t["obj_type"] == $a_obj_type &&
672 $t["sub_type"] == $a_sub_type)
673 {
674 return true;
675 }
676 }
677 return false;
678 }

References $t, and getAssignedObjectTypes().

+ Here is the call graph for this function:

◆ read()

ilAdvancedMDRecord::read ( )
private

read record and assiged object types

@access private

Parameters

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

735 {
736 global $ilDB;
737
738 $query = "SELECT * FROM adv_md_record ".
739 "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
740 $res = $this->db->query($query);
741 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
742 {
743 $this->setImportId($row->import_id);
744 $this->setActive($row->active);
745 $this->setTitle($row->title);
746 $this->setDescription($row->description);
747 $this->setParentObject($row->parent_obj);
748 }
749 $query = "SELECT * FROM adv_md_record_objs ".
750 "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
751 $res = $this->db->query($query);
752 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
753 {
754 $this->obj_types[] = array(
755 "obj_type" => $row->obj_type,
756 "sub_type" => $row->sub_type,
757 "optional" => (bool)$row->optional
758 );
759 }
760 }
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 425 of file class.ilAdvancedMDRecord.php.

426 {
427 global $ilDB;
428
429 // Save import id if given
430 $next_id = $ilDB->nextId('adv_md_record');
431
432 $query = "INSERT INTO adv_md_record (record_id,import_id,active,title,description,parent_obj) ".
433 "VALUES(".
434 $ilDB->quote($next_id,'integer').", ".
435 $this->db->quote($this->getImportId(),'text').", ".
436 $this->db->quote($this->isActive() ,'integer').", ".
437 $this->db->quote($this->getTitle() ,'text').", ".
438 $this->db->quote($this->getDescription() ,'text').", ".
439 $this->db->quote($this->getParentObject() ,'integer')." ".
440 ")";
441 $res = $ilDB->manipulate($query);
442 $this->record_id = $next_id;
443
444 if(!strlen($this->getImportId()))
445 {
446 // set import id to default value
447 $query = "UPDATE adv_md_record ".
448 "SET import_id = ".$this->db->quote($this->generateImportId() ,'text')." ".
449 "WHERE record_id = ".$this->db->quote($this->record_id ,'integer')." ";
450 $res = $ilDB->manipulate($query);
451 }
452
453 foreach($this->getAssignedObjectTypes() as $type)
454 {
455 global $ilDB;
456
457 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) ".
458 "VALUES( ".
459 $this->db->quote($this->getRecordId() ,'integer').", ".
460 $this->db->quote($type["obj_type"] ,'text').", ".
461 $this->db->quote($type["sub_type"] ,'text').", ".
462 $this->db->quote($type["optional"] ,'integer')." ".
463 ")";
464 $res = $ilDB->manipulate($query);
465 }
466 }
generateImportId()
generate unique record id

References $ilDB, $query, $res, generateImportId(), getAssignedObjectTypes(), getDescription(), getImportId(), getParentObject(), getRecordId(), 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 790 of file class.ilAdvancedMDRecord.php.

791 {
792 global $ilDB;
793
794 if ($a_sub_type == "")
795 {
796 $a_sub_type = "-";
797 }
798
799 if((bool)$a_delete_before)
800 {
801 $ilDB->manipulate("DELETE FROM adv_md_obj_rec_select WHERE ".
802 " obj_id = ".$ilDB->quote($a_obj_id, "integer").
803 " AND sub_type = ".$ilDB->quote($a_sub_type, "text"));
804 }
805
806 if (is_array($a_records))
807 {
808 foreach ($a_records as $r)
809 {
810 if ($r > 0)
811 {
812 $ilDB->manipulate("INSERT INTO adv_md_obj_rec_select ".
813 "(obj_id, rec_id, sub_type) VALUES (".
814 $ilDB->quote($a_obj_id, "integer").",".
815 $ilDB->quote($r, "integer").",".
816 $ilDB->quote($a_sub_type, "text").
817 ")");
818 }
819 }
820 }
821 }

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

538 {
539 $this->active = $a_active;
540 }

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

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

◆ setDescription()

ilAdvancedMDRecord::setDescription (   $a_description)

set description

@access public

Parameters
stringdescription

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

584 {
585 $this->description = $a_description;
586 }

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

607 {
608 $this->import_id = $a_id_string;
609 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setParentObject()

ilAdvancedMDRecord::setParentObject (   $a_obj_id)

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

681 {
682 $this->parent_obj = $a_obj_id;
683 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setTitle()

ilAdvancedMDRecord::setTitle (   $a_title)

Set title.

@access public

Parameters
stringtitle

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

561 {
562 $this->title = $a_title;
563 }

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

700 {
701 $writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
702 'id' => $this->generateImportId()));
703 $writer->xmlElement('Title',null,$this->getTitle());
704 $writer->xmlElement('Description',null,$this->getDescription());
705
706 foreach($this->getAssignedObjectTypes() as $obj_type)
707 {
708 $optional = array("optional"=>$obj_type["optional"]);
709 if ($obj_type["sub_type"] == "")
710 {
711 $writer->xmlElement('ObjectType',$optional,$obj_type["obj_type"]);
712 }
713 else
714 {
715 $writer->xmlElement('ObjectType',$optional,$obj_type["obj_type"].":".$obj_type["sub_type"]);
716 }
717 }
718
719 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
721 {
722 $definition->toXML($writer);
723 }
724 $writer->xmlEndTag('Record');
725 }
xmlEndTag($tag)
Writes an endtag.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)

References generateImportId(), getAssignedObjectTypes(), getDescription(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), getRecordId(), 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 474 of file class.ilAdvancedMDRecord.php.

475 {
476 global $ilDB;
477
478 $query = "UPDATE adv_md_record ".
479 "SET active = ".$this->db->quote($this->isActive() ,'integer').", ".
480 "title = ".$this->db->quote($this->getTitle() ,'text').", ".
481 "description = ".$this->db->quote($this->getDescription() ,'text')." ".
482 "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
483 $res = $ilDB->manipulate($query);
484
485 // Delete assignments
486 $query = "DELETE FROM adv_md_record_objs ".
487 "WHERE record_id = ".$this->db->quote($this->getRecordId() ,'integer')." ";
488 $res = $ilDB->manipulate($query);
489
490 // Insert assignments
491 foreach($this->getAssignedObjectTypes() as $type)
492 {
493 $query = "INSERT INTO adv_md_record_objs (record_id,obj_type,sub_type,optional) ".
494 "VALUES ( ".
495 $this->db->quote($this->getRecordId() ,'integer').", ".
496 $this->db->quote($type["obj_type"] ,'text').", ".
497 $this->db->quote($type["sub_type"] ,'text').", ".
498 $this->db->quote($type["optional"] ,'integer')." ".
499 ")";
500 $res = $ilDB->manipulate($query);
501 }
502 }

References $ilDB, $query, $res, getAssignedObjectTypes(), getDescription(), getRecordId(), getTitle(), and isActive().

+ Here is the call graph for this function:

◆ validate()

ilAdvancedMDRecord::validate ( )

Validate settings.

@access public

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

511 {
512 if(!strlen($this->getTitle()))
513 {
514 return false;
515 }
516 return true;
517 }

References getTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $active

ilAdvancedMDRecord::$active
protected

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

Referenced by isActive().

◆ $db

ilAdvancedMDRecord::$db = null
protected

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

◆ $description

ilAdvancedMDRecord::$description
protected

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

Referenced by getDescription().

◆ $import_id

ilAdvancedMDRecord::$import_id
protected

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

Referenced by getImportId().

◆ $instances

ilAdvancedMDRecord::$instances = array()
staticprivate

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

◆ $obj_types

ilAdvancedMDRecord::$obj_types = array()
protected

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

Referenced by _getActivatedObjTypes().

◆ $parent_obj

ilAdvancedMDRecord::$parent_obj
protected

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

Referenced by getParentObject().

◆ $record_id

ilAdvancedMDRecord::$record_id
protected

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

Referenced by _getSelectedRecordsByObject(), and getRecordId().

◆ $title

ilAdvancedMDRecord::$title
protected

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

Referenced by getTitle().


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