31 if(isset(self::$cached_values[$a_obj_id]))
33 return self::$cached_values[$a_obj_id];
35 $query =
"SELECT field_id,value FROM adv_md_values ".
36 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer');
39 self::$cached_values[$a_obj_id] = array();
42 self::$cached_values[$a_obj_id][
$row->field_id] =
$row->value;
44 return self::$cached_values[$a_obj_id];
60 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDFieldDefinition.php');
61 include_once(
'./Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
66 $ilLog->write(__METHOD__.
': No advanced meta data found.');
70 $ilLog->write(__METHOD__.
': Start cloning advanced meta data.');
72 foreach(self::_getValuesByObjId($a_source_id) as $field_id => $value)
74 if(!in_array($field_id,$defs))
79 $new_value->setValue($value);
101 $query =
"SELECT field_id FROM adv_md_record amr ".
102 "JOIN adv_md_record_objs amro ON amr.record_id = amro.record_id ".
103 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
105 "AND obj_type = ".$ilDB->quote($type ,
'text').
" ";
112 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValue.php');
114 $value->appendXML($xml_writer);
116 $xml_writer->
xmlEndTag(
'AdvancedMetaData');
131 $query =
"SELECT obj_id,field_id,value FROM adv_md_values ".
132 "WHERE ".$ilDB->in(
'obj_id',$obj_ids,
false,
'integer');
137 self::$cached_values[
$row->obj_id][
$row->field_id] =
$row->value;
155 $query =
"DELETE FROM adv_md_values ".
156 "WHERE field_id = ".$ilDB->quote($a_field_id ,
'integer').
" ";
172 $query =
"DELETE FROM adv_md_values ".
173 "WHERE obj_id = ".$ilDB->quote($a_obj_id ,
'integer').
" ";
191 $set = $ilDB->query($q =
"SELECT field_id, value, sub_type, sub_id FROM adv_md_values ".
192 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
193 "AND sub_type = ".$ilDB->quote($a_subtype,
'text')
195 while ($rec = $ilDB->fetchAssoc($set))
209 static public function queryForRecords($a_obj_id, $a_subtype, $a_records, $a_obj_id_key, $a_obj_subid_key, $a_amet_filter =
"")
212 if (!is_array($a_obj_id))
214 $a_obj_id = array($a_obj_id);
218 foreach ($a_obj_id as $obj_id)
221 foreach ($values as $v)
223 $val[$obj_id][$v[
"sub_id"]][$v[
"field_id"]] = $v;
228 foreach ($a_records as $rec)
232 if (is_array($a_amet_filter))
234 foreach ($a_amet_filter as $fk => $fv)
236 if (!$skip && substr($fk, 0, 3) ==
"md_")
238 $fka = explode(
"_", $fk);
248 array_key_exists(
"from", $fv) &&
249 array_key_exists(
"to", $fv) &&
250 ($fv[
"from"] !== null || $fv[
"to"] !== null))
252 if (!isset($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka][
"value"]))
260 $md_val = $val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka][
"value"];
271 $md_val = date(
"Y-m-d", $md_val);
276 if($md_val < $from || $md_val > $to)
300 if (!isset($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka][
"value"]))
306 $md_val = $val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]][$fka][
"value"];
307 if (trim($md_val) != trim($fv))
322 if (is_array($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]]))
324 foreach ($val[$rec[$a_obj_id_key]][$rec[$a_obj_subid_key]] as $k => $v)
326 $rec[
"md_".$k] = $v[
"value"];