ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMDRights.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
33class ilMDRights extends ilMDBase
34{
35 // SET/GET
36 function setCosts($a_costs)
37 {
38 switch($a_costs)
39 {
40 case 'Yes':
41 case 'No':
42 $this->costs = $a_costs;
43 return true;
44
45 default:
46 return false;
47 }
48 }
49 function getCosts()
50 {
51 return $this->costs;
52 }
54 {
55 switch($a_caor)
56 {
57 case 'Yes':
58 case 'No':
59 $this->caor = $a_caor;
60 return true;
61
62 default:
63 return false;
64 }
65 }
67 {
68 return $this->caor;
69 }
70 function setDescription($a_description)
71 {
72 $this->description = $a_description;
73 }
74 function getDescription()
75 {
76 return $this->description;
77 }
78 function setDescriptionLanguage(&$lng_obj)
79 {
80 if(is_object($lng_obj))
81 {
82 $this->description_language = $lng_obj;
83 }
84 }
86 {
87 return is_object($this->description_language) ? $this->description_language : false;
88 }
90 {
91 return is_object($this->description_language) ? $this->description_language->getLanguageCode() : false;
92 }
93
94 function save()
95 {
96 if($this->db->autoExecute('il_meta_rights',
97 $this->__getFields(),
99 {
100 $this->setMetaId($this->db->getLastInsertId());
101
102 return $this->getMetaId();
103 }
104 return false;
105 }
106
107 function update()
108 {
109 global $ilDB;
110
111 if($this->getMetaId())
112 {
113 if($this->db->autoExecute('il_meta_rights',
114 $this->__getFields(),
116 "meta_rights_id = ".$ilDB->quote($this->getMetaId())))
117 {
118 return true;
119 }
120 }
121 return false;
122 }
123
124 function delete()
125 {
126 global $ilDB;
127
128 if($this->getMetaId())
129 {
130 $query = "DELETE FROM il_meta_rights ".
131 "WHERE meta_rights_id = ".$ilDB->quote($this->getMetaId());
132
133 $this->db->query($query);
134
135 return true;
136 }
137 return false;
138 }
139
140
141 function __getFields()
142 {
143 return array('rbac_id' => $this->getRBACId(),
144 'obj_id' => $this->getObjId(),
145 'obj_type' => ilUtil::prepareDBString($this->getObjType()),
146 'costs' => ilUtil::prepareDBString($this->getCosts()),
147 'copyright_and_other_restrictions' => ilUtil::prepareDBString($this->getCopyrightAndOtherRestrictions()),
148 'description' => ilUtil::prepareDBString($this->getDescription()),
149 'description_language' => ilUtil::prepareDBString($this->getDescriptionLanguageCode()));
150 }
151
152 function read()
153 {
154 global $ilDB;
155
156 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDLanguageItem.php';
157
158
159 if($this->getMetaId())
160 {
161
162 $query = "SELECT * FROM il_meta_rights ".
163 "WHERE meta_rights_id = ".$ilDB->quote($this->getMetaId());
164
165
166 $res = $this->db->query($query);
167 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
168 {
169 $this->setRBACId($row->rbac_id);
170 $this->setObjId($row->obj_id);
171 $this->setObjType($row->obj_type);
172 $this->setDescription(ilUtil::stripSlashes($row->description));
173 $this->setDescriptionLanguage(new ilMDLanguageItem($row->description_language));
174 $this->setCosts(ilUtil::stripSlashes($row->costs));
175 $this->setCopyrightAndOtherRestrictions(ilUtil::stripSlashes($row->copyright_and_other_restrictions));
176 }
177 return true;
178 }
179 return false;
180 }
181
182 /*
183 * XML Export of all meta data
184 * @param object (xml writer) see class.ilMD2XML.php
185 *
186 */
187 function toXML(&$writer)
188 {
189 $writer->xmlStartTag('Rights',array('Costs' => $this->getCosts(),
190 'CopyrightAndOtherRestrictions' => $this->getCopyrightAndOtherRestrictions()));
191 $writer->xmlElement('Description',array('Language' => $this->getDescriptionLanguageCode()),$this->getDescription());
192 $writer->xmlEndTag('Rights');
193 }
194
195 // STATIC
196 function _getId($a_rbac_id,$a_obj_id)
197 {
198 global $ilDB;
199
200 $query = "SELECT meta_rights_id FROM il_meta_rights ".
201 "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
202 "AND obj_id = ".$ilDB->quote($a_obj_id);
203
204 $res = $ilDB->query($query);
205 while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
206 {
207 return $row->meta_rights_id;
208 }
209 return false;
210 }
211}
212?>
An exception for terminatinating execution or to throw for unit testing.
setObjId($a_id)
setMetaId($a_meta_id, $a_read_data=true)
setObjType($a_type)
setRBACId($a_id)
getCopyrightAndOtherRestrictions()
& getDescriptionLanguage()
setCosts($a_costs)
getDescriptionLanguageCode()
setDescription($a_description)
setDescriptionLanguage(&$lng_obj)
_getId($a_rbac_id, $a_obj_id)
setCopyrightAndOtherRestrictions($a_caor)
toXML(&$writer)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilDB