ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  global $DIC;
56 
57  $ilDB = $DIC['ilDB'];
58 
59  $fields = $this->__getFields();
60  $fields['meta_location_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_location'));
61 
62  if ($this->db->insert('il_meta_location', $fields)) {
63  $this->setMetaId($next_id);
64  return $this->getMetaId();
65  }
66  return false;
67  }
68 
69  public function update()
70  {
71  global $DIC;
72 
73  $ilDB = $DIC['ilDB'];
74 
75  if ($this->getMetaId()) {
76  if ($this->db->update(
77  'il_meta_location',
78  $this->__getFields(),
79  array("meta_location_id" => array('integer',$this->getMetaId()))
80  )) {
81  return true;
82  }
83  }
84  return false;
85  }
86 
87  public function delete()
88  {
89  global $DIC;
90 
91  $ilDB = $DIC['ilDB'];
92 
93  if ($this->getMetaId()) {
94  $query = "DELETE FROM il_meta_location " .
95  "WHERE meta_location_id = " . $ilDB->quote($this->getMetaId(), 'integer');
96  $res = $ilDB->manipulate($query);
97 
98  return true;
99  }
100  return false;
101  }
102 
103 
104  public function __getFields()
105  {
106  return array('rbac_id' => array('integer',$this->getRBACId()),
107  'obj_id' => array('integer',$this->getObjId()),
108  'obj_type' => array('text',$this->getObjType()),
109  'parent_type' => array('text',$this->getParentType()),
110  'parent_id' => array('integer',$this->getParentId()),
111  'location' => array('text',$this->getLocation()),
112  'location_type' => array('text',$this->getLocationType()));
113  }
114 
115  public function read()
116  {
117  global $DIC;
118 
119  $ilDB = $DIC['ilDB'];
120 
121  include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
122 
123  if ($this->getMetaId()) {
124  $query = "SELECT * FROM il_meta_location " .
125  "WHERE meta_location_id = " . $ilDB->quote($this->getMetaId(), 'integer');
126 
127  $res = $this->db->query($query);
128  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
129  $this->setRBACId($row->rbac_id);
130  $this->setObjId($row->obj_id);
131  $this->setObjType($row->obj_type);
132  $this->setParentId($row->parent_id);
133  $this->setParentType($row->parent_type);
134  $this->setLocation($row->location);
135  $this->setLocationType($row->location_type);
136  }
137  }
138  return true;
139  }
140 
141  /*
142  * XML Export of all meta data
143  * @param object (xml writer) see class.ilMD2XML.php
144  *
145  */
146  public function toXML(&$writer)
147  {
148  $writer->xmlElement(
149  'Location',
150  array('Type' => $this->getLocationType()
151  ? $this->getLocationType()
152  : 'LocalFile'),
153  $this->getLocation()
154  );
155  }
156 
157 
158  // STATIC
159  public static function _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
160  {
161  global $DIC;
162 
163  $ilDB = $DIC['ilDB'];
164 
165  $query = "SELECT meta_location_id FROM il_meta_location " .
166  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
167  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
168  "AND parent_id = " . $ilDB->quote($a_parent_id, 'integer') . " " .
169  "AND parent_type = " . $ilDB->quote($a_parent_type, 'text');
170 
171  $res = $ilDB->query($query);
172  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
173  $ids[] = $row->meta_location_id;
174  }
175  return $ids ? $ids : array();
176  }
177 }
setObjType($a_type)
global $DIC
Definition: saml.php:7
setLocationType($a_location_type)
$location
Definition: buildRTE.php:44
setLocation($a_location)
setMetaId($a_meta_id, $a_read_data=true)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
setParentId($a_id)
$row
global $ilDB
setParentType($a_parent_type)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)