ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
31include_once 'class.ilMDBase.php';
32
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 global $ilDB;
63
64 $fields = $this->__getFields();
65 $fields['meta_location_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_location'));
66
67 if($this->db->insert('il_meta_location',$fields))
68 {
69 $this->setMetaId($next_id);
70 return $this->getMetaId();
71 }
72 return false;
73 }
74
75 function update()
76 {
77 global $ilDB;
78
79 if($this->getMetaId())
80 {
81 if($this->db->update('il_meta_location',
82 $this->__getFields(),
83 array("meta_location_id" => array('integer',$this->getMetaId()))))
84 {
85 return true;
86 }
87 }
88 return false;
89 }
90
91 function delete()
92 {
93 global $ilDB;
94
95 if($this->getMetaId())
96 {
97 $query = "DELETE FROM il_meta_location ".
98 "WHERE meta_location_id = ".$ilDB->quote($this->getMetaId() ,'integer');
99 $res = $ilDB->manipulate($query);
100
101 return true;
102 }
103 return false;
104 }
105
106
107 function __getFields()
108 {
109 return array('rbac_id' => array('integer',$this->getRBACId()),
110 'obj_id' => array('integer',$this->getObjId()),
111 'obj_type' => array('text',$this->getObjType()),
112 'parent_type' => array('text',$this->getParentType()),
113 'parent_id' => array('integer',$this->getParentId()),
114 'location' => array('text',$this->getLocation()),
115 'location_type' => array('text',$this->getLocationType()));
116 }
117
118 function read()
119 {
120 global $ilDB;
121
122 include_once 'Services/MetaData/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() ,'integer');
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($row->location);
138 $this->setLocationType($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()
152 ? $this->getLocationType()
153 : 'LocalFile'),
154 $this->getLocation());
155 }
156
157
158 // STATIC
159 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
160 {
161 global $ilDB;
162
163 $query = "SELECT meta_location_id FROM il_meta_location ".
164 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id ,'integer')." ".
165 "AND obj_id = ".$ilDB->quote($a_obj_id ,'integer')." ".
166 "AND parent_id = ".$ilDB->quote($a_parent_id ,'integer')." ".
167 "AND parent_type = ".$ilDB->quote($a_parent_type ,'text');
168
169 $res = $ilDB->query($query);
170 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
171 {
172 $ids[] = $row->meta_location_id;
173 }
174 return $ids ? $ids : array();
175 }
176}
177?>
$location
Definition: buildRTE.php:44
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setObjId($a_id)
setParentId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
setParentType($a_parent_type)
setLocationType($a_location_type)
ilMDLocation($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
setLocation($a_location)
global $ilDB