/** * Init form */ protected function initForm() { $this->setFormAction($this->ctrl->getFormAction($this->parent_gui)); $title = $this->isNew ? $this->pl->txt('choose_cert_type') : $this->pl->txt('edit_settings'); // Certificate Type $type = $this->getTypeInput(); $n_types = count($type->getOptions()); if ($this->isNew) { if (!$n_types) { ilUtil::sendInfo($this->pl->txt('msg_no_types_available')); } else { $this->setTitle($title); $this->addItem($type); $this->addCommandButton('createDefinition', $this->pl->txt('save')); } return; } else { if ($n_types > 1) { $this->setTitle($title); $checkbox = new ilCheckboxInputGUI($this->pl->txt('change_cert_type'), 'change_type'); $checkbox->addSubItem($type); $checkbox->setInfo($this->pl->txt('current_type') . ' ' . $this->definition->getType()->getTitle()); $this->addItem($checkbox); } } // Add all settings inputs $settings_inputs = $this->getSettingsInputs(); $header = new ilFormSectionHeaderGUI(); $header->setTitle($this->pl->txt('certificate')); $this->addItem($header); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_DEFAULT_LANG]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_VALIDITY_TYPE]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_GENERATION]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_DOWNLOADABLE]); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_SCORM_TIMING]); // Custom settings /** @var srCertificateCustomDefinitionSetting $setting */ foreach ($this->definition->getCustomSettings() as $setting) { switch ($setting->getSettingTypeId()) { case srCertificateCustomTypeSetting::SETTING_TYPE_BOOLEAN: $item = new ilCheckboxInputGUI($setting->getLabel($this->user->getLanguage()), 'custom_setting_' . $setting->getIdentifier()); if ($setting->getValue()) { $item->setChecked(true); } break; case srCertificateCustomTypeSetting::SETTING_TYPE_SELECT: $item = new ilSelectInputGUI($setting->getLabel($this->user->getLanguage()), 'custom_setting_' . $setting->getIdentifier()); $item->setValue($setting->getValue()); $item->setOptions($setting->getCustomTypeSetting()->getData(true)); break; } $item->setDisabled(!$setting->isEditable()); $this->addItem($item); } // Notification $header = new ilFormSectionHeaderGUI(); $header->setTitle($this->pl->txt('setting_id_notification')); $this->addItem($header); $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION]); if (isset($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER])) { $this->addItem($settings_inputs[srCertificateTypeSetting::IDENTIFIER_NOTIFICATION_USER]); } $this->addCommandButton("updateDefinition", "Save"); }