ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 Write error message to ilErr. 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...
 

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

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

784 {
785 unset(self::$instances[$this->getRecordId()]);
786 }

References getRecordId().

+ Here is the call graph for this function:

Member Function Documentation

◆ _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 }
static getInstancesByRecordId($a_record_id, $a_only_searchable=false)
Get definitions by record id.

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(DB_FETCHMODE_OBJECT))
193 {
194 $obj_types[] = $row->obj_type;
195 }
196 return $obj_types ? $obj_types : array();
197 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

References $ilDB, $obj_types, $query, $res, $row, and DB_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(DB_FETCHMODE_OBJECT))
278 {
280 }
281
282 return $records;
283 }
static _getInstanceByRecordId($a_record_id)
Get instance by record id.
$records
Definition: simple_test.php:17

References $ilDB, $query, $records, $res, $row, _getInstanceByRecordId(), and DB_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(DB_FETCHMODE_OBJECT))
84 {
86 }
87 return $records ? $records : array();
88 }

References $ilDB, $query, $records, $res, $row, _getInstanceByRecordId(), and DB_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(DB_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 DB_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:40

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

References $ilDB, $query, $records, $res, $row, _getInstanceByRecordId(), and DB_FETCHMODE_OBJECT.

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

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

◆ _getSelectedRecordsByObject()

static ilAdvancedMDRecord::_getSelectedRecordsByObject (   $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(DB_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.
_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 ilWikiFunctionsBlockGUI\fillDataSection(), ilPCAMDPageList\findPages(), ilGlossaryExporter\getActiveAdvMDRecords(), ilAdvancedMDRecordGUI\getActiveRecords(), ilObjBookingPool\getAdvancedMDFields(), ilGlossaryAdvMetaDataAdapter\getAllFields(), ilObjectMetaDataGUI\getBlockHTML(), ilAdvancedMDValues\getInstancesForObjectId(), 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(DB_FETCHMODE_OBJECT))
133 {
134 return $row->record_id;
135 }
136 return 0;
137 }

References $ilDB, $query, $res, $row, and DB_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);
112 $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
113
114 return $title_cache[$a_record_id] = $row->title;
115 }

References $ilDB, $query, $res, $row, and DB_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 645 of file class.ilAdvancedMDRecord.php.

646 {
647 $this->obj_types[] = array(
648 "obj_type"=>$a_obj_type,
649 "sub_type"=>$a_sub_type,
650 "optional"=>(bool)$a_optional
651 );
652 }

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

773 {
774 return 'il_'.IL_INST_ID.'_adv_md_record_'.$this->getRecordId();
775 }

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

661 {
662 return $this->obj_types ? $this->obj_types : array();
663 }

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

+ Here is the caller graph for this function:

◆ getDescription()

ilAdvancedMDRecord::getDescription ( )

get description

@access public

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

References $description.

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

+ Here is the caller graph for this function:

◆ getImportId()

ilAdvancedMDRecord::getImportId ( )

get import id

@access public

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

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

References $ilDB, and $r.

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

+ Here is the caller graph for this function:

◆ getParentObject()

ilAdvancedMDRecord::getParentObject ( )

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

References $parent_obj.

Referenced by save().

+ Here is the caller graph for this function:

◆ getRecordId()

ilAdvancedMDRecord::getRecordId ( )

Get record id.

@access public

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

530 {
531 return $this->record_id;
532 }

References $record_id.

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

+ Here is the caller graph for this function:

◆ getTitle()

ilAdvancedMDRecord::getTitle ( )

get title

@access public

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

References $title.

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

553 {
554 return (bool) $this->active;
555 }

References $active.

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

672 {
673 foreach ($this->getAssignedObjectTypes() as $t)
674 {
675 if ($t["obj_type"] == $a_obj_type &&
676 $t["sub_type"] == $a_sub_type)
677 {
678 return true;
679 }
680 }
681 return false;
682 }
getAssignedObjectTypes()
Get assigned object types.

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

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

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

References $ilDB, and $r.

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

542 {
543 $this->active = $a_active;
544 }

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

634 {
635 $this->obj_types = $a_obj_types;
636 }

◆ setDescription()

ilAdvancedMDRecord::setDescription (   $a_description)

set description

@access public

Parameters
stringdescription

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

588 {
589 $this->description = $a_description;
590 }

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

611 {
612 $this->import_id = $a_id_string;
613 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setParentObject()

ilAdvancedMDRecord::setParentObject (   $a_obj_id)

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

685 {
686 $this->parent_obj = $a_obj_id;
687 }

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

565 {
566 $this->title = $a_title;
567 }

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

704 {
705 $writer->xmlStartTag('Record',array('active' => $this->isActive() ? 1 : 0,
706 'id' => $this->generateImportId()));
707 $writer->xmlElement('Title',null,$this->getTitle());
708 $writer->xmlElement('Description',null,$this->getDescription());
709
710 foreach($this->getAssignedObjectTypes() as $obj_type)
711 {
712 $optional = array("optional"=>$obj_type["optional"]);
713 if ($obj_type["sub_type"] == "")
714 {
715 $writer->xmlElement('ObjectType',$optional,$obj_type["obj_type"]);
716 }
717 else
718 {
719 $writer->xmlElement('ObjectType',$optional,$obj_type["obj_type"].":".$obj_type["sub_type"]);
720 }
721 }
722
723 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
725 {
726 $definition->toXML($writer);
727 }
728 $writer->xmlEndTag('Record');
729 }
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 Write error message to ilErr.

@access public

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

512 {
513 global $ilErr,$lng;
514
515 if(!strlen($this->getTitle()))
516 {
517 $ilErr->setMessage('fill_out_all_required_fields');
518 return false;
519 }
520 return true;
521 }

References $ilErr, $lng, and 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: