ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMDIdentifier.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 ilMDIdentifier extends ilMDBase
34 {
35  // SET/GET
36  public function setCatalog($a_catalog)
37  {
38  $this->catalog = $a_catalog;
39  }
40  public function getCatalog()
41  {
42  return $this->catalog;
43  }
44  public function setEntry($a_entry)
45  {
46  $this->entry = $a_entry;
47  }
48  public function getEntry()
49  {
50  return $this->entry;
51  }
52 
53 
54  public function save()
55  {
56  if ($this->db->autoExecute(
57  'il_meta_identifier',
58  $this->__getFields(),
60  )) {
61  $this->setMetaId($this->db->getLastInsertId());
62 
63  return $this->getMetaId();
64  }
65  return false;
66  }
67 
68  public function update()
69  {
70  global $ilDB;
71 
72  if ($this->getMetaId()) {
73  if ($this->db->autoExecute(
74  'il_meta_identifier',
75  $this->__getFields(),
77  "meta_identifier_id = " . $ilDB->quote($this->getMetaId())
78  )) {
79  return true;
80  }
81  }
82  return false;
83  }
84 
85  public function delete()
86  {
87  global $ilDB;
88 
89  if ($this->getMetaId()) {
90  $query = "DELETE FROM il_meta_identifier " .
91  "WHERE meta_identifier_id = " . $ilDB->quote($this->getMetaId());
92 
93  $this->db->query($query);
94 
95  return true;
96  }
97  return false;
98  }
99 
100 
101  public function __getFields()
102  {
103  return array('rbac_id' => $this->getRBACId(),
104  'obj_id' => $this->getObjId(),
105  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
106  'parent_type' => $this->getParentType(),
107  'parent_id' => $this->getParentId(),
108  'catalog' => ilUtil::prepareDBString($this->getCatalog()),
109  'entry' => ilUtil::prepareDBString($this->getEntry()));
110  }
111 
112  public function read()
113  {
114  global $ilDB;
115 
116  if ($this->getMetaId()) {
117  $query = "SELECT * FROM il_meta_identifier " .
118  "WHERE meta_identifier_id = " . $ilDB->quote($this->getMetaId());
119 
120  $res = $this->db->query($query);
121  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
122  $this->setRBACId($row->rbac_id);
123  $this->setObjId($row->obj_id);
124  $this->setObjType($row->obj_type);
125  $this->setParentId($row->parent_id);
126  $this->setParentType($row->parent_type);
127  $this->setCatalog(ilUtil::stripSlashes($row->catalog));
128  $this->setEntry(ilUtil::stripSlashes($row->entry));
129  }
130  }
131  return true;
132  }
133 
134  /*
135  * XML Export of all meta data
136  * @param object (xml writer) see class.ilMD2XML.php
137  *
138  */
139  public function toXML(&$writer)
140  {
141  $writer->xmlElement('Identifier', array('Catalog' => $this->getCatalog(),
142  'Entry' => $this->getEntry()));
143  }
144 
145 
146  // STATIC
147  public function _getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
148  {
149  global $ilDB;
150 
151  $query = "SELECT meta_identifier_id FROM il_meta_identifier " .
152  "WHERE rbac_id = " . $ilDB->quote($a_rbac_id) . " " .
153  "AND obj_id = " . $ilDB->quote($a_obj_id) . " " .
154  "AND parent_id = " . $ilDB->quote($a_parent_id) . " " .
155  "AND parent_type = " . $ilDB->quote($a_parent_type);
156 
157 
158  $res = $ilDB->query($query);
159  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
160  $ids[] = $row->meta_identifier_id;
161  }
162  return $ids ? $ids : array();
163  }
164 }
setObjType($a_type)
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
setMetaId($a_meta_id, $a_read_data=true)
foreach($_POST as $key=> $value) $res
setObjId($a_id)
setRBACId($a_id)
$query
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
setParentId($a_id)
static prepareDBString($a_str)
prepare a string for db writing (insert/update)
global $ilDB
setParentType($a_parent_type)