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_f_definitions ".
113 "WHERE obj_id = ".$ilDB->quote($a_container_id,
'integer').
" ";
142 return $fields ? $fields : array();
157 $query =
"SELECT * FROM crs_f_definitions ".
158 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
159 "AND field_required = 1";
161 while(
$row = $ilDB->fetchObject(
$res))
163 $req_fields[] =
$row->field_id;
165 return $req_fields ? $req_fields : array();
181 $query =
"SELECT field_name FROM crs_f_definitions ".
182 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer');
186 while(
$row = $ilDB->fetchObject(
$res))
188 $fields[] =
$row->field_name;
190 return implode(
'<br />',$fields);
205 $query =
"SELECT field_id FROM crs_f_definitions ".
206 "WHERE obj_id = ".$ilDB->quote($a_container_id,
'integer').
" ".
209 while(
$row = $ilDB->fetchObject(
$res))
211 $field_ids[] =
$row->field_id;
213 return $field_ids ? $field_ids : array();
228 $query =
"SELECT * FROM crs_f_definitions ".
229 "WHERE field_id = ".$ilDB->quote($a_field_id,
'integer');
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[0] = $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 $next_id = $ilDB->nextId(
'crs_f_definitions');
382 $query =
"INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required) ".
384 $ilDB->quote($next_id,
'integer').
", ".
385 $this->db->quote($this->
getObjId(),
'integer').
", ".
386 $this->db->quote($this->
getName(),
"text").
", ".
387 $this->db->quote($this->
getType(),
'integer').
", ".
388 $this->db->quote(serialize($this->
getValues()),
'text').
", ".
389 $ilDB->quote($this->
isRequired(),
'integer').
" ".
392 $this->
id = $next_id;
406 $query =
"UPDATE crs_f_definitions ".
407 "SET field_name = ".$this->db->quote($this->
getName(),
'text').
", ".
408 "field_type = ".$this->db->quote($this->
getType(),
'integer').
", ".
409 "field_values = ".$this->db->quote(serialize($this->
getValues()),
'text').
", ".
410 "field_required = ".$ilDB->quote($this->
isRequired(),
'integer').
" ".
411 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ".
412 "AND obj_id = ".$this->db->quote($this->
getObjId(),
'integer');
424 public function delete()
428 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
431 $query =
"DELETE FROM crs_f_definitions ".
432 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ";
444 $query =
"SELECT * FROM crs_f_definitions ".
445 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ".
446 "AND obj_id = ".$this->db->quote($this->
getObjId(),
'integer').
" ";