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