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");
31 $this->field_id = $_REQUEST[
"field_id"];
32 $ilCtrl->saveParameter($this,
"field_id", $this->field_id);
34 if ($this->field_id) {
36 $this->field_definition = $user_field_definitions->getDefinition($this->field_id);
51 $next_class = $ilCtrl->getNextClass($this);
52 $cmd = $ilCtrl->getCmd();
54 switch ($next_class) {
57 $cmd =
"listUserDefinedFields";
74 (
int)
$_GET[
"ref_id"],
77 $ilToolbar->addButton(
78 $lng->txt(
"add_user_defined_field"),
79 $ilCtrl->getLinkTarget($this,
"addField")
83 include_once(
"./Services/User/classes/class.ilCustomUserFieldSettingsTableGUI.php");
85 if ($this->confirm_change) {
86 $tab->setConfirmChange();
88 $tpl->setContent(
$tab->getHTML());
104 $tpl->setContent($a_form->getHTML());
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");
157 include_once(
"Services/Membership/classes/class.ilMemberAgreement.php");
159 $lng->loadLanguageModule(
"ps");
163 if ($this->field_definition) {
164 $perms = $this->permissions->hasPermissions(
166 $this->field_definition[
"field_id"],
197 $perm_map = self::getAccessPermissions();
200 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
202 $form->setFormAction($ilCtrl->getFormAction($this));
205 $name->setRequired(
true);
209 $name->setDisabled(
true);
216 $radg->addOption($op1);
218 $radg->addOption($op2);
220 $radg->addOption($op3);
221 $form->addItem($radg);
227 $se_mu->setMaxLength(128);
228 $se_mu->setValues(
array(
''));
229 $op2->addSubItem($se_mu);
232 $se_mu->setDisabled(
true);
233 $se_mu->setRequired(
false);
239 $acc_values =
array();
242 $acc->addOption($opt);
244 if ($this->field_definition && $this->field_definition[
$id]) {
249 $opt->setDisabled(
true);
253 $form->addItem($acc);
255 if ($a_mode ==
"create") {
258 $form->setTitle($lng->txt(
'add_new_user_defined_field'));
260 $form->addCommandButton(
"create", $lng->txt(
"save"));
261 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
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);
268 switch ($this->field_definition[
"field_type"]) {
270 $se_mu->setValue($this->field_definition[
"field_values"]);
271 $form->setTitle($lng->txt(
"udf_update_select_field"));
275 $form->setTitle($lng->txt(
"udf_update_text_field"));
279 $form->setTitle($lng->txt(
"udf_update_wysiwyg_field"));
283 $form->addCommandButton(
"update", $lng->txt(
"save"));
284 $form->addCommandButton(
"listUserDefinedFields", $lng->txt(
"cancel"));
303 if (
$form->checkInput()) {
306 $incoming = (
array)
$form->getInput(
"access");
308 if ($a_field_permissions) {
309 $perm_map = self::getAccessPermissions();
314 $access[
$id] = in_array($id, $incoming);
318 $access[
$id] = $this->field_definition[
$id];
322 if ($access[
'required'] && !$access[
'visib_reg']) {
323 $this->confirm_change =
true;
324 $form->getItemByPostVar(
"access")->setAlert($lng->txt(
'udf_required_requires_visib_reg'));
328 if (!$this->field_id && $user_field_definitions->nameExists(
$form->getInput(
"name"))) {
329 $form->getItemByPostVar(
"name")->setAlert($lng->txt(
'udf_name_already_exists'));
335 $user_field_definitions->setFieldValues(
$form->getInput(
"selvalue"));
336 if (
$error = $user_field_definitions->validateValues()) {
339 $form->getItemByPostVar(
"selvalue")->setAlert($lng->txt(
'udf_duplicate_entries'));
360 $user_field_definitions->setFieldType(
$_POST[
"field_type"]);
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();
379 if ($access[
'course_export']) {
380 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
385 $ilCtrl->redirect($this);
388 $form->setValuesByPost();
397 public function edit($a_form = null)
405 $tpl->setContent($a_form->getHTML());
413 $user_field_definitions->setFieldType($this->field_definition[
"field_type"]);
417 if ($this->field_id) {
418 $old_values = $user_field_definitions->getDefinition($this->field_id);
420 $old_options = $old_values[
"field_values"];
423 $perms = $this->permissions->hasPermissions(
459 if ($this->
validateForm(
$form, $user_field_definitions, $access, $perms) && $this->field_id) {
464 if (is_array($old_options)) {
465 foreach ($old_options as $old_option) {
466 if (!in_array($old_option, $user_field_definitions->getFieldValues())) {
473 elseif (is_array($old_options)) {
474 $user_field_definitions->setFieldValues($old_options);
478 $user_field_definitions->setFieldName(
$form->getInput(
"name"));
480 $user_field_definitions->setFieldName($this->field_definition[
"field_name"]);
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);
496 if ($access[
'course_export']) {
497 include_once(
'Services/Membership/classes/class.ilMemberAgreement.php');
502 $ilCtrl->redirect($this);
505 $form->setValuesByPost();
518 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
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");
527 $definition = $user_field_definitions->getDefinition($id);
528 $confirmation_gui->addItem(
"fields[]", $id, $definition[
"field_name"]);
531 $tpl->setContent($confirmation_gui->getHTML());
550 $field = $user_field_definitions->getDefinition($id);
551 $fail[] = $field[
"field_name"];
556 $ilCtrl->redirect($this,
"listUserDefinedFields");
559 foreach (
$_POST[
"fields"] as $id) {
560 $user_field_definitions->delete($id);
564 $ilCtrl->redirect($this);
575 $a_fields = $user_field_definitions->getDefinitions();
577 $perm_map = self::getAccessPermissions();
579 foreach ($a_fields as
$field_id => $definition) {
580 $perms = $this->permissions->hasPermissions(
610 foreach ($perm_map as $prop => $perm) {
617 foreach ($a_fields as
$field_id => $definition) {
619 (!isset(
$_POST[
'chb'][
'visib_reg_' . $field_id]) || !(
int)
$_POST[
'chb'][
'visib_reg_' . $field_id])) {
620 $this->confirm_change =
true;
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]);
644 $user_field_definitions->update($field_id);
648 $ilCtrl->redirect($this);
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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.
initForm($a_mode="create")
Init field form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
const SUBACTION_FIELD_ACCESS_CERTIFICATE
const SUBACTION_FIELD_ACCESS_CHANGEABLE_PERSONAL
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
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.
Create styles array
The data for the language used.
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
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.