ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSearchSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
36 require_once "classes/class.ilObjectGUI.php";
37 
39 {
44  function ilObjSearchSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
45  {
46  $this->type = "seas";
47  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
48 
49  $this->lng->loadLanguageModule('search');
50  }
51 
52  function &executeCommand()
53  {
54  $next_class = $this->ctrl->getNextClass($this);
55  $cmd = $this->ctrl->getCmd();
56  $this->prepareOutput();
57 
58  switch($next_class)
59  {
60  case 'ilpermissiongui':
61  include_once("./classes/class.ilPermissionGUI.php");
62  $perm_gui =& new ilPermissionGUI($this);
63  $ret =& $this->ctrl->forwardCommand($perm_gui);
64  break;
65 
66  default:
67  if($cmd == "" || $cmd == "view")
68  {
69  $cmd = "settings";
70  }
71  $cmd .= "Object";
72  $this->$cmd();
73 
74  break;
75  }
76  return true;
77  }
78 
79  function cancelObject()
80  {
81  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
82  $this->ctrl->redirect($this, "settings");
83  }
84 
89  function settingsObject()
90  {
91  global $rbacsystem;
92 
93  include_once 'Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
94 
95  $rpc_settings =& new ilRPCServerSettings();
96 
97  if(!$rbacsystem->checkAccess('read',$this->object->getRefId()))
98  {
99  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
100  }
101 
102  $this->object->initSettingsObject();
103 
104  $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.seas_settings.html','Services/Search');
105 
106  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
107  $this->tpl->setVariable("TXT_SEAS_TITLE",$this->lng->txt('seas_settings'));
108 
109  // Max hits
110  $this->tpl->setVariable("TXT_MAX_HITS",$this->lng->txt('seas_max_hits'));
111  $this->tpl->setVariable("TXT_MAX_HITS_INFO",$this->lng->txt('seas_max_hits_info'));
112  for($i = 10; $i <= 100; $i += 10)
113  {
114  $max_hits[$i] = $i;
115  }
116  $this->tpl->setVariable('SELECT_MAX_HITS',ilUtil::formSelect($this->object->settings_obj->getMaxHits(),
117  'max_hits',
118  $max_hits,false,true));
119 
120  $this->tpl->setVariable("TXT_DIRECT",$this->lng->txt('search_direct'));
121  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt('search_index'));
122 
123  $this->tpl->setVariable("TXT_TYPE",$this->lng->txt('search_type'));
124  $this->tpl->setVariable("TXT_LIKE_INFO",$this->lng->txt('search_like_info'));
125  $this->tpl->setVariable("TXT_FULL_INFO",$this->lng->txt('search_full_info'));
126 
127  $this->tpl->setVariable("RADIO_TYPE_LIKE",ilUtil::formRadioButton($this->object->settings_obj->enabledIndex() ? 0 : 1,
128  'search_index',0));
129 
130  $this->tpl->setVariable("RADIO_TYPE_FULL",ilUtil::formRadioButton($this->object->settings_obj->enabledIndex() ? 1 : 0,
131  'search_index',1));
132 
133  // Lucene
134  $this->tpl->setVariable("TXT_LUCENE",$this->lng->txt('search_lucene'));
135  $this->tpl->setVariable("TXT_LUCENE_INFO",$this->lng->txt('search_lucene_info'));
136 
137  $this->tpl->setVariable("CHECK_TYPE_LUCENE",ilUtil::formCheckBox($this->object->settings_obj->enabledLucene() ? 1 : 0,
138  'search_lucene',1));
139  $this->tpl->setVariable("LUCENE_HOST",ilUtil::prepareFormOutput($rpc_settings->getHost()));
140  $this->tpl->setVariable("LUCENE_PORT",ilUtil::prepareFormOutput($rpc_settings->getPort()));
141 
142 
143  $this->tpl->setVariable("CMD_SUBMIT",'saveSettings');
144  $this->tpl->setVariable("TXT_SUBMIT",$this->lng->txt('save'));
145  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
146 
147  return true;
148  }
149 
155  {
156  include_once 'Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
157 
158  global $rbacsystem;
159 
160  if(!$rbacsystem->checkAccess('write',$this->object->getRefId()))
161  {
162  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
163  }
164 
165  $this->object->initSettingsObject();
166  $this->object->settings_obj->setMaxHits((int) $_POST['max_hits']);
167  $this->object->settings_obj->enableIndex($_POST['search_index']);
168  $this->object->settings_obj->enableLucene($_POST['search_lucene']);
169 
170  $rpc_settings =& new ilRPCServerSettings();
171  if($this->object->settings_obj->enabledLucene() and !$rpc_settings->pingServer())
172  {
173  ilUtil::sendInfo($this->lng->txt('search_no_connection_lucene'),true);
174  $this->ctrl->redirect($this,'settings');
175 
176  return false;
177  }
178 
179  $this->object->settings_obj->update();
180 
181  ilUtil::sendInfo($this->lng->txt('settings_saved'),true);
182  $this->ctrl->redirect($this,'settings');
183 
184  return true;
185  }
186 
187  function getAdminTabs(&$tabs_gui)
188  {
189  $this->getTabs($tabs_gui);
190  }
191 
197  function getTabs(&$tabs_gui)
198  {
199  global $rbacsystem;
200 
201  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
202  {
203  $tabs_gui->addTarget("settings",
204  $this->ctrl->getLinkTarget($this, "settings"), array("settings","", "view"), "", "");
205  }
206 
207  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
208  {
209  $tabs_gui->addTarget("perm_settings",
210  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
211  }
212  }
213 } // END class.ilObjSearchSettingsGUI
214 ?>