ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $DIC;
35
36 $lng = $DIC['lng'];
37 $tpl = $DIC['tpl'];
38 $ilCtrl = $DIC['ilCtrl'];
39 $ilTabs = $DIC['ilTabs'];
40
41 $this->server_id = $a_server_id;
42 $this->mid = $a_mid;
43
44 $this->tpl = $tpl;
45 $this->lng = $lng;
46 $this->lng->loadLanguageModule('ecs');
47 $this->ctrl = $ilCtrl;
48 $this->tabs = $ilTabs;
49
50 $this->initSettings();
51 $this->initParticipant();
52 }
53
58 public function getServerId()
59 {
60 return $this->server_id;
61 }
62
67 public function getMid()
68 {
69 return $this->mid;
70 }
71
76 public function getTemplate()
77 {
78 return $this->tpl;
79 }
80
85 public function getCtrl()
86 {
87 return $this->ctrl;
88 }
89
93 public function getLang()
94 {
95 return $this->lng;
96 }
97
102 public function getParticipant()
103 {
104 return $this->participant;
105 }
106
107
115 public function executeCommand()
116 {
117 $this->getCtrl()->saveParameter($this, 'server_id');
118 $this->getCtrl()->saveParameter($this, 'mid');
119
120
121 $next_class = $this->ctrl->getNextClass($this);
122 $cmd = $this->ctrl->getCmd('settings');
123
124 $this->setTabs();
125 switch ($next_class) {
126 default:
127 $this->$cmd();
128 break;
129 }
130
131
132 return true;
133 }
134
138 protected function abort()
139 {
140 $this->getCtrl()->returnToParent($this);
141 }
142
143
148 protected function settings(ilPropertyFormGUI $form = null)
149 {
150 if (!$form instanceof ilPropertyFormGUI) {
151 $form = $this->initFormSettings();
152 }
153 $this->getTemplate()->setContent($form->getHTML());
154 }
155
159 protected function saveSettings()
160 {
161 $form = $this->initFormSettings();
162 if ($form->checkInput()) {
163 $this->getParticipant()->enableToken($form->getInput('token'));
164 $this->getParticipant()->enableDeprecatedToken($form->getInput('dtoken'));
165 $this->getParticipant()->enableExport($form->getInput('export'));
166 $this->getParticipant()->setExportTypes($form->getInput('export_types'));
167 $this->getParticipant()->enableImport($form->getInput('import'));
168 $this->getParticipant()->setImportTypes($form->getInput('import_types'));
169 $this->getParticipant()->update();
170
171 ilUtil::sendSuccess($this->getLang()->txt('settings_saved'), true);
172 $this->getCtrl()->redirect($this, 'settings');
173 return true;
174 }
175 $form->setValuesByPost();
176 ilUtil::sendFailure($this->getLang()->txt('err_check_input'));
177 $this->settings($form);
178 }
179
183 protected function initFormSettings()
184 {
185 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
186 $form = new ilPropertyFormGUI();
187 $form->setFormAction($this->getCtrl()->getFormAction($this));
188 $form->setTitle($this->getLang()->txt('ecs_part_settings') . ' ' . $this->getParticipant()->getTitle());
189
190
191 $token = new ilCheckboxInputGUI($this->getLang()->txt('ecs_token_mechanism'), 'token');
192 $token->setInfo($this->getLang()->txt('ecs_token_mechanism_info'));
193 $token->setValue(1);
194 $token->setChecked($this->getParticipant()->isTokenEnabled());
195 $form->addItem($token);
196
197 $dtoken = new ilCheckboxInputGUI($this->getLang()->txt('ecs_deprecated_token'), 'dtoken');
198 $dtoken->setInfo($this->getLang()->txt('ecs_deprecated_token_info'));
199 $dtoken->setValue(1);
200 $dtoken->setChecked($this->getParticipant()->isDeprecatedTokenEnabled());
201 $form->addItem($dtoken);
202
203 // Export
204 $export = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_export'), 'export');
205 $export->setValue(1);
206 $export->setChecked($this->getParticipant()->isExportEnabled());
207 $form->addItem($export);
208
209 // Export types
210 $obj_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_export_types'), 'export_types');
211 $obj_types->setValue($this->getParticipant()->getExportTypes());
212
213
214 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
215 foreach (ilECSUtils::getPossibleReleaseTypes(true) as $type => $trans) {
216 $obj_types->addOption(new ilCheckboxOption($trans, $type));
217 }
218 $export->addSubItem($obj_types);
219
220
221 // Import
222 $import = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_import'), 'import');
223 $import->setValue(1);
224 $import->setChecked($this->getParticipant()->isImportEnabled());
225 $form->addItem($import);
226
227 // Export types
228 $imp_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_import_types'), 'import_types');
229 $imp_types->setValue($this->getParticipant()->getImportTypes());
230
231
232 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
233 foreach (ilECSUtils::getPossibleRemoteTypes(true) as $type => $trans) {
234 $imp_types->addOption(new ilCheckboxOption($trans, $type));
235 }
236 $import->addSubItem($imp_types);
237
238 $form->addCommandButton('saveSettings', $this->getLang()->txt('save'));
239 $form->addCommandButton('abort', $this->getLang()->txt('cancel'));
240 return $form;
241 }
242
243
247 protected function setTabs()
248 {
249 $this->tabs->clearTargets();
250 $this->tabs->setBackTarget(
251 $this->lng->txt('back'),
252 $this->ctrl->getParentReturn($this)
253 );
254 }
255
261 protected function initSettings()
262 {
263 include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
265 }
266
270 protected function initParticipant()
271 {
272 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
273 $this->participant = new ilECSParticipantSetting($this->getServerId(), $this->getMid());
274 }
275}
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $DIC
Definition: goto.php:24
$type
$token
Definition: xapitoken.php:52