ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMDOrComposite.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.ilMDBase.php';
33include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
34
36{
37 function ilMDOrComposite($a_rbac_id = 0,$a_obj_id = 0,$a_obj_type = '')
38 {
39 parent::ilMDRequirement($a_rbac_id,
40 $a_obj_id,
41 $a_obj_type);
42 }
43
44 // SET/GET
45 function setOrCompositeId($a_or_composite_id)
46 {
47 $this->or_composite_id = (int) $a_or_composite_id;
48 }
50 {
51 global $ilDB;
52
53 if(!$this->or_composite_id)
54 {
55 $query = "SELECT MAX(or_composite_id) AS orc FROM il_meta_requirement ".
56 "WHERE rbac_id = ".$ilDB->quote($this->getRBACId())." ".
57 "AND obj_id = ".$ilDB->quote($this->getObjId())." ".
58 "GROUP BY or_composite_id";
59
60 $res = $this->db->query($query);
61 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
62 {
63 $this->or_composite_id = $row->orc;
64 }
65 ++$this->or_composite_id;
66 }
67 return $this->or_composite_id;
68 }
69
71 {
72 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
73
74 return ilMDRequirement::_getIds($this->getRBACId(),
75 $this->getObjId(),
76 $this->getParentId(),
77 'meta_technical',
78 $this->getOrCompositeId());
79 }
80
81 function &getRequirement($a_requirement_id)
82 {
83 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
84
85 if(!$a_requirement_id)
86 {
87 return false;
88 }
89 $req =& new ilMDRequirement();
90 $req->setMetaId($a_requirement_id);
91
92 return $req;
93 }
94
95 function &addRequirement()
96 {
97 include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDRequirement.php';
98
99 $req =& new ilMDRequirement($this->getRBACId(),$this->getObjId(),$this->getObjType());
100 $req->setParentId($this->getParentId());
101 $req->setParentType('meta_technical');
102 $req->setOrCompositeId($this->getOrCompositeId());
103
104 return $req;
105 }
106
107 /*
108 * Overwritten save method, to get new or_composite_id
109 *
110 */
111 function save()
112 {
113 echo 'Use ilMDOrcomposite::addRequirement()';
114 }
115
116 function delete()
117 {
118 foreach($this->getRequirementIds() as $id)
119 {
120 $req = $this->getRequirement($id);
121 $req->delete();
122 }
123 return true;
124 }
125
126 /*
127 * XML Export of all meta data
128 * @param object (xml writer) see class.ilMD2XML.php
129 *
130 */
131 function toXML(&$writer)
132 {
133 // For all requirements
134 $writer->xmlStartTag('OrComposite');
135
136 foreach($this->getRequirementIds() as $id)
137 {
138 $req = $this->getRequirement($id);
139 $req->toXML($writer);
140 }
141 $writer->xmlEndTag('OrComposite');
142
143 }
144
145
146 // STATIC
147 function _getIds($a_rbac_id,$a_obj_id,$a_parent_id,$a_parent_type)
148 {
149 global $ilDB;
150
151 $query = "SELECT DISTINCT(or_composite_id) AS or_composite_id FROM il_meta_requirement ".
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 "AND or_composite_id > 0 ";
157
158 $res = $ilDB->query($query);
159 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
160 {
161 $ids[] = $row->or_composite_id;
162 }
163 return $ids ? $ids : array();
164 }
165}
166?>
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type)
& getRequirement($a_requirement_id)
setOrCompositeId($a_or_composite_id)
ilMDOrComposite($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
ilMDRequirement($a_rbac_id=0, $a_obj_id=0, $a_obj_type='')
_getIds($a_rbac_id, $a_obj_id, $a_parent_id, $a_parent_type, $a_or_composite_id=0)
global $ilDB