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