ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMDLocation.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 ilMDLocation extends ilMDBase
34 {
35  function ilMDLocation($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 setLocation($a_location)
44  {
45  $this->location = $a_location;
46  }
47  function getLocation()
48  {
49  return $this->location;
50  }
51  function setLocationType($a_location_type)
52  {
53  $this->location_type = $a_location_type;
54  }
55  function getLocationType()
56  {
57  return $this->location_type;
58  }
59 
60  function save()
61  {
62  if($this->db->autoExecute('il_meta_location',
63  $this->__getFields(),
64  DB_AUTOQUERY_INSERT))
65  {
66  $this->setMetaId($this->db->getLastInsertId());
67 
68  return $this->getMetaId();
69  }
70  return false;
71  }
72 
73  function update()
74  {
75  global $ilDB;
76 
77  if($this->getMetaId())
78  {
79  if($this->db->autoExecute('il_meta_location',
80  $this->__getFields(),
81  DB_AUTOQUERY_UPDATE,
82  "meta_location_id = ".$ilDB->quote($this->getMetaId())))
83  {
84  return true;
85  }
86  }
87  return false;
88  }
89 
90  function delete()
91  {
92  global $ilDB;
93 
94  if($this->getMetaId())
95  {
96  $query = "DELETE FROM il_meta_location ".
97  "WHERE meta_location_id = ".$ilDB->quote($this->getMetaId());
98 
99  $this->db->query($query);
100 
101  return true;
102  }
103  return false;
104  }
105 
106 
107  function __getFields()
108  {
109  return array('rbac_id' => $this->getRBACId(),
110  'obj_id' => $this->getObjId(),
111  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
112  'parent_type' => $this->getParentType(),
113  'parent_id' => $this->getParentId(),
114  'location' => ilUtil::prepareDBString($this->getLocation()),
115  'location_type' => ilUtil::prepareDBString($this->getLocationType()));
116  }
117 
118  function read()
119  {
120  global $ilDB;
121 
122  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
123 
124  if($this->getMetaId())
125  {
126  $query = "SELECT * FROM il_meta_location ".
127  "WHERE meta_location_id = ".$ilDB->quote($this->getMetaId());
128 
129  $res = $this->db->query($query);
130  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
131  {
132  $this->setRBACId($row->rbac_id);
133  $this->setObjId($row->obj_id);
134  $this->setObjType($row->obj_type);
135  $this->setParentId($row->parent_id);
136  $this->setParentType($row->parent_type);
137  $this->setLocation(ilUtil::stripSlashes($row->location));
138  $this->setLocationType(ilUtil::stripSlashes($row->location_type));
139  }
140  }
141  return true;
142  }
143 
144  /*
145  * XML Export of all meta data
146  * @param object (xml writer) see class.ilMD2XML.php
147  *
148  */
149  function toXML(&$writer)
150  {
151  $writer->xmlElement('Location',array('Type' => $this->getLocationType()),$this->getLocation());
152  }
153 
154 
155  // STATIC
156  function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
157  {
158  global $ilDB;
159 
160  $query = "SELECT meta_location_id FROM il_meta_location ".
161  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
162  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
163  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
164  "AND parent_type = ".$ilDB->quote($a_parent_type);
165 
166  $res = $ilDB->query($query);
167  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
168  {
169  $ids[] = $row->meta_location_id;
170  }
171  return $ids ? $ids : array();
172  }
173 }
174 ?>