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);
63 $this->obj_id = $a_obj_id;
64 $this->
id = $a_field_id;
81 public static function _clone($a_source_id,$a_target_id)
86 $cdf->setName($field_obj->getName());
87 $cdf->setType($field_obj->getType());
88 $cdf->setValues($field_obj->getValues());
89 $cdf->setValueOptions($field_obj->getValueOptions());
90 $cdf->enableRequired($field_obj->isRequired());
108 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
114 $query =
"DELETE FROM crs_f_definitions ".
115 "WHERE obj_id = ".$ilDB->quote($a_container_id,
'integer').
" ";
144 return $fields ? $fields : array();
159 $query =
"SELECT * FROM crs_f_definitions ".
160 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer').
" ".
161 "AND field_required = 1";
163 while(
$row = $ilDB->fetchObject(
$res))
165 $req_fields[] =
$row->field_id;
167 return $req_fields ? $req_fields : array();
183 $query =
"SELECT field_name FROM crs_f_definitions ".
184 "WHERE obj_id = ".$ilDB->quote($a_obj_id,
'integer');
188 while(
$row = $ilDB->fetchObject(
$res))
190 $fields[] =
$row->field_name;
192 return implode(
'<br />',$fields);
207 $query =
"SELECT field_id FROM crs_f_definitions ".
208 "WHERE obj_id = ".$ilDB->quote($a_container_id,
'integer').
" ".
209 "ORDER BY ".IL_CDF_SORT_ID;
211 while(
$row = $ilDB->fetchObject(
$res))
213 $field_ids[] =
$row->field_id;
215 return $field_ids ? $field_ids : array();
230 $query =
"SELECT * FROM crs_f_definitions ".
231 "WHERE field_id = ".$ilDB->quote($a_field_id,
'integer');
236 return $row->field_name ?
$row->field_name :
'';
253 $this->type = $a_type;
261 $this->name = $a_name;
265 return $this->values ? $this->values : array();
269 $this->values = $a_values;
273 if(is_array($this->values) and array_key_exists($a_id,$this->values))
275 return $this->values[$a_id];
281 return ($pos = array_search($a_value,$this->values) ===
false) ? -1 : $pos;
290 $this->required = $a_status;
295 $this->value_options = $a_options;
316 $options[0] = $lng->txt(
'select_one');
318 foreach($this->values as $key => $value)
333 $tmp_values = array();
335 if(!is_array($a_values))
339 foreach($a_values as $idx => $value)
343 $tmp_values[$idx] = $value;
346 return $tmp_values ? $tmp_values : array();
356 if(!is_array($a_values))
360 $this->values = array_unique(array_merge($this->values,$a_values));
361 #sort($this->values);
372 if(!isset($this->values[$a_id]))
376 unset($this->values[$a_id]);
377 array_merge($this->values);
392 $next_id = $ilDB->nextId(
'crs_f_definitions');
393 $query =
"INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required,field_values_opt) ".
395 $ilDB->quote($next_id,
'integer').
", ".
396 $this->db->quote($this->
getObjId(),
'integer').
", ".
397 $this->db->quote($this->
getName(),
"text").
", ".
398 $this->db->quote($this->
getType(),
'integer').
", ".
399 $this->db->quote(serialize($this->
getValues()),
'text').
", ".
400 $ilDB->quote($this->
isRequired(),
'integer').
", ".
404 $this->
id = $next_id;
418 $query =
"UPDATE crs_f_definitions ".
419 "SET field_name = ".$this->db->quote($this->
getName(),
'text').
", ".
420 "field_type = ".$this->db->quote($this->
getType(),
'integer').
", ".
421 "field_values = ".$this->db->quote(serialize($this->
getValues()),
'text').
", ".
422 "field_required = ".$ilDB->quote($this->
isRequired(),
'integer').
", ".
423 'field_values_opt = '.$ilDB->quote(serialize($this->
getValueOptions()),
'text').
' '.
424 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ".
425 "AND obj_id = ".$this->db->quote($this->
getObjId(),
'integer');
437 public function delete()
441 include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
444 $query =
"DELETE FROM crs_f_definitions ".
445 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ";
457 $query =
"SELECT * FROM crs_f_definitions ".
458 "WHERE field_id = ".$this->db->quote($this->
getId(),
'integer').
" ".
459 "AND obj_id = ".$this->db->quote($this->
getObjId(),
'integer').
" ";