65 $this->field_id = $a_field_id;
81 $query =
"SELECT import_id FROM adv_md_field_definition ".
82 "WHERE field_id = ".$ilDB->quote($a_field_id).
" ";
83 $res = $ilDB->query($query);
85 return $row[
'import_id'] ? $row[
'import_id'] :
'';
100 $query =
"SELECT field_id FROM adv_md_field_definition ".
101 "WHERE import_id = ".$ilDB->quote($a_import_id).
" ";
102 $res = $ilDB->query($query);
104 return $row[
'field_id'] ? $row[
'field_id'] : 0;
119 $query =
"SELECT field_type FROM adv_md_field_definition ".
120 "WHERE field_id = ".$ilDB->quote($a_field_id).
" ";
121 $res = $ilDB->query($query);
123 return $row[
'field_type'] ? $row[
'field_type'] : 0;
139 $query =
"SELECT field_id FROM adv_md_field_definition ".
140 "WHERE field_type = ".self::TYPE_DATETIME.
" ";
141 $res = $ilDB->query($query);
143 $date_fields = array();
146 $date_fields[] = $row->field_id;
162 $query =
"SELECT field_id FROM adv_md_field_definition ".
163 "WHERE field_type = ".self::TYPE_DATE.
" ";
164 $res = $ilDB->query($query);
166 $date_fields = array();
169 $date_fields[] = $row->field_id;
184 if(isset(self::$instances[$a_field_id]))
186 return self::$instances[$a_field_id];
205 $query =
"SELECT field_id FROM adv_md_field_definition ".
206 "WHERE record_id = ".$ilDB->quote($a_record_id).
" ".
207 "ORDER BY position ";
208 $res = $ilDB->query($query);
214 return $defs ? $defs : array();
229 $query =
"SELECT field_id FROM adv_md_record_objs AS aro ".
230 "JOIN adv_md_record AS amr ON aro.record_id = amr.record_id ".
231 "JOIN adv_md_field_definition AS amf ON aro.record_id = amf.record_id ".
233 "AND obj_type = ".$ilDB->quote($a_type).
" ".
234 "ORDER BY aro.record_id,position ";
235 $res = $ilDB->query($query);
238 $field_ids[] = $row->field_id;
240 return $field_ids ? $field_ids : array();
253 $query =
"SELECT field_id FROM adv_md_record AS amr ".
254 "JOIN adv_md_field_definition AS amfd USING (record_id) ".
256 "AND searchable = 1";
257 $res = $ilDB->query($query);
260 $field_ids[] = $row->field_id;
262 return $field_ids ? $field_ids : array();
278 $query =
"SELECT field_id FROM adv_md_field_definition ".
279 "WHERE record_id = ".$ilDB->quote($a_record_id);
280 $res = $ilDB->query($query);
284 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
289 $query =
"DELETE FROM adv_md_field_definition ".
290 "WHERE record_id = ".$ilDB->quote($a_record_id).
" ";
291 $res = $ilDB->query($query);
303 return $this->record_id ?
false :
true;
316 $this->record_id = $a_id;
350 $this->import_id = $a_id_string;
373 $this->position = $a_pos;
397 $this->field_type = $a_type_id;
420 $this->field_values = $a_values;
432 if(strlen(trim($a_value)))
434 $this->field_values[] = trim($a_value);
459 $values = array(0 => $lng->txt(
'select_one'));
460 foreach($this->field_values as $value)
462 $values[$value] = $value;
476 $this->title = $a_title;
498 $this->description = $a_desc;
520 $this->searchable = (bool) $a_status;
550 public function delete()
552 $query =
"DELETE FROM adv_md_field_definition ".
553 "WHERE field_id = ".$this->db->quote($this->
getFieldId()).
" ";
554 $res = $this->db->query($query);
557 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
573 $query =
"INSERT INTO adv_md_field_definition ".
574 "SET record_id = ".$this->db->quote($this->
getRecordId()).
", ".
575 "import_id = ".$this->db->quote($this->
getImportId()).
", ".
576 "position = ".$this->db->quote(
$position + 1).
", ".
577 "field_type = ".$this->db->quote($this->
getFieldType()).
", ".
578 "field_values = '".addslashes(serialize($values)).
"', ".
579 "title = ".$this->db->quote($this->
getTitle()).
", ".
583 $this->db->query($query);
584 $this->field_id = $this->db->getLastInsertId();
588 $query =
"UPDATE adv_md_field_definition ".
590 "WHERE field_id = ".$this->db->quote($this->field_id).
" ";
591 $this->db->query($query);
608 $ilErr->setMessage(
'fill_out_all_required_fields');
622 $query =
"UPDATE adv_md_field_definition ".
623 "SET record_id = ".$this->db->quote($this->
getRecordId()).
", ".
624 "import_id = ".$this->db->quote($this->
getImportId()).
", ".
625 "position = ".$this->db->quote($this->
getPosition()).
", ".
626 "field_type = ".$this->db->quote($this->
getFieldType()).
", ".
627 "field_values = '".addslashes(serialize($this->
getFieldValues())).
"', ".
628 "title = ".$this->db->quote($this->
getTitle()).
", ".
632 "WHERE field_id = ".$this->db->quote($this->
getFieldId()).
" ";
634 $this->db->query($query);
651 case self::TYPE_TEXT:
655 case self::TYPE_SELECT:
659 case self::TYPE_DATE:
663 case self::TYPE_DATETIME:
672 'fieldType' => $type));
682 $writer->
xmlElement(
'FieldValue',null,$value);
702 $query =
"SELECT * FROM adv_md_field_definition ".
703 "WHERE field_id = ".$this->db->quote($this->
getFieldId()).
" ";
704 $res = $this->db->query($query);
707 $this->record_id = $row->record_id;
708 $this->import_id = $row->import_id;
709 $this->position = $row->position;
710 $this->field_type = $row->field_type;
711 $this->field_values = unserialize(stripslashes($row->field_values));
712 $this->title = $row->title;
713 $this->description = $row->description;
714 $this->searchable = $row->searchable;
715 $this->required = $row->required;
727 $query =
"SELECT max(position) as pos FROM adv_md_field_definition ".
728 "WHERE record_id = ".$this->db->quote($this->
getRecordId()).
" ";
729 $res = $this->db->query($query);
745 return 'il_'.IL_INST_ID.
'_adv_md_field_'.$this->
getFieldId();