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