4 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
5 include_once
'./Services/User/classes/class.ilUDFPermissionHelper.php';
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);
56 $next_class =
$ilCtrl->getNextClass($this);
59 switch ($next_class) {
62 $cmd =
"listUserDefinedFields";
79 $ilToolbar = $DIC[
'ilToolbar'];
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();
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");
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"],
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);
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]) {
297 $opt->setDisabled(
true);
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 $se_mu->setValue($this->field_definition[
"field_values"]);
318 $form->setTitle($lng->txt(
"udf_update_select_field"));
322 $form->setTitle($lng->txt(
"udf_update_text_field"));
326 $form->setTitle($lng->txt(
"udf_update_wysiwyg_field"));
332 $form->setTitle($plugin->getDefinitionUpdateFormTitle());
336 $form->addCommandButton(
"update", $lng->txt(
"save"));
337 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
351 protected function validateForm(
$form, $user_field_definitions, array &$access, array $a_field_permissions = null)
357 if (
$form->checkInput()) {
360 $incoming = (array)
$form->getInput(
"access");
362 if ($a_field_permissions) {
363 $perm_map = self::getAccessPermissions();
368 $access[
$id] = in_array($id, $incoming);
372 $access[
$id] = $this->field_definition[
$id];
376 if ($access[
'required'] && !$access[
'visib_reg']) {
377 $this->confirm_change =
true;
378 $form->getItemByPostVar(
"access")->setAlert(
$lng->txt(
'udf_required_requires_visib_reg'));
382 if (!$this->field_id && $user_field_definitions->nameExists(
$form->getInput(
"name"))) {
383 $form->getItemByPostVar(
"name")->setAlert(
$lng->txt(
'udf_name_already_exists'));
389 $user_field_definitions->setFieldValues(
$form->getInput(
"selvalue"));
390 if ($error = $user_field_definitions->validateValues()) {
393 $form->getItemByPostVar(
"selvalue")->setAlert(
$lng->txt(
'udf_duplicate_entries'));
417 $user_field_definitions->setFieldType(
$_POST[
"field_type"]);
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();
436 if ($user_field_definitions->isPluginType()) {
437 include_once
'./Services/User/classes/class.ilCustomUserFieldsHelper.php';
440 $plugin->updateDefinitionFromForm(
$form, $new_id);
443 if ($access[
'course_export']) {
444 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
448 ilUtil::sendSuccess(
$lng->txt(
'udf_added_field'),
true);
452 $form->setValuesByPost();
461 public function edit($a_form = null)
471 $tpl->setContent($a_form->getHTML());
482 $user_field_definitions->setFieldType($this->field_definition[
"field_type"]);
486 if ($this->field_id) {
487 $old_values = $user_field_definitions->getDefinition($this->field_id);
489 $old_options = $old_values[
"field_values"];
492 $perms = $this->permissions->hasPermissions(
528 if ($this->
validateForm(
$form, $user_field_definitions, $access, $perms) && $this->field_id) {
533 if (is_array($old_options)) {
534 foreach ($old_options as $old_option) {
535 if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
542 elseif (is_array($old_options)) {
543 $user_field_definitions->setFieldValues($old_options);
547 $user_field_definitions->setFieldName(
$form->getInput(
"name"));
549 $user_field_definitions->setFieldName($this->field_definition[
"field_name"]);
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);
565 if ($user_field_definitions->isPluginType()) {
566 include_once
'./Services/User/classes/class.ilCustomUserFieldsHelper.php';
569 $plugin->updateDefinitionFromForm(
$form, $this->field_id);
573 if ($access[
'course_export']) {
574 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
578 ilUtil::sendSuccess(
$lng->txt(
'settings_saved'),
true);
582 $form->setValuesByPost();
599 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
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");
608 $definition = $user_field_definitions->getDefinition($id);
609 $confirmation_gui->addItem(
"fields[]", $id, $definition[
"field_name"]);
612 $tpl->setContent($confirmation_gui->getHTML());
634 $field = $user_field_definitions->getDefinition($id);
635 $fail[] = $field[
"field_name"];
640 $ilCtrl->redirect($this,
"listUserDefinedFields");
643 foreach (
$_POST[
"fields"] as $id) {
644 $user_field_definitions->delete($id);
647 ilUtil::sendSuccess(
$lng->txt(
'udf_field_deleted'),
true);
662 $a_fields = $user_field_definitions->getDefinitions();
664 $perm_map = self::getAccessPermissions();
666 foreach ($a_fields as
$field_id => $definition) {
667 $perms = $this->permissions->hasPermissions(
697 foreach ($perm_map as $prop => $perm) {
704 foreach ($a_fields as
$field_id => $definition) {
706 (!isset(
$_POST[
'chb'][
'visib_reg_' . $field_id]) || !(
int)
$_POST[
'chb'][
'visib_reg_' . $field_id])) {
707 $this->confirm_change =
true;
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]);
731 $user_field_definitions->update($field_id);
734 ilUtil::sendSuccess(
$lng->txt(
'settings_saved'),
true);
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
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.
if(isset($_POST['submit'])) $form
const ACTION_FIELD_EDIT_PROPERTY
const SUBACTION_FIELD_ACCESS_VISIBLE_PERSONAL
UDF type deefinition plugin.
const SUBACTION_FIELD_PROPERTIES
This class represents a text property in a property form.
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
const SUBACTION_FIELD_ACCESS_CHANGEABLE_LOCAL
Confirmation screen class.