ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDRequirement.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
24
31include_once 'class.ilMDBase.php';
32
33class ilMDRequirement extends ilMDBase
34{
35 function ilMDRequirement($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
36 {
37 parent::ilMDBase($a_rbac_id,
38 $a_obj_id,
39 $a_obj_type);
40 }
41
42 // SET/GET
43 function setOrCompositeId($a_or_composite_id)
44 {
45 $this->or_composite_id = (int) $a_or_composite_id;
46 }
48 {
49 return (int) $this->or_composite_id;
50 }
51
52
53 function setOperatingSystemName($a_val)
54 {
55 switch($a_val)
56 {
57 case 'PC-DOS':
58 case 'MS-Windows':
59 case 'MacOS':
60 case 'Unix':
61 case 'Multi-OS':
62 case 'None':
63 $this->operating_system_name = $a_val;
64 return true;
65
66 default:
67 return false;
68 }
69 }
71 {
72 return $this->operating_system_name;
73 }
75 {
76 $this->operating_system_minimum_version = $a_val;
77 }
79 {
80 return $this->operating_system_minimum_version;
81 }
83 {
84 $this->operating_system_maximum_version = $a_val;
85 }
87 {
88 return $this->operating_system_maximum_version;
89 }
90 function setBrowserName($a_val)
91 {
92 switch($a_val)
93 {
94 case 'Any':
95 case 'NetscapeCommunicator':
96 case 'MS-InternetExplorer':
97 case 'Opera':
98 case 'Amaya':
99 case 'Mozilla':
100 $this->browser_name = $a_val;
101 return true;
102
103 default:
104 return false;
105 }
106 }
107 function getBrowserName()
108 {
109 return $this->browser_name;
110 }
112 {
113 $this->browser_minimum_version = $a_val;
114 }
116 {
117 return $this->browser_minimum_version;
118 }
120 {
121 $this->browser_maximum_version = $a_val;
122 }
124 {
125 return $this->browser_maximum_version;
126 }
127
128 function save()
129 {
130 if($this->db->autoExecute('il_meta_requirement',
131 $this->__getFields(),
132 DB_AUTOQUERY_INSERT))
133 {
134 $this->setMetaId($this->db->getLastInsertId());
135
136 return $this->getMetaId();
137 }
138 return false;
139 }
140
141 function update()
142 {
143 global $ilDB;
144
145 if($this->getMetaId())
146 {
147 if($this->db->autoExecute('il_meta_requirement',
148 $this->__getFields(),
149 DB_AUTOQUERY_UPDATE,
150 "meta_requirement_id = ".$ilDB->quote($this->getMetaId())))
151 {
152 return true;
153 }
154 }
155 return false;
156 }
157
158 function delete()
159 {
160 global $ilDB;
161
162 if($this->getMetaId())
163 {
164 $query = "DELETE FROM il_meta_requirement ".
165 "WHERE meta_requirement_id = ".$ilDB->quote($this->getMetaId());
166
167 $this->db->query($query);
168
169 return true;
170 }
171 return false;
172 }
173
174
175 function __getFields()
176 {
177 return array('rbac_id' => $this->getRBACId(),
178 'obj_id' => $this->getObjId(),
179 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
180 'parent_type' => $this->getParentType(),
181 'parent_id' => $this->getParentId(),
182 'operating_system_name' => ilUtil::prepareDBString($this->getOperatingSystemName()),
183 'operating_system_minimum_version' => ilUtil::prepareDBString($this->getOperatingSystemMinimumVersion()),
184 'operating_system_maximum_version' => ilUtil::prepareDBString($this->getOperatingSystemMaximumVersion()),
185 'browser_name' => ilUtil::prepareDBString($this->getBrowserName()),
186 'browser_minimum_version' => ilUtil::prepareDBString($this->getBrowserMinimumVersion()),
187 'browser_maximum_version' => ilUtil::prepareDBString($this->getBrowserMaximumVersion()),
188 'or_composite_id' => $this->getOrCompositeId());
189 }
190
191 function read()
192 {
193 global $ilDB;
194
195 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
196
197 if($this->getMetaId())
198 {
199 $query = "SELECT * FROM il_meta_requirement ".
200 "WHERE meta_requirement_id = ".$ilDB->quote($this->getMetaId());
201
202 $res = $this->db->query($query);
203 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
204 {
205 $this->setRBACId($row->rbac_id);
206 $this->setObjId($row->obj_id);
207 $this->setObjType($row->obj_type);
208 $this->setParentId($row->parent_id);
209 $this->setParentType($row->parent_type);
210 $this->setOperatingSystemName(ilUtil::stripSlashes($row->operating_system_name));
211 $this->setOperatingSystemMinimumVersion(ilUtil::stripSlashes($row->operating_system_minimum_version));
212 $this->setOperatingSystemMaximumVersion(ilUtil::stripSlashes($row->operating_system_maximum_version));
213 $this->setBrowserName(ilUtil::stripSlashes($row->browser_name));
214 $this->setBrowserMinimumVersion(ilUtil::stripSlashes($row->browser_minimum_version));
215 $this->setBrowserMaximumVersion(ilUtil::stripSlashes($row->browser_maximum_version));
216 $this->setOrCompositeId(ilUtil::stripSlashes($row->or_composite_id));
217 }
218 }
219 return true;
220 }
221
222 /*
223 * XML Export of all meta data
224 * @param object (xml writer) see class.ilMD2XML.php
225 *
226 */
227 function toXML(&$writer)
228 {
229 $writer->xmlStartTag('Requirement');
230 $writer->xmlStartTag('Type');
231
232 if(strlen($this->getOperatingSystemName()))
233 {
234 $writer->xmlElement('OperatingSystem',array('Name' => $this->getOperatingSystemName(),
235 'MinimumVersion' => $this->getOperatingSystemMinimumVersion(),
236 'MaximumVersion' => $this->getOperatingSystemMaximumVersion()));
237 }
238 else
239 {
240 $writer->xmlElement('Browser',array('Name' => $this->getBrowserName(),
241 'MinimumVersion' => $this->getBrowserMinimumVersion(),
242 'MaximumVersion' => $this->getBrowserMaximumVersion()));
243 }
244 $writer->xmlEndTag('Type');
245 $writer->xmlEndTag('Requirement');
246
247 }
248
249
250 // STATIC
251 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type,$a_or_composite_id = 0)
252 {
253 global $ilDB;
254
255 $query = "SELECT meta_requirement_id FROM il_meta_requirement ".
256 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
257 "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
258 "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
259 "AND parent_type = ".$ilDB->quote($a_parent_type)." ".
260 "AND or_composite_id = ".$ilDB->quote($a_or_composite_id);
261
262 $res = $ilDB->query($query);
263 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
264 {
265 $ids[] = $row->meta_requirement_id;
266 }
267 return $ids ? $ids : array();
268 }
269}
270?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setObjId($a_id)
setParentId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
setParentType($a_parent_type)
setOrCompositeId($a_or_composite_id)
setOperatingSystemMaximumVersion($a_val)
ilMDRequirement($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
setOperatingSystemMinimumVersion($a_val)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type, $a_or_composite_id=0)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilDB