ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
36  function ilMDIdentifier($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
37  {
38  parent::ilMDBase($a_rbac_id,
39  $a_obj_id,
40  $a_obj_type);
41  }
42 
43  // SET/GET
44  function setCatalog($a_catalog)
45  {
46  $this->catalog = $a_catalog;
47  }
48  function getCatalog()
49  {
50  return $this->catalog;
51  }
52  function setEntry($a_entry)
53  {
54  $this->entry = $a_entry;
55  }
56  function getEntry()
57  {
58  return $this->entry;
59  }
60 
61 
62  function save()
63  {
64  if($this->db->autoExecute('il_meta_identifier',
65  $this->__getFields(),
66  DB_AUTOQUERY_INSERT))
67  {
68  $this->setMetaId($this->db->getLastInsertId());
69 
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->autoExecute('il_meta_identifier',
82  $this->__getFields(),
83  DB_AUTOQUERY_UPDATE,
84  "meta_identifier_id = ".$ilDB->quote($this->getMetaId())))
85  {
86  return true;
87  }
88  }
89  return false;
90  }
91 
92  function delete()
93  {
94  global $ilDB;
95 
96  if($this->getMetaId())
97  {
98  $query = "DELETE FROM il_meta_identifier ".
99  "WHERE meta_identifier_id = ".$ilDB->quote($this->getMetaId());
100 
101  $this->db->query($query);
102 
103  return true;
104  }
105  return false;
106  }
107 
108 
109  function __getFields()
110  {
111  return array('rbac_id' => $this->getRBACId(),
112  'obj_id' => $this->getObjId(),
113  'obj_type' => ilUtil::prepareDBString($this->getObjType()),
114  'parent_type' => $this->getParentType(),
115  'parent_id' => $this->getParentId(),
116  'catalog' => ilUtil::prepareDBString($this->getCatalog()),
117  'entry' => ilUtil::prepareDBString($this->getEntry()));
118 
119  }
120 
121  function read()
122  {
123  global $ilDB;
124 
125  if($this->getMetaId())
126  {
127  $query = "SELECT * FROM il_meta_identifier ".
128  "WHERE meta_identifier_id = ".$ilDB->quote($this->getMetaId());
129 
130  $res = $this->db->query($query);
131  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
132  {
133  $this->setRBACId($row->rbac_id);
134  $this->setObjId($row->obj_id);
135  $this->setObjType($row->obj_type);
136  $this->setParentId($row->parent_id);
137  $this->setParentType($row->parent_type);
138  $this->setCatalog(ilUtil::stripSlashes($row->catalog));
139  $this->setEntry(ilUtil::stripSlashes($row->entry));
140  }
141  }
142  return true;
143  }
144 
145  /*
146  * XML Export of all meta data
147  * @param object (xml writer) see class.ilMD2XML.php
148  *
149  */
150  function toXML(&$writer)
151  {
152  $writer->xmlElement('Identifier',array('Catalog' => $this->getCatalog(),
153  'Entry' => $this->getEntry()));
154  }
155 
156 
157  // STATIC
158  function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
159  {
160  global $ilDB;
161 
162  $query = "SELECT meta_identifier_id FROM il_meta_identifier ".
163  "WHERE rbac_id = ".$ilDB->quote($a_rbac_id)." ".
164  "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
165  "AND parent_id = ".$ilDB->quote($a_parent_id)." ".
166  "AND parent_type = ".$ilDB->quote($a_parent_type);
167 
168 
169  $res = $ilDB->query($query);
170  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
171  {
172  $ids[] = $row->meta_identifier_id;
173  }
174  return $ids ? $ids : array();
175  }
176 }
177 ?>