ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSParticipantSettingsGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
5
15{
16 private $server_id = 0;
17 private $mid = 0;
18
19 private $participant = null;
20
21 protected $tpl;
22 protected $lng;
23 protected $ctrl;
24 protected $tabs;
25
26
32 public function __construct($a_server_id, $a_mid)
33 {
34 global $lng,$tpl,$ilCtrl,$ilTabs;
35
36 $this->server_id = $a_server_id;
37 $this->mid = $a_mid;
38
39 $this->tpl = $tpl;
40 $this->lng = $lng;
41 $this->lng->loadLanguageModule('ecs');
42 $this->ctrl = $ilCtrl;
43 $this->tabs = $ilTabs;
44
45 $this->initSettings();
46 $this->initParticipant();
47 }
48
53 public function getServerId()
54 {
55 return $this->server_id;
56 }
57
62 public function getMid()
63 {
64 return $this->mid;
65 }
66
71 public function getTemplate()
72 {
73 return $this->tpl;
74 }
75
80 public function getCtrl()
81 {
82 return $this->ctrl;
83 }
84
88 public function getLang()
89 {
90 return $this->lng;
91 }
92
97 public function getParticipant()
98 {
99 return $this->participant;
100 }
101
102
110 public function executeCommand()
111 {
112 $this->getCtrl()->saveParameter($this, 'server_id');
113 $this->getCtrl()->saveParameter($this, 'mid');
114
115
116 $next_class = $this->ctrl->getNextClass($this);
117 $cmd = $this->ctrl->getCmd('settings');
118
119 $this->setTabs();
120 switch ($next_class) {
121 default:
122 $this->$cmd();
123 break;
124 }
125
126
127 return true;
128 }
129
133 protected function abort()
134 {
135 $this->getCtrl()->returnToParent($this);
136 }
137
138
143 protected function settings(ilPropertyFormGUI $form = null)
144 {
145 if (!$form instanceof ilPropertyFormGUI) {
146 $form = $this->initFormSettings();
147 }
148 $this->getTemplate()->setContent($form->getHTML());
149 }
150
154 protected function saveSettings()
155 {
156 $form = $this->initFormSettings();
157 if ($form->checkInput()) {
158 $this->getParticipant()->enableToken($form->getInput('token'));
159 $this->getParticipant()->enableDeprecatedToken($form->getInput('dtoken'));
160 $this->getParticipant()->enableExport($form->getInput('export'));
161 $this->getParticipant()->setExportTypes($form->getInput('export_types'));
162 $this->getParticipant()->enableImport($form->getInput('import'));
163 $this->getParticipant()->setImportTypes($form->getInput('import_types'));
164 $this->getParticipant()->update();
165
166 ilUtil::sendSuccess($this->getLang()->txt('settings_saved'), true);
167 $this->getCtrl()->redirect($this, 'settings');
168 return true;
169 }
170 $form->setValuesByPost();
171 ilUtil::sendFailure($this->getLang()->txt('err_check_input'));
172 $this->settings($form);
173 }
174
178 protected function initFormSettings()
179 {
180 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
181 $form = new ilPropertyFormGUI();
182 $form->setFormAction($this->getCtrl()->getFormAction($this));
183 $form->setTitle($this->getLang()->txt('ecs_part_settings') . ' ' . $this->getParticipant()->getTitle());
184
185
186 $token = new ilCheckboxInputGUI($this->getLang()->txt('ecs_token_mechanism'), 'token');
187 $token->setInfo($this->getLang()->txt('ecs_token_mechanism_info'));
188 $token->setValue(1);
189 $token->setChecked($this->getParticipant()->isTokenEnabled());
190 $form->addItem($token);
191
192 $dtoken = new ilCheckboxInputGUI($this->getLang()->txt('ecs_deprecated_token'), 'dtoken');
193 $dtoken->setInfo($this->getLang()->txt('ecs_deprecated_token_info'));
194 $dtoken->setValue(1);
195 $dtoken->setChecked($this->getParticipant()->isDeprecatedTokenEnabled());
196 $form->addItem($dtoken);
197
198 // Export
199 $export = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_export'), 'export');
200 $export->setValue(1);
201 $export->setChecked($this->getParticipant()->isExportEnabled());
202 $form->addItem($export);
203
204 // Export types
205 $obj_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_export_types'), 'export_types');
206 $obj_types->setValue($this->getParticipant()->getExportTypes());
207
208
209 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
210 foreach (ilECSUtils::getPossibleReleaseTypes(true) as $type => $trans) {
211 $obj_types->addOption(new ilCheckboxOption($trans, $type));
212 }
213 $export->addSubItem($obj_types);
214
215
216 // Import
217 $import = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_import'), 'import');
218 $import->setValue(1);
219 $import->setChecked($this->getParticipant()->isImportEnabled());
220 $form->addItem($import);
221
222 // Export types
223 $imp_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_import_types'), 'import_types');
224 $imp_types->setValue($this->getParticipant()->getImportTypes());
225
226
227 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
228 foreach (ilECSUtils::getPossibleRemoteTypes(true) as $type => $trans) {
229 $imp_types->addOption(new ilCheckboxOption($trans, $type));
230 }
231 $import->addSubItem($imp_types);
232
233 $form->addCommandButton('saveSettings', $this->getLang()->txt('save'));
234 $form->addCommandButton('abort', $this->getLang()->txt('cancel'));
235 return $form;
236 }
237
238
242 protected function setTabs()
243 {
244 $this->tabs->clearTargets();
245 $this->tabs->setBackTarget(
246 $this->lng->txt('back'),
247 $this->ctrl->getParentReturn($this)
248 );
249 }
250
256 protected function initSettings()
257 {
258 include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
260 }
261
265 protected function initParticipant()
266 {
267 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
268 $this->participant = new ilECSParticipantSetting($this->getServerId(), $this->getMid());
269 }
270}
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
This class represents a checkbox property in a property form.
This class represents an option in a checkbox group.
settings(ilPropertyFormGUI $form=null)
Settings.
__construct($a_server_id, $a_mid)
Constructor.
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
static getPossibleRemoteTypes($a_with_captions=false)
Get all possible remote object types.
static getPossibleReleaseTypes($a_with_captions=false)
Get all possible release object types.
This class represents a property form user interface.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$type
if(isset($_POST['submit'])) $form