ILIAS  Release_4_0_x_branch Revision 61816
 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 {
39  function __construct()
40  {
41  }
42 
49  public static function &_getAvailablePhrases($useronly = 0)
50  {
51  global $ilUser;
52  global $ilDB;
53  global $lng;
54 
55  $phrases = array();
56  $result = $ilDB->queryF("SELECT * FROM svy_phrase WHERE defaultvalue = %s OR owner_fi = %s ORDER BY title",
57  array('text', 'integer'),
58  array('1', $ilUser->getId())
59  );
60  while ($row = $ilDB->fetchObject($result))
61  {
62  if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
63  {
64  if (!$useronly)
65  {
66  $phrases[$row->phrase_id] = array(
67  "title" => $lng->txt($row->title),
68  "owner" => $row->owner_fi
69  );
70  }
71  }
72  else
73  {
74  if ($ilUser->getId() == $row->owner_fi)
75  {
76  $phrases[$row->phrase_id] = array(
77  "title" => $row->title,
78  "owner" => $row->owner_fi
79  );
80  }
81  }
82  }
83  return $phrases;
84  }
85 
92  public static function &_getCategoriesForPhrase($phrase_id)
93  {
94  global $ilDB;
95  global $lng;
96 
97  $categories = array();
98  $result = $ilDB->queryF("SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s ORDER BY svy_phrase_cat.sequence",
99  array('integer'),
100  array($phrase_id)
101  );
102  while ($row = $ilDB->fetchObject($result))
103  {
104  if (($row->defaultvalue == 1) and ($row->owner_fi == 0))
105  {
106  $categories[$row->category_id] = $lng->txt($row->title);
107  }
108  else
109  {
110  $categories[$row->category_id] = $row->title;
111  }
112  }
113  return $categories;
114  }
115 
121  function deletePhrases($phrase_array)
122  {
123  global $ilDB;
124 
125  if ((is_array($phrase_array)) && (count($phrase_array)))
126  {
127  $affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase WHERE " . $ilDB->in('phrase_id', $phrase_array, false, 'integer'));
128  $affectedRows = $ilDB->manipulate("DELETE FROM svy_phrase_cat WHERE " . $ilDB->in('phrase_fi', $phrase_array, false, 'integer'));
129  }
130  }
131 }
132 ?>