ILIAS  Release_3_10_x_branch Revision 61812
 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  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
54  {
55  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_assf"),$this->ilias->error_obj->WARNING);
56  }
57  }
58 
59  function &executeCommand()
60  {
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63  $this->prepareOutput();
64 
65  switch($next_class)
66  {
67  case 'ilpermissiongui':
68  include_once("./classes/class.ilPermissionGUI.php");
69  $perm_gui =& new ilPermissionGUI($this);
70  $ret =& $this->ctrl->forwardCommand($perm_gui);
71  break;
72 
73  default:
74  if($cmd == "" || $cmd == "view")
75  {
76  $cmd = "settings";
77  }
78  $cmd .= "Object";
79  $this->$cmd();
80 
81  break;
82  }
83  return true;
84  }
85 
86 
91  function saveObject()
92  {
93  global $rbacadmin;
94 
95  // create and insert forum in objecttree
96  $newObj = parent::saveObject();
97 
98  // setup rolefolder & default local roles
99  //$roles = $newObj->initDefaultRoles();
100 
101  // ...finally assign role to creator of object
102  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
103 
104  // put here object specific stuff
105 
106  // always send a message
107  ilUtil::sendInfo($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  if ((array_key_exists("user_id", $_POST)) && (count($_POST["user_id"])))
143  {
144  $this->object->addSpecialUsers($_POST["user_id"]);
145  unset($_SESSION["survey_adm_found_users"]);
146  }
147  else
148  {
149  ilUtil::sendInfo($this->lng->txt("adm_search_select_user"), TRUE);
150  }
151  $this->ctrl->redirect($this, "specialusers");
152  }
153 
155  {
156  if ((array_key_exists("special_user_id", $_POST)) && (count($_POST["special_user_id"])))
157  {
158  $this->object->removeSpecialUsers($_POST["special_user_id"]);
159  unset($_SESSION["adm_removed_users"]);
160  }
161  else
162  {
163  ilUtil::sendInfo($this->lng->txt("adm_remove_select_user"), TRUE);
164  }
165  $this->ctrl->redirect($this, "specialusers");
166  }
167 
174  {
175  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_adm_specialusers.html", "Modules/Survey");
176  $found_users = "";
177  if (array_key_exists("survey_adm_found_users", $_SESSION))
178  {
179  if (count($_SESSION["survey_adm_found_users"]))
180  {
181  $data = $_SESSION["survey_adm_found_users"];
182  include_once("./Modules/Survey/classes/class.ilFoundUsersTableGUI.php");
183  $table_gui = new ilFoundUsersTableGUI($this, "specialusers");
184  $table_gui->setPrefix("fu");
185 
186  $table_gui->setTitle($this->lng->txt("found_users"));
187  $table_gui->setData($data);
188 
189  $table_gui->addCommandButton("addSpecialUser", $this->lng->txt("add"));
190  $table_gui->setSelectAllCheckbox("user_id");
191  $found_users = $table_gui->getHTML();
192  }
193  }
194 
195  if (strlen($found_users))
196  {
197  $this->tpl->setCurrentBlock("search_results");
198  $this->tpl->setVariable("SEARCH_RESULTS", $found_users);
199  $this->tpl->parseCurrentBlock();
200  }
201  $this->tpl->setCurrentBlock("adm_content");
202  $this->tpl->setVariable("TXT_SEARCH_USER", $this->lng->txt("search_users"));
203  $this->tpl->setVariable("TXT_SEARCH", $this->lng->txt("search"));
204  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "search"));
205 
206  $special_users = $this->object->getSpecialUsers();
207  if (count($special_users))
208  {
209  include_once("./Modules/Survey/classes/class.ilSpecialUsersTableGUI.php");
210  $table_gui = new ilSpecialUsersTableGUI($this, "specialusers");
211  $table_gui->setPrefix("su");
212 
213  $table_gui->setTitle($this->lng->txt("adm_special_users"));
214  $table_gui->setData($special_users);
215 
216  $table_gui->addCommandButton("removeSpecialUser", $this->lng->txt("remove"));
217  $table_gui->setSelectAllCheckbox("special_user_id");
218  $this->tpl->setVariable("SPECIAL_USERS", $table_gui->getHTML());
219  }
220  else
221  {
222  $this->tpl->setVariable("SPECIAL_USERS", $this->lng->txt("adm_no_special_users"));
223  }
224  $this->tpl->parseCurrentBlock();
225  }
226 
234  function settingsObject()
235  {
236  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl;
237 
238  $surveySetting = new ilSetting("survey");
239  $unlimited_invitation = array_key_exists("unlimited_invitation", $_GET) ? $_GET["unlimited_invitation"] : $surveySetting->get("unlimited_invitation");
240  $googlechart = array_key_exists("googlechart", $_GET) ? $_GET["googlechart"] : $surveySetting->get("googlechart");
241  $use_anonymous_id = array_key_exists("use_anonymous_id", $_GET) ? $_GET["use_anonymous_id"] : $surveySetting->get("use_anonymous_id");
242  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
243  {
244  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
245  }
246 
247  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
248  $form = new ilPropertyFormGUI();
249  $form->setFormAction($ilCtrl->getFormAction($this));
250  $form->setTitle($lng->txt("survey_defaults"));
251 
252  // unlimited invitation
253  $enable = new ilCheckboxInputGUI($lng->txt("survey_unlimited_invitation"), "unlimited_invitation");
254  $enable->setChecked($unlimited_invitation);
255  $enable->setInfo($lng->txt("survey_unlimited_invitation_desc"));
256  $form->addItem($enable);
257 
258  // Google chart API
259  $enable = new ilCheckboxInputGUI($lng->txt("use_google_chart_api"), "googlechart");
260  $enable->setChecked($googlechart);
261  $enable->setInfo($lng->txt("use_google_chart_api_desc"));
262  $form->addItem($enable);
263 
264  // Survey Code
265  $code = new ilCheckboxInputGUI($lng->txt("use_anonymous_id"), "use_anonymous_id");
266  $code->setChecked($use_anonymous_id);
267  $code->setInfo($lng->txt("use_anonymous_id_desc"));
268  $form->addItem($code);
269 
270  $form->addCommandButton("saveSettings", $lng->txt("save"));
271  $form->addCommandButton("defaults", $lng->txt("cancel"));
272 
273  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
274  }
275 
280  {
281  global $ilCtrl;
282 
283  $surveySetting = new ilSetting("survey");
284  $surveySetting->set("unlimited_invitation", ($_POST["unlimited_invitation"]) ? "1" : "0");
285  $surveySetting->set("googlechart", ($_POST["googlechart"]) ? "1" : "0");
286  $surveySetting->set("use_anonymous_id", ($_POST["use_anonymous_id"]) ? "1" : "0");
287  $ilCtrl->redirect($this, "settings");
288  }
289 
290  function getAdminTabs(&$tabs_gui)
291  {
292  $this->getTabs($tabs_gui);
293  }
294 
300  function getTabs(&$tabs_gui)
301  {
302  global $ilAccess;
303 
304  if ($ilAccess->checkAccess("read",'',$this->object->getRefId()))
305  {
306  $tabs_gui->addTarget("settings", $this->ctrl->getLinkTarget($this, "settings"), array("settings","","view"), "", "");
307  $tabs_gui->addTarget("specialusers", $this->ctrl->getLinkTarget($this, "specialusers"), array("specialusers"), "", "");
308  }
309  if ($ilAccess->checkAccess("edit_permission",'',$this->object->getRefId()))
310  {
311  $tabs_gui->addTarget("perm_settings",
312  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
313  }
314  }
315 } // END class.ilObjSurveyAdministrationGUI
316 ?>