ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCloudPluginSettingsGUI.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/Form/classes/class.ilPropertyFormGUI.php");
5 include_once("class.ilCloudUtil.php");
6 
19 {
23  protected $cloud_object;
24 
28  protected $form;
29 
30 
31  public function setCloudObject(ilObjCloud $object)
32  {
33  $this->cloud_object = $object;
34  }
35 
39  function editSettings()
40  {
41  global $tpl, $ilTabs, $lng;
42 
43  $ilTabs->activateTab("settings");
44 
45  try
46  {
47  $this->initSettingsForm();
48  $this->getSettingsValues();
49  $tpl->setContent($this->form->getHTML());
50  } catch (Exception $e)
51  {
52  ilUtil::sendFailure($e->getMessage());
53  }
54  }
55 
56  public function initSettingsForm()
57  {
58  global $ilCtrl, $lng;
59 
60  $this->form = new ilPropertyFormGUI();
61 
62  // title
63  $ti = new ilTextInputGUI($lng->txt("title"), "title");
64  $ti->setRequired(true);
65  $this->form->addItem($ti);
66 
67  // description
68  $ta = new ilTextAreaInputGUI($lng->txt("description"), "desc");
69  $this->form->addItem($ta);
70 
71  // online
72  $cb = new ilCheckboxInputGUI($lng->txt("online"), "online");
73  $this->form->addItem($cb);
74 
75  $folder = new ilTextInputGUI($lng->txt("cld_root_folder"), "root_folder");
76  if(!$this->cloud_object->currentUserIsOwner())
77  {
78  $folder->setDisabled(true);
79  $folder->setInfo($lng->txt("cld_only_owner_has_permission_to_change_root_path"));
80  }
81 
82  $folder->setMaxLength(255);
83  $folder->setSize(50);
84  $this->form->addItem($folder);
85 
86  $this->createPluginSection();
87  $this->initPluginSettings();
88 
89  $this->form->addCommandButton("updateSettings", $lng->txt("save"));
90 
91  $this->form->setTitle($lng->txt("cld_edit_Settings"));
92  $this->form->setFormAction($ilCtrl->getFormActionByClass("ilCloudPluginSettingsGUI"));
93  }
94  protected function createPluginSection()
95  {
96  if(get_class($this) != "ilCloudPluginSettingsGUI" && $this->getMakeOwnPluginSection())
97  {
98  global $lng;
100  $section->setTitle($this->cloud_object->getServiceName()." ".$lng->txt("cld_service_specific_settings"));
101  $this->form->addItem($section);
102  }
103  }
104 
105  protected function initPluginSettings(){}
106 
107  protected function getMakeOwnPluginSection()
108  {
109  return true;
110  }
111 
115  function getSettingsValues()
116  {
117  $values["title"] = $this->cloud_object->getTitle();
118  $values["desc"] = $this->cloud_object->getDescription();
119  $values["online"] = $this->cloud_object->getOnline();
120  $values["root_folder"] = $this->cloud_object->getRootFolder();
121  $this->getPluginSettingsValues($values);
122  $this->form->setValuesByArray($values);
123  }
124 
125 
126  protected function getPluginSettingsValues(&$values){}
130  public function updateSettings()
131  {
132  global $tpl, $lng, $ilCtrl, $ilTabs;
133 
134  $ilTabs->activateTab("settings");
135 
136  try
137  {
138  $this->initSettingsForm();
139  if ($this->form->checkInput())
140  {
141  $this->cloud_object->setTitle($this->form->getInput("title"));
142  $this->cloud_object->setDescription($this->form->getInput("desc"));
143  $this->updatePluginSettings();
144  if (ilCloudUtil::normalizePath($this->form->getInput("root_folder")) != $this->cloud_object->getRootFolder())
145  {
146  $this->cloud_object->setRootFolder($this->form->getInput("root_folder"));
147  $this->cloud_object->setRootId($this->getService()->getRootId($this->cloud_object->getRootFolder()));
148  }
149 
150  $this->cloud_object->setOnline($this->form->getInput("online"));
151  $this->cloud_object->update();
152  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
153  $ilCtrl->redirect($this, 'editSettings');
154  }
155  } catch (Exception $e)
156  {
157  ilUtil::sendFailure($e->getMessage());
158  }
159 
160  $this->form->setValuesByPost();
161  $tpl->setContent($this->form->getHtml());
162  }
163  protected function updatePluginSettings(){}
164 
165 }
166 
167 ?>