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