65 $this->field_id = $a_field_id;
81 $query =
"SELECT import_id FROM adv_mdf_definition ".
82 "WHERE field_id = ".$ilDB->quote($a_field_id,
'integer').
" ";
85 return $row[
'import_id'] ?
$row[
'import_id'] :
'';
100 $query =
"SELECT field_id FROM adv_mdf_definition ".
101 "WHERE import_id = ".$ilDB->quote($a_import_id,
'text').
" ";
104 return $row[
'field_id'] ?
$row[
'field_id'] : 0;
119 $query =
"SELECT field_type FROM adv_mdf_definition ".
120 "WHERE field_id = ".$ilDB->quote($a_field_id ,
'integer').
" ";
123 return $row[
'field_type'] ?
$row[
'field_type'] : 0;
139 $query =
"SELECT field_id FROM adv_mdf_definition ".
140 "WHERE field_type = ".$ilDB->quote(self::TYPE_DATETIME ,
'integer').
" ";
143 $date_fields = array();
146 $date_fields[] =
$row->field_id;
162 $query =
"SELECT field_id FROM adv_mdf_definition ".
163 "WHERE field_type = ".$ilDB->quote(self::TYPE_DATE ,
'integer').
" ";
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_mdf_definition ".
206 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer').
" ".
207 "ORDER BY position ";
214 return $defs ? $defs : array();
229 $query =
"SELECT field_id FROM adv_md_record_objs aro ".
230 "JOIN adv_md_record amr ON aro.record_id = amr.record_id ".
231 "JOIN adv_mdf_definition amf ON aro.record_id = amf.record_id ".
233 "AND obj_type = ".$ilDB->quote($a_type,
'text').
" ".
234 "ORDER BY aro.record_id,position ";
238 $field_ids[] =
$row->field_id;
240 return $field_ids ? $field_ids : array();
253 $query =
"SELECT field_id FROM adv_md_record amr ".
254 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id ".
256 "AND searchable = 1";
260 $field_ids[] =
$row->field_id;
262 return $field_ids ? $field_ids : array();
278 $query =
"SELECT field_id FROM adv_mdf_definition ".
279 "WHERE record_id = ".$ilDB->quote($a_record_id ,
'integer');
284 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
289 $query =
"DELETE FROM adv_mdf_definition ".
290 "WHERE record_id = ".$ilDB->quote($a_record_id,
'integer').
" ";
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;
477 $values = array(0 => $lng->txt(
'search_any'));
478 foreach($this->field_values as $value)
480 $values[$value] = $value;
494 $this->title = $a_title;
516 $this->description = $a_desc;
538 $this->searchable = (bool) $a_status;
568 public function delete()
572 $query =
"DELETE FROM adv_mdf_definition ".
573 "WHERE field_id = ".$this->db->quote($this->
getFieldId() ,
'integer').
" ";
577 include_once(
'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
594 $next_id = $ilDB->nextId(
'adv_mdf_definition');
596 $query =
"INSERT INTO adv_mdf_definition (field_id,record_id,import_id,position,field_type, ".
597 "field_values,title,description,searchable,required) ".
599 $ilDB->quote($next_id,
'integer').
",".
600 $this->db->quote($this->
getRecordId(),
'integer').
", ".
601 $this->db->quote($this->
getImportId(),
'text').
", ".
602 $this->db->quote(
$position + 1 ,
'integer').
", ".
603 $this->db->quote($this->
getFieldType() ,
'integer').
", ".
604 $ilDB->quote(serialize($values),
'text').
", ".
605 $this->db->quote($this->
getTitle() ,
'text').
", ".
608 $ilDB->quote($this->
isRequired(),
'integer').
" ".
611 $this->field_id = $next_id;
615 $query =
"UPDATE adv_mdf_definition ".
617 "WHERE field_id = ".$this->db->quote($this->field_id,
'integer').
" ";
635 $ilErr->setMessage(
'fill_out_all_required_fields');
651 $query =
"UPDATE adv_mdf_definition ".
652 "SET record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
", ".
653 "import_id = ".$this->db->quote($this->
getImportId() ,
'text').
", ".
654 "position = ".$this->db->quote($this->
getPosition() ,
'integer').
", ".
655 "field_type = ".$this->db->quote($this->
getFieldType() ,
'integer').
", ".
656 "field_values = ".$ilDB->quote(serialize($this->
getFieldValues()),
'text').
", ".
657 "title = ".$this->db->quote($this->
getTitle() ,
'text').
", ".
658 "description = ".$this->db->quote($this->
getDescription() ,
'text').
", ".
659 "searchable = ".$ilDB->quote($this->
isSearchable() ,
'integer').
", ".
660 "required = ".$ilDB->quote($this->
isRequired(),
'integer').
" ".
661 "WHERE field_id = ".$this->db->quote($this->
getFieldId() ,
'integer').
" ";
679 case self::TYPE_TEXT:
683 case self::TYPE_SELECT:
687 case self::TYPE_DATE:
691 case self::TYPE_DATETIME:
700 'fieldType' => $type));
710 $writer->
xmlElement(
'FieldValue',null,$value);
732 $query =
"SELECT * FROM adv_mdf_definition ".
733 "WHERE field_id = ".$this->db->quote($this->
getFieldId() ,
'integer').
" ";
737 $this->record_id =
$row->record_id;
738 $this->import_id =
$row->import_id;
739 $this->position =
$row->position;
740 $this->field_type =
$row->field_type;
741 $this->field_values = unserialize(stripslashes(
$row->field_values));
742 $this->title =
$row->title;
743 $this->description =
$row->description;
744 $this->searchable =
$row->searchable;
745 $this->required =
$row->required;
757 $query =
"SELECT max(position) pos FROM adv_mdf_definition ".
758 "WHERE record_id = ".$this->db->quote($this->
getRecordId() ,
'integer').
" ";
775 return 'il_'.IL_INST_ID.
'_adv_md_field_'.$this->
getFieldId();