4define(
'UDF_TYPE_TEXT', 1);
5define(
'UDF_TYPE_SELECT', 2);
6define(
'UDF_TYPE_WYSIWYG', 3);
7define(
'UDF_NO_VALUES', 1);
8define(
'UDF_DUPLICATE_VALUES', 2);
50 if (!is_object($udf)) {
60 if (!strlen($a_import_id)) {
63 $parts = explode(
'_', $a_import_id);
65 if ($parts[0] !=
'il') {
68 if ($parts[1] !=
$ilSetting->get(
'inst_id', 0)) {
71 if ($parts[2] !=
'udf') {
76 if (is_array($this->definitions[
"$parts[3]"])) {
84 foreach ($this->definitions as $definition) {
85 if ($definition[
'field_name'] == $a_name) {
86 return $definition[
'field_id'];
94 return $this->definitions ? $this->definitions : array();
99 return is_array($this->definitions[$a_id]) ? $this->definitions[$a_id] : array();
104 foreach ($this->definitions as
$id => $definition) {
105 if ($definition[
'visible']) {
106 $visible_definition[
$id] = $definition;
109 return $visible_definition ? $visible_definition : array();
114 foreach ($this->definitions as
$id => $definition) {
115 if ($definition[
'visib_lua']) {
116 $visible_definition[
$id] = $definition;
119 return $visible_definition ? $visible_definition : array();
124 foreach ($this->definitions as
$id => $definition) {
125 if ($definition[
'changeable_lua']) {
126 $visible_definition[
$id] = $definition;
129 return $visible_definition ? $visible_definition : array();
134 foreach ($this->definitions as
$id => $definition) {
135 if ($definition[
'visib_reg']) {
136 $visible_definition[
$id] = $definition;
139 return $visible_definition ? $visible_definition : array();
144 foreach ($this->definitions as
$id => $definition) {
145 if ($definition[
'searchable']) {
146 $searchable_definition[
$id] = $definition;
149 return $searchable_definition ? $searchable_definition : array();
154 foreach ($this->definitions as
$id => $definition) {
155 if ($definition[
'required']) {
156 $required_definition[
$id] = $definition;
159 return $required_definition ? $required_definition : array();
171 foreach ($this->definitions as
$id => $definition) {
172 if ($definition[
'course_export']) {
173 $cexp_definition[
$id] = $definition;
176 return $cexp_definition ? $cexp_definition : array();
188 foreach ($this->definitions as
$id => $definition) {
189 if ($definition[
'group_export']) {
190 $cexp_definition[
$id] = $definition;
193 return $cexp_definition ? $cexp_definition : array();
215 $this->field_name = $a_name;
219 return $this->field_name;
227 return $this->field_type;
231 $this->field_values = array();
232 foreach ($a_values as $value) {
233 if (strlen($value)) {
234 $this->field_values[] = $value;
240 return $this->field_values ? $this->field_values : array();
245 $this->field_visible = $a_visible;
249 return $this->field_visible;
253 $this->field_visib_lua = $a_visible;
257 return $this->field_visib_lua;
261 $this->field_changeable = $a_changeable;
265 return $this->field_changeable;
269 $this->field_changeable_lua = $a_changeable;
273 return $this->field_changeable_lua;
277 $this->field_required = $a_required;
281 return $this->field_required;
285 $this->field_searchable = $a_searchable;
289 return $this->field_searchable;
293 $this->field_export = $a_export;
297 return $this->field_export;
301 $this->field_course_export = $a_course_export;
305 return $this->field_course_export;
309 $this->field_group_export = $a_group_export;
313 return $this->field_group_export;
318 $this->field_certificate = $a_c;
322 return $this->field_certificate;
327 $this->field_visible_registration = $a_visible_registration;
345 if ($a_with_selection_info) {
346 $values[
''] =
$lng->txt(
'please_select');
348 foreach ($a_values as $value) {
349 $values[$value] = $value;
351 if (count($values) > (
int) $a_with_selection_info) {
362 if (!strlen($value)) {
366 $unique[$value] = $value;
369 if (!count($unique)) {
372 if ($number != count($unique)) {
382 $query =
"SELECT * FROM udf_definition " .
383 "WHERE field_name = " . $this->db->quote($a_field_name,
'text') .
" ";
386 return (
bool)
$res->numRows();
394 $next_id =
$ilDB->nextId(
'udf_definition');
397 'field_id' => array(
'integer',$next_id),
399 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
400 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
414 $ilDB->insert(
'udf_definition', $values);
417 $field_id = $next_id;
424 public function delete($a_id)
429 $query =
"DELETE FROM udf_definition " .
430 "WHERE field_id = " . $this->db->quote($a_id,
'integer') .
" ";
435 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
449 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
450 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
463 $ilDB->update(
'udf_definition', $values, array(
'field_id' => array(
'integer',$a_id)));
476 $query =
"SELECT * FROM udf_definition ";
479 $this->definitions = array();
481 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
482 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
483 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
484 $this->definitions[
$row->field_id][
'il_id'] =
'il_' .
$ilSetting->get(
'inst_id', 0) .
'_udf_' .
$row->field_id;
487 $tmp = $sort = array();
489 foreach ((array) unserialize(
$row->field_values) as $item) {
490 if (!is_numeric($item)) {
493 $sort[] = array(
"value"=>$item);
496 $tmp[] = $item[
"value"];
499 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
500 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
501 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
502 $this->definitions[
$row->field_id][
'required'] =
$row->required;
503 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
504 $this->definitions[
$row->field_id][
'export'] =
$row->export;
505 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
506 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
507 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
508 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
509 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
511 $this->definitions[
$row->field_id][
'certificate'] =
$row->certificate;
526 $new_values = array();
527 foreach ($definition[
'field_values'] as $value) {
529 $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");
569 "Id" => $definition [
"il_id"],
570 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
571 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
572 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
573 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
574 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
575 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
576 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
577 "Certificate" => $definition[
"certificate"]?
"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) {
589 $xml_writer->xmlElement(
'UDFValue',
null, $field_value);
592 $xml_writer->xmlEndTag(
"UDFDefinition");
594 $xml_writer->xmlEndTag(
"UDFDefinitions");
An exception for terminatinating execution or to throw for unit testing.
const UDF_DUPLICATE_VALUES
static _lookupType($a_id, $a_reference=false)
lookup object type
static deleteFieldValue($a_field_id, $a_value)
Delete data of particular value of a (selection) field.
static deleteEntriesOfField($a_field_id)
Delete data of particular field.
Additional user data fields definition.
enableVisibleRegistration($a_visible_registration)
getChangeableLocalUserAdministrationDefinitions()
fetchFieldIdFromImportId($a_import_id)
enableVisibleLocalUserAdministration($a_visible)
enableSearchable($a_searchable)
enabledChangeableLocalUserAdministration()
enableVisible($a_visible)
enableChangeable($a_changeable)
getLocalUserAdministrationDefinitions()
enableGroupExport($a_group_export)
getCourseExportableFields()
get
getSearchableDefinitions()
getExportableFields($a_obj_id)
Get exportable field.
nameExists($a_field_name)
enableCourseExport($a_course_export)
getRegistrationDefinitions()
getGroupExportableFields()
get fields visible in groups
addToXML($xml_writer)
add user defined field data to xml (using usr dtd)
static _getInstance()
Get instance.
deleteValue($a_field_id, $a_value_id)
setFieldValues($a_values)
enableRequired($a_required)
enableChangeableLocalUserAdministration($a_changeable)
fetchFieldIdFromName($a_name)
fieldValuesToSelectArray($a_values, $a_with_selection_info=true)
enabledVisibleRegistration()
$field_visible_registration
__construct()
Constructor is private -> use getInstance These definition are used e.g in User XML import.
enabledVisibleLocalUserAdministration()
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res