4 define(
'UDF_TYPE_TEXT',1);
5 define(
'UDF_TYPE_SELECT',2);
6 define(
'UDF_TYPE_WYSIWYG',3);
7 define(
'UDF_NO_VALUES',1);
8 define(
'UDF_DUPLICATE_VALUES',2);
57 if(!strlen($a_import_id))
61 $parts = explode(
'_',$a_import_id);
67 if($parts[1] != $ilSetting->get(
'inst_id',0))
71 if($parts[2] !=
'udf')
78 if(is_array($this->definitions[
"$parts[3]"]))
87 foreach($this->definitions as $definition)
89 if($definition[
'field_name'] == $a_name)
91 return $definition[
'field_id'];
99 return $this->definitions ? $this->definitions : array();
104 return is_array($this->definitions[$a_id]) ? $this->definitions[$a_id] : array();
109 foreach($this->definitions as $id => $definition)
111 if($definition[
'visible'])
113 $visible_definition[$id] = $definition;
116 return $visible_definition ? $visible_definition : array();
122 foreach($this->definitions as $id => $definition)
124 if($definition[
'visib_reg'])
126 $visible_definition[$id] = $definition;
129 return $visible_definition ? $visible_definition : array();
134 foreach($this->definitions as $id => $definition)
136 if($definition[
'searchable'])
138 $searchable_definition[$id] = $definition;
141 return $searchable_definition ? $searchable_definition : array();
153 foreach($this->definitions as $id => $definition)
155 if($definition[
'course_export'])
157 $cexp_definition[$id] = $definition;
160 return $cexp_definition ? $cexp_definition : array();
166 $this->field_name = $a_name;
170 return $this->field_name;
174 $this->field_type = $a_type;
178 return $this->field_type;
182 $this->field_values = array();
183 foreach($a_values as $value)
187 $this->field_values[] = $value;
193 return $this->field_values ? $this->field_values : array();
198 $this->field_visible = $a_visible;
202 return $this->field_visible;
206 $this->field_changeable = $a_changeable;
210 return $this->field_changeable;
214 $this->field_required = $a_required;
218 return $this->field_required;
222 $this->field_searchable = $a_searchable;
226 return $this->field_searchable;
230 $this->field_export = $a_export;
234 return $this->field_export;
238 $this->field_course_export = $a_course_export;
242 return $this->field_course_export;
247 $this->field_visible_registration = $a_visible_registration;
256 foreach($a_values as $value)
258 $values[$value] = $value;
260 return $values ? $values : array();
274 $unique[$value] = $value;
281 if($number != count($unique))
292 $query =
"SELECT * FROM udf_definition ".
293 "WHERE field_name = ".$this->db->quote($a_field_name,
'text').
" ";
296 return (
bool)
$res->numRows();
304 $next_id = $ilDB->nextId(
'udf_definition');
307 'field_id' => array(
'integer',$next_id),
309 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
310 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
319 $ilDB->insert(
'udf_definition',$values);
322 $field_id = $next_id;
330 function delete($a_id)
335 $query =
"DELETE FROM udf_definition ".
336 "WHERE field_id = ".$this->db->quote($a_id,
'integer').
" ";
341 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
355 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
356 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
365 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_id)));
378 $query =
"SELECT * FROM udf_definition ";
381 $this->definitions = array();
384 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
385 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
386 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
387 $this->definitions[
$row->field_id][
'il_id'] =
'il_'.$ilSetting->get(
'inst_id',0).
'_udf_'.
$row->field_id;
389 $tmp = (array) unserialize(
$row->field_values);
391 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
393 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
394 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
395 $this->definitions[
$row->field_id][
'required'] =
$row->required;
396 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
397 $this->definitions[
$row->field_id][
'export'] =
$row->export;
398 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
399 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
413 $new_values = array();
414 foreach($definition[
'field_values'] as $value)
416 if($counter++ != $a_value_id)
418 $new_values[] = $value;
427 'field_values' => array(
'clob',serialize($new_values)));
428 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_field_id)));
432 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
448 include_once
'classes/class.ilXmlWriter.php';
453 return $xml_writer->xmlDumpMem(
false);
462 $xml_writer->xmlStartTag (
"UDFDefinitions");
466 "Id" => $definition [
"il_id"],
467 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
468 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
469 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
470 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
471 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
472 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
473 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
474 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE"
476 $xml_writer->xmlStartTag (
"UDFDefinition", $attributes);
477 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
479 $field_values = $definition[
"field_values"];
480 foreach ($field_values as $field_value)
482 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
485 $xml_writer->xmlEndTag (
"UDFDefinition");
487 $xml_writer->xmlEndTag (
"UDFDefinitions");