ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjSurveyAdministrationGUI.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 include_once "./Services/Object/classes/class.ilObjectGUI.php";
25 
39 {
45 
46  function ilObjSurveyAdministrationGUI($a_data,$a_id,$a_call_by_reference)
47  {
48  global $rbacsystem, $lng;
49 
50  $this->type = "svyf";
51  $lng->loadLanguageModule("survey");
52  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
53  }
54 
55  function &executeCommand()
56  {
57  global $ilTabs;
58 
59  $next_class = $this->ctrl->getNextClass($this);
60  $cmd = $this->ctrl->getCmd();
61  $this->prepareOutput();
62 
63  switch($next_class)
64  {
65  case 'ilpermissiongui':
66  $ilTabs->activateTab("perm_settings");
67  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
68  $perm_gui =& new ilPermissionGUI($this);
69  $ret =& $this->ctrl->forwardCommand($perm_gui);
70  break;
71 
72  case 'ilsettingstemplategui':
73  $ilTabs->activateTab("templates");
74  include_once("./Services/Administration/classes/class.ilSettingsTemplateGUI.php");
75  $set_tpl_gui = new ilSettingsTemplateGUI($this->getSettingsTemplateConfig());
76  $this->ctrl->forwardCommand($set_tpl_gui);
77  break;
78 
79  default:
80  if($cmd == "" || $cmd == "view")
81  {
82  $cmd = "settings";
83  }
84  $cmd .= "Object";
85  $this->$cmd();
86 
87  break;
88  }
89  return true;
90  }
91 
92 
97  function saveObject()
98  {
99  global $rbacadmin;
100 
101  // create and insert forum in objecttree
102  $newObj = parent::saveObject();
103 
104  // put here object specific stuff
105 
106  // always send a message
107  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
108 
109  $this->ctrl->redirect($this);
110  }
111 
112  function searchObject()
113  {
114  unset($_SESSION["survey_adm_found_users"]);
115  if (strlen($_POST["search"]) < 2)
116  {
117  ilUtil::sendInfo($this->lng->txt("adm_search_string_too_small"), TRUE);
118  }
119  else
120  {
121  include_once "./Services/User/classes/class.ilObjUser.php";
122  $found = ilObjUser::searchUsers($_POST["search"], $active = 1, $a_return_ids_only = false, $filter_settings = FALSE);
123  if (count($found))
124  {
125  $_SESSION["survey_adm_found_users"] = $found;
126  }
127  else
128  {
129  ilUtil::sendInfo($this->lng->txt("adm_no_users_found"), TRUE);
130 
131  }
132  }
133  $this->ctrl->redirect($this, "specialusers");
134  }
135 
141  {
142  // #7927: special users are deprecated
143  exit();
144 
145  /*
146  if ((array_key_exists("user_id", $_POST)) && (count($_POST["user_id"])))
147  {
148  $this->object->addSpecialUsers($_POST["user_id"]);
149  unset($_SESSION["survey_adm_found_users"]);
150  }
151  else
152  {
153  ilUtil::sendInfo($this->lng->txt("adm_search_select_user"), TRUE);
154  }
155  $this->ctrl->redirect($this, "specialusers");
156  */
157  }
158 
160  {
161  // #7927: special users are deprecated
162  exit();
163 
164  /*
165  if ((array_key_exists("special_user_id", $_POST)) && (count($_POST["special_user_id"])))
166  {
167  $this->object->removeSpecialUsers($_POST["special_user_id"]);
168  unset($_SESSION["adm_removed_users"]);
169  }
170  else
171  {
172  ilUtil::sendInfo($this->lng->txt("adm_remove_select_user"), TRUE);
173  }
174  $this->ctrl->redirect($this, "specialusers");
175  */
176  }
177 
184  {
185  global $ilAccess, $ilTabs;
186 
187  // #7927: special users are deprecated
188  exit();
189 
190  /*
191  $ilTabs->activateTab("specialusers");
192 
193  $a_write_access = ($ilAccess->checkAccess("write", "", $this->object->getRefId())) ? true : false;
194  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_adm_specialusers.html", "Modules/Survey");
195  $found_users = "";
196  if (array_key_exists("survey_adm_found_users", $_SESSION))
197  {
198  if (count($_SESSION["survey_adm_found_users"]))
199  {
200  $data = $_SESSION["survey_adm_found_users"];
201  include_once("./Modules/Survey/classes/tables/class.ilFoundUsersTableGUI.php");
202  $table_gui = new ilFoundUsersTableGUI($this, "specialusers");
203  $table_gui->setPrefix("fu");
204 
205  $table_gui->setTitle($this->lng->txt("found_users"));
206  $table_gui->setData($data);
207 
208  if ($a_write_access)
209  {
210  $table_gui->addCommandButton("addSpecialUser", $this->lng->txt("add"));
211  $table_gui->setSelectAllCheckbox("user_id");
212  }
213  $found_users = $table_gui->getHTML();
214  }
215  }
216 
217  if (strlen($found_users))
218  {
219  $this->tpl->setCurrentBlock("search_results");
220  $this->tpl->setVariable("SEARCH_RESULTS", $found_users);
221  $this->tpl->parseCurrentBlock();
222  }
223  $this->tpl->setCurrentBlock("adm_content");
224  $this->tpl->setVariable("TXT_SEARCH_USER", $this->lng->txt("search_users"));
225  $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
226  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "search"));
227 
228  $special_users = $this->object->getSpecialUsers();
229  if (count($special_users))
230  {
231  include_once("./Modules/Survey/classes/tables/class.ilSpecialUsersTableGUI.php");
232  $table_gui = new ilSpecialUsersTableGUI($this, "specialusers", $a_write_access);
233  $table_gui->setPrefix("su");
234 
235  $table_gui->setTitle($this->lng->txt("adm_special_users"));
236  $table_gui->setData($special_users);
237 
238  if ($a_write_access)
239  {
240  $table_gui->addCommandButton("removeSpecialUser", $this->lng->txt("remove"));
241  $table_gui->setSelectAllCheckbox("special_user_id");
242  }
243  $this->tpl->setVariable("SPECIAL_USERS", $table_gui->getHTML());
244  }
245  else
246  {
247  $this->tpl->setVariable("SPECIAL_USERS", $this->lng->txt("adm_no_special_users"));
248  }
249  $this->tpl->parseCurrentBlock();
250  */
251  }
252 
260  function settingsObject()
261  {
262  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl, $ilTabs;
263 
264  $ilTabs->activateTab("settings");
265 
266  $surveySetting = new ilSetting("survey");
267  $unlimited_invitation = array_key_exists("unlimited_invitation", $_GET) ? $_GET["unlimited_invitation"] : $surveySetting->get("unlimited_invitation");
268  $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
269 
270  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
271  $form = new ilPropertyFormGUI();
272  $form->setFormAction($ilCtrl->getFormAction($this));
273  $form->setTitle($lng->txt("survey_defaults"));
274 
275  // unlimited invitation
276  $enable = new ilCheckboxInputGUI($lng->txt("survey_unlimited_invitation"), "unlimited_invitation");
277  $enable->setChecked($unlimited_invitation);
278  $enable->setInfo($lng->txt("survey_unlimited_invitation_desc"));
279  $form->addItem($enable);
280 
281  // Survey Code
282  $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
283  $code->setChecked($use_anonymous_id);
284  $code->setInfo($lng->txt("use_anonymous_id_desc"));
285  $form->addItem($code);
286 
287  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
288  {
289  $form->addCommandButton("saveSettings", $lng->txt("save"));
290  }
291 
292  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
293  }
294 
299  {
300  global $ilCtrl, $ilAccess;
301 
302  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) $ilCtrl->redirect($this, "settings");
303  $surveySetting = new ilSetting("survey");
304  $surveySetting->set("unlimited_invitation", ($_POST["unlimited_invitation"]) ? "1" : "0");
305  $surveySetting->set("use_anonymous_id", ($_POST["use_anonymous_id"]) ? "1" : "0");
306  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
307  $ilCtrl->redirect($this, "settings");
308  }
309 
310  function getAdminTabs(&$tabs_gui)
311  {
312  $this->getTabs($tabs_gui);
313  }
314 
320  function getTabs(&$tabs_gui)
321  {
322  global $ilAccess, $lng;
323 
324  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
325  {
326  $tabs_gui->addTab("settings",
327  $lng->txt("settings"),
328  $this->ctrl->getLinkTarget($this, "settings"));
329 
330  // #7927: special users are deprecated
331  /*
332  $tabs_gui->addTab("specialusers",
333  $lng->txt("specialusers"),
334  $this->ctrl->getLinkTarget($this, "specialusers"));
335  */
336 
337  $tabs_gui->addTab("templates",
338  $lng->txt("adm_settings_templates"),
339  $this->ctrl->getLinkTargetByClass("ilsettingstemplategui", ""));
340  }
341  if ($ilAccess->checkAccess("edit_permission",'',$this->object->getRefId()))
342  {
343  $tabs_gui->addTab("perm_settings",
344  $lng->txt("perm_settings"),
345  $this->ctrl->getLinkTargetByClass('ilpermissiongui', "perm"));
346  }
347  }
348 
354  private function getSettingsTemplateConfig()
355  {
356  global $lng;
357 
358  $lng->loadLanguageModule("survey");
359 
360  include_once("./Services/Administration/classes/class.ilSettingsTemplateConfig.php");
361  $config = new ilSettingsTemplateConfig("svy");
362 
363  $config->addHidableTab("survey_question_editor", $lng->txt("survey_question_editor_settings_template"));
364  $config->addHidableTab("constraints", $lng->txt("constraints"));
365  $config->addHidableTab("invitation", $lng->txt("invitation"));
366  $config->addHidableTab("meta_data", $lng->txt("meta_data"));
367  $config->addHidableTab("export", $lng->txt("export"));
368 
369  $config->addSetting(
370  "use_pool",
372  $lng->txt("survey_question_pool_usage"),
373  true
374  );
375 
376  $config->addSetting(
377  "anonymization_options",
379  $lng->txt("survey_auth_mode"),
380  true,
381  'personalized',
382  array('personalized' => $this->lng->txt("anonymize_personalized"),
383  'anonymize_without_code' => $this->lng->txt("anonymize_without_code"),
384  'anonymize_with_code' => $this->lng->txt("anonymize_with_code"))
385  );
386 
387  $config->addSetting(
388  "rte_switch",
390  $lng->txt("set_edit_mode"),
391  true,
392  0,
393  array(0 => $this->lng->txt("rte_editor_disabled"),
394  1 => $this->lng->txt("rte_editor_enabled"))
395  );
396 
397  $config->addSetting(
398  "enabled_start_date",
400  $lng->txt("start_date"),
401  true
402  );
403 
404  $config->addSetting(
405  "enabled_end_date",
407  $lng->txt("end_date"),
408  true
409  );
410 
411  $config->addSetting(
412  "show_question_titles",
414  $lng->txt("svy_show_questiontitles"),
415  true
416  );
417 
418  return $config;
419  }
420 
421 } // END class.ilObjSurveyAdministrationGUI
422 ?>