ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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...
 
 initForm ($a_mode="create")
 Init field form. 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 ()
 
 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 $ilCtrl, $lng, ilUserDefinedFields\_getInstance(), and ilClaimingPermissionHelper\getInstance().

25  {
26  global $lng, $ilCtrl;
27 
28  $lng->loadLanguageModule("user");
29  $lng->loadLanguageModule("administration");
30 
31  $this->field_id = $_REQUEST["field_id"];
32  $ilCtrl->saveParameter($this, "field_id", $this->field_id);
33 
34  if ($this->field_id) {
35  $user_field_definitions = ilUserDefinedFields::_getInstance();
36  $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
37  }
38 
39  $this->permissions = ilUDFPermissionHelper::getInstance();
40  }
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
static _getInstance()
Get instance.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
+ 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 96 of file class.ilCustomUserFieldsGUI.php.

References $tpl, and initForm().

Referenced by create().

97  {
98  global $tpl;
99 
100  if (!$a_form) {
101  $a_form = $this->initForm();
102  }
103 
104  $tpl->setContent($a_form->getHTML());
105  }
$tpl
Definition: ilias.php:10
initForm($a_mode="create")
Init field form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ askDeleteField()

ilCustomUserFieldsGUI::askDeleteField ( )

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

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

510  {
511  global $ilCtrl, $lng, $tpl;
512 
513  if (!$_POST["fields"]) {
514  ilUtil::sendFailure($lng->txt("select_one"));
515  return $this->listUserDefinedFields();
516  }
517 
518  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
519  $confirmation_gui = new ilConfirmationGUI();
520  $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
521  $confirmation_gui->setHeaderText($lng->txt("udf_delete_sure"));
522  $confirmation_gui->setCancel($lng->txt("cancel"), "listUserDefinedFields");
523  $confirmation_gui->setConfirm($lng->txt("delete"), "deleteField");
524 
525  $user_field_definitions = ilUserDefinedFields::_getInstance();
526  foreach ($_POST["fields"] as $id) {
527  $definition = $user_field_definitions->getDefinition($id);
528  $confirmation_gui->addItem("fields[]", $id, $definition["field_name"]);
529  }
530 
531  $tpl->setContent($confirmation_gui->getHTML());
532 
533  return true;
534  }
static _getInstance()
Get instance.
$tpl
Definition: ilias.php:10
if(!array_key_exists('StateId', $_REQUEST)) $id
listUserDefinedFields()
List all custom user fields.
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ create()

ilCustomUserFieldsGUI::create ( )

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

References $_POST, $form, $ilCtrl, $lng, ilUserDefinedFields\_getInstance(), ilMemberAgreement\_reset(), addField(), array, initForm(), ilUtil\sendSuccess(), and validateForm().

356  {
357  global $lng, $ilCtrl;
358 
359  $user_field_definitions = ilUserDefinedFields::_getInstance();
360  $user_field_definitions->setFieldType($_POST["field_type"]);
361 
362  $access = array();
363  $form = $this->initForm();
364  if ($this->validateForm($form, $user_field_definitions, $access)) {
365  $user_field_definitions->setFieldName($form->getInput("name"));
366  $user_field_definitions->enableVisible($access['visible']);
367  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
368  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
369  $user_field_definitions->enableCourseExport($access['course_export']);
370  $user_field_definitions->enableGroupExport($access['group_export']);
371  $user_field_definitions->enableChangeable($access['changeable']);
372  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
373  $user_field_definitions->enableRequired($access['required']);
374  $user_field_definitions->enableExport($access['export']);
375  $user_field_definitions->enableSearchable($access['searchable']);
376  $user_field_definitions->enableCertificate($access['certificate']);
377  $user_field_definitions->add();
378 
379  if ($access['course_export']) {
380  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
382  }
383 
384  ilUtil::sendSuccess($lng->txt('udf_added_field'), true);
385  $ilCtrl->redirect($this);
386  }
387 
388  $form->setValuesByPost();
389  $this->addField($form);
390  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getInstance()
Get instance.
addField($a_form=null)
Add field.
static _reset()
Reset all.
initForm($a_mode="create")
Init field form.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
Validate field form.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteField()

ilCustomUserFieldsGUI::deleteField ( )

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

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

537  {
538  global $lng, $ilCtrl;
539 
540  $user_field_definitions = ilUserDefinedFields::_getInstance();
541 
542  // all fields have to be deletable
543  $fail = array();
544  foreach ($_POST["fields"] as $id) {
545  if (!$this->getPermissions()->hasPermission(
547  $id,
549  )) {
550  $field = $user_field_definitions->getDefinition($id);
551  $fail[] = $field["field_name"];
552  }
553  }
554  if ($fail) {
555  ilUtil::sendFailure($lng->txt('msg_no_perm_delete') . " " . implode(", ", $fail), true);
556  $ilCtrl->redirect($this, "listUserDefinedFields");
557  }
558 
559  foreach ($_POST["fields"] as $id) {
560  $user_field_definitions->delete($id);
561  }
562 
563  ilUtil::sendSuccess($lng->txt('udf_field_deleted'), true);
564  $ilCtrl->redirect($this);
565  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getInstance()
Get instance.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
$_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 397 of file class.ilCustomUserFieldsGUI.php.

References $tpl, and initForm().

Referenced by update().

398  {
399  global $tpl;
400 
401  if (!$a_form) {
402  $a_form = $this->initForm("edit");
403  }
404 
405  $tpl->setContent($a_form->getHTML());
406  }
$tpl
Definition: ilias.php:10
initForm($a_mode="create")
Init field form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCustomUserFieldsGUI::executeCommand ( )

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

References $ilCtrl.

48  {
49  global $ilCtrl;
50 
51  $next_class = $ilCtrl->getNextClass($this);
52  $cmd = $ilCtrl->getCmd();
53 
54  switch ($next_class) {
55  default:
56  if (!$cmd) {
57  $cmd = "listUserDefinedFields";
58  }
59  $this->$cmd();
60  break;
61  }
62  return true;
63  }
global $ilCtrl
Definition: ilias.php:18

◆ getAccessOptions()

ilCustomUserFieldsGUI::getAccessOptions ( )

Get all access options, order is kept in forms.

Returns
array

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

References $lng, and array.

Referenced by initForm(), and validateForm().

113  {
114  global $lng;
115 
116  $opts = array();
117  $opts["visible"] = $lng->txt("user_visible_in_profile");
118  $opts["visib_reg"] = $lng->txt("visible_registration");
119  $opts["visib_lua"] = $lng->txt("usr_settings_visib_lua");
120  $opts["course_export"] = $lng->txt("course_export");
121  $opts["group_export"] = $lng->txt("group_export");
122  $opts["changeable"] = $lng->txt("changeable");
123  $opts["changeable_lua"] = $lng->txt("usr_settings_changeable_lua");
124  $opts["required"] = $lng->txt("required_field");
125  $opts["export"] = $lng->txt("export");
126  $opts["searchable"] = $lng->txt("header_searchable");
127  $opts["certificate"] = $lng->txt("certificate");
128  return $opts;
129  }
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the caller graph for this function:

◆ getAccessPermissions()

static ilCustomUserFieldsGUI::getAccessPermissions ( )
static

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

References array, 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().

132  {
144  );
145  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getPermissions()

ilCustomUserFieldsGUI::getPermissions ( )
protected

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

References $permissions.

Referenced by deleteField(), and listUserDefinedFields().

+ Here is the caller graph for this function:

◆ initForm()

ilCustomUserFieldsGUI::initForm (   $a_mode = "create")

Init field form.

Parameters
string$a_mode
Returns
ilPropertyFormGUI

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

References $form, $id, $ilCtrl, $lng, $name, ilMemberAgreement\_hasAgreements(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, array, ilUDFPermissionHelper\CONTEXT_FIELD, getAccessOptions(), ilUtil\sendInfo(), ilFormPropertyGUI\setRequired(), 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, UDF_TYPE_TEXT, and UDF_TYPE_WYSIWYG.

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

154  {
155  global $ilCtrl, $lng;
156 
157  include_once("Services/Membership/classes/class.ilMemberAgreement.php");
159  $lng->loadLanguageModule("ps");
160  ilUtil::sendInfo($lng->txt("ps_warning_modify"));
161  }
162 
163  if ($this->field_definition) {
164  $perms = $this->permissions->hasPermissions(
166  $this->field_definition["field_id"],
167  array(
194  )
195  );
196 
197  $perm_map = self::getAccessPermissions();
198  }
199 
200  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
201  $form = new ilPropertyFormGUI();
202  $form->setFormAction($ilCtrl->getFormAction($this));
203 
204  $name = new ilTextInputGUI($lng->txt("field_name"), "name");
205  $name->setRequired(true);
206  $form->addItem($name);
207 
209  $name->setDisabled(true);
210  }
211 
212  // type
213  $radg = new ilRadioGroupInputGUI($lng->txt("field_type"), "field_type");
214  $radg->setRequired(true);
215  $op1 = new ilRadioOption($lng->txt("udf_type_text"), UDF_TYPE_TEXT);
216  $radg->addOption($op1);
217  $op2 = new ilRadioOption($lng->txt("udf_type_select"), UDF_TYPE_SELECT);
218  $radg->addOption($op2);
219  $op3 = new ilRadioOption($lng->txt("udf_type_wysiwyg"), UDF_TYPE_WYSIWYG);
220  $radg->addOption($op3);
221  $form->addItem($radg);
222 
223  // select values
224  $se_mu = new ilTextWizardInputGUI($lng->txt("value"), "selvalue");
225  $se_mu->setRequired(true);
226  $se_mu->setSize(32);
227  $se_mu->setMaxLength(128);
228  $se_mu->setValues(array(''));
229  $op2->addSubItem($se_mu);
230 
232  $se_mu->setDisabled(true);
233  $se_mu->setRequired(false);
234  }
235 
236  // access
237  $acc = new ilCheckboxGroupInputGUI($lng->txt("access"), "access");
238 
239  $acc_values = array();
240  foreach ($this->getAccessOptions() as $id => $caption) {
241  $opt = new ilCheckboxOption($caption, $id);
242  $acc->addOption($opt);
243 
244  if ($this->field_definition && $this->field_definition[$id]) {
245  $acc_values[] = $id;
246  }
247 
248  if ($perms && !$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
249  $opt->setDisabled(true);
250  }
251  }
252 
253  $form->addItem($acc);
254 
255  if ($a_mode == "create") {
256  $radg->setValue(UDF_TYPE_TEXT);
257 
258  $form->setTitle($lng->txt('add_new_user_defined_field'));
259 
260  $form->addCommandButton("create", $lng->txt("save"));
261  $form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
262  } else {
263  $name->setValue($this->field_definition["field_name"]);
264  $radg->setValue($this->field_definition["field_type"]);
265  $radg->setDisabled(true);
266  $acc->setValue($acc_values);
267 
268  switch ($this->field_definition["field_type"]) {
269  case UDF_TYPE_SELECT:
270  $se_mu->setValue($this->field_definition["field_values"]);
271  $form->setTitle($lng->txt("udf_update_select_field"));
272  break;
273 
274  case UDF_TYPE_TEXT:
275  $form->setTitle($lng->txt("udf_update_text_field"));
276  break;
277 
278  case UDF_TYPE_WYSIWYG:
279  $form->setTitle($lng->txt("udf_update_wysiwyg_field"));
280  break;
281  }
282 
283  $form->addCommandButton("update", $lng->txt("save"));
284  $form->addCommandButton("listUserDefinedFields", $lng->txt("cancel"));
285  }
286 
287  return $form;
288  }
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.
if($format !==null) $name
Definition: metadata.php:146
This class represents a property in a property form.
if(isset($_POST['submit'])) $form
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
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
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 68 of file class.ilCustomUserFieldsGUI.php.

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

Referenced by askDeleteField(), and updateFields().

69  {
70  global $lng, $tpl, $ilToolbar, $ilCtrl;
71 
72  if ($this->getPermissions()->hasPermission(
74  (int) $_GET["ref_id"],
76  )) {
77  $ilToolbar->addButton(
78  $lng->txt("add_user_defined_field"),
79  $ilCtrl->getLinkTarget($this, "addField")
80  );
81  }
82 
83  include_once("./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
84  $tab = new ilCustomUserFieldSettingsTableGUI($this, "listUserDefinedFields", $this->getPermissions());
85  if ($this->confirm_change) {
86  $tab->setConfirmChange();
87  }
88  $tpl->setContent($tab->getHTML());
89  }
$_GET["client_id"]
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
TableGUI class for custom defined user fields.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilCustomUserFieldsGUI::update ( )

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

References $form, $ilCtrl, $lng, ilUserDefinedFields\_getInstance(), ilMemberAgreement\_reset(), ilUDFPermissionHelper\ACTION_FIELD_EDIT_ACCESS, ilUDFPermissionHelper\ACTION_FIELD_EDIT_PROPERTY, array, ilUDFPermissionHelper\CONTEXT_FIELD, ilUserDefinedData\deleteFieldValue(), edit(), initForm(), ilUtil\sendSuccess(), 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().

409  {
410  global $lng, $ilCtrl;
411 
412  $user_field_definitions = ilUserDefinedFields::_getInstance();
413  $user_field_definitions->setFieldType($this->field_definition["field_type"]);
414 
415  // gather old select options
416  $old_options = null;
417  if ($this->field_id) {
418  $old_values = $user_field_definitions->getDefinition($this->field_id);
419  if ($old_values["field_type"] == UDF_TYPE_SELECT) {
420  $old_options = $old_values["field_values"];
421  }
422 
423  $perms = $this->permissions->hasPermissions(
425  $this->field_id,
426  array(
453  )
454  );
455  }
456 
457  $access = array();
458  $form = $this->initForm("edit");
459  if ($this->validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id) {
460  // field values are set in validateForm()...
461 
463  // diff old select options against new to handle deleted values properly
464  if (is_array($old_options)) {
465  foreach ($old_options as $old_option) {
466  if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
467  ilUserDefinedData::deleteFieldValue($this->field_id, $old_option);
468  }
469  }
470  }
471  }
472  // disabled fields
473  elseif (is_array($old_options)) {
474  $user_field_definitions->setFieldValues($old_options);
475  }
476 
478  $user_field_definitions->setFieldName($form->getInput("name"));
479  } else {
480  $user_field_definitions->setFieldName($this->field_definition["field_name"]);
481  }
482 
483  $user_field_definitions->enableVisible($access['visible']);
484  $user_field_definitions->enableVisibleRegistration((int) $access['visib_reg']);
485  $user_field_definitions->enableVisibleLocalUserAdministration($access['visib_lua']);
486  $user_field_definitions->enableCourseExport($access['course_export']);
487  $user_field_definitions->enableGroupExport($access['group_export']);
488  $user_field_definitions->enableChangeable($access['changeable']);
489  $user_field_definitions->enableChangeableLocalUserAdministration($access['changeable_lua']);
490  $user_field_definitions->enableRequired($access['required']);
491  $user_field_definitions->enableExport($access['export']);
492  $user_field_definitions->enableSearchable($access['searchable']);
493  $user_field_definitions->enableCertificate($access['certificate']);
494  $user_field_definitions->update($this->field_id);
495 
496  if ($access['course_export']) {
497  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
499  }
500 
501  ilUtil::sendSuccess($lng->txt('settings_saved'), true);
502  $ilCtrl->redirect($this);
503  }
504 
505  $form->setValuesByPost();
506  $this->edit($form);
507  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const UDF_TYPE_SELECT
static _getInstance()
Get instance.
edit($a_form=null)
Edit field.
static _reset()
Reset all.
initForm($a_mode="create")
Init field form.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
Validate field form.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
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 570 of file class.ilCustomUserFieldsGUI.php.

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

571  {
572  global $lng, $ilCtrl;
573 
574  $user_field_definitions = ilUserDefinedFields::_getInstance();
575  $a_fields = $user_field_definitions->getDefinitions();
576 
577  $perm_map = self::getAccessPermissions();
578 
579  foreach ($a_fields as $field_id => $definition) {
580  $perms = $this->permissions->hasPermissions(
582  $field_id,
583  array(
606  )
607  );
608 
609  // disabled field
610  foreach ($perm_map as $prop => $perm) {
612  $_POST['chb'][$prop . '_' . $field_id] = $definition[$prop];
613  }
614  }
615  }
616 
617  foreach ($a_fields as $field_id => $definition) {
618  if (isset($_POST['chb']['required_' . $field_id]) && (int) $_POST['chb']['required_' . $field_id] &&
619  (!isset($_POST['chb']['visib_reg_' . $field_id]) || !(int) $_POST['chb']['visib_reg_' . $field_id])) {
620  $this->confirm_change = true;
621 
622  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
623  $this->listUserDefinedFields();
624  return false;
625  }
626  }
627 
628  foreach ($a_fields as $field_id => $definition) {
629  $user_field_definitions->setFieldName($definition['field_name']);
630  $user_field_definitions->setFieldType($definition['field_type']);
631  $user_field_definitions->setFieldValues($definition['field_values']);
632  $user_field_definitions->enableVisible((int) $_POST['chb']['visible_' . $field_id]);
633  $user_field_definitions->enableChangeable((int) $_POST['chb']['changeable_' . $field_id]);
634  $user_field_definitions->enableRequired((int) $_POST['chb']['required_' . $field_id]);
635  $user_field_definitions->enableSearchable((int) $_POST['chb']['searchable_' . $field_id]);
636  $user_field_definitions->enableExport((int) $_POST['chb']['export_' . $field_id]);
637  $user_field_definitions->enableCourseExport((int) $_POST['chb']['course_export_' . $field_id]);
638  $user_field_definitions->enableVisibleLocalUserAdministration((int) $_POST['chb']['visib_lua_' . $field_id]);
639  $user_field_definitions->enableChangeableLocalUserAdministration((int) $_POST['chb']['changeable_lua_' . $field_id]);
640  $user_field_definitions->enableGroupExport((int) $_POST['chb']['group_export_' . $field_id]);
641  $user_field_definitions->enableVisibleRegistration((int) $_POST['chb']['visib_reg_' . $field_id]);
642  $user_field_definitions->enableCertificate((int) $_POST['chb']['certificate_' . $field_id]);
643 
644  $user_field_definitions->update($field_id);
645  }
646 
647  ilUtil::sendSuccess($lng->txt('settings_saved'), true);
648  $ilCtrl->redirect($this);
649  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _getInstance()
Get instance.
listUserDefinedFields()
List all custom user fields.
global $ilCtrl
Definition: ilias.php:18
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
$_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 299 of file class.ilCustomUserFieldsGUI.php.

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

Referenced by create(), and update().

300  {
301  global $lng;
302 
303  if ($form->checkInput()) {
304  $valid = true;
305 
306  $incoming = (array) $form->getInput("access");
307 
308  if ($a_field_permissions) {
309  $perm_map = self::getAccessPermissions();
310  }
311 
312  $access = array();
313  foreach (array_keys($this->getAccessOptions()) as $id) {
314  $access[$id] = in_array($id, $incoming);
315 
316  // disabled fields
317  if ($a_field_permissions && !$a_field_permissions[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$perm_map[$id]]) {
318  $access[$id] = $this->field_definition[$id];
319  }
320  }
321 
322  if ($access['required'] && !$access['visib_reg']) {
323  $this->confirm_change = true;
324  $form->getItemByPostVar("access")->setAlert($lng->txt('udf_required_requires_visib_reg'));
325  $valid = false;
326  }
327 
328  if (!$this->field_id && $user_field_definitions->nameExists($form->getInput("name"))) {
329  $form->getItemByPostVar("name")->setAlert($lng->txt('udf_name_already_exists'));
330  $valid = false;
331  }
332 
333  if ($form->getInput("field_type") == UDF_TYPE_SELECT &&
335  $user_field_definitions->setFieldValues($form->getInput("selvalue"));
336  if ($error = $user_field_definitions->validateValues()) {
337  switch ($error) {
339  $form->getItemByPostVar("selvalue")->setAlert($lng->txt('udf_duplicate_entries'));
340  $valid = false;
341  break;
342  }
343  }
344  }
345 
346  if (!$valid) {
347  ilUtil::sendFailure($lng->txt("form_input_not_valid"));
348  }
349  return $valid;
350  }
351 
352  return false;
353  }
const UDF_TYPE_SELECT
$valid
if(!array_key_exists('StateId', $_REQUEST)) $id
getAccessOptions()
Get all access options, order is kept in forms.
$error
Definition: Error.php:17
if(isset($_POST['submit'])) $form
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
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: