3declare(strict_types=1);
 
   51        $this->
http = $DIC->http();
 
   54        $this->ref_id = $a_ref_id;
 
   57        $this->
ctrl = $DIC->ctrl();
 
   58        $this->tpl = 
$DIC->ui()->mainTemplate();
 
   59        $this->
lng = $DIC->language();
 
   60        $this->
lng->loadLanguageModule(
'ps');
 
   61        $this->
user = $DIC->user();
 
   70        $next_class = $this->
ctrl->getNextClass($this);
 
   71        $cmd = $this->
ctrl->getCmd();
 
   73        switch ($next_class) {
 
   75                if (!$cmd || $cmd === 
'view') {
 
   76                    $cmd = 
'showAgreement';
 
  102        $this->tpl->setContent($form->getHTML());
 
  108        $form->setTitle($this->
lng->txt($this->type . 
'_agreement_header'));
 
  109        $form->setFormAction($this->
ctrl->getFormAction($this));
 
  110        $form->addCommandButton(
'save', $this->
lng->txt(
'save'));
 
  115        if ($this->
getPrivacy()->confirmationRequired($this->type)) {
 
  133        $tpl = 
new ilTemplate(
'tpl.agreement_form.html', 
true, 
true, 
'Services/Membership');
 
  135        foreach ($fields_info->getExportableFields() as $field) {
 
  160        $agreement->setRequired(
true);
 
  161        $agreement->setOptionTitle(
$lng->txt($a_type . 
'_info_agree'));
 
  162        $agreement->setValue(
'1');
 
  172        string $a_mode = 
'user' 
  182        if ($a_mode === 
'user') {
 
  184            $cdf->setValue(
$lng->txt($a_type . 
'_ps_cdf_info'));
 
  185            $cdf->setRequired(
true);
 
  188        foreach ($cdf_fields as $field_obj) {
 
  189            switch ($field_obj->getType()) {
 
  192                    if ($field_obj->getValueOptions()) {
 
  195                        if ($field_obj->isRequired()) {
 
  196                            $option_radios->setRequired(
true);
 
  199                        $open_answer_indexes = $field_obj->getValueOptions();
 
  200                        foreach ($field_obj->getValues() as 
$key => $val) {
 
  204                            if (in_array(
$key, $open_answer_indexes)) {
 
  206                                    $lng->txt(
"form_open_answer"),
 
  207                                    'cdf_oa_' . $field_obj->getId() . 
'_' . 
$key 
  209                                $open_answer->setRequired(
true);
 
  210                                $option_radio->addSubItem($open_answer);
 
  213                            $option_radios->addOption($option_radio);
 
  215                        if ($a_mode === 
'user') {
 
  216                            $cdf->addSubItem($option_radios);
 
  218                            $form->
addItem($option_radios);
 
  221                        $select = 
new ilSelectInputGUI($field_obj->getName(), 
'cdf_' . $field_obj->getId());
 
  222                        $select->setOptions($field_obj->prepareSelectBox());
 
  223                        if ($field_obj->isRequired()) {
 
  224                            $select->setRequired(
true);
 
  226                        if ($a_mode === 
'user') {
 
  227                            $cdf->addSubItem($select);
 
  235                    $text = 
new ilTextInputGUI($field_obj->getName(), 
'cdf_' . $field_obj->getId());
 
  237                    $text->setMaxLength(255);
 
  238                    if ($field_obj->isRequired()) {
 
  239                        $text->setRequired(
true);
 
  241                    if ($a_mode === 
'user') {
 
  242                        $cdf->addSubItem($text);
 
  249        if ($a_mode === 
'user') {
 
  257        $form = $this->initFormAgreement();
 
  260        if ($this->checkAgreement() && $form->
checkInput()) {
 
  261            self::saveCourseDefinedFields($form, $this->obj_id);
 
  263            $this->getAgreement()->setAccepted(
true);
 
  264            $this->getAgreement()->setAcceptanceTime(time());
 
  265            $this->getAgreement()->save();
 
  268            $history->setUpdateUser($this->
user->getId());
 
  272            $this->
ctrl->returnToParent($this);
 
  273        } elseif (!$this->checkAgreement()) {
 
  274            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt($this->type . 
'_agreement_required'));
 
  276            $this->showAgreement($form);
 
  279            $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'fill_out_all_required_fields'));
 
  281            $this->showAgreement($form);
 
  303            $current_value = (string) ($ud[$a_usr_id][$field_obj->getId()] ?? 
'');
 
  304            if (!$current_value) {
 
  308            switch ($field_obj->getType()) {
 
  311                    $id = $field_obj->getIdByValue($current_value);
 
  315                        $item->setValue($field_obj->getId() . 
'_' . 
$id);
 
  318                        $open_answer_indexes = $field_obj->getValueOptions();
 
  319                        $open_answer_index = end($open_answer_indexes);
 
  321                        $item->setValue($field_obj->getId() . 
'_' . $open_answer_index);
 
  322                        $item_txt = $form->
getItemByPostVar(
'cdf_oa_' . $field_obj->getId() . 
'_' . $open_answer_index);
 
  324                            $item_txt->setValue($current_value);
 
  331                    $item->setValue($current_value);
 
  347            switch ($field_obj->getType()) {
 
  350                    $exp = explode(
'_', $form->
getInput(
'cdf_' . $field_obj->getId()));
 
  352                    $option_id = $exp[1] ?? 
null;
 
  353                    $open_answer_indexes = $field_obj->getValueOptions();
 
  354                    if (in_array($option_id, $open_answer_indexes)) {
 
  355                        $value = $form->
getInput(
'cdf_oa_' . $field_obj->getId() . 
'_' . $option_id);
 
  357                        $value = $field_obj->getValueById((
int) $option_id);
 
  362                    $value = $form->
getInput(
'cdf_' . $field_obj->getId());
 
  367            $course_user_data->setValue($value);
 
  368            $course_user_data->update();
 
  375        if ($this->
http->wrapper()->post()->has(
'agreement')) {
 
  376            $agreement = $this->
http->wrapper()->post()->retrieve(
 
  384        if ($this->privacy->confirmationRequired($this->type)) {
 
  393        $this->agreement_required = $this->getAgreement()->agreementRequired();
 
  399        if ($this->agreement_required) {
 
  400            $message = $this->
lng->txt($this->type . 
'_ps_agreement_req_info');
 
  402        if (!$this->required_fullfilled) {
 
  406            $message .= $this->
lng->txt($this->type . 
'_ps_required_info');
 
  409            $this->tpl->setOnScreenMessage(
'failure', 
$message);
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
 
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _getValuesByObjId(int $a_obj_id)
 
static _checkRequired(int $a_usr_id, int $a_obj_id)
 
@classDescription Date and time handling
 
static _getInstanceByType(string $a_type)
Get Singleton Instance.
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
static addCustomFields(ilPropertyFormGUI $form, int $a_obj_id, string $a_type, string $a_mode='user')
 
static setCourseDefinedFieldValues(ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)
 
bool $required_fullfilled
 
static addAgreement(ilPropertyFormGUI $form, int $a_obj_id, string $a_type)
 
__construct(int $a_ref_id)
 
ilMemberAgreement $agreement
 
ilGlobalTemplateInterface $tpl
 
static addExportFieldInfo(ilPropertyFormGUI $form, int $a_obj_id, string $a_type)
 
showAgreement(?ilPropertyFormGUI $form=null)
Show agreement form.
 
static saveCourseDefinedFields(ilPropertyFormGUI $form, int $a_obj_id, int $a_usr_id=0)
 
ilPrivacySettings $privacy
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _lookupType(int $id, bool $reference=false)
 
static _lookupObjId(int $ref_id)
 
Singleton class that stores all privacy settings.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
special template class to simplify handling of ITX/PEAR
 
This class represents a text property in a property form.
 
Interface GlobalHttpState.
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
 
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
 
setVariable(string $variable, $value='')
Sets the given variable to the given value.
 
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
 
static http()
Fetches the global http state from ILIAS.