ILIAS  release_8 Revision v8.23
ilCustomUserFieldsGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCustomUserFieldsGUI:

Public Member Functions

 __construct (int $ref_id, int $requested_field_id)
 
 executeCommand ()
 
 listUserDefinedFields ()
 
 addField (ilPropertyFormGUI $a_form=null)
 
 getAccessOptions ()
 Get all access options, order is kept in forms. More...
 
 create ()
 
 edit (ilPropertyFormGUI $a_form=null)
 
 update ()
 
 askDeleteField ()
 
 deleteField ()
 
 updateFields (string $action="")
 Update custom fields properties (from table gui) More...
 

Static Public Member Functions

static getAccessPermissions ()
 

Protected Member Functions

 getPermissions ()
 
 initFieldDefinition ()
 
 initForm (string $a_mode='create')
 
 validateForm (ilPropertyFormGUI $form, ilUserDefinedFields $user_field_definitions, array &$access, array $a_field_permissions=null)
 

Protected Attributes

ILIAS User StandardGUIRequest $request
 
int $ref_id = 0
 
bool $confirm_change = false
 
int $field_id = 0
 
array $field_definition = []
 
ilClaimingPermissionHelper $permissions
 

Private Attributes

ilGlobalTemplateInterface $main_tpl
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilCustomUserFieldsGUI

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om ilCustomUserFieldsGUI:

Definition at line 23 of file class.ilCustomUserFieldsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCustomUserFieldsGUI::__construct ( int  $ref_id,
int  $requested_field_id 
)

Definition at line 36 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $lng, $ref_id, ilUserDefinedFields\_getInstance(), and ilClaimingPermissionHelper\getInstance().

39  {
40  global $DIC;
41  $this->main_tpl = $DIC->ui()->mainTemplate();
42 
43  $lng = $DIC['lng'];
44  $ilCtrl = $DIC['ilCtrl'];
45  $this->ref_id = $ref_id;
46 
47  $lng->loadLanguageModule("user");
48  $lng->loadLanguageModule("administration");
49 
50  $this->field_id = $requested_field_id;
51  $ilCtrl->saveParameter($this, "field_id", $this->field_id);
52 
53  if ($this->field_id) {
54  $user_field_definitions = ilUserDefinedFields::_getInstance();
55  $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
56  }
57 
58  $this->permissions = ilUDFPermissionHelper::getInstance(
59  $DIC->user()->getId(),
60  $ref_id
61  );
62  $this->request = new \ILIAS\User\StandardGUIRequest(
63  $DIC->http(),
64  $DIC->refinery()
65  );
66  }
$lng
global $DIC
Definition: feed.php:28
static getInstance(int $a_user_id, int $a_ref_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ addField()

ilCustomUserFieldsGUI::addField ( ilPropertyFormGUI  $a_form = null)

Definition at line 119 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $tpl, and initForm().

Referenced by create().

119  : void
120  {
121  global $DIC;
122 
123  $tpl = $DIC['tpl'];
124 
125  if (!$a_form) {
126  $a_form = $this->initForm('create');
127  }
128 
129  $tpl->setContent($a_form->getHTML());
130  }
global $DIC
Definition: feed.php:28
initForm(string $a_mode='create')
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ askDeleteField()

ilCustomUserFieldsGUI::askDeleteField ( )

Definition at line 589 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $id, $lng, $tpl, ilUserDefinedFields\_getInstance(), and listUserDefinedFields().

589  : bool
590  {
591  global $DIC;
592 
593  $ilCtrl = $DIC['ilCtrl'];
594  $lng = $DIC['lng'];
595  $tpl = $DIC['tpl'];
596 
597  $fields = $this->request->getFields();
598  if (count($fields) == 0) {
599  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("select_one"));
600  $this->listUserDefinedFields();
601  return false;
602  }
603 
604  $confirmation_gui = new ilConfirmationGUI();
605  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
606  $confirmation_gui->setHeaderText($lng->txt("udf_delete_sure"));
607  $confirmation_gui->setCancel($lng->txt("cancel"), "listUserDefinedFields");
608  $confirmation_gui->setConfirm($lng->txt("delete"), "deleteField");
609 
610  $user_field_definitions = ilUserDefinedFields::_getInstance();
611  foreach ($fields as $id) {
612  $definition = $user_field_definitions->getDefinition($id);
613  $confirmation_gui->addItem("fields[]", $id, $definition["field_name"]);
614  }
615 
616  $tpl->setContent($confirmation_gui->getHTML());
617 
618  return true;
619  }
$lng
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ create()

ilCustomUserFieldsGUI::create ( )

Definition at line 418 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $lng, XapiProxy\$plugin, ilUserDefinedFields\_getInstance(), ilMemberAgreement\_reset(), addField(), ilCustomUserFieldsHelper\getInstance(), initForm(), and validateForm().

418  : void
419  {
420  global $DIC;
421 
422  $lng = $DIC['lng'];
423  $ilCtrl = $DIC['ilCtrl'];
424 
425  $user_field_definitions = ilUserDefinedFields::_getInstance();
426  $user_field_definitions->setFieldType(
427  $this->request->getFieldType()
428  );
429 
430  $access = array();
431  $form = $this->initForm('create');
432  if ($this->validateForm($form, $user_field_definitions, $access)) {
433  $user_field_definitions->setFieldName($form->getInput("name"));
434  $user_field_definitions->enableVisible($access['visible']);
435  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
436  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
437  $user_field_definitions->enableCourseExport($access['course_export']);
438  $user_field_definitions->enableGroupExport($access['group_export']);
439  $user_field_definitions->enableChangeable($access['changeable']);
440  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
441  $user_field_definitions->enableRequired($access['required']);
442  $user_field_definitions->enableExport($access['export']);
443  $user_field_definitions->enableSearchable($access['searchable']);
444  $user_field_definitions->enableCertificate($access['certificate']);
445  $new_id = $user_field_definitions->add();
446 
447  if ($user_field_definitions->isPluginType()) {
448  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($user_field_definitions->getFieldType());
449  if ($plugin instanceof ilUDFDefinitionPlugin) {
450  $plugin->updateDefinitionFromForm($form, $new_id);
451  }
452  }
453  if ($access['course_export']) {
455  }
456 
457  $this->main_tpl->setOnScreenMessage('success', $lng->txt('udf_added_field'), true);
458  $ilCtrl->redirect($this);
459  }
460 
461  $form->setValuesByPost();
462  $this->addField($form);
463  }
$lng
static _reset()
Reset all.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
validateForm(ilPropertyFormGUI $form, ilUserDefinedFields $user_field_definitions, array &$access, array $a_field_permissions=null)
addField(ilPropertyFormGUI $a_form=null)
initForm(string $a_mode='create')
+ Here is the call graph for this function:

◆ deleteField()

ilCustomUserFieldsGUI::deleteField ( )

Definition at line 621 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $id, $lng, ilUserDefinedFields\_getInstance(), ilUDFPermissionHelper\ACTION_FIELD_DELETE, ilUDFPermissionHelper\CONTEXT_FIELD, and getPermissions().

621  : void
622  {
623  global $DIC;
624 
625  $lng = $DIC['lng'];
626  $ilCtrl = $DIC['ilCtrl'];
627 
628  $user_field_definitions = ilUserDefinedFields::_getInstance();
629  $fields = $this->request->getFields();
630 
631  // all fields have to be deletable
632  $fail = array();
633  foreach ($fields as $id) {
634  if (!$this->getPermissions()->hasPermission(
636  (string) $id,
638  )) {
639  $field = $user_field_definitions->getDefinition($id);
640  $fail[] = $field["field_name"];
641  }
642  }
643  if ($fail) {
644  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
645  $ilCtrl->redirect($this, "listUserDefinedFields");
646  }
647 
648  foreach ($fields as $id) {
649  $user_field_definitions->delete($id);
650  }
651 
652  $this->main_tpl->setOnScreenMessage('success', $lng->txt('udf_field_deleted'), true);
653  $ilCtrl->redirect($this);
654  }
$lng
global $DIC
Definition: feed.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ edit()

ilCustomUserFieldsGUI::edit ( ilPropertyFormGUI  $a_form = null)

Definition at line 465 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $tpl, and initForm().

Referenced by update().

465  : void
466  {
467  global $DIC;
468 
469  $tpl = $DIC['tpl'];
470 
471  if (!$a_form) {
472  $a_form = $this->initForm("edit");
473  }
474 
475  $tpl->setContent($a_form->getHTML());
476  }
global $DIC
Definition: feed.php:28
initForm(string $a_mode='create')
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCustomUserFieldsGUI::executeCommand ( )

Definition at line 73 of file class.ilCustomUserFieldsGUI.php.

References $DIC.

73  : void
74  {
75  global $DIC;
76 
77  $ilCtrl = $DIC['ilCtrl'];
78 
79  $next_class = $ilCtrl->getNextClass($this);
80  $cmd = $ilCtrl->getCmd();
81 
82  switch ($next_class) {
83  default:
84  if (!$cmd) {
85  $cmd = "listUserDefinedFields";
86  }
87  $this->$cmd();
88  break;
89  }
90  }
global $DIC
Definition: feed.php:28

◆ getAccessOptions()

ilCustomUserFieldsGUI::getAccessOptions ( )

Get all access options, order is kept in forms.

Returns
array<string,string>

Definition at line 136 of file class.ilCustomUserFieldsGUI.php.

References $DIC, and $lng.

Referenced by initForm(), and validateForm().

136  : array
137  {
138  global $DIC;
139 
140  $lng = $DIC['lng'];
141 
142  $opts = array();
143  $opts["visible"] = $lng->txt("user_visible_in_profile");
144  $opts["visib_reg"] = $lng->txt("visible_registration");
145  $opts["visib_lua"] = $lng->txt("usr_settings_visib_lua");
146  $opts["course_export"] = $lng->txt("course_export");
147  $opts["group_export"] = $lng->txt("group_export");
148  $opts["changeable"] = $lng->txt("changeable");
149  $opts["changeable_lua"] = $lng->txt("usr_settings_changeable_lua");
150  $opts["required"] = $lng->txt("required_field");
151  $opts["export"] = $lng->txt("export");
152  $opts["searchable"] = $lng->txt("header_searchable");
153  $opts["certificate"] = $lng->txt("certificate");
154  return $opts;
155  }
$lng
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getAccessPermissions()

static ilCustomUserFieldsGUI::getAccessPermissions ( )
static
Returns
array<string,string>

Definition at line 160 of file class.ilCustomUserFieldsGUI.php.

References ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CERTIFICATE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_EXPORT, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_REQUIRED, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_SEARCHABLE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_COURSES, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL, and ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION.

Referenced by ilCustomUserFieldSettingsTableGUI\__construct().

160  : array
161  {
173  );
174  }
+ Here is the caller graph for this function:

◆ getPermissions()

ilCustomUserFieldsGUI::getPermissions ( )
protected

Definition at line 68 of file class.ilCustomUserFieldsGUI.php.

References $permissions.

Referenced by deleteField(), and listUserDefinedFields().

69  {
70  return $this->permissions;
71  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilClaimingPermissionHelper $permissions
+ Here is the caller graph for this function:

◆ initFieldDefinition()

ilCustomUserFieldsGUI::initFieldDefinition ( )
protected

Definition at line 176 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $lng, ilMemberAgreement\_hasAgreements(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilUDFPermissionHelper\CONTEXT_FIELD, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CERTIFICATE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_EXPORT, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_REQUIRED, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_SEARCHABLE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_COURSES, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION, ilUDFPermissionHelper\SUBACTION_FIELD_PROPERTIES, and ilUDFPermissionHelper\SUBACTION_FIELD_TITLE.

Referenced by initForm().

176  : array // Missing array type.
177  {
178  global $DIC;
179 
180  $lng = $DIC['lng'];
181 
183  $lng->loadLanguageModule("ps");
184  $this->main_tpl->setOnScreenMessage('info', $lng->txt("ps_warning_modify"));
185  }
186 
187  $perms = array();
188  if ($this->field_definition) {
189  $perms = $this->permissions->hasPermissions(
191  (string) $this->field_definition["field_id"],
192  array(
219  )
220  );
221  }
222  return $perms;
223  }
$lng
global $DIC
Definition: feed.php:28
static _hasAgreements()
Check if there is any user agreement.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initForm()

ilCustomUserFieldsGUI::initForm ( string  $a_mode = 'create')
protected

Definition at line 225 of file class.ilCustomUserFieldsGUI.php.

References $id, $lng, $name, XapiProxy\$plugin, ilMemberAgreement\_hasAgreements(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, getAccessOptions(), ilCustomUserFieldsHelper\getInstance(), initFieldDefinition(), ilFormPropertyGUI\setRequired(), ilUDFPermissionHelper\SUBACTION_FIELD_PROPERTIES, ilUDFPermissionHelper\SUBACTION_FIELD_TITLE, UDF_TYPE_SELECT, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

Referenced by addField(), create(), edit(), and update().

226  {
227  global $ilCtrl, $lng;
228 
229  $perms = [];
230  $se_mu = null;
231  $perm_map = [];
232  $udf_type = null;
233 
235  $lng->loadLanguageModule("ps");
236  $this->main_tpl->setOnScreenMessage('info', $lng->txt("ps_warning_modify"));
237  }
238 
239  if ($this->field_definition) {
240  $perms = $this->initFieldDefinition();
241  $perm_map = self::getAccessPermissions();
242  }
243 
244  $form = new ilPropertyFormGUI();
245  $form->setFormAction($ilCtrl->getFormAction($this));
246 
247  $name = new ilTextInputGUI($lng->txt("field_name"), "name");
248  $name->setRequired(true);
249  $form->addItem($name);
250 
252  $name->setDisabled(true);
253  }
254 
255  // type
256  $radg = new ilRadioGroupInputGUI($lng->txt("field_type"), "field_type");
257  $radg->setRequired(true);
258  foreach (ilCustomUserFieldsHelper::getInstance()->getUDFTypes() as $udf_type => $udf_name) {
259  $op = new ilRadioOption($udf_name, $udf_type);
260  $radg->addOption($op);
261 
262  switch ($udf_type) {
263  case UDF_TYPE_TEXT:
264  case UDF_TYPE_WYSIWYG:
265  // do nothing
266  break;
267  case UDF_TYPE_SELECT:
268  // select values
269  $se_mu = new ilTextWizardInputGUI($lng->txt("value"), "selvalue");
270  $se_mu->setRequired(true);
271  $se_mu->setSize(32);
272  $se_mu->setMaxLength(128);
273  $se_mu->setValues(array(''));
274  $op->addSubItem($se_mu);
275  break;
276 
277  default:
278  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($udf_type);
279  if ($plugin instanceof ilUDFDefinitionPlugin) {
280  $plugin->addDefinitionTypeOptionsToRadioOption($op, $this->field_id);
281  }
282  break;
283  }
284  }
285 
286  $form->addItem($radg);
287 
289  $se_mu->setDisabled(true);
290  $se_mu->setRequired(false);
291  }
292 
293 
294  // access
295  $acc = new ilCheckboxGroupInputGUI($lng->txt("access"), "access");
296 
297  $acc_values = array();
298  foreach ($this->getAccessOptions() as $id => $caption) {
299  $opt = new ilCheckboxOption($caption, $id);
300  $acc->addOption($opt);
301 
302  if ($this->field_definition && $this->field_definition[$id]) {
303  $acc_values[] = $id;
304  }
305 
306  if ($perms && !$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
307  $opt->setDisabled(true);
308  }
309  }
310 
311  $form->addItem($acc);
312 
313 
314  if ($a_mode == 'create') {
315  $radg->setValue(UDF_TYPE_TEXT);
316  $form->setTitle($lng->txt('add_new_user_defined_field'));
317  $form->addCommandButton("create", $lng->txt("save"));
318  } else {
319  $name->setValue($this->field_definition["field_name"]);
320  $radg->setValue($this->field_definition["field_type"]);
321  $radg->setDisabled(true);
322  $acc->setValue($acc_values);
323 
324  switch ($this->field_definition["field_type"]) {
325  case UDF_TYPE_SELECT:
326  $values = $this->field_definition["field_values"];
327  if (!is_array($values) || $values === []) {
328  $values = [''];
329  }
330  $se_mu->setValue($values);
331  $form->setTitle($lng->txt("udf_update_select_field"));
332  break;
333 
334  case UDF_TYPE_TEXT:
335  $form->setTitle($lng->txt("udf_update_text_field"));
336  break;
337 
338  case UDF_TYPE_WYSIWYG:
339  $form->setTitle($lng->txt("udf_update_wysiwyg_field"));
340  break;
341 
342  default:
343  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($udf_type);
344  if ($plugin instanceof ilUDFDefinitionPlugin) {
345  $form->setTitle($plugin->getDefinitionUpdateFormTitle());
346  }
347  break;
348  }
349  $form->addCommandButton("update", $lng->txt("save"));
350  }
351  $form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
352  return $form;
353  }
const UDF_TYPE_SELECT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lng
getAccessOptions()
Get all access options, order is kept in forms.
if($format !==null) $name
Definition: metadata.php:247
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const UDF_TYPE_TEXT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _hasAgreements()
Check if there is any user agreement.
setRequired(bool $a_required)
const UDF_TYPE_WYSIWYG
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listUserDefinedFields()

ilCustomUserFieldsGUI::listUserDefinedFields ( )

Definition at line 92 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $lng, $tpl, ilUDFPermissionHelper\ACTION_UDF_CREATE_FIELD, ilUDFPermissionHelper\CONTEXT_UDF, and getPermissions().

Referenced by askDeleteField(), and updateFields().

92  : void
93  {
94  global $DIC;
95 
96  $lng = $DIC['lng'];
97  $tpl = $DIC['tpl'];
98  $ilToolbar = $DIC['ilToolbar'];
99  $ilCtrl = $DIC['ilCtrl'];
100 
101  if ($this->getPermissions()->hasPermission(
103  (string) $this->ref_id,
105  )) {
106  $ilToolbar->addButton(
107  $lng->txt("add_user_defined_field"),
108  $ilCtrl->getLinkTarget($this, "addField")
109  );
110  }
111 
112  $tab = new ilCustomUserFieldSettingsTableGUI($this, "listUserDefinedFields", $this->getPermissions());
113  if ($this->confirm_change) {
114  $tab->setConfirmChange();
115  }
116  $tpl->setContent($tab->getHTML());
117  }
$lng
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilCustomUserFieldsGUI::update ( )

Definition at line 478 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $lng, XapiProxy\$plugin, ilUserDefinedFields\_getInstance(), ilMemberAgreement\_reset(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilUDFPermissionHelper\CONTEXT_FIELD, ilUserDefinedData\deleteFieldValue(), edit(), ilCustomUserFieldsHelper\getInstance(), initForm(), ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CERTIFICATE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_EXPORT, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_REQUIRED, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_SEARCHABLE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_COURSES, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION, ilUDFPermissionHelper\SUBACTION_FIELD_PROPERTIES, ilUDFPermissionHelper\SUBACTION_FIELD_TITLE, UDF_TYPE_SELECT, and validateForm().

478  : void
479  {
480  global $DIC;
481 
482  $lng = $DIC['lng'];
483  $ilCtrl = $DIC['ilCtrl'];
484  $perms = [];
485 
486  $user_field_definitions = ilUserDefinedFields::_getInstance();
487  $user_field_definitions->setFieldType($this->field_definition["field_type"]);
488 
489  // gather old select options
490  $old_options = null;
491  if ($this->field_id) {
492  $old_values = $user_field_definitions->getDefinition($this->field_id);
493  if ($old_values["field_type"] == UDF_TYPE_SELECT) {
494  $old_options = $old_values["field_values"];
495  }
496 
497  $perms = $this->permissions->hasPermissions(
499  (string) $this->field_id,
500  array(
527  )
528  );
529  }
530 
531  $access = array();
532  $form = $this->initForm("edit");
533  if ($this->validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id) {
534  // field values are set in validateForm()...
535 
537  // diff old select options against new to handle deleted values properly
538  if (is_array($old_options)) {
539  foreach ($old_options as $old_option) {
540  if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
541  ilUserDefinedData::deleteFieldValue($this->field_id, $old_option);
542  }
543  }
544  }
545  }
546  // disabled fields
547  elseif (is_array($old_options)) {
548  $user_field_definitions->setFieldValues($old_options);
549  }
550 
552  $user_field_definitions->setFieldName($form->getInput("name"));
553  } else {
554  $user_field_definitions->setFieldName($this->field_definition["field_name"]);
555  }
556 
557  $user_field_definitions->enableVisible($access['visible']);
558  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
559  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
560  $user_field_definitions->enableCourseExport($access['course_export']);
561  $user_field_definitions->enableGroupExport($access['group_export']);
562  $user_field_definitions->enableChangeable($access['changeable']);
563  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
564  $user_field_definitions->enableRequired($access['required']);
565  $user_field_definitions->enableExport($access['export']);
566  $user_field_definitions->enableSearchable($access['searchable']);
567  $user_field_definitions->enableCertificate($access['certificate']);
568  $user_field_definitions->update($this->field_id);
569 
570  if ($user_field_definitions->isPluginType()) {
571  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($user_field_definitions->getFieldType());
572  if ($plugin instanceof ilUDFDefinitionPlugin) {
573  $plugin->updateDefinitionFromForm($form, $this->field_id);
574  }
575  }
576 
577  if ($access['course_export']) {
579  }
580 
581  $this->main_tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
582  $ilCtrl->redirect($this);
583  }
584 
585  $form->setValuesByPost();
586  $this->edit($form);
587  }
const UDF_TYPE_SELECT
$lng
edit(ilPropertyFormGUI $a_form=null)
static _reset()
Reset all.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
validateForm(ilPropertyFormGUI $form, ilUserDefinedFields $user_field_definitions, array &$access, array $a_field_permissions=null)
static deleteFieldValue(int $a_field_id, string $a_value)
Delete data of particular value of a (selection) field.
initForm(string $a_mode='create')
+ Here is the call graph for this function:

◆ updateFields()

ilCustomUserFieldsGUI::updateFields ( string  $action = "")

Update custom fields properties (from table gui)

Definition at line 659 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $field_id, $lng, $valid, ilUserDefinedFields\_getInstance(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\CONTEXT_FIELD, listUserDefinedFields(), ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CERTIFICATE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_EXPORT, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_REQUIRED, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_SEARCHABLE, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_COURSES, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL, ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL, and ilUDFPermissionHelper\SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION.

659  : void
660  {
661  global $DIC;
662 
663  $lng = $DIC['lng'];
664  $ilCtrl = $DIC['ilCtrl'];
665 
666  $user_field_definitions = ilUserDefinedFields::_getInstance();
667  $a_fields = $user_field_definitions->getDefinitions();
668 
669  $checked = $this->request->getChecked();
670 
671  $perm_map = self::getAccessPermissions();
672 
673  foreach ($a_fields as $field_id => $definition) {
674  $perms = $this->permissions->hasPermissions(
676  (string) $field_id,
677  array(
700  )
701  );
702 
703  // disabled field
704  foreach ($perm_map as $prop => $perm) {
706  $checked[$prop . '_' . $field_id] = $definition[$prop];
707  }
708  }
709  }
710 
711  $valid = true;
712  foreach ($a_fields as $field_id => $definition) {
713  if (isset($checked['required_' . $field_id]) && (int) $checked['required_' . $field_id] &&
714  (!isset($checked['visib_reg_' . $field_id]) || !(int) $checked['visib_reg_' . $field_id])) {
715  $this->confirm_change = true;
716 
717  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('invalid_visible_required_options_selected'));
718  $valid = false;
719  }
720  }
721 
722  if (!$valid) {
723  $this->listUserDefinedFields();
724  return;
725  }
726 
727  foreach ($a_fields as $field_id => $definition) {
728  $user_field_definitions->setFieldName($definition['field_name']);
729  $user_field_definitions->setFieldType($definition['field_type']);
730  $user_field_definitions->setFieldValues($definition['field_values']);
731  $user_field_definitions->enableVisible((bool) ($checked['visible_' . $field_id] ?? false));
732  $user_field_definitions->enableChangeable((bool) ($checked['changeable_' . $field_id] ?? false));
733  $user_field_definitions->enableRequired((bool) ($checked['required_' . $field_id] ?? false));
734  $user_field_definitions->enableSearchable((bool) ($checked['searchable_' . $field_id] ?? false));
735  $user_field_definitions->enableExport((bool) ($checked['export_' . $field_id] ?? false));
736  $user_field_definitions->enableCourseExport((bool) ($checked['course_export_' . $field_id] ?? false));
737  $user_field_definitions->enableVisibleLocalUserAdministration((bool) ($checked['visib_lua_' . $field_id] ?? false));
738  $user_field_definitions->enableChangeableLocalUserAdministration((bool) ($checked['changeable_lua_' . $field_id] ?? false));
739  $user_field_definitions->enableGroupExport((bool) ($checked['group_export_' . $field_id] ?? false));
740  $user_field_definitions->enableVisibleRegistration((bool) ($checked['visib_reg_' . $field_id] ?? false));
741  $user_field_definitions->enableCertificate((bool) ($checked['certificate_' . $field_id] ?? false));
742 
743  $user_field_definitions->update($field_id);
744  }
745 
746  $this->main_tpl->setOnScreenMessage('success', $lng->txt('settings_saved'), true);
747  $ilCtrl->redirect($this);
748  }
$lng
$valid
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ validateForm()

ilCustomUserFieldsGUI::validateForm ( ilPropertyFormGUI  $form,
ilUserDefinedFields  $user_field_definitions,
array &  $access,
array  $a_field_permissions = null 
)
protected

Definition at line 355 of file class.ilCustomUserFieldsGUI.php.

References $DIC, $id, $lng, $valid, ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilPropertyFormGUI\checkInput(), getAccessOptions(), ilPropertyFormGUI\getInput(), ilPropertyFormGUI\getItemByPostVar(), ilUserDefinedFields\nameExists(), ilUserDefinedFields\setFieldValues(), ilUDFPermissionHelper\SUBACTION_FIELD_PROPERTIES, UDF_DUPLICATE_VALUES, UDF_TYPE_SELECT, and ilUserDefinedFields\validateValues().

Referenced by create(), and update().

360  : bool {
361  global $DIC;
362 
363  $lng = $DIC['lng'];
364  $perm_map = [];
365 
366  if ($form->checkInput()) {
367  $valid = true;
368 
369  $incoming = (array) $form->getInput("access");
370 
371  if ($a_field_permissions) {
372  $perm_map = self::getAccessPermissions();
373  }
374 
375  $access = array();
376  foreach (array_keys($this->getAccessOptions()) as $id) {
377  $access[$id] = in_array($id, $incoming);
378 
379  // disabled fields
380  if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
381  $access[$id] = $this->field_definition[$id];
382  }
383  }
384 
385  if ($access['required'] && !$access['visib_reg']) {
386  $this->confirm_change = true;
387  $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
388  $valid = false;
389  }
390 
391  if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
392  $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
393  $valid = false;
394  }
395 
396  if ($form->getInput("field_type") == UDF_TYPE_SELECT &&
398  $user_field_definitions->setFieldValues($form->getInput("selvalue"));
399  if ($error = $user_field_definitions->validateValues()) {
400  switch ($error) {
402  $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
403  $valid = false;
404  break;
405  }
406  }
407  }
408 
409  if (!$valid) {
410  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("form_input_not_valid"));
411  }
412  return $valid;
413  }
414 
415  return false;
416  }
const UDF_TYPE_SELECT
getItemByPostVar(string $a_post_var)
$lng
$valid
getAccessOptions()
Get all access options, order is kept in forms.
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
global $DIC
Definition: feed.php:28
nameExists(string $a_field_name)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
const UDF_DUPLICATE_VALUES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $confirm_change

bool ilCustomUserFieldsGUI::$confirm_change = false
protected

Definition at line 27 of file class.ilCustomUserFieldsGUI.php.

◆ $field_definition

array ilCustomUserFieldsGUI::$field_definition = []
protected

Definition at line 32 of file class.ilCustomUserFieldsGUI.php.

◆ $field_id

int ilCustomUserFieldsGUI::$field_id = 0
protected

Definition at line 28 of file class.ilCustomUserFieldsGUI.php.

Referenced by updateFields().

◆ $main_tpl

ilGlobalTemplateInterface ilCustomUserFieldsGUI::$main_tpl
private

Definition at line 34 of file class.ilCustomUserFieldsGUI.php.

◆ $permissions

ilClaimingPermissionHelper ilCustomUserFieldsGUI::$permissions
protected

Definition at line 33 of file class.ilCustomUserFieldsGUI.php.

Referenced by getPermissions().

◆ $ref_id

int ilCustomUserFieldsGUI::$ref_id = 0
protected

Definition at line 26 of file class.ilCustomUserFieldsGUI.php.

Referenced by __construct().

◆ $request

ILIAS User StandardGUIRequest ilCustomUserFieldsGUI::$request
protected

Definition at line 25 of file class.ilCustomUserFieldsGUI.php.


The documentation for this class was generated from the following file: