ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjHelpSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObject2GUI.php");
5 
18 {
22  function getType()
23  {
24  return "hlps";
25  }
26 
33  public function executeCommand()
34  {
35  global $rbacsystem, $ilErr, $ilAccess, $lng;
36 
37  $lng->loadLanguageModule("help");
38 
39  $next_class = $this->ctrl->getNextClass($this);
40  $cmd = $this->ctrl->getCmd();
41 
42  $this->prepareOutput();
43 
44  if (!$ilAccess->checkAccess('read','',$this->object->getRefId()))
45  {
46  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
47  }
48 
49  switch($next_class)
50  {
51  case 'ilpermissiongui':
52  $this->tabs_gui->setTabActive('perm_settings');
53  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
54  $perm_gui =& new ilPermissionGUI($this);
55  $ret =& $this->ctrl->forwardCommand($perm_gui);
56  break;
57 
58  default:
59  if(!$cmd || $cmd == 'view')
60  {
61  $cmd = "editSettings";
62  }
63 
64  $this->$cmd();
65  break;
66  }
67  return true;
68  }
69 
73  public function editSettings()
74  {
75  global $ilCtrl, $lng, $ilSetting, $ilTabs, $ilToolbar;
76 
77  $ilTabs->activateTab("settings");
78 
79  if (OH_REF_ID > 0)
80  {
81  ilUtil::sendInfo("This installation is used for online help authoring. Help modules cannot be imported.");
82  return;
83  }
84 
85  if ($this->checkPermissionBool("write"))
86  {
87  // help file
88  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
89  $fi = new ilFileInputGUI($lng->txt("help_help_file"), "help_file");
90  $fi->setSuffixes(array("zip"));
91  $ilToolbar->addInputItem($fi, true);
92  $ilToolbar->addFormButton($lng->txt("upload"), "uploadHelpFile");
93  $ilToolbar->addSeparator();
94 
95  // help mode
96  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
97  $options = array(
98  "" => $lng->txt("help_tooltips_and_help"),
99  "1" => $lng->txt("help_help_only"),
100  "2" => $lng->txt("help_tooltips_only")
101  );
102  $si = new ilSelectInputGUI($this->lng->txt("help_mode"), "help_mode");
103  $si->setOptions($options);
104  $si->setValue($ilSetting->get("help_mode"));
105  $ilToolbar->addInputItem($si);
106 
107  $ilToolbar->addFormButton($lng->txt("help_set_mode"), "setMode");
108 
109  }
110  $ilToolbar->setFormAction($ilCtrl->getFormAction($this), true);
111 
112  include_once("./Services/Help/classes/class.ilHelpModuleTableGUI.php");
113  $tab = new ilHelpModuleTableGUI($this, "editSettings");
114 
115  $this->tpl->setContent($tab->getHTML());
116  }
117 
121  function getAdminTabs(&$tabs_gui)
122  {
123  global $tree;
124 
125  if ($this->checkPermissionBool("visible,read"))
126  {
127  $tabs_gui->addTab("settings",
128  $this->lng->txt("settings"),
129  $this->ctrl->getLinkTarget($this, "editSettings"));
130 
131  }
132 
133  if ($this->checkPermissionBool("edit_permission"))
134  {
135  $tabs_gui->addTab("perm_settings",
136  $this->lng->txt("perm_settings"),
137  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
138  );
139  }
140  }
141 
142 
143 
144 
151  function uploadHelpFile()
152  {
153  global $lng, $ilCtrl;
154 
155  if ($this->checkPermissionBool("write"))
156  {
157  $this->object->uploadHelpModule($_FILES["help_file"]);
158  ilUtil::sendSuccess($lng->txt("help_module_uploaded"), true);
159  }
160 
161  $ilCtrl->redirect($this, "editSettings");
162  }
163 
168  {
169  global $ilCtrl, $tpl, $lng;
170 
171  if (!is_array($_POST["id"]) || count($_POST["id"]) == 0)
172  {
173  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
174  $ilCtrl->redirect($this, "editSettings");
175  }
176  else
177  {
178  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
179  $cgui = new ilConfirmationGUI();
180  $cgui->setFormAction($ilCtrl->getFormAction($this));
181  $cgui->setHeaderText($lng->txt("help_sure_delete_help_modules"));
182  $cgui->setCancel($lng->txt("cancel"), "editSettings");
183  $cgui->setConfirm($lng->txt("delete"), "deleteHelpModules");
184 
185  foreach ($_POST["id"] as $i)
186  {
187  $cgui->addItem("id[]", $i, $this->object->lookupModuleTitle($i));
188  }
189 
190  $tpl->setContent($cgui->getHTML());
191  }
192  }
193 
200  function deleteHelpModules()
201  {
202  global $ilDB, $ilCtrl;
203 
204  if (is_array($_POST["id"]))
205  {
206  foreach ($_POST["id"] as $i)
207  {
208  $this->object->deleteModule((int) $i);
209  }
210  }
211 
212  $ilCtrl->redirect($this, "editSettings");
213  }
214 
221  function activateModule()
222  {
223  global $ilSetting, $lng, $ilCtrl;
224 
225  $ilSetting->set("help_module", (int) $_GET["hm_id"]);
226  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
227  $ilCtrl->redirect($this, "editSettings");
228  }
229 
236  function deactivateModule()
237  {
238  global $ilSetting, $lng, $ilCtrl;
239 
240  if ($ilSetting->get("help_module") == (int) $_GET["hm_id"])
241  {
242  $ilSetting->set("help_module", "");
243  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
244  }
245  $ilCtrl->redirect($this, "editSettings");
246  }
247 
254  function setMode()
255  {
256  global $lng, $ilCtrl, $ilSetting;
257 
258  if ($this->checkPermissionBool("write"))
259  {
260  $ilSetting->set("help_mode", ilUtil::stripSlashes($_POST["help_mode"]));
261  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
262  }
263 
264  $ilCtrl->redirect($this, "editSettings");
265  }
266 
267 
268 }
269 ?>