ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCustomUserFieldsGUI Class Reference

Class ilCustomUserFieldsGUI. More...

+ Collaboration diagram for ilCustomUserFieldsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 listUserDefinedFields ()
 List all custom user fields. More...
 
 addField ($a_form=null)
 Add field. More...
 
 getAccessOptions ()
 Get all access options, order is kept in forms. More...
 
 create ()
 
 edit ($a_form=null)
 Edit field. More...
 
 update ()
 
 askDeleteField ()
 
 deleteField ()
 
 updateFields ($action="")
 Update custom fields properties (from table gui) More...
 

Static Public Member Functions

static getAccessPermissions ()
 

Protected Member Functions

 getPermissions ()
 
 initFieldDefinition ()
 init field definition More...
 
 initForm ($a_mode='create')
 
 validateForm ($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
 Validate field form. More...
 

Protected Attributes

 $confirm_change
 
 $field_id
 
 $field_definition
 
 $permissions
 

Detailed Description

Class ilCustomUserFieldsGUI.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id
class.ilObjUserFolderGUI.php 30361 2011-08-25 11:05:41Z jluetzen

ilCustomUserFieldsGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilCustomUserFieldsGUI::__construct ( )

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

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

25  {
26  global $DIC;
27 
28  $lng = $DIC['lng'];
29  $ilCtrl = $DIC['ilCtrl'];
30 
31  $lng->loadLanguageModule("user");
32  $lng->loadLanguageModule("administration");
33 
34  $this->field_id = $_REQUEST["field_id"];
35  $ilCtrl->saveParameter($this, "field_id", $this->field_id);
36 
37  if ($this->field_id) {
38  $user_field_definitions = ilUserDefinedFields::_getInstance();
39  $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
40  }
41 
42  $this->permissions = ilUDFPermissionHelper::getInstance();
43  }
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$lng
+ Here is the call graph for this function:

Member Function Documentation

◆ addField()

ilCustomUserFieldsGUI::addField (   $a_form = null)

Add field.

Parameters
ilPropertyFormGUI$a_form

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

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

Referenced by create().

107  {
108  global $DIC;
109 
110  $tpl = $DIC['tpl'];
111 
112  if (!$a_form) {
113  $a_form = $this->initForm('create');
114  }
115 
116  $tpl->setContent($a_form->getHTML());
117  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ askDeleteField()

ilCustomUserFieldsGUI::askDeleteField ( )

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

References $_POST, $DIC, $id, $ilCtrl, $lng, $tpl, ilUserDefinedFields\_getInstance(), listUserDefinedFields(), and ilUtil\sendFailure().

587  {
588  global $DIC;
589 
590  $ilCtrl = $DIC['ilCtrl'];
591  $lng = $DIC['lng'];
592  $tpl = $DIC['tpl'];
593 
594  if (!$_POST["fields"]) {
595  ilUtil::sendFailure($lng->txt("select_one"));
596  return $this->listUserDefinedFields();
597  }
598 
599  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
600  $confirmation_gui = new ilConfirmationGUI();
601  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
602  $confirmation_gui->setHeaderText($lng->txt("udf_delete_sure"));
603  $confirmation_gui->setCancel($lng->txt("cancel"), "listUserDefinedFields");
604  $confirmation_gui->setConfirm($lng->txt("delete"), "deleteField");
605 
606  $user_field_definitions = ilUserDefinedFields::_getInstance();
607  foreach ($_POST["fields"] as $id) {
608  $definition = $user_field_definitions->getDefinition($id);
609  $confirmation_gui->addItem("fields[]", $id, $definition["field_name"]);
610  }
611 
612  $tpl->setContent($confirmation_gui->getHTML());
613 
614  return true;
615  }
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
listUserDefinedFields()
List all custom user fields.
global $ilCtrl
Definition: ilias.php:18
$lng
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ create()

ilCustomUserFieldsGUI::create ( )

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

References $_POST, $DIC, $form, $ilCtrl, $lng, ilUserDefinedFields\_getInstance(), ilMemberAgreement\_reset(), addField(), ilCustomUserFieldsHelper\getInstance(), initForm(), and validateForm().

410  {
411  global $DIC;
412 
413  $lng = $DIC['lng'];
414  $ilCtrl = $DIC['ilCtrl'];
415 
416  $user_field_definitions = ilUserDefinedFields::_getInstance();
417  $user_field_definitions->setFieldType($_POST["field_type"]);
418 
419  $access = array();
420  $form = $this->initForm('create');
421  if ($this->validateForm($form, $user_field_definitions, $access)) {
422  $user_field_definitions->setFieldName($form->getInput("name"));
423  $user_field_definitions->enableVisible($access['visible']);
424  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
425  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
426  $user_field_definitions->enableCourseExport($access['course_export']);
427  $user_field_definitions->enableGroupExport($access['group_export']);
428  $user_field_definitions->enableChangeable($access['changeable']);
429  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
430  $user_field_definitions->enableRequired($access['required']);
431  $user_field_definitions->enableExport($access['export']);
432  $user_field_definitions->enableSearchable($access['searchable']);
433  $user_field_definitions->enableCertificate($access['certificate']);
434  $new_id = $user_field_definitions->add();
435 
436  if ($user_field_definitions->isPluginType()) {
437  include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
438  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($user_field_definitions->getFieldType());
439  if ($plugin instanceof ilUDFDefinitionPlugin) {
440  $plugin->updateDefinitionFromForm($form, $new_id);
441  }
442  }
443  if ($access['course_export']) {
444  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
446  }
447 
448  ilUtil::sendSuccess($lng->txt('udf_added_field'), true);
449  $ilCtrl->redirect($this);
450  }
451 
452  $form->setValuesByPost();
453  $this->addField($form);
454  }
static _getInstance()
Get instance.
addField($a_form=null)
Add field.
global $DIC
Definition: saml.php:7
static _reset()
Reset all.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
$lng
UDF type deefinition plugin.
validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
Validate field form.
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteField()

ilCustomUserFieldsGUI::deleteField ( )

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

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

618  {
619  global $DIC;
620 
621  $lng = $DIC['lng'];
622  $ilCtrl = $DIC['ilCtrl'];
623 
624  $user_field_definitions = ilUserDefinedFields::_getInstance();
625 
626  // all fields have to be deletable
627  $fail = array();
628  foreach ($_POST["fields"] as $id) {
629  if (!$this->getPermissions()->hasPermission(
631  $id,
633  )) {
634  $field = $user_field_definitions->getDefinition($id);
635  $fail[] = $field["field_name"];
636  }
637  }
638  if ($fail) {
639  ilUtil::sendFailure($lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
640  $ilCtrl->redirect($this, "listUserDefinedFields");
641  }
642 
643  foreach ($_POST["fields"] as $id) {
644  $user_field_definitions->delete($id);
645  }
646 
647  ilUtil::sendSuccess($lng->txt('udf_field_deleted'), true);
648  $ilCtrl->redirect($this);
649  }
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$lng
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ edit()

ilCustomUserFieldsGUI::edit (   $a_form = null)

Edit field.

Parameters
ilPropertyFormGUI$a_form

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

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

Referenced by update().

462  {
463  global $DIC;
464 
465  $tpl = $DIC['tpl'];
466 
467  if (!$a_form) {
468  $a_form = $this->initForm("edit");
469  }
470 
471  $tpl->setContent($a_form->getHTML());
472  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCustomUserFieldsGUI::executeCommand ( )

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

References $DIC, and $ilCtrl.

51  {
52  global $DIC;
53 
54  $ilCtrl = $DIC['ilCtrl'];
55 
56  $next_class = $ilCtrl->getNextClass($this);
57  $cmd = $ilCtrl->getCmd();
58 
59  switch ($next_class) {
60  default:
61  if (!$cmd) {
62  $cmd = "listUserDefinedFields";
63  }
64  $this->$cmd();
65  break;
66  }
67  return true;
68  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ getAccessOptions()

ilCustomUserFieldsGUI::getAccessOptions ( )

Get all access options, order is kept in forms.

Returns
array

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

References $DIC, and $lng.

Referenced by initForm(), and validateForm().

125  {
126  global $DIC;
127 
128  $lng = $DIC['lng'];
129 
130  $opts = array();
131  $opts["visible"] = $lng->txt("user_visible_in_profile");
132  $opts["visib_reg"] = $lng->txt("visible_registration");
133  $opts["visib_lua"] = $lng->txt("usr_settings_visib_lua");
134  $opts["course_export"] = $lng->txt("course_export");
135  $opts["group_export"] = $lng->txt("group_export");
136  $opts["changeable"] = $lng->txt("changeable");
137  $opts["changeable_lua"] = $lng->txt("usr_settings_changeable_lua");
138  $opts["required"] = $lng->txt("required_field");
139  $opts["export"] = $lng->txt("export");
140  $opts["searchable"] = $lng->txt("header_searchable");
141  $opts["certificate"] = $lng->txt("certificate");
142  return $opts;
143  }
global $DIC
Definition: saml.php:7
$lng
+ Here is the caller graph for this function:

◆ getAccessPermissions()

static ilCustomUserFieldsGUI::getAccessPermissions ( )
static

Definition at line 145 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().

146  {
158  );
159  }
+ Here is the caller graph for this function:

◆ getPermissions()

ilCustomUserFieldsGUI::getPermissions ( )
protected

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

References $permissions.

Referenced by deleteField(), and listUserDefinedFields().

+ Here is the caller graph for this function:

◆ initFieldDefinition()

ilCustomUserFieldsGUI::initFieldDefinition ( )
protected

init field definition

Returns
array

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

References $DIC, $ilCtrl, $lng, ilMemberAgreement\_hasAgreements(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, ilUDFPermissionHelper\CONTEXT_FIELD, ilUtil\sendInfo(), 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().

167  {
168  global $DIC;
169 
170  $ilCtrl = $DIC['ilCtrl'];
171  $lng = $DIC['lng'];
172 
173  include_once("Services/Membership/classes/class.ilMemberAgreement.php");
175  $lng->loadLanguageModule("ps");
176  ilUtil::sendInfo($lng->txt("ps_warning_modify"));
177  }
178 
179  $perms = array();
180  if ($this->field_definition) {
181  $perms = $this->permissions->hasPermissions(
183  $this->field_definition["field_id"],
184  array(
211  )
212  );
213  }
214  return $perms;
215  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$lng
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 (   $a_mode = 'create')
protected

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

References $form, $id, $ilCtrl, $lng, $name, ilMemberAgreement\_hasAgreements(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, getAccessOptions(), ilCustomUserFieldsHelper\getInstance(), initFieldDefinition(), ilUtil\sendInfo(), 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().

218  {
219  global $ilCtrl, $lng;
220 
221  include_once("Services/Membership/classes/class.ilMemberAgreement.php");
223  $lng->loadLanguageModule("ps");
224  ilUtil::sendInfo($lng->txt("ps_warning_modify"));
225  }
226 
227  if ($this->field_definition) {
228  $perms = $this->initFieldDefinition();
229  $perm_map = self::getAccessPermissions();
230  }
231 
232  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
233  $form = new ilPropertyFormGUI();
234  $form->setFormAction($ilCtrl->getFormAction($this));
235 
236  $name = new ilTextInputGUI($lng->txt("field_name"), "name");
237  $name->setRequired(true);
238  $form->addItem($name);
239 
241  $name->setDisabled(true);
242  }
243 
244  // type
245  $radg = new ilRadioGroupInputGUI($lng->txt("field_type"), "field_type");
246  $radg->setRequired(true);
247  include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
248  foreach (ilCustomUserFieldsHelper::getInstance()->getUDFTypes() as $udf_type => $udf_name) {
249  $op = new ilRadioOption($udf_name, $udf_type);
250  $radg->addOption($op);
251 
252  switch ($udf_type) {
253  case UDF_TYPE_TEXT:
254  case UDF_TYPE_WYSIWYG:
255  // do nothing
256  break;
257  case UDF_TYPE_SELECT:
258  // select values
259  $se_mu = new ilTextWizardInputGUI($lng->txt("value"), "selvalue");
260  $se_mu->setRequired(true);
261  $se_mu->setSize(32);
262  $se_mu->setMaxLength(128);
263  $se_mu->setValues(array(''));
264  $op->addSubItem($se_mu);
265  break;
266 
267  default:
268  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($udf_type);
269  if ($plugin instanceof ilUDFDefinitionPlugin) {
270  $plugin->addDefinitionTypeOptionsToRadioOption($op, $this->field_id);
271  }
272  break;
273  }
274  }
275 
276  $form->addItem($radg);
277 
279  $se_mu->setDisabled(true);
280  $se_mu->setRequired(false);
281  }
282 
283 
284  // access
285  $acc = new ilCheckboxGroupInputGUI($lng->txt("access"), "access");
286 
287  $acc_values = array();
288  foreach ($this->getAccessOptions() as $id => $caption) {
289  $opt = new ilCheckboxOption($caption, $id);
290  $acc->addOption($opt);
291 
292  if ($this->field_definition && $this->field_definition[$id]) {
293  $acc_values[] = $id;
294  }
295 
296  if ($perms && !$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
297  $opt->setDisabled(true);
298  }
299  }
300 
301  $form->addItem($acc);
302 
303 
304  if ($a_mode == 'create') {
305  $radg->setValue(UDF_TYPE_TEXT);
306  $form->setTitle($lng->txt('add_new_user_defined_field'));
307  $form->addCommandButton("create", $lng->txt("save"));
308  $form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
309  } else {
310  $name->setValue($this->field_definition["field_name"]);
311  $radg->setValue($this->field_definition["field_type"]);
312  $radg->setDisabled(true);
313  $acc->setValue($acc_values);
314 
315  switch ($this->field_definition["field_type"]) {
316  case UDF_TYPE_SELECT:
317  $se_mu->setValue($this->field_definition["field_values"]);
318  $form->setTitle($lng->txt("udf_update_select_field"));
319  break;
320 
321  case UDF_TYPE_TEXT:
322  $form->setTitle($lng->txt("udf_update_text_field"));
323  break;
324 
325  case UDF_TYPE_WYSIWYG:
326  $form->setTitle($lng->txt("udf_update_wysiwyg_field"));
327  break;
328 
329  default:
330  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($udf_type);
331  if ($plugin instanceof ilUDFDefinitionPlugin) {
332  $form->setTitle($plugin->getDefinitionUpdateFormTitle());
333  }
334  break;
335  }
336  $form->addCommandButton("update", $lng->txt("save"));
337  $form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
338  }
339  return $form;
340  }
const UDF_TYPE_SELECT
This class represents an option in a radio group.
This class represents an option in a checkbox group.
This class represents a property form user interface.
if(!array_key_exists('StateId', $_REQUEST)) $id
getAccessOptions()
Get all access options, order is kept in forms.
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
$lng
UDF type deefinition plugin.
const UDF_TYPE_TEXT
This class represents a text property in a property form.
This class represents a property in a property form.
static _hasAgreements()
Check if there is any user agreement.
const UDF_TYPE_WYSIWYG
initFieldDefinition()
init field definition
This class represents a text wizard property in a property form.
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listUserDefinedFields()

ilCustomUserFieldsGUI::listUserDefinedFields ( )

List all custom user fields.

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

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

Referenced by askDeleteField(), and updateFields().

74  {
75  global $DIC;
76 
77  $lng = $DIC['lng'];
78  $tpl = $DIC['tpl'];
79  $ilToolbar = $DIC['ilToolbar'];
80  $ilCtrl = $DIC['ilCtrl'];
81 
82  if ($this->getPermissions()->hasPermission(
84  (int) $_GET["ref_id"],
86  )) {
87  $ilToolbar->addButton(
88  $lng->txt("add_user_defined_field"),
89  $ilCtrl->getLinkTarget($this, "addField")
90  );
91  }
92 
93  include_once("./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
94  $tab = new ilCustomUserFieldSettingsTableGUI($this, "listUserDefinedFields", $this->getPermissions());
95  if ($this->confirm_change) {
96  $tab->setConfirmChange();
97  }
98  $tpl->setContent($tab->getHTML());
99  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
TableGUI class for custom defined user fields.
$lng
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilCustomUserFieldsGUI::update ( )

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

References $DIC, $form, $ilCtrl, $lng, 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().

475  {
476  global $DIC;
477 
478  $lng = $DIC['lng'];
479  $ilCtrl = $DIC['ilCtrl'];
480 
481  $user_field_definitions = ilUserDefinedFields::_getInstance();
482  $user_field_definitions->setFieldType($this->field_definition["field_type"]);
483 
484  // gather old select options
485  $old_options = null;
486  if ($this->field_id) {
487  $old_values = $user_field_definitions->getDefinition($this->field_id);
488  if ($old_values["field_type"] == UDF_TYPE_SELECT) {
489  $old_options = $old_values["field_values"];
490  }
491 
492  $perms = $this->permissions->hasPermissions(
494  $this->field_id,
495  array(
522  )
523  );
524  }
525 
526  $access = array();
527  $form = $this->initForm("edit");
528  if ($this->validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id) {
529  // field values are set in validateForm()...
530 
532  // diff old select options against new to handle deleted values properly
533  if (is_array($old_options)) {
534  foreach ($old_options as $old_option) {
535  if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
536  ilUserDefinedData::deleteFieldValue($this->field_id, $old_option);
537  }
538  }
539  }
540  }
541  // disabled fields
542  elseif (is_array($old_options)) {
543  $user_field_definitions->setFieldValues($old_options);
544  }
545 
547  $user_field_definitions->setFieldName($form->getInput("name"));
548  } else {
549  $user_field_definitions->setFieldName($this->field_definition["field_name"]);
550  }
551 
552  $user_field_definitions->enableVisible($access['visible']);
553  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
554  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
555  $user_field_definitions->enableCourseExport($access['course_export']);
556  $user_field_definitions->enableGroupExport($access['group_export']);
557  $user_field_definitions->enableChangeable($access['changeable']);
558  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
559  $user_field_definitions->enableRequired($access['required']);
560  $user_field_definitions->enableExport($access['export']);
561  $user_field_definitions->enableSearchable($access['searchable']);
562  $user_field_definitions->enableCertificate($access['certificate']);
563  $user_field_definitions->update($this->field_id);
564 
565  if ($user_field_definitions->isPluginType()) {
566  include_once './Services/User/classes/class.ilCustomUserFieldsHelper.php';
567  $plugin = ilCustomUserFieldsHelper::getInstance()->getPluginForType($user_field_definitions->getFieldType());
568  if ($plugin instanceof ilUDFDefinitionPlugin) {
569  $plugin->updateDefinitionFromForm($form, $this->field_id);
570  }
571  }
572 
573  if ($access['course_export']) {
574  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
576  }
577 
578  ilUtil::sendSuccess($lng->txt('settings_saved'), true);
579  $ilCtrl->redirect($this);
580  }
581 
582  $form->setValuesByPost();
583  $this->edit($form);
584  }
const UDF_TYPE_SELECT
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
edit($a_form=null)
Edit field.
static _reset()
Reset all.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
$lng
UDF type deefinition plugin.
validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
Validate field form.
static deleteFieldValue($a_field_id, $a_value)
Delete data of particular value of a (selection) field.
+ Here is the call graph for this function:

◆ updateFields()

ilCustomUserFieldsGUI::updateFields (   $action = "")

Update custom fields properties (from table gui)

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

References $_POST, $DIC, $field_id, $ilCtrl, $lng, ilUserDefinedFields\_getInstance(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\CONTEXT_FIELD, listUserDefinedFields(), ilUtil\sendFailure(), 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.

655  {
656  global $DIC;
657 
658  $lng = $DIC['lng'];
659  $ilCtrl = $DIC['ilCtrl'];
660 
661  $user_field_definitions = ilUserDefinedFields::_getInstance();
662  $a_fields = $user_field_definitions->getDefinitions();
663 
664  $perm_map = self::getAccessPermissions();
665 
666  foreach ($a_fields as $field_id => $definition) {
667  $perms = $this->permissions->hasPermissions(
669  $field_id,
670  array(
693  )
694  );
695 
696  // disabled field
697  foreach ($perm_map as $prop => $perm) {
699  $_POST['chb'][$prop . '_' . $field_id] = $definition[$prop];
700  }
701  }
702  }
703 
704  foreach ($a_fields as $field_id => $definition) {
705  if (isset($_POST['chb']['required_' . $field_id]) && (int) $_POST['chb']['required_' . $field_id] &&
706  (!isset($_POST['chb']['visib_reg_' . $field_id]) || !(int) $_POST['chb']['visib_reg_' . $field_id])) {
707  $this->confirm_change = true;
708 
709  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
710  $this->listUserDefinedFields();
711  return false;
712  }
713  }
714 
715  foreach ($a_fields as $field_id => $definition) {
716  $user_field_definitions->setFieldName($definition['field_name']);
717  $user_field_definitions->setFieldType($definition['field_type']);
718  $user_field_definitions->setFieldValues($definition['field_values']);
719  $user_field_definitions->enableVisible((int) $_POST['chb']['visible_' . $field_id]);
720  $user_field_definitions->enableChangeable((int) $_POST['chb']['changeable_' . $field_id]);
721  $user_field_definitions->enableRequired((int) $_POST['chb']['required_' . $field_id]);
722  $user_field_definitions->enableSearchable((int) $_POST['chb']['searchable_' . $field_id]);
723  $user_field_definitions->enableExport((int) $_POST['chb']['export_' . $field_id]);
724  $user_field_definitions->enableCourseExport((int) $_POST['chb']['course_export_' . $field_id]);
725  $user_field_definitions->enableVisibleLocalUserAdministration((int) $_POST['chb']['visib_lua_' . $field_id]);
726  $user_field_definitions->enableChangeableLocalUserAdministration((int) $_POST['chb']['changeable_lua_' . $field_id]);
727  $user_field_definitions->enableGroupExport((int) $_POST['chb']['group_export_' . $field_id]);
728  $user_field_definitions->enableVisibleRegistration((int) $_POST['chb']['visib_reg_' . $field_id]);
729  $user_field_definitions->enableCertificate((int) $_POST['chb']['certificate_' . $field_id]);
730 
731  $user_field_definitions->update($field_id);
732  }
733 
734  ilUtil::sendSuccess($lng->txt('settings_saved'), true);
735  $ilCtrl->redirect($this);
736  }
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
listUserDefinedFields()
List all custom user fields.
global $ilCtrl
Definition: ilias.php:18
$lng
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ validateForm()

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

Validate field form.

Parameters
ilPropertyFormGUI$form
ilUserDefinedFields$user_field_definitions
array$access
array$a_field_permissions
Returns
bool

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

References $DIC, $form, $id, $lng, $valid, ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, getAccessOptions(), ilUtil\sendFailure(), ilUDFPermissionHelper\SUBACTION_FIELD_PROPERTIES, UDF_DUPLICATE_VALUES, and UDF_TYPE_SELECT.

Referenced by create(), and update().

352  {
353  global $DIC;
354 
355  $lng = $DIC['lng'];
356 
357  if ($form->checkInput()) {
358  $valid = true;
359 
360  $incoming = (array) $form->getInput("access");
361 
362  if ($a_field_permissions) {
363  $perm_map = self::getAccessPermissions();
364  }
365 
366  $access = array();
367  foreach (array_keys($this->getAccessOptions()) as $id) {
368  $access[$id] = in_array($id, $incoming);
369 
370  // disabled fields
371  if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
372  $access[$id] = $this->field_definition[$id];
373  }
374  }
375 
376  if ($access['required'] && !$access['visib_reg']) {
377  $this->confirm_change = true;
378  $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
379  $valid = false;
380  }
381 
382  if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
383  $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
384  $valid = false;
385  }
386 
387  if ($form->getInput("field_type") == UDF_TYPE_SELECT &&
389  $user_field_definitions->setFieldValues($form->getInput("selvalue"));
390  if ($error = $user_field_definitions->validateValues()) {
391  switch ($error) {
393  $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
394  $valid = false;
395  break;
396  }
397  }
398  }
399 
400  if (!$valid) {
401  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
402  }
403  return $valid;
404  }
405 
406  return false;
407  }
const UDF_TYPE_SELECT
global $DIC
Definition: saml.php:7
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
getAccessOptions()
Get all access options, order is kept in forms.
if(isset($_POST['submit'])) $form
$lng
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const UDF_DUPLICATE_VALUES
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $confirm_change

ilCustomUserFieldsGUI::$confirm_change
protected

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

◆ $field_definition

ilCustomUserFieldsGUI::$field_definition
protected

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

◆ $field_id

ilCustomUserFieldsGUI::$field_id
protected

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

Referenced by updateFields().

◆ $permissions

ilCustomUserFieldsGUI::$permissions
protected

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

Referenced by getPermissions().


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