ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjExternalToolsSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "./classes/class.ilObjectGUI.php";
6 
7 
19 {
24  function ilObjExternalToolsSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
25  {
26  global $lng;
27 
28  $this->type = "extt";
29  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
30 
31  define ("ILINC_DEFAULT_HTTP_PORT",80);
32  define ("ILINC_DEFAULT_SSL_PORT",443);
33  define ("ILINC_DEFAULT_TIMEOUT",30);
34  $lng->loadLanguageModule("delic");
35  $lng->loadLanguageModule("gmaps");
36  $lng->loadLanguageModule("jsmath");
37  $lng->loadLanguageModule("excel");
38  }
39 
45  function viewObject()
46  {
47  global $rbacsystem;
48 
49  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
50  {
51  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
52  }
53 
54  $this->__initSubTabs("view");
55 
56  $this->getTemplateFile("general");
57 
58  $this->tpl->setVariable("FORMACTION",
59  $this->ctrl->getFormAction($this));
60  $this->tpl->setVariable("TXT_EXTT_TITLE", $this->lng->txt("extt_title_configure"));
61 
62  $this->tpl->setVariable("TXT_EXTT_NAME", $this->lng->txt("extt_name"));
63  $this->tpl->setVariable("TXT_EXTT_ACTIVE", $this->lng->txt("active")."?");
64  $this->tpl->setVariable("TXT_EXTT_DESC", $this->lng->txt("description"));
65 
66  $this->tpl->setVariable("TXT_CONFIGURE", $this->lng->txt("extt_configure"));
67  $this->tpl->setVariable("TXT_EXTT_REMARK", $this->lng->txt("extt_remark"));
68 
69  // ilinc
70  $this->tpl->setVariable("TXT_EXTT_ILINC_NAME", $this->lng->txt("extt_ilinc"));
71  $this->tpl->setVariable("TXT_EXTT_ILINC_DESC", $this->lng->txt("extt_ilinc_desc"));
72 
73 
74  // icon handlers
75  $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>";
76  $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.gif")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
77 
78  $this->tpl->setVariable("EXTT_ILINC_ACTIVE", $this->ilias->getSetting('ilinc_active') ? $icon_ok : $icon_not_ok);
79  }
80 
81  function cancelObject()
82  {
83  $this->ctrl->redirect($this, "view");
84  }
85 
86  function getAdminTabs(&$tabs_gui)
87  {
88  $this->getTabs($tabs_gui);
89  }
90 
96  function getTabs(&$tabs_gui)
97  {
98  global $rbacsystem;
99 
100  $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
101 
102  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
103  {
104  $tabs_gui->addTarget("settings",
105  $this->ctrl->getLinkTarget($this, "view"),
106  array("view","editiLinc","editDelicious", "editGoogleMaps","editjsMath","editExcel", ""), "", "");
107 
108  $this->lng->loadLanguageModule('ecs');
109  $tabs_gui->addTarget('ecs_server_settings',
110  $this->ctrl->getLinkTargetByClass('ilecssettingsgui','settings'));
111 
112  }
113 
114  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
115  {
116  $tabs_gui->addTarget("perm_settings",
117  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
118  }
119  }
120 
126  function editiLincObject()
127  {
128  global $rbacsystem, $rbacreview;
129 
130  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
131  {
132  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
133  }
134 
135  $this->__initSubTabs("editiLinc");
136 
137  if ($_SESSION["error_post_vars"])
138  {
139  if ($_SESSION["error_post_vars"]["ilinc"]["active"] == "1")
140  {
141  $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
142  }
143 
144  if ($_SESSION["error_post_vars"]["ilinc"]["akclassvalues_active"] == "1")
145  {
146  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_ACTIVE", "checked=\"checked\"");
147  }
148 
149  if ($_SESSION["error_post_vars"]["ilinc"]["akclassvalues_required"] == "1")
150  {
151  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_REQUIRED", "checked=\"checked\"");
152  }
153 
154  $this->tpl->setVariable("ILINC_SERVER", $_SESSION["error_post_vars"]["ilinc"]["server"]);
155  $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $_SESSION["error_post_vars"]["ilinc"]["registrar_login"]);
156  $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $_SESSION["error_post_vars"]["ilinc"]["registrar_passwd"]);
157  $this->tpl->setVariable("ILINC_CUSTOMER_ID", $_SESSION["error_post_vars"]["ilinc"]["customer_id"]);
158  }
159  else
160  {
161  // set already saved data or default value for port
162  $settings = $this->ilias->getAllSettings();
163 
164  if ($settings["ilinc_active"] == "1")
165  {
166  $this->tpl->setVariable("CHK_ILINC_ACTIVE", "checked=\"checked\"");
167  }
168 
169  $this->tpl->setVariable("ILINC_SERVER", $settings["ilinc_server"].$settings["ilinc_path"]);
170  $this->tpl->setVariable("ILINC_REGISTRAR_LOGIN", $settings["ilinc_registrar_login"]);
171  $this->tpl->setVariable("ILINC_REGISTRAR_PASSWD", $settings["ilinc_registrar_passwd"]);
172  $this->tpl->setVariable("ILINC_CUSTOMER_ID", $settings["ilinc_customer_id"]);
173 
174  if (empty($settings["ilinc_port"]))
175  {
176  $this->tpl->setVariable("ILINC_PORT", ILINC_DEFAULT_HTTP_PORT);
177  }
178  else
179  {
180  $this->tpl->setVariable("ILINC_PORT", $settings["ilinc_port"]);
181  }
182 
183  if ($settings["ilinc_protocol"] == "https")
184  {
185  $this->tpl->setVariable("ILINC_PROTOCOL_SSL_SEL", "selected=\"selected\"");
186  }
187  else
188  {
189  $this->tpl->setVariable("ILINC_PROTOCOL_HTTP_SEL", "selected=\"selected\"");
190  }
191 
192  if (empty($settings["ilinc_timeout"]))
193  {
194  $this->tpl->setVariable("ILINC_TIMEOUT", ILINC_DEFAULT_TIMEOUT);
195  }
196  else
197  {
198  $this->tpl->setVariable("ILINC_TIMEOUT", $settings["ilinc_timeout"]);
199  }
200 
201  if ($settings["ilinc_akclassvalues_active"] == "1")
202  {
203  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_ACTIVE", "checked=\"checked\"");
204  }
205 
206  if ($settings["ilinc_akclassvalues_required"] == "1")
207  {
208  $this->tpl->setVariable("CHK_ILINC_AKCLASSVALUES_REQUIRED", "checked=\"checked\"");
209  }
210  }
211 
212  $this->getTemplateFile("ilinc");
213 
214  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
215  $this->tpl->setVariable("TXT_ILINC_TITLE", $this->lng->txt("extt_ilinc_configure"));
216  $this->tpl->setVariable("TXT_ILINC_ACTIVE", $this->lng->txt("extt_ilinc_enable"));
217  $this->tpl->setVariable("TXT_ILINC_CONNECTION_DATA", $this->lng->txt("extt_ilinc_connection_data"));
218  $this->tpl->setVariable("TXT_ILINC_ADDITIONAL_OPTIONS", $this->lng->txt("extt_ilinc_additional_options"));
219  $this->tpl->setVariable("TXT_ILINC_SERVER", $this->lng->txt("extt_ilinc_server"));
220  $this->tpl->setVariable("TXT_ILINC_PROTOCOL_PORT", $this->lng->txt("extt_ilinc_protocol_port"));
221  $this->tpl->setVariable("TXT_ILINC_TIMEOUT", $this->lng->txt("extt_ilinc_timeout"));
222  $this->tpl->setVariable("ILINC_DEFAULT_HTTP_PORT", ILINC_DEFAULT_HTTP_PORT);
223  $this->tpl->setVariable("ILINC_DEFAULT_SSL_PORT", ILINC_DEFAULT_SSL_PORT);
224  $this->tpl->setVariable("TXT_HTTP", $this->lng->txt('http'));
225  $this->tpl->setVariable("TXT_SSL", $this->lng->txt('ssl'));
226 
227  $this->tpl->setVariable("TXT_SECONDS", $this->lng->txt("seconds"));
228  $this->tpl->setVariable("TXT_ILINC_REGISTRAR_LOGIN", $this->lng->txt("extt_ilinc_registrar_login"));
229  $this->tpl->setVariable("TXT_ILINC_REGISTRAR_PASSWD", $this->lng->txt("extt_ilinc_registrar_passwd"));
230  $this->tpl->setVariable("TXT_ILINC_CUSTOMER_ID", $this->lng->txt("extt_ilinc_customer_id"));
231 
232  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_ACTIVE", $this->lng->txt("extt_ilinc_akclassvalues_active"));
233  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_ACTIVE_INFO", $this->lng->txt("extt_ilinc_akclassvalues_active_info"));
234  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_REQUIRED", $this->lng->txt("extt_ilinc_akclassvalues_required"));
235  $this->tpl->setVariable("TXT_ILINC_AKCLASSVALUES_REQUIRED_INFO", $this->lng->txt("extt_ilinc_akclassvalues_required_info"));
236 
237  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
238  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
239  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
240  $this->tpl->setVariable("CMD_SUBMIT", "saveiLinc");
241  }
242 
248  function saveiLincObject()
249  {
250  global $ilUser;
251 
252  // validate required data
253  if (!$_POST["ilinc"]["server"] or !$_POST["ilinc"]["port"] or !$_POST["ilinc"]["registrar_login"] or !$_POST["ilinc"]["registrar_passwd"] or !$_POST["ilinc"]["customer_id"])
254  {
255  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
256  }
257 
258  // validate port
259  if ((preg_match("/^[0-9]{0,5}$/",$_POST["ilinc"]["port"])) == false)
260  {
261  $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
262  }
263 
264  if (substr($_POST["ilinc"]["server"],0,8) != "https://" and substr($_POST["ilinc"]["server"],0,7) != "http://")
265  {
266  $_POST["ilinc"]["server"] = $_POST["ilinc"]["protocol"]."://".$_POST["ilinc"]["server"];
267  }
268 
269  $url = parse_url($_POST["ilinc"]["server"]);
270 
271  if (!ilUtil::isIPv4($url["host"]) and !ilUtil::isDN($url["host"]))
272  {
273  $this->ilias->raiseError($this->lng->txt("err_invalid_server"),$this->ilias->error_obj->MESSAGE);
274  }
275 
276  if (is_numeric($_POST["ilinc"]["timeout"]))
277  {
278  $this->ilias->setSetting("ilinc_timeout", $_POST["ilinc"]["timeout"]);
279  }
280 
281  // all ok. save settings
282  $this->ilias->setSetting("ilinc_server", $url["host"]);
283  $this->ilias->setSetting("ilinc_path", $url["path"]);
284  $this->ilias->setSetting("ilinc_protocol", $_POST["ilinc"]["protocol"]);
285  $this->ilias->setSetting("ilinc_port", $_POST["ilinc"]["port"]);
286  $this->ilias->setSetting("ilinc_active", $_POST["ilinc"]["active"]);
287  $this->ilias->setSetting("ilinc_registrar_login", $_POST["ilinc"]["registrar_login"]);
288  $this->ilias->setSetting("ilinc_registrar_passwd", $_POST["ilinc"]["registrar_passwd"]);
289  $this->ilias->setSetting("ilinc_customer_id", $_POST["ilinc"]["customer_id"]);
290 
291  $this->ilias->setSetting("ilinc_akclassvalues_active", $_POST["ilinc"]["akclassvalues_active"]);
292  $this->ilias->setSetting("ilinc_akclassvalues_required", $_POST["ilinc"]["akclassvalues_required"]);
293 
294  ilUtil::sendSuccess($this->lng->txt("extt_ilinc_settings_saved"),true);
295  $this->ctrl->redirect($this,'editiLinc');
296  }
297 
299  {
300  global $ilAccess, $rbacreview, $lng, $ilCtrl;
301 
302  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
303  {
304  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
305  }
306 
307  $this->__initSubTabs("editSocialBookmarks");
308 
309  include_once 'class.ilSocialBookmarks.php';
310  $form = ilSocialBookmarks::_initForm($this, 'create');
311  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
312  }
313 
315  {
316  global $ilAccess, $rbacreview, $lng, $ilCtrl;
317 
318  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
319  {
320  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
321  }
322 
323  include_once 'class.ilSocialBookmarks.php';
324  $form = ilSocialBookmarks::_initForm($this, 'create');
325  if ($form->checkInput())
326  {
327  $title = $form->getInput('title');
328  $link = $form->getInput('link');
329  $file = $form->getInput('image_file');
330  $active = $form->getInput('activate');
331 
332  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
333  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
334 
335  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
336  if (!is_dir($path))
338 
339  ilSocialBookmarks::_insertSocialBookmark($title, $link, $active, $icon_path);
340 
341  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
342 
343  $this->editSocialBookmarksObject();
344  }
345  else
346  {
347  $this->__initSubTabs("editSocialBookmarks");
348  $form->setValuesByPost();
349  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
350  }
351  }
352 
354  {
355  global $ilAccess, $rbacreview, $lng, $ilCtrl;
356 
357  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
358  {
359  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
360  }
361 
362  include_once 'class.ilSocialBookmarks.php';
363  $form = ilSocialBookmarks::_initForm($this, 'update');
364  if ($form->checkInput())
365  {
366  $title = $form->getInput('title');
367  $link = $form->getInput('link');
368  $file = $form->getInput('image_file');
369  $active = $form->getInput('activate');
370  $id = $form->getInput('sbm_id');
371 
372  if (!$file['name'])
373  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active);
374  else
375  {
376  $extension = pathinfo($file['name'], PATHINFO_EXTENSION);
377  $icon_path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons' . DIRECTORY_SEPARATOR . time() . '.' . $extension;
378 
379  $path = ilUtil::getWebspaceDir() . DIRECTORY_SEPARATOR . 'social_bm_icons';
380  if (!is_dir($path))
382 
384  ilSocialBookmarks::_updateSocialBookmark($id, $title, $link, $active, $icon_path);
385  ilUtil::moveUploadedFile($file['tmp_name'], $file['name'], $icon_path);
386  }
387 
388  $this->editSocialBookmarksObject();
389  }
390  else
391  {
392  $this->__initSubTabs("editSocialBookmarks");
393  $form->setValuesByPost();
394  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
395  }
396  }
397 
404  {
405  global $ilAccess, $rbacreview, $lng, $ilCtrl;
406 
407  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
408  {
409  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
410  }
411 
412  $this->__initSubTabs("editSocialBookmarks");
413 
414  include_once 'class.ilSocialBookmarks.php';
416  $dset = array
417  (
418  'sbm_id' => $row->sbm_id,
419  'title' => $row->sbm_title,
420  'link' => $row->sbm_link,
421  'activate' => $row->sbm_active
422  );
423 
424  $form = ilSocialBookmarks::_initForm($this, 'update');
425  $form->setValuesByArray($dset);
426  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
427  }
428 
430  {
431  global $ilAccess, $rbacreview, $lng, $ilCtrl;
432 
433  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
434  {
435  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
436  }
437 
438  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
439  include_once 'class.ilSocialBookmarks.php';
440  ilSocialBookmarks::_setActive($ids, true);
441  $this->editSocialBookmarksObject();
442  }
443 
445  {
446  global $ilAccess, $rbacreview, $lng, $ilCtrl;
447 
448  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
449  {
450  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
451 
452  }
453  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
454  include_once 'class.ilSocialBookmarks.php';
455  ilSocialBookmarks::_setActive($ids, false);
456  $this->editSocialBookmarksObject();
457  }
458 
460  {
461  global $ilAccess, $rbacreview, $lng, $ilCtrl;
462 
463  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
464  {
465  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
466 
467  }
468 
469  $this->__initSubTabs("editSocialBookmarks");
470 
471  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
472  $c_gui = new ilConfirmationGUI();
473 
474  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
475 
476  // set confirm/cancel commands
477  $c_gui->setFormAction($ilCtrl->getFormAction($this, "confirmDeleteSocialBookmarks"));
478  $c_gui->setHeaderText($lng->txt("socialbm_sure_delete_entry"));
479  $c_gui->setCancel($lng->txt("cancel"), "editSocialBookmarks");
480  $c_gui->setConfirm($lng->txt("confirm"), "confirmDeleteSocialBookmarks");
481 
482  include_once 'class.ilSocialBookmarks.php';
483  // add items to delete
484  foreach($ids as $id)
485  {
486  $entry = ilSocialBookmarks::_getEntry($id);
487  $c_gui->addItem("sbm_id[]", $id, $entry->sbm_title . ' (' . str_replace('{', '&#123;', $entry->sbm_link) . ')');
488  }
489 
490  $this->tpl->setVariable('ADM_CONTENT', $c_gui->getHTML());
491  }
492 
494  {
495  global $ilAccess, $rbacreview, $lng, $ilCtrl;
496 
497  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
498  {
499  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
500  }
501 
502 
503  $ids = ((int)$_GET['sbm_id']) ? array((int)$_GET['sbm_id']) : $_POST['sbm_id'];
504  include_once 'class.ilSocialBookmarks.php';
505  ilSocialBookmarks::_delete($ids, false);
506  $this->editSocialBookmarksObject();
507  }
508 
515  {
516  global $ilAccess, $rbacreview, $lng, $ilCtrl;
517 
518  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
519  {
520  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
521  }
522 
523  $this->__initSubTabs("editSocialBookmarks");
524 
525 
526 
527  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
528 
529  include_once 'class.ilSocialBookmarks.php';
531 
532  $counter = 0;
533  foreach($rset as $row)
534  {
535  $current_selection_list = new ilAdvancedSelectionListGUI();
536  $current_selection_list->setListTitle($lng->txt("actions"));
537  $current_selection_list->setId("act_".$counter++);
538 
539  $ilCtrl->setParameter($this, 'sbm_id', $row->sbm_id);
540 
541  $current_selection_list->addItem($lng->txt("edit"), '', $ilCtrl->getLinkTarget($this, "editSocialBookmark"));
542  $current_selection_list->addItem($lng->txt("delete"), '', $ilCtrl->getLinkTarget($this, "deleteSocialBookmarks"));
543 
544  $toggle_action = '';
545  if ($row->sbm_active)
546  {
547  $current_selection_list->addItem($lng->txt("socialbm_disable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "disableSocialBookmarks"));
548  }
549  else
550  {
551  $current_selection_list->addItem($lng->txt("socialbm_enable"), '', $toggle_action = $ilCtrl->getLinkTarget($this, "enableSocialBookmarks"));
552  }
553 
554 
555 
556  $dset[] = array
557  (
558  'CHECK' => ilUtil::formCheckbox(0, 'sbm_id[]', $row->sbm_id),
559  'ID' => $row->sbm_id,
560  'TITLE' => $row->sbm_title,
561  'LINK' => str_replace('{', '&#123;', $row->sbm_link),
562  'ICON' => $row->sbm_icon,
563  'ACTIVE' => $row->sbm_active ? $lng->txt('enabled') : $lng->txt('disabled'),
564  'ACTIONS' => $current_selection_list->getHTML(),
565  'TOGGLE_LINK' => $toggle_action
566  );
567  $ilCtrl->clearParameters($this);
568  }
569 
570  require_once 'Services/Table/classes/class.ilTable2GUI.php';
571  $table = new ilTable2GUI($this, 'editSocialBookmarks');
572  $table->setFormName('smtable');
573  $table->setId('smtable');
574  $table->setPrefix('sm');
575  $table->setFormAction($ilCtrl->getFormAction($this, 'saveSocialBookmarks'));
576  $table->addColumn('', 'check', '', true);
577  $table->addColumn($lng->txt('icon'), '');
578  $table->addColumn($lng->txt('title'), 'TITLE');
579  $table->addColumn($lng->txt('link'), 'LINK');
580  $table->addColumn($lng->txt('active'), 'ACTIVE');
581  $table->addColumn($lng->txt('actions'), '');
582  $table->setTitle($lng->txt('bm_manage_social_bm'));
583  $table->setData($dset);
584  $table->setRowTemplate('tpl.social_bookmarking_row.html', 'Services/Administration');
585  $table->setSelectAllCheckbox('sbm_id');
586 
587  $table->setDefaultOrderField("title");
588  $table->setDefaultOrderDirection("asc");
589 
590  $table->addMultiCommand('enableSocialBookmarks', $lng->txt('socialbm_enable'));
591  $table->addMultiCommand('disableSocialBookmarks', $lng->txt('socialbm_disable'));
592  $table->addMultiCommand('deleteSocialBookmarks', $lng->txt('delete'));
593 
594  $table->addCommandButton('addSocialBookmark', $lng->txt('create'));
595 
596  $this->tpl->setVariable('ADM_CONTENT', $table->getHTML());
597  }
598 
599 
605  function editjsMathObject()
606  {
607  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
608 
609  $jsMathSetting = new ilSetting("jsMath");
610  $path_to_jsmath = array_key_exists("path_to_jsmath", $_GET) ? $_GET["path_to_jsmath"] : $jsMathSetting->get("path_to_jsmath");
611 
612  $this->__initSubTabs("editjsMath");
613 
614  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
615  $form = new ilPropertyFormGUI();
616  $form->setFormAction($ilCtrl->getFormAction($this));
617  $form->setTitle($lng->txt("jsmath_settings"));
618 
619  // Enable jsMath
620  $enable = new ilCheckboxInputGUI($lng->txt("jsmath_enable_jsmath"), "enable");
621  $enable->setChecked($jsMathSetting->get("enable"));
622  $enable->setInfo($lng->txt("jsmath_enable_jsmath_info"));
623  $form->addItem($enable);
624  // Path to jsMath
625  $text_prop = new ilTextInputGUI($lng->txt("jsmath_path_to_jsmath"), "path_to_jsmath");
626  $text_prop->setInfo($lng->txt("jsmath_path_to_jsmath_desc"));
627  $text_prop->setValue($path_to_jsmath);
628  $text_prop->setRequired(TRUE);
629  $text_prop->setMaxLength(400);
630  $text_prop->setSize(80);
631  $form->addItem($text_prop);
632  // jsMath as default
633  $enable = new ilCheckboxInputGUI($lng->txt("jsmath_default_setting"), "makedefault");
634  $enable->setChecked($jsMathSetting->get("makedefault"));
635  $enable->setInfo($lng->txt("jsmath_default_setting_info"));
636  $form->addItem($enable);
637 
638  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
639  {
640  $form->addCommandButton("savejsMath", $lng->txt("save"));
641  }
642 
643  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
644  }
645 
651  function editExcelObject()
652  {
653  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
654 
655  $excelSetting = new ilSetting("excel");
656  $this->__initSubTabs("editExcel");
657 
658  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
659  $form = new ilPropertyFormGUI();
660  $form->setFormAction($ilCtrl->getFormAction($this));
661  $form->setTitle($lng->txt("excel_settings"));
662 
663  // Choose creator
664  $enable = new ilSelectInputGUI($lng->txt("excel_creator"), "creator");
665  $enable->setOptions(array('xls' => $lng->txt('excel_creator_xls'), 'xlsx' => $lng->txt('excel_creator_xlsx')));
666  $enable->setInfo($lng->txt("excel_creator_info"));
667  if (!(extension_loaded('zip') && extension_loaded('xml')))
668  {
669  $enable->setValue('xls');
670  $enable->setDisabled(true);
671  }
672  else
673  {
674  $enable->setValue($excelSetting->get('creator'));
675  $enable->setDisabled(false);
676  }
677  $form->addItem($enable);
678 
679  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
680  {
681  $form->addCommandButton("saveExcel", $lng->txt("save"));
682  }
683 
684  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
685  }
686 
690  function saveExcelObject()
691  {
692  global $ilCtrl;
693 
694  $excelSetting = new ilSetting("excel");
695  $excelSetting->set("creator", strlen($_POST["creator"]) ? $_POST["creator"] : 'xls');
696  ilUtil::sendSuccess($this->lng->txt("settings_saved"), TRUE);
697  $ilCtrl->redirect($this, "editExcel");
698  }
699 
703  function savejsMathObject()
704  {
705  global $ilCtrl;
706  $error = FALSE;
707 
708  $path_to_jsmath = ilUtil::stripSlashes($_POST["path_to_jsmath"]);
709  while (strrpos($path_to_jsmath, "/") == strlen($path_to_jsmath)-1)
710  {
711  $path_to_jsmath = substr($path_to_jsmath, 0, strlen($path_to_jsmath)-1);
712  }
713  // check jsmath path
714  if (file_exists($path_to_jsmath . "/" . "jsMath.js"))
715  {
716  }
717  else
718  {
719  $error = TRUE;
720  if (strlen($path_to_jsmath) == 0)
721  {
722  ilUtil::sendFailure($this->lng->txt("fill_out_all_required_fields"), TRUE);
723  }
724  else
725  {
726  $ilCtrl->setParameter($this, "path_to_jsmath", $path_to_jsmath);
727  ilUtil::sendFailure($this->lng->txt("jsmath_path_not_found"), TRUE);
728  }
729  }
730 
731  if (!$error)
732  {
733  $jsMathSetting = new ilSetting("jsMath");
734  $jsMathSetting->set("path_to_jsmath", $path_to_jsmath);
735  $jsMathSetting->set("enable", ilUtil::stripSlashes($_POST["enable"]));
736  $jsMathSetting->set("makedefault", ilUtil::stripSlashes($_POST["makedefault"]));
737  }
738 
739  $ilCtrl->redirect($this, "editjsMath");
740  }
741 
748  {
749  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
750 
751  $gm_set = new ilSetting("google_maps");
752 
753  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
754  {
755  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
756  }
757 
758  $this->__initSubTabs("editGoogleMaps");
759 
760  $api_key = $gm_set->get("api_key");
761  $std_latitude = $gm_set->get("std_latitude");
762  $std_longitude = $gm_set->get("std_longitude");
763  $std_zoom = $gm_set->get("std_zoom");
764  $api_url = "http://www.google.com/apis/maps/signup.html";
765 
766  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
767  $form = new ilPropertyFormGUI();
768  $form->setFormAction($ilCtrl->getFormAction($this));
769  $form->setTitle($lng->txt("gmaps_settings"));
770 
771  // Enable Google Maps
772  $enable = new ilCheckboxInputGUI($lng->txt("gmaps_enable_gmaps"), "enable");
773  $enable->setChecked($gm_set->get("enable"));
774  $enable->setInfo($lng->txt("gmaps_enable_gmaps_info"));
775  $form->addItem($enable);
776 
777  // API key
778  $text_prop = new ilTextInputGUI($lng->txt("gmaps_api_key"), "api_key");
779  $text_prop->setInfo($lng->txt("gmaps_api_key_desc").' <a href="'.$api_url.'" target="_blank">'.$api_url.'</a>');
780  $text_prop->setValue($api_key);
781  $text_prop->setRequired(false);
782  $text_prop->setMaxLength(200);
783  $text_prop->setSize(60);
784  $form->addItem($text_prop);
785 
786  // location property
787  $loc_prop = new ilLocationInputGUI($lng->txt("gmaps_std_location"),
788  "std_location");
789  $loc_prop->setLatitude($std_latitude);
790  $loc_prop->setLongitude($std_longitude);
791  $loc_prop->setZoom($std_zoom);
792  $form->addItem($loc_prop);
793 
794  $form->addCommandButton("saveGoogleMaps", $lng->txt("save"));
795  $form->addCommandButton("view", $lng->txt("cancel"));
796 
797  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
798  }
799 
800 
805  {
806  global $ilCtrl;
807 
808  $gm_set = new ilSetting("google_maps");
809 
810  $gm_set->set("enable", ilUtil::stripSlashes($_POST["enable"]));
811  $gm_set->set("api_key", ilUtil::stripSlashes($_POST["api_key"]));
812  $gm_set->set("std_latitude", ilUtil::stripSlashes($_POST["std_location"]["latitude"]));
813  $gm_set->set("std_longitude", ilUtil::stripSlashes($_POST["std_location"]["longitude"]));
814  $gm_set->set("std_zoom", ilUtil::stripSlashes($_POST["std_location"]["zoom"]));
815 
816  $ilCtrl->redirect($this, "editGoogleMaps");
817  }
818 
819  // init sub tabs
820  function __initSubTabs($a_cmd)
821  {
822  $ilinc = ($a_cmd == 'editiLinc') ? true : false;
823  $overview = ($a_cmd == 'view' or $a_cmd == '') ? true : false;
824  //$delicious = ($a_cmd == 'editDelicious') ? true : false;
825  $socialbookmarks = ($a_cmd == 'editSocialBookmarks') ? true : false;
826  $gmaps = ($a_cmd == 'editGoogleMaps') ? true : false;
827  $jsmath = ($a_cmd == 'editjsMath') ? true : false;
828  $excel = ($a_cmd == 'editExcel') ? true : false;
829 
830  $this->tabs_gui->addSubTabTarget("overview", $this->ctrl->getLinkTarget($this, "view"),
831  "", "", "", $overview);
832  /*$this->tabs_gui->addSubTabTarget("delic_extt_delicious", $this->ctrl->getLinkTarget($this, "editDelicious"),
833  "", "", "", $delicious);*/
834  $this->tabs_gui->addSubTabTarget("socialbm_extt_social_bookmarks", $this->ctrl->getLinkTarget($this, "editSocialBookmarks"),
835  "", "", "", $socialbookmarks);
836  $this->tabs_gui->addSubTabTarget("jsmath_extt_jsmath", $this->ctrl->getLinkTarget($this, "editjsMath"),
837  "", "", "", $jsmath);
838  $this->tabs_gui->addSubTabTarget("excel_extt_excel", $this->ctrl->getLinkTarget($this, "editExcel"),
839  "", "", "", $excel);
840  $this->tabs_gui->addSubTabTarget("gmaps_extt_gmaps", $this->ctrl->getLinkTarget($this, "editGoogleMaps"),
841  "", "", "", $gmaps);
842  $this->tabs_gui->addSubTabTarget("extt_ilinc", $this->ctrl->getLinkTarget($this, "editiLinc"),
843  "", "", "", $ilinc);
844  }
845 
846  function &executeCommand()
847  {
848 
849  $next_class = $this->ctrl->getNextClass($this);
850  $cmd = $this->ctrl->getCmd();
851  $this->prepareOutput();
852 
853  switch($next_class)
854  {
855  case 'ilecssettingsgui':
856  include_once('./Services/WebServices/ECS/classes/class.ilECSSettingsGUI.php');
857  $this->ctrl->forwardCommand(new ilECSSettingsGUI());
858  $this->tabs_gui->setTabActive('ecs_server_settings');
859  break;
860 
861  case 'ilpermissiongui':
862  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
863  $perm_gui =& new ilPermissionGUI($this);
864  $ret =& $this->ctrl->forwardCommand($perm_gui);
865  $this->tabs_gui->setTabActive('perm_settings');
866  break;
867 
868  default:
869  $this->tabs_gui->setTabActive('settings');
870  if(!$cmd)
871  {
872  $cmd = "view";
873  }
874  $cmd .= "Object";
875  $this->$cmd();
876 
877  break;
878  }
879  return true;
880  }
881 
882 } // END class.ilObjExternalToolsSettingsGUI
883 ?>