ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSMappingSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
5 
6 /*
7  * Class for ECS node and directory mapping settings
8  *
9  * @author Stefan Meyer <smeyer.ilias@gmx.de>
10  * @version $ID$
11  *
12  * @ingroup ServicesWebServicesECS
13  * @ilCtrl_isCalledBy ilECSMappingSettingsGUI: ilECSSettingsGUI
14  */
16 {
17  const TAB_DIRECTORY = 1;
18  const TAB_COURSE = 2;
19 
20  private $container = null;
21  private $server = null;
22 
23  protected $lng = null;
24  protected $ctrl = null;
25 
30  public function __construct($settingsContainer, $server_id)
31  {
32  global $lng,$ilCtrl;
33 
34  $this->container = $settingsContainer;
35  $this->server = ilECSSetting::getInstanceByServerId($server_id);
36  $this->lng = $lng;
37  $this->ctrl = $ilCtrl;
38  }
39 
44  public function getContainer()
45  {
46  return $this->container;
47  }
48 
53  public function getServer()
54  {
55  return $this->server;
56  }
57 
61  public function executeCommand()
62  {
63  global $ilCtrl;
64 
65  $GLOBALS['tpl']->setTitle($this->lng->txt('ecs_campus_connect_title'));
66 
67  $this->ctrl->saveParameter($this,'server_id');
68 
69  $next_class = $this->ctrl->getNextClass($this);
70  $cmd = $this->ctrl->getCmd();
71 
72  $this->setTabs();
73  switch($next_class)
74  {
75  default:
76  if(!$cmd)
77  {
78  $cmd = "cStart";
79  }
80  $this->$cmd();
81  break;
82  }
83 
84  $GLOBALS['tpl']->setTitle($this->getServer()->getTitle());
85  $GLOBALS['tpl']->setDescription('');
86 
87  return true;
88  }
89 
93  public function cancel()
94  {
95  $GLOBALS['ilCtrl']->returnToParent($this);
96  }
97 
102  protected function cStart()
103  {
104  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
105  if(!ilECSNodeMappingSettings::getInstance()->isEnabled())
106  {
107  return $this->cSettings();
108  }
109  }
110 
115  protected function dStart()
116  {
117  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
118  if(!ilECSNodeMappingSettings::getInstance()->isEnabled())
119  {
120  return $this->dSettings();
121  }
122  return $this->dSettings();
123  }
124 
130  protected function cSettings()
131  {
132  global $ilTabs;
133 
134  $ilTabs->activateTab('ecs_crs_allocation');
135 
136  $form = $this->initFormCSettings();
137 
138  $GLOBALS['tpl']->setContent($form->getHTML());
139 
140  return true;
141  }
142 
146  protected function initFormCSettings()
147  {
148  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
149  $form = new ilPropertyFormGUI();
150  $form->setFormAction($this->ctrl->getFormAction($this));
151  $form->setTitle($this->lng->txt('settings'));
152 
153  // add default container
154  $imp = new ilCustomInputGUI($this->lng->txt('ecs_import_id'),'import_id');
155  $imp->setRequired(true);
156 
157  $tpl = new ilTemplate('tpl.ecs_import_id_form.html',true,true,'Services/WebServices/ECS');
158  $tpl->setVariable('SIZE',5);
159  $tpl->setVariable('MAXLENGTH',11);
160  $tpl->setVariable('POST_VAR','import_id');
161 # $tpl->setVariable('PROPERTY_VALUE',$this->rule->getContainerId());
162 
163  #if($this->settings->getImportId())
164  {
165  # $tpl->setVariable('COMPLETE_PATH',$this->buildPath($this->rule->getContainerId()));
166  }
167 
168  $imp->setHTML($tpl->get());
169  $imp->setInfo($this->lng->txt('ecs_import_id_info'));
170  $form->addItem($imp);
171 
172  // individual course allocation
173  $check = new ilCheckboxInputGUI($this->lng->txt('ecs_individual_alloc'), 'individual');
174  $check->setInfo($this->lng->txt('ecs_individual_alloc'));
175  $form->addItem($check);
176 
177  $form->addCommandButton('cUpdateSettings',$this->lng->txt('save'));
178  $form->addCommandButton('cSettings', $this->lng->txt('cancel'));
179 
180  return $form;
181  }
182 
187  protected function dSettings()
188  {
189  global $ilTabs;
190 
191  $this->setSubTabs(self::TAB_DIRECTORY);
192  $ilTabs->activateTab('ecs_dir_allocation');
193  $ilTabs->activateSubTab('dSettings');
194 
195  $form = $this->initFormDSettings();
196 
197  $GLOBALS['tpl']->setContent($form->getHTML());
198  return true;
199  }
200 
204  protected function dUpdateSettings()
205  {
206  global $ilCtrl;
207 
208  $form = $this->initFormDSettings();
209  if($form->checkInput())
210  {
211  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
212  ilECSNodeMappingSettings::getInstance()->enable((bool) $form->getInput('active'));
213  ilECSNodeMappingSettings::getInstance()->enableEmptyContainerCreation(!$form->getInput('empty'));
215  ilUtil::sendSuccess($this->lng->txt('saved_settings'),true);
216  }
217  else
218  {
219  ilUtil::sendFailure($this->lng->txt('err_check_input'),true);
220  $form->setValuesByPost();
221  }
222  $ilCtrl->redirect($this,'dSettings');
223  }
224 
228  protected function initFormDSettings()
229  {
230  include_once './Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingSettings.php';
231  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
232 
233  $form = new ilPropertyFormGUI();
234  $form->setFormAction($this->ctrl->getFormAction($this));
235  $form->setTitle($this->lng->txt('general_settings'));
236 
237  $active = new ilCheckboxInputGUI($this->lng->txt('ecs_node_mapping_activate'), 'active');
238  $active->setChecked(ilECSNodeMappingSettings::getInstance()->isEnabled());
239  $form->addItem($active);
240 
241  $create_empty = new ilCheckboxInputGUI($this->lng->txt('ecs_node_mapping_create_empty'), 'empty');
242  $create_empty->setChecked(!ilECSNodeMappingSettings::getInstance()->isEmptyContainerCreationEnabled());
243  $create_empty->setInfo($this->lng->txt('ecs_node_mapping_create_empty_info'));
244  $form->addItem($create_empty);
245 
246  $form->addCommandButton('dUpdateSettings',$this->lng->txt('save'));
247  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
248 
249  return $form;
250  }
251 
255  protected function dTrees()
256  {
257  $this->setSubTabs(self::TAB_DIRECTORY);
258  $GLOBALS['ilTabs']->activateSubTab('dTrees');
259  $GLOBALS['ilTabs']->activateTab('ecs_dir_allocation');
260  }
261 
265  protected function dMappingOverview()
266  {
267  $this->setSubTabs(self::TAB_DIRECTORY);
268  $GLOBALS['ilTabs']->activateSubTab('dMappingOverview');
269  $GLOBALS['ilTabs']->activateTab('ecs_dir_allocation');
270  }
271 
276  protected function setTabs()
277  {
278  global $ilTabs;
279 
280  $ilTabs->clearTargets();
281  $ilTabs->setBackTarget(
282  $this->lng->txt('ecs_back_settings'),
283  $this->ctrl->getParentReturn($this)
284  );
285  $ilTabs->addTab(
286  'ecs_dir_allocation',
287  $this->lng->txt('ecs_dir_alloc'),
288  $this->ctrl->getLinkTarget($this,'dSettings')
289  );
290  $ilTabs->addTab(
291  'ecs_crs_allocation',
292  $this->lng->txt('ecs_crs_alloc'),
293  $this->ctrl->getLinkTarget($this,'cSettings')
294  );
295  }
296 
302  protected function setSubTabs($a_tab)
303  {
304  global $ilTabs;
305 
306  if($a_tab == self::TAB_DIRECTORY)
307  {
308  $ilTabs->addSubTab(
309  'dMappingOverview',
310  $this->lng->txt('ecs_cc_mapping_overview'),
311  $this->ctrl->getLinkTarget($this,'dMappingOverview')
312  );
313  $ilTabs->addSubTab(
314  'dTrees',
315  $this->lng->txt('ecs_cms_dir_tree'),
316  $this->ctrl->getLinkTarget($this,'dTrees')
317  );
318  $ilTabs->addSubTab(
319  'dSettings',
320  $this->lng->txt('settings'),
321  $this->ctrl->getLinkTarget($this,'dSettings')
322  );
323  }
324  }
325 }
326 ?>