ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
122 default:
123 $this->$cmd();
124 break;
125 }
126
127
128 return true;
129 }
130
134 protected function abort()
135 {
136 $this->getCtrl()->returnToParent($this);
137 }
138
139
144 protected function settings(ilPropertyFormGUI $form = null)
145 {
146 if(!$form instanceof ilPropertyFormGUI)
147 {
148 $form = $this->initFormSettings();
149 }
150 $this->getTemplate()->setContent($form->getHTML());
151 }
152
156 protected function saveSettings()
157 {
158 $form = $this->initFormSettings();
159 if($form->checkInput())
160 {
161 $this->getParticipant()->enableToken($form->getInput('token'));
162 $this->getParticipant()->enableDeprecatedToken($form->getInput('dtoken'));
163 $this->getParticipant()->enableExport($form->getInput('export'));
164 $this->getParticipant()->setExportTypes($form->getInput('export_types'));
165 $this->getParticipant()->enableImport($form->getInput('import'));
166 $this->getParticipant()->setImportTypes($form->getInput('import_types'));
167 $this->getParticipant()->update();
168
169 ilUtil::sendSuccess($this->getLang()->txt('settings_saved'),TRUE);
170 $this->getCtrl()->redirect($this,'settings');
171 return TRUE;
172 }
173 $form->setValuesByPost();
174 ilUtil::sendFailure($this->getLang()->txt('err_check_input'));
175 $this->settings($form);
176 }
177
181 protected function initFormSettings()
182 {
183 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
184 $form = new ilPropertyFormGUI();
185 $form->setFormAction($this->getCtrl()->getFormAction($this));
186 $form->setTitle($this->getLang()->txt('ecs_part_settings').' '.$this->getParticipant()->getTitle());
187
188
189 $token = new ilCheckboxInputGUI($this->getLang()->txt('ecs_token_mechanism'),'token');
190 $token->setInfo($this->getLang()->txt('ecs_token_mechanism_info'));
191 $token->setValue(1);
192 $token->setChecked($this->getParticipant()->isTokenEnabled());
193 $form->addItem($token);
194
195 $dtoken = new ilCheckboxInputGUI($this->getLang()->txt('ecs_deprecated_token'),'dtoken');
196 $dtoken->setInfo($this->getLang()->txt('ecs_deprecated_token_info'));
197 $dtoken->setValue(1);
198 $dtoken->setChecked($this->getParticipant()->isDeprecatedTokenEnabled());
199 $form->addItem($dtoken);
200
201 // Export
202 $export = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_export'), 'export');
203 $export->setValue(1);
204 $export->setChecked($this->getParticipant()->isExportEnabled());
205 $form->addItem($export);
206
207 // Export types
208 $obj_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_export_types'), 'export_types');
209 $obj_types->setValue($this->getParticipant()->getExportTypes());
210
211
212 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
213 foreach(ilECSUtils::getPossibleReleaseTypes(TRUE) as $type => $trans)
214 {
215 $obj_types->addOption(new ilCheckboxOption($trans, $type));
216 }
217 $export->addSubItem($obj_types);
218
219
220 // Import
221 $import = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_import'), 'import');
222 $import->setValue(1);
223 $import->setChecked($this->getParticipant()->isImportEnabled());
224 $form->addItem($import);
225
226 // Export types
227 $imp_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_import_types'), 'import_types');
228 $imp_types->setValue($this->getParticipant()->getImportTypes());
229
230
231 include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
232 foreach(ilECSUtils::getPossibleRemoteTypes(TRUE) as $type => $trans)
233 {
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}
276
277?>
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
$cmd
Definition: sahs_server.php:35