24define(
"IL_CDF_SORT_ID", 
'field_id');
 
   25define(
"IL_CDF_SORT_NAME", 
'field_name');
 
   27define(
'IL_CDF_TYPE_TEXT', 1);
 
   28define(
'IL_CDF_TYPE_SELECT', 2);
 
   63        $this->obj_id = $a_obj_id;
 
   64        $this->
id = $a_field_id;
 
   80    public static function _clone($a_source_id, $a_target_id)
 
   84            $cdf->setName($field_obj->getName());
 
   85            $cdf->setType($field_obj->getType());
 
   86            $cdf->setValues($field_obj->getValues());
 
   87            $cdf->setValueOptions($field_obj->getValueOptions());
 
   88            $cdf->enableRequired($field_obj->isRequired());
 
  106        include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
 
  111        $query = 
"DELETE FROM crs_f_definitions " .
 
  112            "WHERE obj_id = " . 
$ilDB->quote($a_container_id, 
'integer') . 
" ";
 
  140        return $fields ? $fields : array();
 
  155        $query = 
"SELECT * FROM crs_f_definitions " .
 
  156            "WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
'integer') . 
" " .
 
  157            "AND field_required = 1";
 
  160            $req_fields[] = 
$row->field_id;
 
  162        return $req_fields ? $req_fields : array();
 
  178        $query = 
"SELECT field_name FROM crs_f_definitions " .
 
  179            "WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
'integer');
 
  184            $fields[] = 
$row->field_name;
 
  186        return implode(
'<br />', $fields);
 
  201        $query = 
"SELECT field_id FROM crs_f_definitions " .
 
  202            "WHERE obj_id = " . 
$ilDB->quote($a_container_id, 
'integer') . 
" " .
 
  206            $field_ids[] = 
$row->field_id;
 
  208        return $field_ids ? $field_ids : array();
 
  223        $query = 
"SELECT * FROM crs_f_definitions " .
 
  224            "WHERE field_id = " . 
$ilDB->quote($a_field_id, 
'integer');
 
  229        return $row->field_name ? 
$row->field_name : 
'';
 
  254        $this->name = $a_name;
 
  258        return $this->values ? $this->values : array();
 
  262        $this->values = $a_values;
 
  266        if (is_array($this->values) and array_key_exists($a_id, $this->values)) {
 
  267            return $this->values[$a_id];
 
  273        return (($pos = array_search($a_value, $this->values)) === 
false) ? -1 : $pos;
 
  282        $this->required = $a_status;
 
  287        $this->value_options = $a_options;
 
  310        foreach ($this->values as 
$key => $value) {
 
  324        $tmp_values = array();
 
  326        if (!is_array($a_values)) {
 
  329        foreach ($a_values as $idx => $value) {
 
  330            if (strlen($value)) {
 
  331                $tmp_values[$idx] = $value;
 
  334        return $tmp_values ? $tmp_values : array();
 
  344        if (!is_array($a_values)) {
 
  347        $this->values = array_unique(array_merge($this->values, $a_values));
 
  348        #sort($this->values); 
  359        if (!isset($this->values[$a_id])) {
 
  362        unset($this->values[$a_id]);
 
  363        array_merge($this->values);
 
  378        $next_id = 
$ilDB->nextId(
'crs_f_definitions');
 
  379        $query = 
"INSERT INTO crs_f_definitions (field_id,obj_id,field_name,field_type,field_values,field_required,field_values_opt) " .
 
  381            $ilDB->quote($next_id, 
'integer') . 
", " .
 
  382            $this->db->quote($this->
getObjId(), 
'integer') . 
", " .
 
  383            $this->db->quote($this->
getName(), 
"text") . 
", " .
 
  384            $this->db->quote($this->
getType(), 
'integer') . 
", " .
 
  385            $this->db->quote(serialize($this->
getValues()), 
'text') . 
", " .
 
  386            $ilDB->quote($this->
isRequired(), 
'integer') . 
", " .
 
  390        $this->
id = $next_id;
 
  404        $query = 
"UPDATE crs_f_definitions " .
 
  405            "SET field_name = " . $this->db->quote($this->
getName(), 
'text') . 
", " .
 
  406            "field_type = " . $this->db->quote($this->
getType(), 
'integer') . 
", " .
 
  407            "field_values = " . $this->db->quote(serialize($this->
getValues()), 
'text') . 
", " .
 
  408            "field_required = " . $ilDB->quote($this->
isRequired(), 
'integer') . 
", " .
 
  409            'field_values_opt = ' . $ilDB->quote(serialize($this->
getValueOptions()), 
'text') . 
' ' .
 
  410            "WHERE field_id = " . $this->db->quote($this->
getId(), 
'integer') . 
" " .
 
  411            "AND obj_id = " . $this->db->quote($this->
getObjId(), 
'integer');
 
  423    public function delete()
 
  427        include_once(
'Modules/Course/classes/Export/class.ilCourseUserData.php');
 
  430        $query = 
"DELETE FROM crs_f_definitions " .
 
  431            "WHERE field_id = " . $this->db->quote($this->
getId(), 
'integer') . 
" ";
 
  443        $query = 
"SELECT * FROM crs_f_definitions " .
 
  444            "WHERE field_id = " . $this->db->quote($this->
getId(), 
'integer') . 
" " .
 
  445            "AND obj_id = " . $this->db->quote($this->
getObjId(), 
'integer') . 
" ";
 
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
static _getFieldIds($a_container_id, $a_sort=IL_CDF_SORT_ID)
Get all field ids of a container.
appendValues($a_values)
Append Values.
prepareValues($a_values)
Prepare values from POST.
enableRequired($a_status)
static _deleteByContainer($a_container_id)
Delete all fields of a container.
setValueOptions($a_options)
static _getFields($a_container_id, $a_sort=IL_CDF_SORT_NAME)
Get all fields of a container.
static _hasFields($a_container_id)
Check if there are any define fields.
static _getRequiredFieldIds($a_obj_id)
Get required filed id's.
static _clone($a_source_id, $a_target_id)
Clone fields.
deleteValue($a_id)
Delete value by id.
prepareSelectBox()
Prepare an array of options for ilUtil::formSelect()
__construct($a_obj_id, $a_field_id=0)
Constructor.
static _fieldsToInfoString($a_obj_id)
Fields to info string.
static _lookupName($a_field_id)
Lookup field name.
static _deleteByField($a_field_id)
Delete by field.
foreach($_POST as $key=> $value) $res