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);
52 if (!is_object($udf)) {
64 if (!strlen($a_import_id)) {
67 $parts = explode(
'_', $a_import_id);
69 if ($parts[0] !=
'il') {
72 if ($parts[1] !=
$ilSetting->get(
'inst_id', 0)) {
75 if ($parts[2] !=
'udf') {
80 if (is_array($this->definitions[
"$parts[3]"])) {
88 foreach ($this->definitions as $definition) {
89 if ($definition[
'field_name'] == $a_name) {
90 return $definition[
'field_id'];
101 return $this->definitions ? $this->definitions : array();
106 return is_array($this->definitions[$a_id]) ? $this->definitions[$a_id] : array();
111 foreach ($this->definitions as
$id => $definition) {
112 if ($definition[
'visible']) {
113 $visible_definition[
$id] = $definition;
116 return $visible_definition ? $visible_definition : array();
121 foreach ($this->definitions as
$id => $definition) {
122 if ($definition[
'visib_lua']) {
123 $visible_definition[
$id] = $definition;
126 return $visible_definition ? $visible_definition : array();
131 foreach ($this->definitions as
$id => $definition) {
132 if ($definition[
'changeable_lua']) {
133 $visible_definition[
$id] = $definition;
136 return $visible_definition ? $visible_definition : array();
141 foreach ($this->definitions as
$id => $definition) {
142 if ($definition[
'visib_reg']) {
143 $visible_definition[
$id] = $definition;
146 return $visible_definition ? $visible_definition : array();
151 foreach ($this->definitions as
$id => $definition) {
152 if ($definition[
'searchable']) {
153 $searchable_definition[
$id] = $definition;
156 return $searchable_definition ? $searchable_definition : array();
161 foreach ($this->definitions as
$id => $definition) {
162 if ($definition[
'required']) {
163 $required_definition[
$id] = $definition;
166 return $required_definition ? $required_definition : array();
178 foreach ($this->definitions as
$id => $definition) {
179 if ($definition[
'course_export']) {
180 $cexp_definition[
$id] = $definition;
183 return $cexp_definition ? $cexp_definition : array();
195 foreach ($this->definitions as
$id => $definition) {
196 if ($definition[
'group_export']) {
197 $cexp_definition[
$id] = $definition;
200 return $cexp_definition ? $cexp_definition : array();
222 $this->field_name = $a_name;
226 return $this->field_name;
235 if (!$this->field_type) {
238 switch ($this->field_type) {
251 return $this->field_type;
255 $this->field_values = array();
256 foreach ($a_values as $value) {
257 if (strlen($value)) {
258 $this->field_values[] = $value;
264 return $this->field_values ? $this->field_values : array();
269 $this->field_visible = $a_visible;
273 return $this->field_visible;
277 $this->field_visib_lua = $a_visible;
281 return $this->field_visib_lua;
285 $this->field_changeable = $a_changeable;
289 return $this->field_changeable;
293 $this->field_changeable_lua = $a_changeable;
297 return $this->field_changeable_lua;
301 $this->field_required = $a_required;
305 return $this->field_required;
309 $this->field_searchable = $a_searchable;
313 return $this->field_searchable;
317 $this->field_export = $a_export;
321 return $this->field_export;
325 $this->field_course_export = $a_course_export;
329 return $this->field_course_export;
333 $this->field_group_export = $a_group_export;
337 return $this->field_group_export;
342 $this->field_certificate = $a_c;
346 return $this->field_certificate;
351 $this->field_visible_registration = $a_visible_registration;
367 $lng = $DIC->language();
369 if ($a_with_selection_info) {
372 foreach ($a_values as $value) {
375 if (count(
$values) > (
int) $a_with_selection_info) {
386 if (!strlen($value)) {
390 $unique[$value] = $value;
393 if (!count($unique)) {
396 if ($number != count($unique)) {
406 $ilDB = $DIC[
'ilDB'];
408 $query =
"SELECT * FROM udf_definition " .
409 "WHERE field_name = " . $this->db->quote($a_field_name,
'text') .
" ";
412 return (
bool)
$res->numRows();
419 $ilDB = $DIC[
'ilDB'];
422 $next_id =
$ilDB->nextId(
'udf_definition');
425 'field_id' => array(
'integer',$next_id),
427 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
428 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
445 $field_id = $next_id;
452 public function delete($a_id)
456 $ilDB = $DIC[
'ilDB'];
459 $query =
"DELETE FROM udf_definition " .
460 "WHERE field_id = " . $this->db->quote($a_id,
'integer') .
" ";
465 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
477 $ilDB = $DIC[
'ilDB'];
481 'field_type' => array(
'integer', (
int) $this->
getFieldType()),
482 'field_values' => array(
'clob',serialize($this->
getFieldValues())),
495 $ilDB->update(
'udf_definition',
$values, array(
'field_id' => array(
'integer',$a_id)));
510 $query =
"SELECT * FROM udf_definition ";
513 $this->definitions = array();
515 $this->definitions[
$row->field_id][
'field_id'] =
$row->field_id;
516 $this->definitions[
$row->field_id][
'field_name'] =
$row->field_name;
517 $this->definitions[
$row->field_id][
'field_type'] =
$row->field_type;
518 $this->definitions[
$row->field_id][
'il_id'] =
'il_' .
$ilSetting->get(
'inst_id', 0) .
'_udf_' .
$row->field_id;
521 $tmp = $sort = array();
523 foreach ((array) unserialize(
$row->field_values) as $item) {
524 if (!is_numeric($item)) {
527 $sort[] = array(
"value" => $item);
530 $tmp[] = $item[
"value"];
533 $this->definitions[
$row->field_id][
'field_values'] = $tmp;
534 $this->definitions[
$row->field_id][
'visible'] =
$row->visible;
535 $this->definitions[
$row->field_id][
'changeable'] =
$row->changeable;
536 $this->definitions[
$row->field_id][
'required'] =
$row->required;
537 $this->definitions[
$row->field_id][
'searchable'] =
$row->searchable;
538 $this->definitions[
$row->field_id][
'export'] =
$row->export;
539 $this->definitions[
$row->field_id][
'course_export'] =
$row->course_export;
540 $this->definitions[
$row->field_id][
'visib_reg'] =
$row->registration_visible;
541 $this->definitions[
$row->field_id][
'visib_lua'] =
$row->visible_lua;
542 $this->definitions[
$row->field_id][
'changeable_lua'] =
$row->changeable_lua;
543 $this->definitions[
$row->field_id][
'group_export'] =
$row->group_export;
545 $this->definitions[
$row->field_id][
'certificate'] =
$row->certificate;
557 $ilDB = $DIC[
'ilDB'];
562 $new_values = array();
563 foreach ($definition[
'field_values'] as $value) {
564 if ($counter++ != $a_value_id) {
565 $new_values[] = $value;
572 'field_values' => array(
'clob',serialize($new_values)));
573 $ilDB->update(
'udf_definition',
$values, array(
'field_id' => array(
'integer',$a_field_id)));
577 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
588 include_once
'./Services/Xml/classes/class.ilXmlWriter.php';
593 return $xml_writer->xmlDumpMem(
false);
602 $xml_writer->xmlStartTag(
"UDFDefinitions");
605 "Id" => $definition [
"il_id"],
606 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT?
"SELECT" :
"TEXT",
607 "Visible" => $definition[
"visible"]?
"TRUE" :
"FALSE",
608 "Changeable" => $definition[
"changeable"]?
"TRUE" :
"FALSE",
609 "Required" => $definition[
"required"]?
"TRUE" :
"FALSE",
610 "Searchable" => $definition[
"searchable"]?
"TRUE" :
"FALSE",
611 "CourseExport" => $definition[
"course_export"]?
"TRUE" :
"FALSE",
612 "GroupExport" => $definition[
"group_export"]?
"TRUE" :
"FALSE",
613 "Certificate" => $definition[
"certificate"]?
"TRUE" :
"FALSE",
614 "Export" => $definition[
"export"]?
"TRUE" :
"FALSE",
615 "RegistrationVisible" => $definition[
"visib_reg"]?
"TRUE" :
"FALSE",
616 "LocalUserAdministrationVisible" => $definition[
"visib_lua"]?
"TRUE" :
"FALSE",
617 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"]?
"TRUE" :
"FALSE",
620 $xml_writer->xmlStartTag(
"UDFDefinition",
$attributes);
621 $xml_writer->xmlElement(
'UDFName', null, $definition[
'field_name']);
623 $field_values = $definition[
"field_values"];
624 foreach ($field_values as $field_value) {
625 $xml_writer->xmlElement(
'UDFValue', null, $field_value);
628 $xml_writer->xmlEndTag(
"UDFDefinition");
630 $xml_writer->xmlEndTag(
"UDFDefinitions");
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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)
if(!array_key_exists('StateId', $_REQUEST)) $id
fetchFieldIdFromName($a_name)
getSearchableDefinitions()
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...
foreach($_POST as $key=> $value) $res
getRegistrationDefinitions()
enabledVisibleRegistration()
getCourseExportableFields()
get
setFieldValues($a_values)
if(array_key_exists('yes', $_REQUEST)) $attributes
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()
fieldValuesToSelectArray($a_values, $a_with_selection_info=true)
enableChangeableLocalUserAdministration($a_changeable)