4 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
5 include_once
'./Services/User/classes/class.ilUDFPermissionHelper.php';
29 $ilCtrl = $DIC[
'ilCtrl'];
31 $lng->loadLanguageModule(
"user");
32 $lng->loadLanguageModule(
"administration");
34 $this->field_id = $_REQUEST[
"field_id"];
35 $ilCtrl->saveParameter($this,
"field_id", $this->field_id);
37 if ($this->field_id) {
39 $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
54 $ilCtrl = $DIC[
'ilCtrl'];
56 $next_class = $ilCtrl->getNextClass($this);
57 $cmd = $ilCtrl->getCmd();
59 switch ($next_class) {
62 $cmd =
"listUserDefinedFields";
79 $ilToolbar = $DIC[
'ilToolbar'];
80 $ilCtrl = $DIC[
'ilCtrl'];
84 (
int)
$_GET[
"ref_id"],
87 $ilToolbar->addButton(
88 $lng->txt(
"add_user_defined_field"),
89 $ilCtrl->getLinkTarget($this,
"addField")
93 include_once(
"./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
95 if ($this->confirm_change) {
96 $tab->setConfirmChange();
98 $tpl->setContent($tab->getHTML());
113 $a_form = $this->
initForm(
'create');
116 $tpl->setContent($a_form->getHTML());
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");
170 $ilCtrl = $DIC[
'ilCtrl'];
173 include_once(
"Services/Membership/classes/class.ilMemberAgreement.php");
175 $lng->loadLanguageModule(
"ps");
180 if ($this->field_definition) {
181 $perms = $this->permissions->hasPermissions(
183 $this->field_definition[
"field_id"],
219 global $ilCtrl,
$lng;
221 include_once(
"Services/Membership/classes/class.ilMemberAgreement.php");
223 $lng->loadLanguageModule(
"ps");
227 if ($this->field_definition) {
229 $perm_map = self::getAccessPermissions();
232 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
234 $form->setFormAction($ilCtrl->getFormAction($this));
237 $name->setRequired(
true);
238 $form->addItem(
$name);
241 $name->setDisabled(
true);
247 include_once
'./Services/User/classes/class.ilCustomUserFieldsHelper.php';
250 $radg->addOption($op);
262 $se_mu->setMaxLength(128);
263 $se_mu->setValues(array(
''));
264 $op->addSubItem($se_mu);
270 $plugin->addDefinitionTypeOptionsToRadioOption($op, $this->field_id);
276 $form->addItem($radg);
279 $se_mu->setDisabled(
true);
280 $se_mu->setRequired(
false);
287 $acc_values = array();
290 $acc->addOption($opt);
292 if ($this->field_definition && $this->field_definition[$id]) {
301 $form->addItem($acc);
304 if ($a_mode ==
'create') {
306 $form->setTitle($lng->txt(
'add_new_user_defined_field'));
307 $form->addCommandButton(
"create", $lng->txt(
"save"));
308 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
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);
315 switch ($this->field_definition[
"field_type"]) {
317 $values = $this->field_definition[
"field_values"];
318 if (!is_array($values) || $values === []) {
321 $se_mu->setValue($values);
322 $form->setTitle($lng->txt(
"udf_update_select_field"));
326 $form->setTitle($lng->txt(
"udf_update_text_field"));
330 $form->setTitle($lng->txt(
"udf_update_wysiwyg_field"));
336 $form->setTitle(
$plugin->getDefinitionUpdateFormTitle());
340 $form->addCommandButton(
"update", $lng->txt(
"save"));
341 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
355 protected function validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions = null)
361 if ($form->checkInput()) {
364 $incoming = (array) $form->getInput(
"access");
366 if ($a_field_permissions) {
367 $perm_map = self::getAccessPermissions();
372 $access[$id] = in_array($id, $incoming);
376 $access[$id] = $this->field_definition[$id];
380 if ($access[
'required'] && !$access[
'visib_reg']) {
381 $this->confirm_change =
true;
382 $form->getItemByPostVar(
"access")->setAlert(
$lng->txt(
'udf_required_requires_visib_reg'));
386 if (!$this->field_id && $user_field_definitions->nameExists($form->getInput(
"name"))) {
387 $form->getItemByPostVar(
"name")->setAlert(
$lng->txt(
'udf_name_already_exists'));
393 $user_field_definitions->setFieldValues($form->getInput(
"selvalue"));
394 if ($error = $user_field_definitions->validateValues()) {
397 $form->getItemByPostVar(
"selvalue")->setAlert(
$lng->txt(
'udf_duplicate_entries'));
418 $ilCtrl = $DIC[
'ilCtrl'];
421 $user_field_definitions->setFieldType(
$_POST[
"field_type"]);
425 if ($this->
validateForm($form, $user_field_definitions, $access)) {
426 $user_field_definitions->setFieldName($form->getInput(
"name"));
427 $user_field_definitions->enableVisible($access[
'visible']);
428 $user_field_definitions->enableVisibleRegistration((
int) $access[
'visib_reg']);
429 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
430 $user_field_definitions->enableCourseExport($access[
'course_export']);
431 $user_field_definitions->enableGroupExport($access[
'group_export']);
432 $user_field_definitions->enableChangeable($access[
'changeable']);
433 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
434 $user_field_definitions->enableRequired($access[
'required']);
435 $user_field_definitions->enableExport($access[
'export']);
436 $user_field_definitions->enableSearchable($access[
'searchable']);
437 $user_field_definitions->enableCertificate($access[
'certificate']);
438 $new_id = $user_field_definitions->add();
440 if ($user_field_definitions->isPluginType()) {
441 include_once
'./Services/User/classes/class.ilCustomUserFieldsHelper.php';
444 $plugin->updateDefinitionFromForm($form, $new_id);
447 if ($access[
'course_export']) {
448 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
452 ilUtil::sendSuccess(
$lng->txt(
'udf_added_field'),
true);
453 $ilCtrl->redirect($this);
456 $form->setValuesByPost();
465 public function edit($a_form = null)
475 $tpl->setContent($a_form->getHTML());
483 $ilCtrl = $DIC[
'ilCtrl'];
486 $user_field_definitions->setFieldType($this->field_definition[
"field_type"]);
490 if ($this->field_id) {
491 $old_values = $user_field_definitions->getDefinition($this->field_id);
493 $old_options = $old_values[
"field_values"];
496 $perms = $this->permissions->hasPermissions(
532 if ($this->
validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id) {
537 if (is_array($old_options)) {
538 foreach ($old_options as $old_option) {
539 if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
546 elseif (is_array($old_options)) {
547 $user_field_definitions->setFieldValues($old_options);
551 $user_field_definitions->setFieldName($form->getInput(
"name"));
553 $user_field_definitions->setFieldName($this->field_definition[
"field_name"]);
556 $user_field_definitions->enableVisible($access[
'visible']);
557 $user_field_definitions->enableVisibleRegistration((
int) $access[
'visib_reg']);
558 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
559 $user_field_definitions->enableCourseExport($access[
'course_export']);
560 $user_field_definitions->enableGroupExport($access[
'group_export']);
561 $user_field_definitions->enableChangeable($access[
'changeable']);
562 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
563 $user_field_definitions->enableRequired($access[
'required']);
564 $user_field_definitions->enableExport($access[
'export']);
565 $user_field_definitions->enableSearchable($access[
'searchable']);
566 $user_field_definitions->enableCertificate($access[
'certificate']);
567 $user_field_definitions->update($this->field_id);
569 if ($user_field_definitions->isPluginType()) {
570 include_once
'./Services/User/classes/class.ilCustomUserFieldsHelper.php';
573 $plugin->updateDefinitionFromForm($form, $this->field_id);
577 if ($access[
'course_export']) {
578 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
582 ilUtil::sendSuccess(
$lng->txt(
'settings_saved'),
true);
583 $ilCtrl->redirect($this);
586 $form->setValuesByPost();
594 $ilCtrl = $DIC[
'ilCtrl'];
603 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
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");
611 foreach (
$_POST[
"fields"] as $id) {
612 $definition = $user_field_definitions->getDefinition($id);
613 $confirmation_gui->addItem(
"fields[]", $id, $definition[
"field_name"]);
616 $tpl->setContent($confirmation_gui->getHTML());
626 $ilCtrl = $DIC[
'ilCtrl'];
632 foreach (
$_POST[
"fields"] as $id) {
638 $field = $user_field_definitions->getDefinition($id);
639 $fail[] = $field[
"field_name"];
644 $ilCtrl->redirect($this,
"listUserDefinedFields");
647 foreach (
$_POST[
"fields"] as $id) {
648 $user_field_definitions->delete($id);
651 ilUtil::sendSuccess(
$lng->txt(
'udf_field_deleted'),
true);
652 $ilCtrl->redirect($this);
663 $ilCtrl = $DIC[
'ilCtrl'];
666 $a_fields = $user_field_definitions->getDefinitions();
668 $perm_map = self::getAccessPermissions();
670 foreach ($a_fields as
$field_id => $definition) {
671 $perms = $this->permissions->hasPermissions(
701 foreach ($perm_map as $prop => $perm) {
708 foreach ($a_fields as
$field_id => $definition) {
710 (!isset(
$_POST[
'chb'][
'visib_reg_' . $field_id]) || !(
int)
$_POST[
'chb'][
'visib_reg_' . $field_id])) {
711 $this->confirm_change =
true;
719 foreach ($a_fields as
$field_id => $definition) {
720 $user_field_definitions->setFieldName($definition[
'field_name']);
721 $user_field_definitions->setFieldType($definition[
'field_type']);
722 $user_field_definitions->setFieldValues($definition[
'field_values']);
723 $user_field_definitions->enableVisible((
int)
$_POST[
'chb'][
'visible_' .
$field_id]);
724 $user_field_definitions->enableChangeable((
int)
$_POST[
'chb'][
'changeable_' . $field_id]);
725 $user_field_definitions->enableRequired((
int)
$_POST[
'chb'][
'required_' . $field_id]);
726 $user_field_definitions->enableSearchable((
int)
$_POST[
'chb'][
'searchable_' . $field_id]);
727 $user_field_definitions->enableExport((
int)
$_POST[
'chb'][
'export_' . $field_id]);
728 $user_field_definitions->enableCourseExport((
int)
$_POST[
'chb'][
'course_export_' . $field_id]);
729 $user_field_definitions->enableVisibleLocalUserAdministration((
int)
$_POST[
'chb'][
'visib_lua_' . $field_id]);
730 $user_field_definitions->enableChangeableLocalUserAdministration((
int)
$_POST[
'chb'][
'changeable_lua_' . $field_id]);
731 $user_field_definitions->enableGroupExport((
int)
$_POST[
'chb'][
'group_export_' . $field_id]);
732 $user_field_definitions->enableVisibleRegistration((
int)
$_POST[
'chb'][
'visib_reg_' . $field_id]);
733 $user_field_definitions->enableCertificate((
int)
$_POST[
'chb'][
'certificate_' . $field_id]);
735 $user_field_definitions->update($field_id);
738 ilUtil::sendSuccess(
$lng->txt(
'settings_saved'),
true);
739 $ilCtrl->redirect($this);
This class represents an option in a radio group.
const SUBACTION_FIELD_ACCESS_VISIBLE_GROUPS
static getInstance($a_user_id=null, $a_ref_id=null)
Factory.
const SUBACTION_FIELD_ACCESS_SEARCHABLE
This class represents an option in a checkbox group.
static _getInstance()
Get instance.
addField($a_form=null)
Add field.
const SUBACTION_FIELD_ACCESS_VISIBLE_COURSES
edit($a_form=null)
Edit field.
const ACTION_FIELD_DELETE
listUserDefinedFields()
List all custom user fields.
const SUBACTION_FIELD_ACCESS_EXPORT
static _reset()
Reset all.
getAccessOptions()
Get all access options, order is kept in forms.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getInstance()
Get instance.
const SUBACTION_FIELD_ACCESS_CERTIFICATE
const SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL
initForm($a_mode='create')
Class ilCustomUserFieldsGUI.
const SUBACTION_FIELD_ACCESS_REQUIRED
const ACTION_FIELD_EDIT_ACCESS
TableGUI class for custom defined user fields.
const ACTION_FIELD_EDIT_PROPERTY
const SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL
UDF type deefinition plugin.
const SUBACTION_FIELD_PROPERTIES
validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions=null)
Validate field form.
static getAccessPermissions()
static _hasAgreements()
Check if there is any user agreement.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const SUBACTION_FIELD_TITLE
updateFields($action="")
Update custom fields properties (from table gui)
const SUBACTION_FIELD_ACCESS_VISIBLE_LOCAL
const ACTION_UDF_CREATE_FIELD
initFieldDefinition()
init field definition
const SUBACTION_FIELD_ACCESS_VISIBLE_REGISTRATION
This class represents a text wizard property in a property form.
static deleteFieldValue($a_field_id, $a_value)
Delete data of particular value of a (selection) field.
const UDF_DUPLICATE_VALUES
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
const SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL
Confirmation screen class.