ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilUserProfileInfoSettingsGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Object/classes/class.ilObjectGUI.php";
6
17{
21 protected $ctrl;
22
26 protected $tpl;
27
31 protected $lng;
32
36 protected $user_prompt;
37
42
46 public function __construct()
47 {
48 global $DIC;
49
50 $this->ctrl = $DIC->ctrl();
51 $this->tpl = $DIC["tpl"];
52 $this->lng = $DIC->language();
53 $this->user_prompt = new ilUserProfilePromptService();
54 $this->prompt_settings = $this->user_prompt->data()->getSettings();
55 }
56
57
61 public function executeCommand()
62 {
63 $next_class = $this->ctrl->getNextClass($this);
64 $cmd = $this->ctrl->getCmd("show");
65
66 switch ($next_class) {
67 default:
68 if (in_array($cmd, array("show", "save"))) {
69 $this->$cmd();
70 }
71 }
72 }
73
77 public function show()
78 {
80
81 $form = $this->initForm();
82 $tpl->setContent($form->getHTML());
83 }
84
89 public function initForm()
90 {
94
95 $lng->loadLanguageModule("meta");
96
97 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
98 $form = new ilPropertyFormGUI();
99
100 // default info text
101 $first = true;
102 foreach ($lng->getInstalledLanguages() as $l) {
103 // info text
104 include_once("Services/Form/classes/class.ilTextAreaInputGUI.php");
105 $ti = new ilTextAreaInputGUI($lng->txt("meta_l_" . $l), "user_profile_info_text_" . $l);
106 $ti->setRows(7);
107 if ($first) {
108 $ti->setInfo($lng->txt("user_profile_info_text_info"));
109 }
110 $first = false;
111 $ti->setValue($prompt_settings->getInfoText($l));
112 $form->addItem($ti);
113 }
114
115 // prompting settings
116 $sec = new ilFormSectionHeaderGUI();
117 $sec->setTitle($lng->txt('user_prompting_settings'));
118 $form->addItem($sec);
119
120 // prompt mode
121 $radg = new ilRadioGroupInputGUI($lng->txt("user_prompting_recurrence"), "prompt_mode");
122 $radg->setValue($prompt_settings->getMode());
123
124 // ... only if incomplete
125 $op1 = new ilRadioOption(
126 $lng->txt("user_prompt_incomplete"),
128 $lng->txt("user_prompt_incomplete_info")
129 );
130 $radg->addOption($op1);
131
132 // ... once after login
133 $op2 = new ilRadioOption(
134 $lng->txt("user_prompt_once_after_login"),
136 $lng->txt("user_prompt_once_after_login_info")
137 );
138 $radg->addOption($op2);
139
140 // days after login
141 $ti = new ilNumberInputGUI($lng->txt("days"), "days_after_login");
142 $ti->setMaxLength(4);
143 $ti->setSize(4);
144 $ti->setValue($prompt_settings->getDays());
145 $op2->addSubItem($ti);
146
147 // ... repeatly
148 $op3 = new ilRadioOption(
149 $lng->txt("user_prompt_repeat"),
151 $lng->txt("user_prompt_repeat_info")
152 );
153 $radg->addOption($op3);
154
155 // repeat all x days
156 $ti = new ilNumberInputGUI($lng->txt("days"), "days_repeat");
157 $ti->setMaxLength(4);
158 $ti->setSize(4);
159 $ti->setRequired(true);
160 $ti->setMinValue(1);
161 $ti->setValue($prompt_settings->getDays());
162 $op3->addSubItem($ti);
163
164 $form->addItem($radg);
165
166
167 // prompting info text
168 $first = true;
169 foreach ($lng->getInstalledLanguages() as $l) {
170 // info text
171 include_once("Services/Form/classes/class.ilTextAreaInputGUI.php");
172 $ti = new ilTextAreaInputGUI($lng->txt("meta_l_" . $l), "user_profile_prompt_text_" . $l);
173 $ti->setRows(7);
174 if ($first) {
175 $ti->setInfo($lng->txt("user_profile_prompt_text_info"));
176 }
177 $first = false;
178 $ti->setValue($prompt_settings->getPromptText($l));
179 $form->addItem($ti);
180 }
181
182 $form->addCommandButton("save", $lng->txt("save"));
183
184 $form->setTitle($lng->txt("user_profile_info_std"));
185 $form->setFormAction($ctrl->getFormAction($this));
186
187 return $form;
188 }
189
193 public function save()
194 {
198
199 $form = $this->initForm();
200 if ($form->checkInput()) {
201 $days = ($form->getInput("prompt_mode") == ilProfilePromptSettings::MODE_ONCE_AFTER_LOGIN)
202 ? $form->getInput("days_after_login")
203 : $form->getInput("days_repeat");
204 $info_text = $prompt_text = [];
205 foreach ($lng->getInstalledLanguages() as $l) {
206 $info_text[$l] = $form->getInput("user_profile_info_text_" . $l);
207 $prompt_text[$l] = $form->getInput("user_profile_prompt_text_" . $l);
208 }
209 $this->user_prompt->data()->saveSettings($this->user_prompt->settings(
210 (int) $form->getInput("prompt_mode"),
211 (int) $days,
212 $info_text,
213 $prompt_text
214 ));
215 /*$setting = new ilSetting("user");
216 foreach ($lng->getInstalledLanguages() as $l)
217 {
218 $setting->set("user_profile_info_".$l, $form->getInput("user_profile_info_text_".$l));
219 }*/
220
221 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
222 $ctrl->redirect($this, "show");
223 } else {
224 $form->setValuesByPost();
225 $tpl->setContent($form->getHtml());
226 }
227 }
228}
An exception for terminatinating execution or to throw for unit testing.
This class represents a section header in a property form.
This class represents a number property in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a text area property in a property form.
User profile info settings UI class.
global $DIC
Definition: goto.php:24