24 define(
"IL_CDF_SORT_ID",
'field_id');
25 define(
"IL_CDF_SORT_NAME",
'field_name');
27 define(
'IL_CDF_TYPE_TEXT',1);
28 define(
'IL_CDF_TYPE_SELECT',2);
62 $this->obj_id = $a_obj_id;
63 $this->
id = $a_field_id;
80 public static function _clone($a_source_id,$a_target_id)
85 $cdf->setName($field_obj->getName());
86 $cdf->setType($field_obj->getType());
87 $cdf->setValues($field_obj->getValues());
88 $cdf->enableRequired($field_obj->isRequired());
106 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
112 $query =
"DELETE FROM crs_defined_field_definitions ".
113 "WHERE obj_id = ".$ilDB->quote($a_container_id).
" ";
114 $ilDB->query($query);
142 return $fields ? $fields : array();
157 $query =
"SELECT * FROM crs_defined_field_definitions ".
158 "WHERE obj_id = ".$ilDB->quote($a_obj_id).
" ".
159 "AND field_required = 1";
160 $res = $ilDB->query($query);
163 $req_fields[] = $row->field_id;
165 return $req_fields ? $req_fields : array();
181 $query =
"SELECT field_name FROM crs_defined_field_definitions ".
182 "WHERE obj_id = ".$ilDB->quote($a_obj_id);
184 $res = $ilDB->query($query);
188 $fields[] = $row->field_name;
190 return implode(
'<br />',$fields);
205 $query =
"SELECT field_id FROM crs_defined_field_definitions ".
206 "WHERE obj_id = ".$ilDB->quote($a_container_id).
" ".
207 "ORDER BY ".$ilDB->quote($a_sort);
208 $res = $ilDB->query($query);
211 $field_ids[] = $row->field_id;
213 return $field_ids ? $field_ids : array();
228 $query =
"SELECT * FROM crs_defined_field_definitions ".
229 "WHERE field_id = ".$ilDB->quote($a_field_id);
231 $res = $ilDB->query($query);
234 return $row->field_name ? $row->field_name :
'';
251 $this->type = $a_type;
259 $this->name = $a_name;
263 return $this->values ? $this->values : array();
267 $this->values = $a_values;
271 if(is_array($this->values) and array_key_exists($a_id,$this->values))
273 return $this->values[$a_id];
279 return ($pos = array_search($a_value,$this->values) ===
false) ? -1 : $pos;
288 $this->required = $a_status;
303 $options[-1] = $lng->txt(
'select_one');
305 foreach($this->values as $value)
307 $options[$value] = $value;
320 $tmp_values = array();
322 if(!is_array($a_values))
326 foreach($a_values as $value)
331 $tmp_values[] = $value;
335 return $tmp_values ? $tmp_values : array();
345 if(!is_array($a_values))
349 $this->values = array_unique(array_merge($this->values,$a_values));
361 if(!isset($this->values[$a_id]))
365 unset($this->values[$a_id]);
366 array_merge($this->values);
381 $query =
"INSERT INTO crs_defined_field_definitions ".
382 "SET obj_id = ".$this->db->quote($this->
getObjId()).
", ".
383 "field_name = ".$this->db->quote($this->
getName()).
", ".
384 "field_type = ".$this->db->quote($this->
getType()).
", ".
385 "field_values = ".$this->db->quote(serialize($this->
getValues())).
", ".
386 "field_required = ".$ilDB->quote($this->
isRequired()).
" ";
387 $res = $this->db->query($query);
388 $this->
id = $this->db->getLastInsertId();
402 $query =
"UPDATE crs_defined_field_definitions ".
403 "SET field_name = ".$this->db->quote($this->
getName()).
", ".
404 "field_type = ".$this->db->quote($this->
getType()).
", ".
405 "field_values = ".$this->db->quote(serialize($this->
getValues())).
", ".
406 "field_required = ".$ilDB->quote($this->
isRequired()).
" ".
407 "WHERE field_id = ".$this->db->quote($this->
getId()).
" ".
408 "AND obj_id = ".$this->db->quote($this->
getObjId());
409 $this->db->query($query);
420 public function delete()
424 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
427 $query =
"DELETE FROM crs_defined_field_definitions ".
428 "WHERE field_id = ".$this->db->quote($this->
getId()).
" ";
429 $this->db->query($query);
440 $query =
"SELECT * FROM crs_defined_field_definitions ".
441 "WHERE field_id = ".$this->db->quote($this->
getId()).
" ".
442 "AND obj_id = ".$this->db->quote($this->
getObjId()).
" ";
444 $res = $this->db->query($query);
447 $this->
setName($row->field_name);
448 $this->
setType($row->field_type);
449 $this->
setValues(unserialize($row->field_values));