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  global $ilDB;
56 
57  $fields = $this->__getFields();
58  $fields['meta_location_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_location'));
59 
60  if($this->db->insert('il_meta_location',$fields))
61  {
62  $this->setMetaId($next_id);
63  return $this->getMetaId();
64  }
65  return false;
66  }
67 
68  function update()
69  {
70  global $ilDB;
71 
72  if($this->getMetaId())
73  {
74  if($this->db->update('il_meta_location',
75  $this->__getFields(),
76  array("meta_location_id" => array('integer',$this->getMetaId()))))
77  {
78  return true;
79  }
80  }
81  return false;
82  }
83 
84  function delete()
85  {
86  global $ilDB;
87 
88  if($this->getMetaId())
89  {
90  $query = "DELETE FROM il_meta_location ".
91  "WHERE meta_location_id = ".$ilDB->quote($this->getMetaId() ,'integer');
92  $res = $ilDB->manipulate($query);
93 
94  return true;
95  }
96  return false;
97  }
98 
99 
100  function __getFields()
101  {
102  return array('rbac_id' => array('integer',$this->getRBACId()),
103  'obj_id' => array('integer',$this->getObjId()),
104  'obj_type' => array('text',$this->getObjType()),
105  'parent_type' => array('text',$this->getParentType()),
106  'parent_id' => array('integer',$this->getParentId()),
107  'location' => array('text',$this->getLocation()),
108  'location_type' => array('text',$this->getLocationType()));
109  }
110 
111  function read()
112  {
113  global $ilDB;
114 
115  include_once 'Services/MetaData/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() ,'integer');
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($row->location);
131  $this->setLocationType($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()
145  ? $this->getLocationType()
146  : 'LocalFile'),
147  $this->getLocation());
148  }
149 
150 
151  // STATIC
152  static function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
153  {
154  global $ilDB;
155 
156  $query = "SELECT meta_location_id FROM il_meta_location ".
157  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
158  "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
159  "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
160  "AND parent_type = ".$ilDB->quote($a_parent_type ,'text');
161 
162  $res = $ilDB->query($query);
163  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
164  {
165  $ids[] = $row->meta_location_id;
166  }
167  return $ids ? $ids : array();
168  }
169 }
170 ?>
setObjType($a_type)
setLocationType($a_location_type)
$location
Definition: buildRTE.php:44
setLocation($a_location)
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)
global $ilDB
setParentType($a_parent_type)
static _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)