ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSurveyPhrases.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 
35 {
43  function ilSurveyPhrases()
44  {
45  }
46 
56  function &_getAvailablePhrases($useronly = 0)
57  {
58  global $ilUser;
59  global $ilDB;
60  global $lng;
61 
62  $phrases = array();
63  $query = sprintf("SELECT * FROM survey_phrase WHERE defaultvalue = '1' OR owner_fi = %s ORDER BY title",
64  $ilDB->quote($ilUser->getId())
65  );
66  $result = $ilDB->query($query);
67  while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
68  {
69  if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
70  {
71  if (!$useronly)
72  {
73  $phrases[$row->phrase_id] = array(
74  "title" => $lng->txt($row->title),
75  "owner" => $row->owner_fi
76  );
77  }
78  }
79  else
80  {
81  if ($ilUser->getId() == $row->owner_fi)
82  {
83  $phrases[$row->phrase_id] = array(
84  "title" => $row->title,
85  "owner" => $row->owner_fi
86  );
87  }
88  }
89  }
90  return $phrases;
91  }
92 
102  function &_getCategoriesForPhrase($phrase_id)
103  {
104  global $ilDB;
105  global $lng;
106 
107  $categories = array();
108  $query = sprintf("SELECT survey_category.* FROM survey_category, survey_phrase_category WHERE survey_phrase_category.category_fi = survey_category.category_id AND survey_phrase_category.phrase_fi = %s ORDER BY survey_phrase_category.sequence",
109  $ilDB->quote($phrase_id)
110  );
111  $result = $ilDB->query($query);
112  while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
113  {
114  if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
115  {
116  $categories[$row->category_id] = $lng->txt($row->title);
117  }
118  else
119  {
120  $categories[$row->category_id] = $row->title;
121  }
122  }
123  return $categories;
124  }
125 
134  function deletePhrases($phrase_array)
135  {
136  global $ilDB;
137 
138  if ((is_array($phrase_array)) && (count($phrase_array)))
139  {
140  $query = "DELETE FROM survey_phrase WHERE phrase_id IN ('" . join($phrase_array, "','") . "')";
141  $result = $ilDB->query($query);
142  $query = "DELETE FROM survey_phrase_category WHERE phrase_fi IN ('" . join($phrase_array, "','") . "')";
143  $result = $ilDB->query($query);
144  }
145  }
146 
147 }
148 ?>