ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilAdvancedMDValues Class Reference
+ Collaboration diagram for ilAdvancedMDValues:

Public Member Functions

 __construct ($a_record_id, $a_obj_id, $a_sub_type="-", $a_sub_id=0)
 
 setActiveRecordPrimary (int $a_obj_id, string $a_sub_type="-", int $a_sub_id=0)
 
 getDefinitions ()
 Get record field definitions. More...
 
 getADTGroup ()
 
 isDisabled (string $a_element_id)
 
 read ()
 Get record values. More...
 
 write (?array $a_additional_data=null)
 Write record values. More...
 

Static Public Member Functions

static getInstancesForObjectId (int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
 
static findByObjectId (int $a_obj_id)
 Find all entries for object (regardless of sub-type/sub-id) More...
 
static _deleteByFieldId (int $a_field_id, ilADT $a_adt)
 Delete values by field_id. More...
 
static _deleteByObjId (int $a_obj_id)
 Delete by objekt id. More...
 
static preloadByObjIds (array $a_obj_ids)
 Preload list gui data. More...
 
static preloadedRead (string $a_type, int $a_obj_id)
 
static _cloneValues (int $copy_id, int $a_source_id, int $a_target_id, ?string $a_sub_type=null, ?int $a_source_sub_id=null, ?int $a_target_sub_id=null)
 Clone Advanced Meta Data. More...
 
static _appendXMLByObjId (ilXmlWriter $a_xml_writer, int $a_obj_id)
 Get xml of object values. More...
 
static queryForRecords (int $adv_rec_obj_ref_id, string $adv_rec_obj_type, string $adv_rec_obj_subtype, array $a_obj_id, string $a_subtype, array $a_records, string $a_obj_id_key, string $a_obj_subid_key, ?array $a_amet_filter=null)
 

Protected Member Functions

 getActiveRecord ()
 Init ADT DB Bridge (aka active record helper class) More...
 

Static Protected Member Functions

static getParentMapping (int $copy_id, string $target)
 

Protected Attributes

int $record_id
 
int $obj_id
 
int $sub_id
 
string $sub_type
 
array $defs = null
 
ilADTGroup $adt_group = null
 
ilADTActiveRecordByType $active_record = null
 
array $disabled = []
 

Static Protected Attributes

static array $preload_obj_records = []
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDValues::__construct (   $a_record_id,
  $a_obj_id,
  $a_sub_type = "-",
  $a_sub_id = 0 
)

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

References ILIAS\Repository\int().

43  {
44  $this->record_id = (int) $a_record_id;
45  $this->obj_id = (int) $a_obj_id;
46  $this->sub_type = $a_sub_type ?: "-";
47  $this->sub_id = (int) $a_sub_id;
48  }
+ Here is the call graph for this function:

Member Function Documentation

◆ _appendXMLByObjId()

static ilAdvancedMDValues::_appendXMLByObjId ( ilXmlWriter  $a_xml_writer,
int  $a_obj_id 
)
static

Get xml of object values.

Parameters
ilXmlWriter$a_xml_writer
int$a_obj_id

Definition at line 455 of file class.ilAdvancedMDValues.php.

References ilObject\_lookupType(), null, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

Referenced by ilCourseXMLWriter\__buildAdvancedMetaData(), and ilGroupXMLWriter\__buildAdvancedMetaData().

455  : void
456  {
457  $a_xml_writer->xmlStartTag('AdvancedMetaData');
458 
459  self::preloadByObjIds(array($a_obj_id));
460  $values_records = self::preloadedRead(ilObject::_lookupType($a_obj_id), $a_obj_id);
461 
462  foreach ($values_records as $values_record) {
463  $defs = $values_record->getDefinitions();
464  foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
465  $def = $defs[$element_id];
466 
467  $value = null;
468  if (!$element->isNull()) {
469  $value = $def->getValueForXML($element);
470  }
471 
472  $a_xml_writer->xmlElement(
473  'Value',
474  array('id' => $def->getImportId()),
475  $value
476  );
477  }
478  }
479  $a_xml_writer->xmlEndTag('AdvancedMetaData');
480  }
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _cloneValues()

static ilAdvancedMDValues::_cloneValues ( int  $copy_id,
int  $a_source_id,
int  $a_target_id,
?string  $a_sub_type = null,
?int  $a_source_sub_id = null,
?int  $a_target_sub_id = null 
)
static

Clone Advanced Meta Data.

Definition at line 290 of file class.ilAdvancedMDValues.php.

References $DIC, $record_id, ilCopyWizardOptions\_getInstance(), ilAdvancedMDRecord\_getRecords(), ilADTActiveRecordByType\cloneByPrimary(), ilADTActiveRecordByType\deleteByPrimary(), ilADTFactory\getInstance(), ilAdvancedMDRecord\getObjRecSelection(), null, and ilAdvancedMDRecord\saveObjRecSelection().

Referenced by ilObject\_prepareCloneSelection(), ilObjWiki\cloneObject(), ilObjPortfolioBase\clonePagesAndSettings(), ILIAS\MediaPool\MediaPoolManager\copyMetadataOfItem(), ILIAS\EmployeeTalk\Metadata\MetadataHandler\copyValues(), ILIAS\Wiki\Page\PageManager\createWikiPage(), and ilObjWiki\createWikiPage().

297  : void {
298  global $DIC;
299 
300  $ilLog = $DIC['ilLog'];
301 
302  // clone local records
303 
304  // new records are created automatically, only if source and target id differs.
305  $new_records = $fields_map = array();
306 
307  // if we have a sub object and are in a copy process,
308  // get mapping from parent
309  $parent_mapping = null;
310  if (!is_null($a_source_sub_id) && $copy_id > 0) {
311  $parent_mapping = self::getParentMapping($copy_id, (string) $a_target_id);
312  if (!is_null($parent_mapping)) {
313  $new_records = $parent_mapping["records"];
314  $fields_map = $parent_mapping["fields"];
315  }
316  }
317 
318  $record_mapping = [];
319  foreach (ilAdvancedMDRecord::_getRecords() as $record) {
320  if ($record->getParentObject() == $a_source_id && is_null($parent_mapping)) {
321  // if we have a sub object and are in a copy process,
322  // the main object must have already copied its records
323  if (!is_null($a_source_sub_id) && $copy_id > 0) {
324  throw new ilException("ilAdvancedMDValues::_cloneValues must be called for parent object first.");
325  }
326 
327  $tmp = array();
328  if ($a_source_id != $a_target_id) {
329  $new_records[$record->getRecordId()] = $record->_clone($tmp, $a_target_id);
330  $record_mapping[$record->getRecordId()] = $new_records[$record->getRecordId()]->getRecordId();
331  } else {
332  $new_records[$record->getRecordId()] = $record->getRecordId();
333  }
334  $fields_map[$record->getRecordId()] = $tmp;
335  }
336  }
337 
338  // write mapping when not in sub-object
339  if ($copy_id > 0 && is_null($a_source_sub_id)) {
340  $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
341  $cp_options->appendMapping(
342  $a_target_id . '_adv_rec',
343  $record_mapping
344  );
345  $cp_options->appendMapping(
346  $a_target_id . '_adv_rec_fields',
347  $fields_map
348  );
349  $cp_options->read(); // otherwise mapping will not be available for getMappings
350  }
351 
352  // object record selection
353 
354  $source_sel = ilAdvancedMDRecord::getObjRecSelection($a_source_id, (string) $a_sub_type);
355  if ($source_sel) {
356  $target_sel = array();
357  foreach ($source_sel as $record_id) {
358  // (local) record has been cloned
359  if (array_key_exists($record_id, $new_records)) {
360  $record_id = $new_records[$record_id]->getRecordId();
361  }
362  $target_sel[] = $record_id;
363  }
364  ilAdvancedMDRecord::saveObjRecSelection($a_target_id, (string) $a_sub_type, $target_sel);
365  }
366 
367  // clone values
368 
369  $source_primary = array("obj_id" => array("integer", $a_source_id));
370  $target_primary = array("obj_id" => array("integer", $a_target_id));
371 
372  // sub-type support
373  if ($a_sub_type &&
374  $a_source_sub_id &&
375  $a_target_sub_id) {
376  $source_primary["sub_type"] = array("text", $a_sub_type);
377  $source_primary["sub_id"] = array("integer", $a_source_sub_id);
378  $target_primary["sub_type"] = array("text", $a_sub_type);
379  $target_primary["sub_id"] = array("integer", $a_target_sub_id);
380  }
381 
382  ilADTFactory::getInstance()->initActiveRecordByType();
384  "adv_md_values",
385  array(
386  "obj_id" => "integer",
387  "sub_type" => "text",
388  "sub_id" => "integer",
389  "field_id" => "integer"
390  ),
391  $source_primary,
392  $target_primary,
393  array("disabled" => "integer")
394  );
395 
396  // move values of local records to newly created fields
397 
398  foreach ($fields_map as $source_record_id => $fields) {
399  // just to make sure
400  if (array_key_exists($source_record_id, $new_records)) {
401  foreach ($fields as $source_field_id => $target_field_id) {
402  // delete entry for old field id (was cloned above)
403  $del_target_primary = $target_primary;
404  $del_target_primary["field_id"] = array("integer", $source_field_id);
405  ilADTActiveRecordByType::deleteByPrimary("adv_md_values", $del_target_primary);
406 
407  // create entry for new id
408  $fix_source_primary = $source_primary;
409  $fix_source_primary["field_id"] = array("integer", $source_field_id);
410  $fix_target_primary = $target_primary;
411  $fix_target_primary["field_id"] = array("integer", $target_field_id);
413  "adv_md_values",
414  array(
415  "obj_id" => "integer",
416  "sub_type" => "text",
417  "sub_id" => "integer",
418  "field_id" => "integer"
419  ),
420  $fix_source_primary,
421  $fix_target_primary,
422  array("disabled" => "integer")
423  );
424  }
425  }
426  }
427 
428  if (!$has_cloned) {
429  $ilLog->write(__METHOD__ . ': No advanced meta data found.');
430  } else {
431  $ilLog->write(__METHOD__ . ': Start cloning advanced meta data.');
432  }
433  }
static _getRecords()
Get records public.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static deleteByPrimary(string $a_table, array $a_primary, ?string $a_type=null)
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
global $DIC
Definition: shib_login.php:22
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", ?array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
static _getInstance(int $a_copy_id)
static cloneByPrimary(string $a_table, array $a_primary_def, array $a_source_primary, array $a_target_primary, ?array $a_additional=null)
Clone values by (partial) primary key.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteByFieldId()

static ilAdvancedMDValues::_deleteByFieldId ( int  $a_field_id,
ilADT  $a_adt 
)
static

Delete values by field_id.

Typically called after deleting a field

Parameters
int$a_field_id
ilADT$a_adt

Definition at line 197 of file class.ilAdvancedMDValues.php.

References ilADTActiveRecordByType\deleteByPrimary(), ilADTFactory\getInstance(), and ilADT\getType().

Referenced by ilAdvancedMDFieldDefinition\delete().

197  : void
198  {
199  ilADTFactory::getInstance()->initActiveRecordByType();
201  "adv_md_values",
202  array("field_id" => array("integer", $a_field_id)),
203  $a_adt->getType()
204  );
205  }
getType()
Get type (from class/instance)
Definition: class.ilADT.php:64
static deleteByPrimary(string $a_table, array $a_primary, ?string $a_type=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _deleteByObjId()

static ilAdvancedMDValues::_deleteByObjId ( int  $a_obj_id)
static

Delete by objekt id.

Definition at line 210 of file class.ilAdvancedMDValues.php.

References ilADTActiveRecordByType\deleteByPrimary(), and ilADTFactory\getInstance().

Referenced by ilObject\delete().

211  {
212  ilADTFactory::getInstance()->initActiveRecordByType();
214  "adv_md_values",
215  array("obj_id" => array("integer", $a_obj_id))
216  );
217  }
static deleteByPrimary(string $a_table, array $a_primary, ?string $a_type=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findByObjectId()

static ilAdvancedMDValues::findByObjectId ( int  $a_obj_id)
static

Find all entries for object (regardless of sub-type/sub-id)

Definition at line 145 of file class.ilAdvancedMDValues.php.

References ilADTFactory\initActiveRecordByType(), and ilADTActiveRecordByType\readByPrimary().

Referenced by ilAdvancedMetaDataExporter\getXmlRepresentation().

145  : ?array
146  {
148  return ilADTActiveRecordByType::readByPrimary("adv_md_values", array("obj_id" => array("integer", $a_obj_id)));
149  }
static readByPrimary(string $a_table, array $a_primary, ?string $a_type=null)
Read directly.
static initActiveRecordByType()
Init active record by type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveRecord()

ilAdvancedMDValues::getActiveRecord ( )
protected

Init ADT DB Bridge (aka active record helper class)

Definition at line 113 of file class.ilAdvancedMDValues.php.

References $active_record, getADTGroup(), and ilADTFactory\getInstance().

Referenced by read(), and write().

114  {
115  if (!$this->active_record instanceof ilADTActiveRecordByType) {
116  $factory = ilADTFactory::getInstance();
117 
118  $adt_group_db = $factory->getDBBridgeForInstance($this->getADTGroup());
119 
120  $primary = array(
121  "obj_id" => array("integer", $this->obj_id),
122  "sub_type" => array("text", $this->sub_type),
123  "sub_id" => array("integer", $this->sub_id)
124  );
125  $adt_group_db->setPrimary($primary);
126  $adt_group_db->setTable("adv_md_values");
127 
128  // multi-enum fakes single in adv md
129  foreach ($adt_group_db->getElements() as $element) {
130  if ($element->getADT()->getType() == "MultiEnum") {
131  $element->setFakeSingle(true);
132  }
133  }
134 
135  $this->active_record = $factory->getActiveRecordByTypeInstance($adt_group_db);
136  $this->active_record->setElementIdColumn("field_id", "integer");
137  }
138 
139  return $this->active_record;
140  }
ADT Active Record by type helper class This class expects a valid primary for all actions! ...
ilADTActiveRecordByType $active_record
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getADTGroup()

ilAdvancedMDValues::getADTGroup ( )

Definition at line 102 of file class.ilAdvancedMDValues.php.

References $adt_group, ilAdvancedMDFieldDefinition\getADTGroupForDefinitions(), and getDefinitions().

Referenced by getActiveRecord().

102  : ilADTGroup
103  {
104  if (!$this->adt_group instanceof ilADTGroup) {
106  }
107  return $this->adt_group;
108  }
static getADTGroupForDefinitions(array $a_defs)
Init ADTGroup for definitions.
getDefinitions()
Get record field definitions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinitions()

ilAdvancedMDValues::getDefinitions ( )

Get record field definitions.

Returns
ilAdvancedMDFieldDefinition[]

Definition at line 94 of file class.ilAdvancedMDValues.php.

References $defs, and ilAdvancedMDFieldDefinition\getInstancesByRecordId().

Referenced by getADTGroup().

94  : array
95  {
96  if (!is_array($this->defs)) {
97  $this->defs = ilAdvancedMDFieldDefinition::getInstancesByRecordId($this->record_id);
98  }
99  return $this->defs;
100  }
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstancesForObjectId()

static ilAdvancedMDValues::getInstancesForObjectId ( int  $a_obj_id,
?string  $a_obj_type = null,
string  $a_sub_type = "-",
int  $a_sub_id = 0 
)
static

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

References $id, $ref_id, $res, ilObject\_getAllReferences(), ilAdvancedMDRecord\_getSelectedRecordsByObject(), and ilObject\_lookupType().

Referenced by ilECSUtils\getAdvancedMDValuesForObjId(), ilAdvancedMDValueParser\handlerBeginTag(), ilRemoteObjectBase\importMetadataFromJson(), ILIAS\Cache\Services\ObjectModes\Custom\Custom\initSets(), ilAdvancedMDRecordGUI\parseAppointmentPresentationa(), ilAdvancedMDRecordGUI\parseInfoPage(), and ilObjOrgUnit\setOrgUnitTypeId().

55  : array {
56  $res = array();
57 
58  if (!$a_obj_type) {
59  $a_obj_type = ilObject::_lookupType($a_obj_id);
60  }
61 
62  // @todo refactor
63  $refs = ilObject::_getAllReferences($a_obj_id);
64  foreach ($refs as $ref_id) {
65  $records = ilAdvancedMDRecord::_getSelectedRecordsByObject($a_obj_type, $ref_id, $a_sub_type);
66  $orderings = new ilAdvancedMDRecordObjectOrderings();
67  $records = $orderings->sortRecords($records, $a_obj_id);
68 
69  foreach ($records as $record) {
70  $id = $record->getRecordId();
71 
72  if (!isset($res[$id])) {
73  $res[$id] = new self($id, $a_obj_id, $a_sub_type, $a_sub_id);
74  }
75  }
76  }
77  return $res;
78  }
$res
Definition: ltiservices.php:66
static _getAllReferences(int $id)
get all reference ids for object ID
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
$ref_id
Definition: ltiauth.php:65
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentMapping()

static ilAdvancedMDValues::getParentMapping ( int  $copy_id,
string  $target 
)
staticprotected

Definition at line 435 of file class.ilAdvancedMDValues.php.

References ilCopyWizardOptions\_getInstance(), and null.

435  : ?array
436  {
437  $cp_options = ilCopyWizardOptions::_getInstance($copy_id);
438  $mappings = $cp_options->getMappings();
439  $key1 = $target . '_adv_rec';
440  $key2 = $target . '_adv_rec_fields';
441  if (is_array($mappings) && isset($mappings[$key1])) {
442  return [
443  "records" => $mappings[$key1],
444  "fields" => $mappings[$key2] ?? []
445  ];
446  }
447  return null;
448  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getInstance(int $a_copy_id)
+ Here is the call graph for this function:

◆ isDisabled()

ilAdvancedMDValues::isDisabled ( string  $a_element_id)

Definition at line 158 of file class.ilAdvancedMDValues.php.

References ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and null.

158  : ?bool
159  {
160  if (is_array($this->disabled)) {
161  return in_array($a_element_id, $this->disabled);
162  }
163  return null;
164  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ preloadByObjIds()

static ilAdvancedMDValues::preloadByObjIds ( array  $a_obj_ids)
static

Preload list gui data.

Parameters
int[]$a_obj_ids

Definition at line 223 of file class.ilAdvancedMDValues.php.

References $DIC, $ilDB, ilADTFactory\getInstance(), ILIAS\Repository\int(), and ilADTActiveRecordByType\preloadByPrimary().

Referenced by ilObjectListGUIPreloader\preload(), and ILIAS\UI\Component\Legacy\Content\ItemSetManager\preloadAdvancedMDValues().

223  : void
224  {
225  global $DIC;
226 
227  $ilDB = $DIC['ilDB'];
228 
229  // preload values
230  ilADTFactory::getInstance()->initActiveRecordByType();
232  "adv_md_values",
233  array("obj_id" => array("integer", $a_obj_ids))
234  );
235 
236  // preload record ids for object types
237 
238  self::$preload_obj_records = array();
239 
240  // get active records for object types
241  $query = "SELECT amro.*" .
242  " FROM adv_md_record_objs amro" .
243  " JOIN adv_md_record amr ON (amr.record_id = amro.record_id)" .
244  " WHERE active = " . $ilDB->quote(1, "integer");
245  $set = $ilDB->query($query);
246  while ($row = $ilDB->fetchAssoc($set)) {
247  self::$preload_obj_records[(string) $row["obj_type"]][] = array((int) $row["record_id"],
248  (int) $row["optional"]
249  );
250  }
251  }
static preloadByPrimary(string $a_table, array $a_primary)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preloadedRead()

static ilAdvancedMDValues::preloadedRead ( string  $a_type,
int  $a_obj_id 
)
static

Definition at line 253 of file class.ilAdvancedMDValues.php.

References $record_id, $res, and ilAdvancedMDRecord\_getSelectedRecordsByObject().

Referenced by ilAdvancedMDSubstitution\getParsedSubstitutions().

253  : array
254  {
255  $res = array();
256 
257  if (isset(self::$preload_obj_records[$a_type])) {
258  foreach (self::$preload_obj_records[$a_type] as $item) {
259  $record_id = $item[0];
260 
261  // record is optional, check activation for object
262  if ($item[1]) {
263  $found = false;
265  $a_type,
266  $a_obj_id,
267  '',
268  false
269  ) as $record) {
270  if ($record->getRecordId() == $item[0]) {
271  $found = true;
272  }
273  }
274  if (!$found) {
275  continue;
276  }
277  }
278 
279  $res[$record_id] = new self($record_id, $a_obj_id);
280  $res[$record_id]->read();
281  }
282  }
283 
284  return $res;
285  }
$res
Definition: ltiservices.php:66
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ queryForRecords()

static ilAdvancedMDValues::queryForRecords ( int  $adv_rec_obj_ref_id,
string  $adv_rec_obj_type,
string  $adv_rec_obj_subtype,
array  $a_obj_id,
string  $a_subtype,
array  $a_records,
string  $a_obj_id_key,
string  $a_obj_subid_key,
?array  $a_amet_filter = null 
)
static
Todo:
refactor this

Definition at line 485 of file class.ilAdvancedMDValues.php.

References $record_id, $results, ilAdvancedMDRecord\_getSelectedRecordsByObject(), ilAdvancedMDFieldDefinition\getADTGroupForDefinitions(), ilADTGroup\getElement(), ilADTGroup\getElements(), ilADTFactory\getInstance(), ilAdvancedMDFieldDefinition\getInstancesByRecordId(), ilADTGroup\hasElement(), ILIAS\Repository\int(), null, ilADTActiveRecordByType\preloadByPrimary(), ilADTActiveRecordByType\read(), and ilADTActiveRecordByType\setElementIdColumn().

Referenced by ILIAS\Cache\Services\SubObjectModes\DataTable\Supplier\getData(), ilBookingObjectsTableGUI\getItems(), ilMediaPoolTableGUI\getItems(), ilBookingReservationsTableGUI\getItems(), and ilGlossaryTerm\getTermList().

495  : array {
496  $results = array();
497 
498  $sub_obj_ids = array();
499  foreach ($a_records as $rec) {
500  $sub_obj_ids[] = $rec[$a_obj_subid_key];
501  }
502 
503  // preload adv data for object id(s)
504  ilADTFactory::getInstance()->initActiveRecordByType();
506  "adv_md_values",
507  array(
508  "obj_id" => array("integer", $a_obj_id),
509  "sub_type" => array("text", $a_subtype),
510  "sub_id" => array("integer", $sub_obj_ids)
511  )
512  );
513 
514  $record_groups = array();
515 
516  foreach ($a_records as $rec) {
517  $obj_id = (int) ($rec[$a_obj_id_key] ?? 0);
518  $sub_id = $rec[$a_obj_subid_key];
519 
520  // get adv records
522  $adv_rec_obj_type,
523  $adv_rec_obj_ref_id,
524  $adv_rec_obj_subtype
525  ) as $adv_record) {
526  $record_id = $adv_record->getRecordId();
527 
528  if (!isset($record_groups[$record_id])) {
531  $record_groups[$record_id] = ilADTFactory::getInstance()->getDBBridgeForInstance($record_groups[$record_id]);
532  $record_groups[$record_id]->setTable("adv_md_values");
533  }
534 
535  // prepare ADT group for record id
536  $record_groups[$record_id]->setPrimary(array(
537  "obj_id" => array("integer", $obj_id),
538  "sub_type" => array("text", $a_subtype),
539  "sub_id" => array("integer", $sub_id)
540  ));
541  // multi-enum fakes single in adv md
542  foreach ($record_groups[$record_id]->getElements() as $element) {
543  if ($element->getADT()->getType() == "MultiEnum") {
544  $element->setFakeSingle(true);
545  }
546  }
547 
548  // read (preloaded) data
549  $active_record = new ilADTActiveRecordByType($record_groups[$record_id]);
550  $active_record->setElementIdColumn("field_id", "integer");
551  $active_record->read();
552 
553  $adt_group = $record_groups[$record_id]->getADT();
554  // filter against amet values
555  if ($a_amet_filter) {
556  foreach ($a_amet_filter as $field_id => $element) {
557  if ($adt_group->hasElement((string) $field_id)) {
558  if (!$element->isInCondition($adt_group->getElement((string) $field_id))) {
559  continue(3);
560  }
561  }
562  }
563  }
564  // add amet values to glossary term record
565  foreach ($adt_group->getElements() as $element_id => $element) {
566  if (!$element->isNull()) {
567  // we are reusing the ADT group for all $a_records, so we need to clone
568  $pb = ilADTFactory::getInstance()->getPresentationBridgeForInstance(clone $element);
569  $rec["md_" . $element_id] = $pb->getSortable();
570  $rec["md_" . $element_id . "_presentation"] = $pb;
571  } else {
572  $rec["md_" . $element_id] = null;
573  }
574  }
575  }
576 
577  $results[] = $rec;
578  }
579 
580  return $results;
581  }
setElementIdColumn(string $a_name, string $a_type)
hasElement(string $a_name)
ADT Active Record by type helper class This class expects a valid primary for all actions! ...
static preloadByPrimary(string $a_table, array $a_primary)
static getADTGroupForDefinitions(array $a_defs)
Init ADTGroup for definitions.
static _getSelectedRecordsByObject(string $a_obj_type, int $a_id, string $a_sub_type="", bool $is_ref_id=true)
static getInstancesByRecordId( $a_record_id, $a_only_searchable=false, string $language='')
Get definitions by record id.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ilADTActiveRecordByType $active_record
$results
read(bool $a_return_additional_data=false)
Read record.
getElement(string $a_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilAdvancedMDValues::read ( )

Get record values.

Definition at line 169 of file class.ilAdvancedMDValues.php.

References $data, ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getActiveRecord().

169  : void
170  {
171  $this->disabled = array();
172 
173  $tmp = $this->getActiveRecord()->read(true);
174  if ($tmp) {
175  foreach ($tmp as $element_id => $data) {
176  if ($data["disabled"]) {
177  $this->disabled[] = $element_id;
178  }
179  }
180  }
181  }
getActiveRecord()
Init ADT DB Bridge (aka active record helper class)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ setActiveRecordPrimary()

ilAdvancedMDValues::setActiveRecordPrimary ( int  $a_obj_id,
string  $a_sub_type = "-",
int  $a_sub_id = 0 
)

Definition at line 80 of file class.ilAdvancedMDValues.php.

References null.

80  : void
81  {
82  $this->obj_id = $a_obj_id;
83  $this->sub_type = $a_sub_type ?: "-";
84  $this->sub_id = $a_sub_id;
85 
86  // make sure they get used
87  $this->active_record = null;
88  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ write()

ilAdvancedMDValues::write ( ?array  $a_additional_data = null)

Write record values.

Definition at line 186 of file class.ilAdvancedMDValues.php.

References getActiveRecord().

186  : void
187  {
188  $this->getActiveRecord()->write($a_additional_data);
189  }
getActiveRecord()
Init ADT DB Bridge (aka active record helper class)
+ Here is the call graph for this function:

Field Documentation

◆ $active_record

ilADTActiveRecordByType ilAdvancedMDValues::$active_record = null
protected

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

Referenced by getActiveRecord().

◆ $adt_group

ilADTGroup ilAdvancedMDValues::$adt_group = null
protected

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

Referenced by getADTGroup().

◆ $defs

array ilAdvancedMDValues::$defs = null
protected

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

Referenced by getDefinitions().

◆ $disabled

array ilAdvancedMDValues::$disabled = []
protected

Definition at line 38 of file class.ilAdvancedMDValues.php.

◆ $obj_id

int ilAdvancedMDValues::$obj_id
protected

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

◆ $preload_obj_records

array ilAdvancedMDValues::$preload_obj_records = []
staticprotected

Definition at line 40 of file class.ilAdvancedMDValues.php.

◆ $record_id

int ilAdvancedMDValues::$record_id
protected

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

Referenced by _cloneValues(), preloadedRead(), and queryForRecords().

◆ $sub_id

int ilAdvancedMDValues::$sub_id
protected

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

◆ $sub_type

string ilAdvancedMDValues::$sub_type
protected

Definition at line 32 of file class.ilAdvancedMDValues.php.


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