ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSurveyPhrasesGUI.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 {
37  var $object;
39  var $lng;
40  var $tpl;
41  var $ctrl;
42  var $ilias;
43  var $tree;
44  var $ref_id;
45 
50  function __construct($a_object)
51  {
52  global $lng, $tpl, $ilCtrl, $ilias, $tree;
53 
54  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
55  $this->lng =& $lng;
56  $this->tpl =& $tpl;
57  $this->ctrl =& $ilCtrl;
58  $this->ilias =& $ilias;
59  $this->gui_object =& $a_object;
60  $this->object = new ilSurveyPhrases();
61  $this->tree =& $tree;
62  $this->ref_id = $a_object->ref_id;
63  }
64 
68  public function &executeCommand()
69  {
70  $cmd = $this->ctrl->getCmd();
71  $next_class = $this->ctrl->getNextClass($this);
72 
73  $cmd = $this->getCommand($cmd);
74  switch($next_class)
75  {
76  default:
77  $ret =& $this->$cmd();
78  break;
79  }
80  return $ret;
81  }
82 
86  public function getCommand($cmd)
87  {
88  return $cmd;
89  }
90 
94  public function deletePhrase()
95  {
97 
98  $checked_phrases = $_POST['phrase'];
99  if (count($checked_phrases))
100  {
101  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_phrases"));
102  $this->deletePhrasesForm($checked_phrases);
103  return;
104  }
105  else
106  {
107  ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
108  $this->phrases();
109  return;
110  }
111  }
112 
118  public function phrases()
119  {
120  global $rbacsystem;
121 
122  if ($rbacsystem->checkAccess("write", $this->ref_id))
123  {
124  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
125  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
127  $data = array();
128  foreach ($phrases as $phrase_id => $phrase_array)
129  {
130  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
131  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
132  }
133  $table_gui->setData($data);
134  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
135  }
136  else
137  {
138  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
139  }
140  }
141 
145  public function cancelDeletePhrase()
146  {
147  $this->ctrl->redirect($this, "phrases");
148  }
149 
153  public function confirmDeletePhrase()
154  {
155  $phrases = $_POST['phrase'];
156  $this->object->deletePhrases($phrases);
157  ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
158  $this->ctrl->redirect($this, "phrases");
159  }
160 
166  public function deletePhrasesForm($checked_phrases)
167  {
168  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
169  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
171  $data = array();
172  foreach ($checked_phrases as $phrase_id)
173  {
174  $phrase_array = $phrases[$phrase_id];
175  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
176  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
177  }
178  $table_gui->setData($data);
179  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
180  }
181 }
182 ?>