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_certificate = $a_c;
351 return $this->field_certificate;
356 $this->field_visible_registration = $a_visible_registration;
365 foreach($a_values as $value)
367 $values[$value] = $value;
369 return $values ? $values : array();
383 $unique[$value] = $value;
390 if($number != count($unique))
401 $query =
"SELECT * FROM udf_definition ".
402 "WHERE field_name = ".$this->db->quote($a_field_name,
'text').
" ";
405 return (
bool)
$res->numRows();
413 $next_id = $ilDB->nextId(
'udf_definition');
416 'field_id' => array(
'integer',$next_id),
418 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
419 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
433 $ilDB->insert(
'udf_definition',$values);
436 $field_id = $next_id;
443 function delete($a_id)
448 $query =
"DELETE FROM udf_definition ".
449 "WHERE field_id = ".$this->db->quote($a_id,
'integer').
" ";
454 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
468 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
469 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
482 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_id)));
495 $query =
"SELECT * FROM udf_definition ";
498 $this->definitions = array();
501 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
502 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
503 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
504 $this->definitions[
$row->field_id][
'il_id'] =
'il_'.$ilSetting->get(
'inst_id',0).
'_udf_'.
$row->field_id;
506 $tmp = (array) unserialize(
$row->field_values);
508 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
510 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
511 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
512 $this->definitions[
$row->field_id][
'required'] =
$row->required;
513 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
514 $this->definitions[
$row->field_id][
'export'] =
$row->export;
515 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
516 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
517 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
518 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
519 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
521 $this->definitions[
$row->field_id][
'certificate'] =
$row->certificate;
536 $new_values = array();
537 foreach($definition[
'field_values'] as $value)
539 if($counter++ != $a_value_id)
541 $new_values[] = $value;
550 'field_values' => array(
'clob',serialize($new_values)));
551 $ilDB->update(
'udf_definition',$values,array(
'field_id' => array(
'integer',$a_field_id)));
555 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
566 include_once
'./Services/Xml/classes/class.ilXmlWriter.php';
571 return $xml_writer->xmlDumpMem(
false);
580 $xml_writer->xmlStartTag (
"UDFDefinitions");
584 "Id" => $definition [
"il_id"],
585 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
586 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
587 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
588 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
589 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
590 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
591 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
592 "Certificate" => $definition[
"certificate"]?
"TRUE" :
"FALSE",
593 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
594 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE",
595 "LocalUserAdministrationVisible" => $definition[
"visib_lua"]?
"TRUE" :
"FALSE",
596 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"]?
"TRUE" :
"FALSE",
599 $xml_writer->xmlStartTag (
"UDFDefinition", $attributes);
600 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
602 $field_values = $definition[
"field_values"];
603 foreach ($field_values as $field_value)
605 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
608 $xml_writer->xmlEndTag (
"UDFDefinition");
610 $xml_writer->xmlEndTag (
"UDFDefinitions");