4 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
5 include_once
'./Services/User/classes/class.ilUDFPermissionHelper.php';
28 $lng->loadLanguageModule(
"user");
29 $lng->loadLanguageModule(
"administration");
32 $ilCtrl->saveParameter($this,
"field_id", $this->field_id);
37 $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
52 $next_class = $ilCtrl->getNextClass($this);
53 $cmd = $ilCtrl->getCmd();
60 $cmd =
"listUserDefinedFields";
78 $ilToolbar->addButton($lng->txt(
"add_user_defined_field"),
79 $ilCtrl->getLinkTarget($this,
"addField"));
82 include_once(
"./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
84 if($this->confirm_change)
86 $tab->setConfirmChange();
88 $tpl->setContent(
$tab->getHTML());
105 $tpl->setContent($a_form->getHTML());
118 $opts[
"visible"] = $lng->txt(
"user_visible_in_profile");
119 $opts[
"visib_reg"] = $lng->txt(
"visible_registration");
120 $opts[
"visib_lua"] = $lng->txt(
"usr_settings_visib_lua");
121 $opts[
"course_export"] = $lng->txt(
"course_export");
122 $opts[
"group_export"] = $lng->txt(
"group_export");
123 $opts[
"changeable"] = $lng->txt(
"changeable");
124 $opts[
"changeable_lua"] = $lng->txt(
"usr_settings_changeable_lua");
125 $opts[
"required"] = $lng->txt(
"required_field");
126 $opts[
"export"] = $lng->txt(
"export");
127 $opts[
"searchable"] = $lng->txt(
"header_searchable");
128 $opts[
"certificate"] = $lng->txt(
"certificate");
158 include_once(
"Services/Membership/classes/class.ilMemberAgreement.php");
161 $lng->loadLanguageModule(
"ps");
165 if($this->field_definition)
168 $this->field_definition[
"field_id"], array(
200 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
202 $form->setFormAction($ilCtrl->getFormAction($this));
206 $form->addItem($name);
210 $name->setDisabled(
true);
217 $radg->addOption($op1);
219 $radg->addOption($op2);
221 $radg->addOption($op3);
222 $form->addItem($radg);
228 $se_mu->setMaxLength(128);
229 $se_mu->setValues(array(
''));
230 $op2->addSubItem($se_mu);
234 $se_mu->setDisabled(
true);
235 $se_mu->setRequired(
false);
241 $acc_values = array();
245 $acc->addOption($opt);
247 if($this->field_definition && $this->field_definition[$id])
258 $form->addItem($acc);
260 if($a_mode ==
"create")
264 $form->setTitle($lng->txt(
'add_new_user_defined_field'));
266 $form->addCommandButton(
"create", $lng->txt(
"save"));
267 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
271 $name->setValue($this->field_definition[
"field_name"]);
272 $radg->setValue($this->field_definition[
"field_type"]);
273 $radg->setDisabled(
true);
274 $acc->setValue($acc_values);
276 switch($this->field_definition[
"field_type"])
279 $se_mu->setValue($this->field_definition[
"field_values"]);
280 $form->setTitle($lng->txt(
"udf_update_select_field"));
284 $form->setTitle($lng->txt(
"udf_update_text_field"));
288 $form->setTitle($lng->txt(
"udf_update_wysiwyg_field"));
292 $form->addCommandButton(
"update", $lng->txt(
"save"));
293 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
308 protected function validateForm($form, $user_field_definitions, array &$access, array $a_field_permissions = null)
312 if($form->checkInput())
316 $incoming = (array)$form->getInput(
"access");
318 if($a_field_permissions)
326 $access[$id] = in_array($id, $incoming);
331 $access[$id] = $this->field_definition[$id];
335 if($access[
'required'] && !$access[
'visib_reg'])
337 $this->confirm_change =
true;
338 $form->getItemByPostVar(
"access")->setAlert($lng->txt(
'udf_required_requires_visib_reg'));
342 if(!$this->field_id && $user_field_definitions->nameExists($form->getInput(
"name")))
344 $form->getItemByPostVar(
"name")->setAlert($lng->txt(
'udf_name_already_exists'));
351 $user_field_definitions->setFieldValues($form->getInput(
"selvalue"));
352 if($error = $user_field_definitions->validateValues())
357 $form->getItemByPostVar(
"selvalue")->setAlert($lng->txt(
'udf_duplicate_entries'));
379 $user_field_definitions->setFieldType(
$_POST[
"field_type"]);
383 if($this->
validateForm($form, $user_field_definitions, $access))
385 $user_field_definitions->setFieldName($form->getInput(
"name"));
386 $user_field_definitions->enableVisible($access[
'visible']);
387 $user_field_definitions->enableVisibleRegistration((
int)$access[
'visib_reg']);
388 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
389 $user_field_definitions->enableCourseExport($access[
'course_export']);
390 $user_field_definitions->enableGroupExport($access[
'group_export']);
391 $user_field_definitions->enableChangeable($access[
'changeable']);
392 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
393 $user_field_definitions->enableRequired($access[
'required']);
394 $user_field_definitions->enableExport($access[
'export']);
395 $user_field_definitions->enableSearchable($access[
'searchable']);
396 $user_field_definitions->enableCertificate($access[
'certificate']);
397 $user_field_definitions->add();
399 if ($access[
'course_export'])
401 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
406 $ilCtrl->redirect($this);
409 $form->setValuesByPost();
427 $tpl->setContent($a_form->getHTML());
435 $user_field_definitions->setFieldType($this->field_definition[
"field_type"]);
441 $old_values = $user_field_definitions->getDefinition($this->field_id);
444 $old_options = $old_values[
"field_values"];
448 $this->field_id, array(
480 if($this->
validateForm($form, $user_field_definitions, $access, $perms) && $this->field_id)
487 if(is_array($old_options))
489 foreach($old_options as $old_option)
491 if(!in_array($old_option, $user_field_definitions->getFieldValues()))
499 else if(is_array($old_options))
501 $user_field_definitions->setFieldValues($old_options);
506 $user_field_definitions->setFieldName($form->getInput(
"name"));
510 $user_field_definitions->setFieldName($this->field_definition[
"field_name"]);
513 $user_field_definitions->enableVisible($access[
'visible']);
514 $user_field_definitions->enableVisibleRegistration((
int)$access[
'visib_reg']);
515 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
516 $user_field_definitions->enableCourseExport($access[
'course_export']);
517 $user_field_definitions->enableGroupExport($access[
'group_export']);
518 $user_field_definitions->enableChangeable($access[
'changeable']);
519 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
520 $user_field_definitions->enableRequired($access[
'required']);
521 $user_field_definitions->enableExport($access[
'export']);
522 $user_field_definitions->enableSearchable($access[
'searchable']);
523 $user_field_definitions->enableCertificate($access[
'certificate']);
524 $user_field_definitions->update($this->field_id);
526 if ($access[
'course_export'])
528 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
533 $ilCtrl->redirect($this);
536 $form->setValuesByPost();
550 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
552 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
553 $confirmation_gui->setHeaderText($lng->txt(
"udf_delete_sure"));
554 $confirmation_gui->setCancel($lng->txt(
"cancel"),
"listUserDefinedFields");
555 $confirmation_gui->setConfirm($lng->txt(
"delete"),
"deleteField");
558 foreach(
$_POST[
"fields"] as $id)
560 $definition = $user_field_definitions->getDefinition($id);
561 $confirmation_gui->addItem(
"fields[]", $id, $definition[
"field_name"]);
564 $tpl->setContent($confirmation_gui->getHTML());
577 foreach(
$_POST[
"fields"] as $id)
584 $field = $user_field_definitions->getDefinition($id);
585 $fail[] = $field[
"field_name"];
591 $ilCtrl->redirect($this,
"listUserDefinedFields");
594 foreach(
$_POST[
"fields"] as $id)
596 $user_field_definitions->delete($id);
600 $ilCtrl->redirect($this);
611 $a_fields = $user_field_definitions->getDefinitions();
615 foreach($a_fields as
$field_id => $definition)
644 foreach($perm_map as $prop => $perm)
653 foreach($a_fields as
$field_id => $definition)
656 (!isset(
$_POST[
'chb'][
'visib_reg_'.$field_id]) || !(
int)
$_POST[
'chb'][
'visib_reg_'.$field_id]))
658 $this->confirm_change =
true;
666 foreach($a_fields as
$field_id => $definition)
668 $user_field_definitions->setFieldName($definition[
'field_name']);
669 $user_field_definitions->setFieldType($definition[
'field_type']);
670 $user_field_definitions->setFieldValues($definition[
'field_values']);
671 $user_field_definitions->enableVisible((
int)
$_POST[
'chb'][
'visible_'.
$field_id]);
672 $user_field_definitions->enableChangeable((
int)
$_POST[
'chb'][
'changeable_'.$field_id]);
673 $user_field_definitions->enableRequired((
int)
$_POST[
'chb'][
'required_'.$field_id]);
674 $user_field_definitions->enableSearchable((
int)
$_POST[
'chb'][
'searchable_'.$field_id]);
675 $user_field_definitions->enableExport((
int)
$_POST[
'chb'][
'export_'.$field_id]);
676 $user_field_definitions->enableCourseExport((
int)
$_POST[
'chb'][
'course_export_'.$field_id]);
677 $user_field_definitions->enableVisibleLocalUserAdministration((
int)
$_POST[
'chb'][
'visib_lua_'.$field_id]);
678 $user_field_definitions->enableChangeableLocalUserAdministration((
int)
$_POST[
'chb'][
'changeable_lua_'.$field_id]);
679 $user_field_definitions->enableGroupExport((
int)
$_POST[
'chb'][
'group_export_'.$field_id]);
680 $user_field_definitions->enableVisibleRegistration((
int)
$_POST[
'chb'][
'visib_reg_'.$field_id]);
681 $user_field_definitions->enableCertificate((
int)
$_POST[
'chb'][
'certificate_'.$field_id]);
683 $user_field_definitions->update($field_id);
687 $ilCtrl->redirect($this);