ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  public function setLocation($a_location)
37  {
38  $this->location = $a_location;
39  }
40  public function getLocation()
41  {
42  return $this->location;
43  }
44  public function setLocationType($a_location_type)
45  {
46  $this->location_type = $a_location_type;
47  }
48  public function getLocationType()
49  {
50  return $this->location_type;
51  }
52 
53  public function save()
54  {
55  if ($this->db->autoExecute(
56  'il_meta_location',
57  $this->__getFields(),
59  )) {
60  $this->setMetaId($this->db->getLastInsertId());
61 
62  return $this->getMetaId();
63  }
64  return false;
65  }
66 
67  public function update()
68  {
69  global $ilDB;
70 
71  if ($this->getMetaId()) {
72  if ($this->db->autoExecute(
73  'il_meta_location',
74  $this->__getFields(),
76  "meta_location_id = " . $ilDB->quote($this->getMetaId())
77  )) {
78  return true;
79  }
80  }
81  return false;
82  }
83 
84  public function delete()
85  {
86  global $ilDB;
87 
88  if ($this->getMetaId()) {
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  public 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  public function read()
112  {
113  global $ilDB;
114 
115  include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
116 
117  if ($this->getMetaId()) {
118  $query = "SELECT * FROM il_meta_location " .
119  "WHERE meta_location_id = " . $ilDB->quote($this->getMetaId());
120 
121  $res = $this->db->query($query);
122  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
123  $this->setRBACId($row->rbac_id);
124  $this->setObjId($row->obj_id);
125  $this->setObjType($row->obj_type);
126  $this->setParentId($row->parent_id);
127  $this->setParentType($row->parent_type);
128  $this->setLocation(ilUtil::stripSlashes($row->location));
129  $this->setLocationType(ilUtil::stripSlashes($row->location_type));
130  }
131  }
132  return true;
133  }
134 
135  /*
136  * XML Export of all meta data
137  * @param object (xml writer) see class.ilMD2XML.php
138  *
139  */
140  public function toXML(&$writer)
141  {
142  $writer->xmlElement('Location', array('Type' => $this->getLocationType()), $this->getLocation());
143  }
144 
145 
146  // STATIC
147  public function _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
148  {
149  global $ilDB;
150 
151  $query = "SELECT meta_location_id FROM il_meta_location " .
152  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id) . " " .
153  "AND obj_id = " . $ilDB->quote($a_obj_id) . " " .
154  "AND parent_id = " . $ilDB->quote($a_parent_id) . " " .
155  "AND parent_type = " . $ilDB->quote($a_parent_type);
156 
157  $res = $ilDB->query($query);
158  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
159  $ids[] = $row->meta_location_id;
160  }
161  return $ids ? $ids : array();
162  }
163 }
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)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
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)