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 
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  global $ilDB;
124 
125  $fields = $this->__getFields();
126  $fields['meta_requirement_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_requirement'));
127 
128  if($this->db->insert('il_meta_requirement',$fields))
129  {
130  $this->setMetaId($next_id);
131  return $this->getMetaId();
132  }
133  return false;
134  }
135 
136  function update()
137  {
138  global $ilDB;
139 
140  if($this->getMetaId())
141  {
142  if($this->db->update('il_meta_requirement',
143  $this->__getFields(),
144  array("meta_requirement_id" => array('integer',$this->getMetaId()))))
145  {
146  return true;
147  }
148  }
149  return false;
150  }
151 
152  function delete()
153  {
154  global $ilDB;
155 
156  if($this->getMetaId())
157  {
158  $query = "DELETE FROM il_meta_requirement ".
159  "WHERE meta_requirement_id = ".$ilDB->quote($this->getMetaId() ,'integer');
160  $res = $ilDB->manipulate($query);
161  return true;
162  }
163  return false;
164  }
165 
166 
167  function __getFields()
168  {
169  return array('rbac_id' => array('integer',$this->getRBACId()),
170  'obj_id' => array('integer',$this->getObjId()),
171  'obj_type' => array('text',$this->getObjType()),
172  'parent_type' => array('text',$this->getParentType()),
173  'parent_id' => array('integer',$this->getParentId()),
174  'operating_system_name' => array('text',$this->getOperatingSystemName()),
175  'os_min_version' => array('text',$this->getOperatingSystemMinimumVersion()),
176  'os_max_version' => array('text',$this->getOperatingSystemMaximumVersion()),
177  'browser_name' => array('text',$this->getBrowserName()),
178  'browser_minimum_version' => array('text',$this->getBrowserMinimumVersion()),
179  'browser_maximum_version' => array('text',$this->getBrowserMaximumVersion()),
180  'or_composite_id' => array('integer',$this->getOrCompositeId()));
181  }
182 
183  function read()
184  {
185  global $ilDB;
186 
187  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
188 
189  if($this->getMetaId())
190  {
191  $query = "SELECT * FROM il_meta_requirement ".
192  "WHERE meta_requirement_id = ".$ilDB->quote($this->getMetaId() ,'integer');
193 
194  $res = $this->db->query($query);
195  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
196  {
197  $this->setRBACId($row->rbac_id);
198  $this->setObjId($row->obj_id);
199  $this->setObjType($row->obj_type);
200  $this->setParentId($row->parent_id);
201  $this->setParentType($row->parent_type);
202  $this->setOperatingSystemName($row->operating_system_name);
203  $this->setOperatingSystemMinimumVersion($row->os_min_version);
204  $this->setOperatingSystemMaximumVersion($row->os_max_version);
205  $this->setBrowserName($row->browser_name);
206  $this->setBrowserMinimumVersion($row->browser_minimum_version);
207  $this->setBrowserMaximumVersion($row->browser_maximum_version);
208  $this->setOrCompositeId($row->or_composite_id);
209  }
210  }
211  return true;
212  }
213 
214  /*
215  * XML Export of all meta data
216  * @param object (xml writer) see class.ilMD2XML.php
217  *
218  */
219  function toXML(&$writer)
220  {
221  $writer->xmlStartTag('Requirement');
222  $writer->xmlStartTag('Type');
223 
224  if(strlen($this->getOperatingSystemName()))
225  {
226  $writer->xmlElement('OperatingSystem',array('Name' => $this->getOperatingSystemName()
227  ? $this->getOperatingSystemName()
228  : 'None',
229  'MinimumVersion' => $this->getOperatingSystemMinimumVersion(),
230  'MaximumVersion' => $this->getOperatingSystemMaximumVersion()));
231  }
232  if(strlen($this->getBrowserName()))
233  {
234  $writer->xmlElement('Browser',array('Name' => $this->getBrowserName()
235  ? $this->getBrowserName()
236  : 'Any',
237  'MinimumVersion' => $this->getBrowserMinimumVersion(),
238  'MaximumVersion' => $this->getBrowserMaximumVersion()));
239  }
240  $writer->xmlEndTag('Type');
241  $writer->xmlEndTag('Requirement');
242 
243  }
244 
245 
246  // STATIC
247  static function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type,$a_or_composite_id = 0)
248  {
249  global $ilDB;
250 
251  $query = "SELECT meta_requirement_id FROM il_meta_requirement ".
252  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
253  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
254  "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
255  "AND parent_type = ".$ilDB->quote($a_parent_type ,'text')." ".
256  "AND or_composite_id = ".$ilDB->quote($a_or_composite_id ,'integer');
257 
258  $res = $ilDB->query($query);
259  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
260  {
261  $ids[] = $row->meta_requirement_id;
262  }
263  return $ids ? $ids : array();
264  }
265 }
266 ?>
setObjType($a_type)
setOperatingSystemMinimumVersion($a_val)
setOrCompositeId($a_or_composite_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjId($a_id)
setRBACId($a_id)
Create styles array
The data for the language used.
setParentId($a_id)
setOperatingSystemMaximumVersion($a_val)
global $ilDB
setParentType($a_parent_type)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type, $a_or_composite_id=0)