ILIAS  Release_4_0_x_branch Revision 61816
 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  // setup rolefolder & default local roles
95  //$roles = $newObj->initDefaultRoles();
96 
97  // ...finally assign role to creator of object
98  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
99 
100  // put here object specific stuff
101 
102  // always send a message
103  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
104 
105  $this->ctrl->redirect($this);
106  }
107 
108  function searchObject()
109  {
110  unset($_SESSION["survey_adm_found_users"]);
111  if (strlen($_POST["search"]) < 2)
112  {
113  ilUtil::sendInfo($this->lng->txt("adm_search_string_too_small"), TRUE);
114  }
115  else
116  {
117  include_once "./Services/User/classes/class.ilObjUser.php";
118  $found = ilObjUser::searchUsers($_POST["search"], $active = 1, $a_return_ids_only = false, $filter_settings = FALSE);
119  if (count($found))
120  {
121  $_SESSION["survey_adm_found_users"] = $found;
122  }
123  else
124  {
125  ilUtil::sendInfo($this->lng->txt("adm_no_users_found"), TRUE);
126 
127  }
128  }
129  $this->ctrl->redirect($this, "specialusers");
130  }
131 
137  {
138  if ((array_key_exists("user_id", $_POST)) && (count($_POST["user_id"])))
139  {
140  $this->object->addSpecialUsers($_POST["user_id"]);
141  unset($_SESSION["survey_adm_found_users"]);
142  }
143  else
144  {
145  ilUtil::sendInfo($this->lng->txt("adm_search_select_user"), TRUE);
146  }
147  $this->ctrl->redirect($this, "specialusers");
148  }
149 
151  {
152  if ((array_key_exists("special_user_id", $_POST)) && (count($_POST["special_user_id"])))
153  {
154  $this->object->removeSpecialUsers($_POST["special_user_id"]);
155  unset($_SESSION["adm_removed_users"]);
156  }
157  else
158  {
159  ilUtil::sendInfo($this->lng->txt("adm_remove_select_user"), TRUE);
160  }
161  $this->ctrl->redirect($this, "specialusers");
162  }
163 
170  {
171  global $ilAccess;
172 
173  $a_write_access = ($ilAccess->checkAccess("write", "", $this->object->getRefId())) ? true : false;
174  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_adm_specialusers.html", "Modules/Survey");
175  $found_users = "";
176  if (array_key_exists("survey_adm_found_users", $_SESSION))
177  {
178  if (count($_SESSION["survey_adm_found_users"]))
179  {
180  $data = $_SESSION["survey_adm_found_users"];
181  include_once("./Modules/Survey/classes/tables/class.ilFoundUsersTableGUI.php");
182  $table_gui = new ilFoundUsersTableGUI($this, "specialusers");
183  $table_gui->setPrefix("fu");
184 
185  $table_gui->setTitle($this->lng->txt("found_users"));
186  $table_gui->setData($data);
187 
188  if ($a_write_access)
189  {
190  $table_gui->addCommandButton("addSpecialUser", $this->lng->txt("add"));
191  $table_gui->setSelectAllCheckbox("user_id");
192  }
193  $found_users = $table_gui->getHTML();
194  }
195  }
196 
197  if (strlen($found_users))
198  {
199  $this->tpl->setCurrentBlock("search_results");
200  $this->tpl->setVariable("SEARCH_RESULTS", $found_users);
201  $this->tpl->parseCurrentBlock();
202  }
203  $this->tpl->setCurrentBlock("adm_content");
204  $this->tpl->setVariable("TXT_SEARCH_USER", $this->lng->txt("search_users"));
205  $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
206  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "search"));
207 
208  $special_users = $this->object->getSpecialUsers();
209  if (count($special_users))
210  {
211  include_once("./Modules/Survey/classes/tables/class.ilSpecialUsersTableGUI.php");
212  $table_gui = new ilSpecialUsersTableGUI($this, "specialusers", $a_write_access);
213  $table_gui->setPrefix("su");
214 
215  $table_gui->setTitle($this->lng->txt("adm_special_users"));
216  $table_gui->setData($special_users);
217 
218  if ($a_write_access)
219  {
220  $table_gui->addCommandButton("removeSpecialUser", $this->lng->txt("remove"));
221  $table_gui->setSelectAllCheckbox("special_user_id");
222  }
223  $this->tpl->setVariable("SPECIAL_USERS", $table_gui->getHTML());
224  }
225  else
226  {
227  $this->tpl->setVariable("SPECIAL_USERS", $this->lng->txt("adm_no_special_users"));
228  }
229  $this->tpl->parseCurrentBlock();
230  }
231 
239  function settingsObject()
240  {
241  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
242 
243  $surveySetting = new ilSetting("survey");
244  $unlimited_invitation = array_key_exists("unlimited_invitation", $_GET) ? $_GET["unlimited_invitation"] : $surveySetting->get("unlimited_invitation");
245  $googlechart = array_key_exists("googlechart", $_GET) ? $_GET["googlechart"] : $surveySetting->get("googlechart");
246  $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
247 
248  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
249  $form = new ilPropertyFormGUI();
250  $form->setFormAction($ilCtrl->getFormAction($this));
251  $form->setTitle($lng->txt("survey_defaults"));
252 
253  // unlimited invitation
254  $enable = new ilCheckboxInputGUI($lng->txt("survey_unlimited_invitation"), "unlimited_invitation");
255  $enable->setChecked($unlimited_invitation);
256  $enable->setInfo($lng->txt("survey_unlimited_invitation_desc"));
257  $form->addItem($enable);
258 
259  // Google chart API
260  $enable = new ilCheckboxInputGUI($lng->txt("use_google_chart_api"), "googlechart");
261  $enable->setChecked($googlechart);
262  $enable->setInfo($lng->txt("use_google_chart_api_desc"));
263  $form->addItem($enable);
264 
265  // Survey Code
266  $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
267  $code->setChecked($use_anonymous_id);
268  $code->setInfo($lng->txt("use_anonymous_id_desc"));
269  $form->addItem($code);
270 
271  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
272  {
273  $form->addCommandButton("saveSettings", $lng->txt("save"));
274  }
275 
276  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
277  }
278 
283  {
284  global $ilCtrl, $ilAccess;
285 
286  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) $ilCtrl->redirect($this, "settings");
287  $surveySetting = new ilSetting("survey");
288  $surveySetting->set("unlimited_invitation", ($_POST["unlimited_invitation"]) ? "1" : "0");
289  $surveySetting->set("googlechart", ($_POST["googlechart"]) ? "1" : "0");
290  $surveySetting->set("use_anonymous_id", ($_POST["use_anonymous_id"]) ? "1" : "0");
291  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
292  $ilCtrl->redirect($this, "settings");
293  }
294 
295  function getAdminTabs(&$tabs_gui)
296  {
297  $this->getTabs($tabs_gui);
298  }
299 
305  function getTabs(&$tabs_gui)
306  {
307  global $ilAccess;
308 
309  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
310  {
311  $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "settings"), array("settings","","view"), "", "");
312  $tabs_gui->addTarget("specialusers", $this->ctrl->getLinkTarget($this, "specialusers"), array("specialusers"), "", "");
313  }
314  if ($ilAccess->checkAccess("edit_permission",'',$this->object->getRefId()))
315  {
316  $tabs_gui->addTarget("perm_settings",
317  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
318  }
319  }
320 } // END class.ilObjSurveyAdministrationGUI
321 ?>