56 $this->db = $DIC->database();
64 if (!is_object($udf)) {
76 if (!strlen($a_import_id)) {
79 $parts = explode(
'_', $a_import_id);
81 if ((
$parts[0] ??
'') !=
'il') {
87 if ((
$parts[2] ??
'') !=
'udf') {
92 if (is_array(($this->definitions[
$parts[3]] ??
false))) {
101 foreach ($this->definitions as $definition) {
102 if ($definition[
'field_name'] == $a_name) {
103 return $definition[
'field_id'];
111 return $this->definitions ?: [];
116 return $this->definitions[$a_id] ?? [];
121 $visible_definition = [];
122 foreach ($this->definitions as
$id => $definition) {
123 if ($definition[
'visible']) {
124 $visible_definition[
$id] = $definition;
127 return $visible_definition;
132 $visible_definition = [];
133 foreach ($this->definitions as
$id => $definition) {
134 if ($definition[
'visib_lua']) {
135 $visible_definition[
$id] = $definition;
138 return $visible_definition;
143 $visible_definition = [];
144 foreach ($this->definitions as
$id => $definition) {
145 if ($definition[
'changeable_lua']) {
146 $visible_definition[
$id] = $definition;
149 return $visible_definition;
154 $visible_definition = [];
155 foreach ($this->definitions as
$id => $definition) {
156 if ($definition[
'visib_reg']) {
157 $visible_definition[
$id] = $definition;
160 return $visible_definition;
165 $searchable_definition = [];
166 foreach ($this->definitions as
$id => $definition) {
167 if ($definition[
'searchable']) {
168 $searchable_definition[
$id] = $definition;
171 return $searchable_definition;
176 $required_definition = [];
177 foreach ($this->definitions as
$id => $definition) {
178 if ($definition[
'required']) {
179 $required_definition[
$id] = $definition;
182 return $required_definition;
187 $cexp_definition = [];
188 foreach ($this->definitions as
$id => $definition) {
189 if ($definition[
'course_export']) {
190 $cexp_definition[
$id] = $definition;
193 return $cexp_definition;
198 $cexp_definition = [];
199 foreach ($this->definitions as
$id => $definition) {
200 if ($definition[
'group_export']) {
201 $cexp_definition[
$id] = $definition;
204 return $cexp_definition;
209 $prg_exp_definition = [];
210 foreach ($this->definitions as
$id => $definition) {
211 if ($definition[
'prg_export']) {
212 $prg_exp_definition[
$id] = $definition;
215 return $prg_exp_definition;
230 return $this->getPRGExportableFields();
238 $this->field_name = $a_name;
248 $this->field_type = $a_type;
253 if (!$this->field_type) {
256 switch ($this->field_type) {
277 $this->field_values = [];
278 foreach ($a_values as $value) {
279 if (strlen($value)) {
280 $this->field_values[] = $value;
287 return $this->field_values ?: [];
292 $this->field_visible = $a_visible;
302 $this->field_visib_lua = $a_visible;
312 $this->field_changeable = $a_changeable;
322 $this->field_changeable_lua = $a_changeable;
332 $this->field_required = $a_required;
342 $this->field_searchable = $a_searchable;
352 $this->field_export = $a_export;
362 $this->field_course_export = $a_course_export;
372 $this->field_group_export = $a_group_export;
382 $this->field_prg_export = $prg_export;
392 $this->field_certificate = $a_c;
402 $this->field_visible_registration = $a_visible_registration;
412 bool $a_with_selection_info =
true 416 $lng = $DIC->language();
418 if ($a_with_selection_info) {
419 $values[
''] =
$lng->txt(
'please_select');
421 foreach ($a_values as $value) {
422 $values[$value] = $value;
424 if (count($values) > (
int) $a_with_selection_info) {
435 if (!strlen($value)) {
439 $unique[$value] = $value;
442 if (!count($unique)) {
445 if ($number != count($unique)) {
455 $ilDB = $DIC[
'ilDB'];
457 $query =
"SELECT * FROM udf_definition " .
458 "WHERE field_name = " . $this->db->quote($a_field_name,
'text') .
" ";
461 return (
bool)
$res->numRows();
468 $ilDB = $DIC[
'ilDB'];
471 $next_id =
$ilDB->nextId(
'udf_definition');
474 'field_id' => [
'integer',$next_id],
493 $ilDB->insert(
'udf_definition', $values);
496 $field_id = $next_id;
504 public function delete(
int $a_id):
void 508 $ilDB = $DIC[
'ilDB'];
511 $query =
"DELETE FROM udf_definition " .
512 "WHERE field_id = " . $this->db->quote($a_id,
'integer') .
" ";
513 $ilDB->manipulate($query);
540 $this->db->update(
'udf_definition', $values, [
'field_id' => [
'integer',$a_id]]);
550 $query =
"SELECT * FROM udf_definition;";
551 $res = $this->db->query($query);
553 $this->definitions = [];
555 $this->definitions[$row->field_id][
'field_id'] = $row->field_id;
556 $this->definitions[$row->field_id][
'field_name'] = $row->field_name;
557 $this->definitions[$row->field_id][
'field_type'] = $row->field_type;
558 $this->definitions[$row->field_id][
'il_id'] =
'il_' .
$ilSetting->get(
'inst_id',
'0') .
'_udf_' . $row->field_id;
563 foreach ((array) unserialize($row->field_values, [
'allowed_classes' =>
false]) as $item) {
564 if (!is_numeric($item)) {
567 $sort[] = [
"value" => $item];
570 $tmp[] = $item[
"value"];
573 $this->definitions[$row->field_id][
'field_values'] = $tmp;
574 $this->definitions[$row->field_id][
'visible'] = $row->visible;
575 $this->definitions[$row->field_id][
'changeable'] = $row->changeable;
576 $this->definitions[$row->field_id][
'required'] = $row->required;
577 $this->definitions[$row->field_id][
'searchable'] = $row->searchable;
578 $this->definitions[$row->field_id][
'export'] = $row->export;
579 $this->definitions[$row->field_id][
'course_export'] = $row->course_export;
580 $this->definitions[$row->field_id][
'visib_reg'] = $row->registration_visible;
581 $this->definitions[$row->field_id][
'visib_lua'] = $row->visible_lua;
582 $this->definitions[$row->field_id][
'changeable_lua'] = $row->changeable_lua;
583 $this->definitions[$row->field_id][
'group_export'] = $row->group_export;
584 $this->definitions[$row->field_id][
'certificate'] = $row->certificate;
585 $this->definitions[$row->field_id][
'prg_export'] = $row->prg_export;
595 $ilDB = $DIC[
'ilDB'];
602 foreach ($definition[
'field_values'] as $value) {
603 if ($counter++ != $a_value_id) {
604 $new_values[] = $value;
611 'field_values' => [
'clob',serialize($new_values)]];
612 $ilDB->update(
'udf_definition', $values, [
'field_id' => [
'integer',$a_field_id]]);
626 return $xml_writer->xmlDumpMem(
false);
637 "Id" => $definition [
"il_id"],
638 "Type" => $definition[
"field_type"] ==
UDF_TYPE_SELECT ?
"SELECT" :
"TEXT",
639 "Visible" => $definition[
"visible"] ?
"TRUE" :
"FALSE",
640 "Changeable" => $definition[
"changeable"] ?
"TRUE" :
"FALSE",
641 "Required" => $definition[
"required"] ?
"TRUE" :
"FALSE",
642 "Searchable" => $definition[
"searchable"] ?
"TRUE" :
"FALSE",
643 "CourseExport" => $definition[
"course_export"] ?
"TRUE" :
"FALSE",
644 "GroupExport" => $definition[
"group_export"] ?
"TRUE" :
"FALSE",
645 "PRGExport" => $definition[
"prg_export"] ?
"TRUE" :
"FALSE",
646 "Certificate" => $definition[
"certificate"] ?
"TRUE" :
"FALSE",
647 "Export" => $definition[
"export"] ?
"TRUE" :
"FALSE",
648 "RegistrationVisible" => $definition[
"visib_reg"] ?
"TRUE" :
"FALSE",
649 "LocalUserAdministrationVisible" => $definition[
"visib_lua"] ?
"TRUE" :
"FALSE",
650 "LocalUserAdministrationChangeable" => $definition[
"changeable_lua"] ?
"TRUE" :
"FALSE" 652 $xml_writer->
xmlStartTag(
"UDFDefinition", $attributes);
653 $xml_writer->
xmlElement(
'UDFName',
null, $definition[
'field_name']);
655 $field_values = $definition[
"field_values"];
656 foreach ($field_values as $field_value) {
662 $xml_writer->
xmlEndTag(
"UDFDefinitions");
enableVisibleLocalUserAdministration(bool $a_visible)
static deleteEntriesOfField(int $a_field_id)
Delete data of particular field.
bool $field_course_export
fetchFieldIdFromImportId(string $a_import_id)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
int $field_visible_registration
Additional user data fields definition.
fieldValuesToSelectArray(array $a_values, bool $a_with_selection_info=true)
enableSearchable(bool $a_searchable)
getSearchableDefinitions()
addToXML(ilXmlWriter $xml_writer)
add user defined field data to xml (using usr dtd)
getProgrammeExportableFields()
xmlEndTag(string $tag)
Writes an endtag.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRegistrationDefinitions()
enabledVisibleRegistration()
getExportableFields(int $a_obj_id)
Get exportable field.
nameExists(string $a_field_name)
enablePrgExport(bool $prg_export)
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getCourseExportableFields()
enableVisibleRegistration(bool $a_visible_registration)
enableCertificate(bool $a_c)
static deleteFieldValue(int $a_field_id, string $a_value)
Delete data of particular value of a (selection) field.
getGroupExportableFields()
fetchFieldIdFromName(string $a_name)
enabledChangeableLocalUserAdministration()
getLocalUserAdministrationDefinitions()
bool $field_changeable_lua
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
deleteValue(int $a_field_id, int $a_value_id)
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
enableRequired(bool $a_required)
enableCourseExport(bool $a_course_export)
enabledVisibleLocalUserAdministration()
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
setFieldName(string $a_name)
const UDF_DUPLICATE_VALUES
static _lookupType(int $id, bool $reference=false)
getChangeableLocalUserAdministrationDefinitions()
enableGroupExport(bool $a_group_export)
enableExport(bool $a_export)
setFieldType(int $a_type)
setFieldValues(array $a_values)
enableVisible(bool $a_visible)
enableChangeable(bool $a_changeable)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
enableChangeableLocalUserAdministration(bool $a_changeable)