ILIAS  Release_4_1_x_branch Revision 61804
 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 "./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  $next_class = $this->ctrl->getNextClass($this);
58  $cmd = $this->ctrl->getCmd();
59  $this->prepareOutput();
60 
61  switch($next_class)
62  {
63  case 'ilpermissiongui':
64  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
65  $perm_gui =& new ilPermissionGUI($this);
66  $ret =& $this->ctrl->forwardCommand($perm_gui);
67  break;
68 
69  default:
70  if($cmd == "" || $cmd == "view")
71  {
72  $cmd = "settings";
73  }
74  $cmd .= "Object";
75  $this->$cmd();
76 
77  break;
78  }
79  return true;
80  }
81 
82 
87  function saveObject()
88  {
89  global $rbacadmin;
90 
91  // create and insert forum in objecttree
92  $newObj = parent::saveObject();
93 
94  // put here object specific stuff
95 
96  // always send a message
97  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
98 
99  $this->ctrl->redirect($this);
100  }
101 
102  function searchObject()
103  {
104  unset($_SESSION["survey_adm_found_users"]);
105  if (strlen($_POST["search"]) < 2)
106  {
107  ilUtil::sendInfo($this->lng->txt("adm_search_string_too_small"), TRUE);
108  }
109  else
110  {
111  include_once "./Services/User/classes/class.ilObjUser.php";
112  $found = ilObjUser::searchUsers($_POST["search"], $active = 1, $a_return_ids_only = false, $filter_settings = FALSE);
113  if (count($found))
114  {
115  $_SESSION["survey_adm_found_users"] = $found;
116  }
117  else
118  {
119  ilUtil::sendInfo($this->lng->txt("adm_no_users_found"), TRUE);
120 
121  }
122  }
123  $this->ctrl->redirect($this, "specialusers");
124  }
125 
131  {
132  if ((array_key_exists("user_id", $_POST)) && (count($_POST["user_id"])))
133  {
134  $this->object->addSpecialUsers($_POST["user_id"]);
135  unset($_SESSION["survey_adm_found_users"]);
136  }
137  else
138  {
139  ilUtil::sendInfo($this->lng->txt("adm_search_select_user"), TRUE);
140  }
141  $this->ctrl->redirect($this, "specialusers");
142  }
143 
145  {
146  if ((array_key_exists("special_user_id", $_POST)) && (count($_POST["special_user_id"])))
147  {
148  $this->object->removeSpecialUsers($_POST["special_user_id"]);
149  unset($_SESSION["adm_removed_users"]);
150  }
151  else
152  {
153  ilUtil::sendInfo($this->lng->txt("adm_remove_select_user"), TRUE);
154  }
155  $this->ctrl->redirect($this, "specialusers");
156  }
157 
164  {
165  global $ilAccess;
166 
167  $a_write_access = ($ilAccess->checkAccess("write", "", $this->object->getRefId())) ? true : false;
168  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_adm_specialusers.html", "Modules/Survey");
169  $found_users = "";
170  if (array_key_exists("survey_adm_found_users", $_SESSION))
171  {
172  if (count($_SESSION["survey_adm_found_users"]))
173  {
174  $data = $_SESSION["survey_adm_found_users"];
175  include_once("./Modules/Survey/classes/tables/class.ilFoundUsersTableGUI.php");
176  $table_gui = new ilFoundUsersTableGUI($this, "specialusers");
177  $table_gui->setPrefix("fu");
178 
179  $table_gui->setTitle($this->lng->txt("found_users"));
180  $table_gui->setData($data);
181 
182  if ($a_write_access)
183  {
184  $table_gui->addCommandButton("addSpecialUser", $this->lng->txt("add"));
185  $table_gui->setSelectAllCheckbox("user_id");
186  }
187  $found_users = $table_gui->getHTML();
188  }
189  }
190 
191  if (strlen($found_users))
192  {
193  $this->tpl->setCurrentBlock("search_results");
194  $this->tpl->setVariable("SEARCH_RESULTS", $found_users);
195  $this->tpl->parseCurrentBlock();
196  }
197  $this->tpl->setCurrentBlock("adm_content");
198  $this->tpl->setVariable("TXT_SEARCH_USER", $this->lng->txt("search_users"));
199  $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
200  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "search"));
201 
202  $special_users = $this->object->getSpecialUsers();
203  if (count($special_users))
204  {
205  include_once("./Modules/Survey/classes/tables/class.ilSpecialUsersTableGUI.php");
206  $table_gui = new ilSpecialUsersTableGUI($this, "specialusers", $a_write_access);
207  $table_gui->setPrefix("su");
208 
209  $table_gui->setTitle($this->lng->txt("adm_special_users"));
210  $table_gui->setData($special_users);
211 
212  if ($a_write_access)
213  {
214  $table_gui->addCommandButton("removeSpecialUser", $this->lng->txt("remove"));
215  $table_gui->setSelectAllCheckbox("special_user_id");
216  }
217  $this->tpl->setVariable("SPECIAL_USERS", $table_gui->getHTML());
218  }
219  else
220  {
221  $this->tpl->setVariable("SPECIAL_USERS", $this->lng->txt("adm_no_special_users"));
222  }
223  $this->tpl->parseCurrentBlock();
224  }
225 
233  function settingsObject()
234  {
235  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
236 
237  $surveySetting = new ilSetting("survey");
238  $unlimited_invitation = array_key_exists("unlimited_invitation", $_GET) ? $_GET["unlimited_invitation"] : $surveySetting->get("unlimited_invitation");
239  $googlechart = array_key_exists("googlechart", $_GET) ? $_GET["googlechart"] : $surveySetting->get("googlechart");
240  $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
241 
242  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
243  $form = new ilPropertyFormGUI();
244  $form->setFormAction($ilCtrl->getFormAction($this));
245  $form->setTitle($lng->txt("survey_defaults"));
246 
247  // unlimited invitation
248  $enable = new ilCheckboxInputGUI($lng->txt("survey_unlimited_invitation"), "unlimited_invitation");
249  $enable->setChecked($unlimited_invitation);
250  $enable->setInfo($lng->txt("survey_unlimited_invitation_desc"));
251  $form->addItem($enable);
252 
253  // Google chart API
254  $enable = new ilCheckboxInputGUI($lng->txt("use_google_chart_api"), "googlechart");
255  $enable->setChecked($googlechart);
256  $enable->setInfo($lng->txt("use_google_chart_api_desc"));
257  $form->addItem($enable);
258 
259  // Survey Code
260  $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
261  $code->setChecked($use_anonymous_id);
262  $code->setInfo($lng->txt("use_anonymous_id_desc"));
263  $form->addItem($code);
264 
265  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
266  {
267  $form->addCommandButton("saveSettings", $lng->txt("save"));
268  }
269 
270  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
271  }
272 
277  {
278  global $ilCtrl, $ilAccess;
279 
280  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) $ilCtrl->redirect($this, "settings");
281  $surveySetting = new ilSetting("survey");
282  $surveySetting->set("unlimited_invitation", ($_POST["unlimited_invitation"]) ? "1" : "0");
283  $surveySetting->set("googlechart", ($_POST["googlechart"]) ? "1" : "0");
284  $surveySetting->set("use_anonymous_id", ($_POST["use_anonymous_id"]) ? "1" : "0");
285  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
286  $ilCtrl->redirect($this, "settings");
287  }
288 
289  function getAdminTabs(&$tabs_gui)
290  {
291  $this->getTabs($tabs_gui);
292  }
293 
299  function getTabs(&$tabs_gui)
300  {
301  global $ilAccess;
302 
303  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
304  {
305  $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "settings"), array("settings","","view"), "", "");
306  $tabs_gui->addTarget("specialusers", $this->ctrl->getLinkTarget($this, "specialusers"), array("specialusers"), "", "");
307  }
308  if ($ilAccess->checkAccess("edit_permission",'',$this->object->getRefId()))
309  {
310  $tabs_gui->addTarget("perm_settings",
311  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
312  }
313  }
314 } // END class.ilObjSurveyAdministrationGUI
315 ?>