4 include_once
"Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php";
39 public function __construct($a_record_id, $a_obj_id, $a_sub_type =
"-", $a_sub_id = 0)
41 $this->record_id = (int)$a_record_id;
42 $this->obj_id = (int)$a_obj_id;
43 $this->sub_type = $a_sub_type ? $a_sub_type :
"-";
44 $this->sub_id = (int)$a_sub_id;
66 $query =
"SELECT amro.record_id".
67 " FROM adv_md_record_objs amro".
68 " JOIN adv_md_record amr ON (amr.record_id = amro.record_id)".
69 " WHERE active = ".$ilDB->quote(1,
"integer").
70 " AND obj_type = ".$ilDB->quote($a_obj_type,
"text");
71 $set = $ilDB->query(
$query);
72 while(
$row = $ilDB->fetchAssoc($set))
74 $res[
$row[
"record_id"]] =
new self($row[
"record_id"], $a_obj_id);
87 if(!is_array($this->defs))
117 include_once
"Services/ADT/classes/class.ilADTFactory.php";
120 $adt_group_db = $factory->getDBBridgeForInstance($this->
getADTGroup());
123 "obj_id" => array(
"integer", $this->obj_id),
124 "sub_type" => array(
"text", $this->sub_type),
125 "sub_id" => array(
"integer", $this->sub_id)
127 $adt_group_db->setPrimary($primary);
128 $adt_group_db->setTable(
"adv_md_values");
131 foreach($adt_group_db->getElements() as $element)
133 if($element->getADT()->getType() ==
"MultiEnum")
135 $element->setFakeSingle(
true);
139 $this->active_record = $factory->getActiveRecordByTypeInstance($adt_group_db);
140 $this->active_record->setElementIdColumn(
"field_id",
"integer");
154 include_once
"Services/ADT/classes/class.ilADTFactory.php";
174 if(is_array($this->disabled))
176 return in_array($a_element_id, $this->disabled);
190 $this->disabled = array();
195 foreach($tmp as $element_id => $data)
197 if($data[
"disabled"])
199 $this->disabled[] = $element_id;
210 public function write(array $a_additional_data = null)
227 array(
"field_id"=>array(
"integer", $a_field_id)),
241 array(
"obj_id"=>array(
"integer", $a_obj_id)));
263 array(
"obj_id"=>array(
"integer", $a_obj_ids)));
268 self::$preload_obj_records = array();
272 " FROM adv_md_record_objs amro".
273 " JOIN adv_md_record amr ON (amr.record_id = amro.record_id)".
274 " WHERE active = ".$ilDB->quote(1,
"integer");
275 $set = $ilDB->query(
$query);
276 while(
$row = $ilDB->fetchAssoc($set))
278 self::$preload_obj_records[
$row[
"obj_type"]][] = $row[
"record_id"];
286 if(isset(self::$preload_obj_records[$a_type]))
288 foreach(self::$preload_obj_records[$a_type] as
$record_id)
312 public static function _cloneValues($a_source_id,$a_target_id,$a_sub_type = null,$a_source_sub_id = null,$a_target_sub_id=null)
316 $source_primary = array(
"obj_id"=>array(
"integer", $a_source_id));
317 $target_primary = array(
"obj_id"=>array(
"integer", $a_target_id));
324 $source_primary[
"sub_type"] = array(
"text", $a_sub_type);
325 $source_primary[
"sub_id"] = array(
"integer", $a_source_sub_id);
326 $target_primary[
"sub_type"] = array(
"text", $a_sub_type);
327 $target_primary[
"sub_id"] = array(
"integer", $a_target_sub_id);
334 "obj_id" =>
"integer",
335 "sub_type" =>
"text",
336 "sub_id" =>
"integer",
337 "field_id" =>
"integer"
341 array(
"disabled"=>
"integer"));
345 $ilLog->write(__METHOD__.
': No advanced meta data found.');
349 $ilLog->write(__METHOD__.
': Start cloning advanced meta data.');
367 foreach($values_records as $values_record)
369 $defs = $values_record->getDefinitions();
370 foreach($values_record->getADTGroup()->getElements() as $element_id => $element)
372 $def =
$defs[$element_id];
375 if(!$element->isNull())
377 $value = $def->getValueForXML($element);
382 array(
'id' => $def->getImportId()),
388 $a_xml_writer->
xmlEndTag(
'AdvancedMetaData');
402 static public function queryForRecords($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, array $a_amet_filter = null)
406 if (!is_array($a_obj_id))
408 $a_obj_id = array($a_obj_id);
411 $sub_obj_ids = array();
412 foreach($a_records as $rec)
414 $sub_obj_ids[] = $rec[$a_obj_subid_key];
421 "obj_id" => array(
"integer", $a_obj_id),
422 "sub_type" => array(
"text", $a_subtype),
423 "sub_id" => array(
"integer", $sub_obj_ids)
426 $record_groups = array();
428 foreach($a_records as $rec)
431 $sub_id = $rec[$a_obj_subid_key];
443 $record_groups[
$record_id]->setTable(
"adv_md_values");
448 "obj_id" => array(
"integer",
$obj_id),
449 "sub_type" => array(
"text", $a_subtype),
450 "sub_id" => array(
"integer",
$sub_id)
454 foreach($record_groups[$record_id]->getElements() as $element)
456 if($element->getADT()->getType() ==
"MultiEnum")
458 $element->setFakeSingle(
true);
472 foreach($a_amet_filter as $field_id => $element)
476 if(!$element->isInCondition(
$adt_group->getElement($field_id)))
485 foreach(
$adt_group->getElements() as $element_id => $element)
487 if(!$element->isNull())
491 $rec[
"md_".$element_id] = $pb->getSortable();
492 $rec[
"md_".$element_id.
"_presentation"] = $pb;
497 $rec[
"md_".$element_id] = null;