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;
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),
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");
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;
507 $tmp = $sort =
array();
509 foreach((
array) unserialize(
$row->field_values) as $item)
511 if(!is_numeric($item))
515 $sort[] =
array(
"value"=>$item);
519 $tmp[] = $item[
"value"];
522 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
523 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
524 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
525 $this->definitions[
$row->field_id][
'required'] =
$row->required;
526 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
527 $this->definitions[
$row->field_id][
'export'] =
$row->export;
528 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
529 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
530 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
531 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
532 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
534 $this->definitions[
$row->field_id][
'certificate'] =
$row->certificate;
549 $new_values =
array();
550 foreach($definition[
'field_values'] as $value)
554 $new_values[] = $value;
563 'field_values' =>
array(
'clob',serialize($new_values)));
564 $ilDB->update(
'udf_definition',$values,
array(
'field_id' =>
array(
'integer',$a_field_id)));
568 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
579 include_once
'./Services/Xml/classes/class.ilXmlWriter.php';
584 return $xml_writer->xmlDumpMem(
false);
593 $xml_writer->xmlStartTag (
"UDFDefinitions");
597 "Id" => $definition [
"il_id"],
598 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
599 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
600 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
601 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
602 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
603 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
604 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
605 "Certificate" => $definition[
"certificate"]?
"TRUE" :
"FALSE",
606 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
607 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE",
608 "LocalUserAdministrationVisible" => $definition[
"visib_lua"]?
"TRUE" :
"FALSE",
609 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"]?
"TRUE" :
"FALSE",
612 $xml_writer->xmlStartTag (
"UDFDefinition", $attributes);
613 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
615 $field_values = $definition[
"field_values"];
616 foreach ($field_values as $field_value)
618 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
621 $xml_writer->xmlEndTag (
"UDFDefinition");
623 $xml_writer->xmlEndTag (
"UDFDefinitions");
addToXML($xml_writer)
add user defined field data to xml (using usr dtd)
$field_visible_registration
enableVisible($a_visible)
enableVisibleRegistration($a_visible_registration)
static _getInstance()
Get instance.
fetchFieldIdFromImportId($a_import_id)
static deleteEntriesOfField($a_field_id)
Delete data of particular field.
Additional user data fields definition.
deleteValue($a_field_id, $a_value_id)
fetchFieldIdFromName($a_name)
getSearchableDefinitions()
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
enableCourseExport($a_course_export)
enableGroupExport($a_group_export)
getExportableFields($a_obj_id)
Get exportable field.
__construct()
Constructor is private -> use getInstance These definition are used e.g in User XML import...
getRegistrationDefinitions()
enabledVisibleRegistration()
fieldValuesToSelectArray($a_values)
getCourseExportableFields()
get
setFieldValues($a_values)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
getGroupExportableFields()
get fields visible in groups
enableVisibleLocalUserAdministration($a_visible)
enabledChangeableLocalUserAdministration()
getLocalUserAdministrationDefinitions()
enableRequired($a_required)
enableChangeable($a_changeable)
enabledVisibleLocalUserAdministration()
static deleteFieldValue($a_field_id, $a_value)
Delete data of particular value of a (selection) field.
const UDF_DUPLICATE_VALUES
enableSearchable($a_searchable)
nameExists($a_field_name)
getChangeableLocalUserAdministrationDefinitions()
enableChangeableLocalUserAdministration($a_changeable)