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);
61 if(!strlen($a_import_id))
65 $parts = explode(
'_',$a_import_id);
71 if($parts[1] != $ilSetting->get(
'inst_id',0))
75 if($parts[2] !=
'udf')
82 if(is_array($this->definitions[
"$parts[3]"]))
91 foreach($this->definitions as $definition)
93 if($definition[
'field_name'] == $a_name)
95 return $definition[
'field_id'];
103 return $this->definitions ? $this->definitions : array();
108 return is_array($this->definitions[$a_id]) ? $this->definitions[$a_id] : array();
113 foreach($this->definitions as $id => $definition)
115 if($definition[
'visible'])
117 $visible_definition[$id] = $definition;
120 return $visible_definition ? $visible_definition : array();
125 foreach($this->definitions as $id => $definition)
127 if($definition[
'visib_lua'])
129 $visible_definition[$id] = $definition;
132 return $visible_definition ? $visible_definition : array();
137 foreach($this->definitions as $id => $definition)
139 if($definition[
'changeable_lua'])
141 $visible_definition[$id] = $definition;
144 return $visible_definition ? $visible_definition : array();
149 foreach($this->definitions as $id => $definition)
151 if($definition[
'visib_reg'])
153 $visible_definition[$id] = $definition;
156 return $visible_definition ? $visible_definition : array();
161 foreach($this->definitions as $id => $definition)
163 if($definition[
'searchable'])
165 $searchable_definition[$id] = $definition;
168 return $searchable_definition ? $searchable_definition : array();
180 foreach($this->definitions as $id => $definition)
182 if($definition[
'course_export'])
184 $cexp_definition[$id] = $definition;
187 return $cexp_definition ? $cexp_definition : array();
199 foreach($this->definitions as $id => $definition)
201 if($definition[
'group_export'])
203 $cexp_definition[$id] = $definition;
206 return $cexp_definition ? $cexp_definition : array();
230 $this->field_name = $a_name;
234 return $this->field_name;
238 $this->field_type = $a_type;
242 return $this->field_type;
246 $this->field_values = array();
247 foreach($a_values as $value)
251 $this->field_values[] = $value;
257 return $this->field_values ? $this->field_values : array();
262 $this->field_visible = $a_visible;
266 return $this->field_visible;
270 $this->field_visib_lua = $a_visible;
274 return $this->field_visib_lua;
278 $this->field_changeable = $a_changeable;
282 return $this->field_changeable;
286 $this->field_changeable_lua = $a_changeable;
290 return $this->field_changeable_lua;
294 $this->field_required = $a_required;
298 return $this->field_required;
302 $this->field_searchable = $a_searchable;
306 return $this->field_searchable;
310 $this->field_export = $a_export;
314 return $this->field_export;
318 $this->field_course_export = $a_course_export;
322 return $this->field_course_export;
326 $this->field_group_export = $a_group_export;
330 return $this->field_group_export;
335 $this->field_visible_registration = $a_visible_registration;
344 foreach($a_values as $value)
346 $values[$value] = $value;
348 return $values ? $values : array();
362 $unique[$value] = $value;
369 if($number != count($unique))
380 $query =
"SELECT * FROM udf_definition ".
381 "WHERE field_name = ".$this->db->quote($a_field_name,
'text').
" ";
384 return (
bool)
$res->numRows();
392 $next_id = $ilDB->nextId(
'udf_definition');
395 'field_id' => array(
'integer',$next_id),
397 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
398 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
411 $ilDB->insert(
'udf_definition',$values);
414 $field_id = $next_id;
421 function delete($a_id)
426 $query =
"DELETE FROM udf_definition ".
427 "WHERE field_id = ".$this->db->quote($a_id,
'integer').
" ";
432 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
446 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
447 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
459 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_id)));
472 $query =
"SELECT * FROM udf_definition ";
475 $this->definitions = array();
478 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
479 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
480 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
481 $this->definitions[
$row->field_id][
'il_id'] =
'il_'.$ilSetting->get(
'inst_id',0).
'_udf_'.
$row->field_id;
483 $tmp = (array) unserialize(
$row->field_values);
485 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
487 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
488 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
489 $this->definitions[
$row->field_id][
'required'] =
$row->required;
490 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
491 $this->definitions[
$row->field_id][
'export'] =
$row->export;
492 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
493 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
494 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
495 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
496 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
510 $new_values = array();
511 foreach($definition[
'field_values'] as $value)
513 if($counter++ != $a_value_id)
515 $new_values[] = $value;
524 'field_values' => array(
'clob',serialize($new_values)));
525 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_field_id)));
529 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
540 include_once
'./Services/Xml/classes/class.ilXmlWriter.php';
545 return $xml_writer->xmlDumpMem(
false);
554 $xml_writer->xmlStartTag (
"UDFDefinitions");
558 "Id" => $definition [
"il_id"],
559 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
560 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
561 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
562 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
563 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
564 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
565 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
566 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
567 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE",
568 "LocalUserAdministrationVisible" => $definition[
"visib_lua"]?
"TRUE" :
"FALSE",
569 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"]?
"TRUE" :
"FALSE",
572 $xml_writer->xmlStartTag (
"UDFDefinition", $attributes);
573 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
575 $field_values = $definition[
"field_values"];
576 foreach ($field_values as $field_value)
578 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
581 $xml_writer->xmlEndTag (
"UDFDefinition");
583 $xml_writer->xmlEndTag (
"UDFDefinitions");