ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMD5295Format.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
32include_once 'class.ilMD5295Base.php';
33
35{
36 // SET/GET
37 public function setFormat($a_format)
38 {
39 $this->format = $a_format;
40 }
41 public function getFormat()
42 {
43 return $this->format;
44 }
45
46 public function save()
47 {
48 global $DIC;
49
50 $ilDB = $DIC['ilDB'];
51
52 $fields = $this->__getFields();
53 $fields['meta_format_id'] = array('integer',$next_id = $ilDB->nextId('il_meta_format'));
54
55 if ($this->db->insert('il_meta_format', $fields)) {
56 $this->setMetaId($next_id);
57 return $this->getMetaId();
58 }
59 return false;
60 }
61
62 public function update()
63 {
64 global $DIC;
65
66 $ilDB = $DIC['ilDB'];
67
68 if ($this->getMetaId()) {
69 if ($this->db->update(
70 'il_meta_format',
71 $this->__getFields(),
72 array("meta_format_id" => array('integer',$this->getMetaId()))
73 )) {
74 return true;
75 }
76 }
77 return false;
78 }
79
80 public function delete()
81 {
82 global $DIC;
83
84 $ilDB = $DIC['ilDB'];
85
86 if ($this->getMetaId()) {
87 $query = "DELETE FROM il_meta_format " .
88 "WHERE meta_format_id = " . $ilDB->quote($this->getMetaId(), 'integer');
89 $res = $ilDB->manipulate($query);
90
91 return true;
92 }
93 return false;
94 }
95
96
97 public function __getFields()
98 {
99 return array('rbac_id' => array('integer',$this->getRBACId()),
100 'obj_id' => array('integer',$this->getObjId()),
101 'obj_type' => array('text',$this->getObjType()),
102 'format' => array('text',$this->getFormat()));
103 }
104
105 public function read()
106 {
107 global $DIC;
108
109 $ilDB = $DIC['ilDB'];
110
111 include_once 'Services/Migration/DBUpdate_5295/classes/class.ilMD5295LanguageItem.php';
112
113 if ($this->getMetaId()) {
114 $query = "SELECT * FROM il_meta_format " .
115 "WHERE meta_format_id = " . $ilDB->quote($this->getMetaId(), 'integer');
116
117 $res = $this->db->query($query);
118 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
119 $this->setRBACId($row->rbac_id);
120 $this->setObjId($row->obj_id);
121 $this->setObjType($row->obj_type);
122 $this->setFormat($row->format);
123 }
124 }
125 return true;
126 }
127
128 /*
129 * XML Export of all meta data
130 * @param object (xml writer) see class.ilMD52952XML.php
131 *
132 */
133 public function toXML(&$writer)
134 {
135 if ($this->getFormat()) {
136 $writer->xmlElement('Format', null, $this->getFormat());
137 }
138 }
139
140
141 // STATIC
142 public static function _getIds($a_rbac_id, $a_obj_id)
143 {
144 global $DIC;
145
146 $ilDB = $DIC['ilDB'];
147
148 $query = "SELECT meta_format_id FROM il_meta_format " .
149 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
150 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
151
152 $res = $ilDB->query($query);
153 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
154 $ids[] = $row->meta_format_id;
155 }
156 return $ids ? $ids : array();
157 }
158}
An exception for terminatinating execution or to throw for unit testing.
setMetaId($a_meta_id, $a_read_data=true)
static _getIds($a_rbac_id, $a_obj_id)
$format
Definition: metadata.php:218
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46