4 include_once
'./Services/User/classes/class.ilUserDefinedFields.php';
26 $lng->loadLanguageModule(
"user");
27 $lng->loadLanguageModule(
"administration");
30 $ilCtrl->saveParameter($this,
"field_id", $this->field_id);
35 $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
43 $next_class = $ilCtrl->getNextClass($this);
44 $cmd = $ilCtrl->getCmd();
51 $cmd =
"listUserDefinedFields";
66 $ilToolbar->addButton($lng->txt(
"add_user_defined_field"),
67 $ilCtrl->getLinkTarget($this,
"addField"));
69 include_once(
"./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
71 if($this->confirm_change)
73 $tab->setConfirmChange();
75 $tpl->setContent(
$tab->getHTML());
92 $tpl->setContent($a_form->getHTML());
105 $opts[
"visible"] = $lng->txt(
"user_visible_in_profile");
106 $opts[
"visib_reg"] = $lng->txt(
"visible_registration");
107 $opts[
"visib_lua"] = $lng->txt(
"usr_settings_visib_lua");
108 $opts[
"course_export"] = $lng->txt(
"course_export");
109 $opts[
"group_export"] = $lng->txt(
"group_export");
110 $opts[
"changeable"] = $lng->txt(
"changeable");
111 $opts[
"changeable_lua"] = $lng->txt(
"usr_settings_changeable_lua");
112 $opts[
"required"] = $lng->txt(
"required_field");
113 $opts[
"export"] = $lng->txt(
"export");
114 $opts[
"searchable"] = $lng->txt(
"header_searchable");
128 include_once(
"Services/Membership/classes/class.ilMemberAgreement.php");
131 $lng->loadLanguageModule(
"ps");
135 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
137 $form->setFormAction($ilCtrl->getFormAction($this));
141 $form->addItem($name);
147 $radg->addOption($op1);
149 $radg->addOption($op2);
151 $radg->addOption($op3);
152 $form->addItem($radg);
158 $se_mu->setMaxLength(128);
159 $se_mu->setValues(array(
''));
160 $op2->addSubItem($se_mu);
165 $acc_values = array();
169 $acc->addOption($opt);
171 if($this->field_definition && $this->field_definition[$id])
177 $form->addItem($acc);
179 if($a_mode ==
"create")
184 $form->setTitle($lng->txt(
'add_new_user_defined_field'));
186 $form->addCommandButton(
"create", $lng->txt(
"save"));
187 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
191 $name->setValue($this->field_definition[
"field_name"]);
192 $radg->setValue($this->field_definition[
"field_type"]);
193 $radg->setDisabled(
true);
194 $acc->setValue($acc_values);
196 switch($this->field_definition[
"field_type"])
199 $se_mu->setValue($this->field_definition[
"field_values"]);
200 $form->setTitle($lng->txt(
"udf_update_select_field"));
204 $form->setTitle($lng->txt(
"udf_update_text_field"));
208 $form->setTitle($lng->txt(
"udf_update_wysiwyg_field"));
212 $form->addCommandButton(
"update", $lng->txt(
"save"));
213 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
227 protected function validateForm($form, $user_field_definitions, array &$access)
231 if($form->checkInput())
235 $incoming = (array)$form->getInput(
"access");
239 $access[$id] = in_array($id, $incoming);
242 if($access[
'required'] && !$access[
'visib_reg'])
244 $this->confirm_change =
true;
245 $form->getItemByPostVar(
"access")->setAlert($lng->txt(
'udf_required_requires_visib_reg'));
249 if(!$this->field_id && $user_field_definitions->nameExists($form->getInput(
"name")))
251 $form->getItemByPostVar(
"name")->setAlert($lng->txt(
'udf_name_already_exists'));
257 $user_field_definitions->setFieldValues($form->getInput(
"selvalue"));
258 if($error = $user_field_definitions->validateValues())
263 $form->getItemByPostVar(
"selvalue")->setAlert($lng->txt(
'udf_duplicate_entries'));
285 $user_field_definitions->setFieldType(
$_POST[
"field_type"]);
289 if($this->
validateForm($form, $user_field_definitions, $access))
291 $user_field_definitions->setFieldName($form->getInput(
"name"));
292 $user_field_definitions->enableVisible($access[
'visible']);
293 $user_field_definitions->enableVisibleRegistration((
int)$access[
'visib_reg']);
294 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
295 $user_field_definitions->enableCourseExport($access[
'course_export']);
296 $user_field_definitions->enableGroupExport($access[
'group_export']);
297 $user_field_definitions->enableChangeable($access[
'changeable']);
298 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
299 $user_field_definitions->enableRequired($access[
'required']);
300 $user_field_definitions->enableExport($access[
'export']);
301 $user_field_definitions->enableSearchable($access[
'searchable']);
302 $user_field_definitions->add();
304 if ($access[
'course_export'])
306 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
311 $ilCtrl->redirect($this);
314 $form->setValuesByPost();
332 $tpl->setContent($a_form->getHTML());
340 $user_field_definitions->setFieldType($this->field_definition[
"field_type"]);
344 if($this->
validateForm($form, $user_field_definitions, $access) && $this->field_id)
348 $user_field_definitions->setFieldName($form->getInput(
"name"));
349 $user_field_definitions->enableVisible($access[
'visible']);
350 $user_field_definitions->enableVisibleRegistration((
int)$access[
'visib_reg']);
351 $user_field_definitions->enableVisibleLocalUserAdministration($access[
'visib_lua']);
352 $user_field_definitions->enableCourseExport($access[
'course_export']);
353 $user_field_definitions->enableGroupExport($access[
'group_export']);
354 $user_field_definitions->enableChangeable($access[
'changeable']);
355 $user_field_definitions->enableChangeableLocalUserAdministration($access[
'changeable_lua']);
356 $user_field_definitions->enableRequired($access[
'required']);
357 $user_field_definitions->enableExport($access[
'export']);
358 $user_field_definitions->enableSearchable($access[
'searchable']);
359 $user_field_definitions->update($this->field_id);
361 if ($access[
'course_export'])
363 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
368 $ilCtrl->redirect($this);
371 $form->setValuesByPost();
385 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
387 $confirmation_gui->setFormAction($ilCtrl->getFormAction($this));
388 $confirmation_gui->setHeaderText($lng->txt(
"udf_delete_sure"));
389 $confirmation_gui->setCancel($lng->txt(
"cancel"),
"listUserDefinedFields");
390 $confirmation_gui->setConfirm($lng->txt(
"delete"),
"deleteField");
393 foreach(
$_POST[
"fields"] as $id)
395 $definition = $user_field_definitions->getDefinition($id);
396 $confirmation_gui->addItem(
"fields[]", $id, $definition[
"field_name"]);
399 $tpl->setContent($confirmation_gui->getHTML());
409 foreach(
$_POST[
"fields"] as $id)
411 $user_field_definitions->delete($id);
415 $ilCtrl->redirect($this);
426 $a_fields = $user_field_definitions->getDefinitions();
428 foreach($a_fields as
$field_id => $definition)
431 (!isset(
$_POST[
'chb'][
'visib_reg_'.$field_id]) || !(
int)
$_POST[
'chb'][
'visib_reg_'.$field_id]))
433 $this->confirm_change =
true;
441 foreach($a_fields as
$field_id => $definition)
443 $user_field_definitions->setFieldName($definition[
'field_name']);
444 $user_field_definitions->setFieldType($definition[
'field_type']);
445 $user_field_definitions->setFieldValues($definition[
'field_values']);
446 $user_field_definitions->enableVisible((
int)
$_POST[
'chb'][
'visible_'.
$field_id]);
447 $user_field_definitions->enableChangeable((
int)
$_POST[
'chb'][
'changeable_'.$field_id]);
448 $user_field_definitions->enableRequired((
int)
$_POST[
'chb'][
'required_'.$field_id]);
449 $user_field_definitions->enableSearchable((
int)
$_POST[
'chb'][
'searchable_'.$field_id]);
450 $user_field_definitions->enableExport((
int)
$_POST[
'chb'][
'export_'.$field_id]);
451 $user_field_definitions->enableCourseExport((
int)
$_POST[
'chb'][
'course_export_'.$field_id]);
452 $user_field_definitions->enableVisibleLocalUserAdministration((
int)
$_POST[
'chb'][
'visib_lua_'.$field_id]);
453 $user_field_definitions->enableChangeableLocalUserAdministration((
int)
$_POST[
'chb'][
'changeable_lua_'.$field_id]);
454 $user_field_definitions->enableGroupExport((
int)
$_POST[
'chb'][
'group_export_'.$field_id]);
455 $user_field_definitions->enableVisibleRegistration((
int)
$_POST[
'chb'][
'visib_reg_'.$field_id]);
457 $user_field_definitions->update($field_id);
461 $ilCtrl->redirect($this);