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();
173 foreach($this->definitions as $id => $definition)
175 if($definition[
'required'])
177 $required_definition[$id] = $definition;
180 return $required_definition ? $required_definition : array();
192 foreach($this->definitions as $id => $definition)
194 if($definition[
'course_export'])
196 $cexp_definition[$id] = $definition;
199 return $cexp_definition ? $cexp_definition : array();
211 foreach($this->definitions as $id => $definition)
213 if($definition[
'group_export'])
215 $cexp_definition[$id] = $definition;
218 return $cexp_definition ? $cexp_definition : array();
242 $this->field_name = $a_name;
246 return $this->field_name;
250 $this->field_type = $a_type;
254 return $this->field_type;
258 $this->field_values = array();
259 foreach($a_values as $value)
263 $this->field_values[] = $value;
269 return $this->field_values ? $this->field_values : array();
274 $this->field_visible = $a_visible;
278 return $this->field_visible;
282 $this->field_visib_lua = $a_visible;
286 return $this->field_visib_lua;
290 $this->field_changeable = $a_changeable;
294 return $this->field_changeable;
298 $this->field_changeable_lua = $a_changeable;
302 return $this->field_changeable_lua;
306 $this->field_required = $a_required;
310 return $this->field_required;
314 $this->field_searchable = $a_searchable;
318 return $this->field_searchable;
322 $this->field_export = $a_export;
326 return $this->field_export;
330 $this->field_course_export = $a_course_export;
334 return $this->field_course_export;
338 $this->field_group_export = $a_group_export;
342 return $this->field_group_export;
347 $this->field_visible_registration = $a_visible_registration;
356 foreach($a_values as $value)
358 $values[$value] = $value;
360 return $values ? $values : array();
374 $unique[$value] = $value;
381 if($number != count($unique))
392 $query =
"SELECT * FROM udf_definition ".
393 "WHERE field_name = ".$this->db->quote($a_field_name,
'text').
" ";
396 return (
bool)
$res->numRows();
404 $next_id = $ilDB->nextId(
'udf_definition');
407 'field_id' => array(
'integer',$next_id),
409 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
410 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
423 $ilDB->insert(
'udf_definition',$values);
426 $field_id = $next_id;
433 function delete($a_id)
438 $query =
"DELETE FROM udf_definition ".
439 "WHERE field_id = ".$this->db->quote($a_id,
'integer').
" ";
444 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
458 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
459 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
471 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_id)));
484 $query =
"SELECT * FROM udf_definition ";
487 $this->definitions = array();
490 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
491 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
492 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
493 $this->definitions[
$row->field_id][
'il_id'] =
'il_'.$ilSetting->get(
'inst_id',0).
'_udf_'.
$row->field_id;
495 $tmp = (array) unserialize(
$row->field_values);
497 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
499 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
500 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
501 $this->definitions[
$row->field_id][
'required'] =
$row->required;
502 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
503 $this->definitions[
$row->field_id][
'export'] =
$row->export;
504 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
505 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
506 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
507 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
508 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
522 $new_values = array();
523 foreach($definition[
'field_values'] as $value)
525 if($counter++ != $a_value_id)
527 $new_values[] = $value;
536 'field_values' => array(
'clob',serialize($new_values)));
537 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_field_id)));
541 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
552 include_once
'./Services/Xml/classes/class.ilXmlWriter.php';
557 return $xml_writer->xmlDumpMem(
false);
566 $xml_writer->xmlStartTag (
"UDFDefinitions");
570 "Id" => $definition [
"il_id"],
571 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
572 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
573 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
574 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
575 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
576 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
577 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
578 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
579 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE",
580 "LocalUserAdministrationVisible" => $definition[
"visib_lua"]?
"TRUE" :
"FALSE",
581 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"]?
"TRUE" :
"FALSE",
584 $xml_writer->xmlStartTag (
"UDFDefinition", $attributes);
585 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
587 $field_values = $definition[
"field_values"];
588 foreach ($field_values as $field_value)
590 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
593 $xml_writer->xmlEndTag (
"UDFDefinition");
595 $xml_writer->xmlEndTag (
"UDFDefinitions");