Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezbugcategory.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezbugcategory.php 8229 2001-11-01 20:33:09Z vl $
5 //
6 // Definition of eZBugCategory class
7 //
8 // Created on: <27-Nov-2000 19:08:57 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
51 // include_once( "classes/ezdb.php" );
52
53
54 class eZBugCategory
55 {
62 function __construct( $id = -1 )
63 {
64 if ( $id != -1 )
65 {
66 $this->ID = $id;
67 $this->get( $this->ID );
68 }
69 }
70
74 function store()
75 {
76 $db =& eZDB::globalDatabase();
77
78 $name = $db->escapeString( $this->Name );
79 $description = $db->escapeString( $this->Description );
80
81 $db->begin();
82 if ( !isset( $this->ID ) )
83 {
84 $db->lock( "eZBug_Category" );
85 $this->ID = $db->nextID( "eZBug_Category", "ID" );
86 $res = $db->query( "INSERT INTO eZBug_Category
87 (ID, Name, Description) VALUES
88 ('$this->ID', '$name', '$description')" );
89 $db->unlock();
90
91 }
92 else
93 {
94 $res = $db->query( "UPDATE eZBug_Category SET
95 Name='$name',
96 Description='$description'
97 WHERE ID='$this->ID'" );
98 }
99
100 if ( $res == false )
101 $db->rollback();
102 else
103 $db->commit();
104
105
106 return true;
107 }
108
113 function delete()
114 {
115 $db =& eZDB::globalDatabase();
116
117 if ( isset( $this->ID ) )
118 {
119 $db->begin();
120 // delete from BugCategoryLink
121 $res[] = $db->query( "DELETE FROM eZBug_BugCategoryLink WHERE CategoryID='$this->ID'" );
122 // delete actual group entry
123 $res[] = $db->query( "DELETE FROM eZBug_Category WHERE ID='$this->ID'" );
124
125 if ( in_array( false, $res ) )
126 $db->rollback();
127 else
128 $db->commit();
129 }
130
131 return true;
132 }
133
137 function get( $id=-1 )
138 {
139 $db =& eZDB::globalDatabase();
140
141 if ( $id != "" )
142 {
143 $db->array_query( $category_array, "SELECT * FROM eZBug_Category WHERE ID='$id'" );
144 if ( count( $category_array ) > 1 )
145 {
146 die( "Error: Category's with the same ID was found in the database. This shouldent happen." );
147 }
148 else if ( count( $category_array ) == 1 )
149 {
150 $this->ID = $category_array[0][$db->fieldName( "ID" )];
151 $this->Name = $category_array[0][$db->fieldName( "Name" )];
152 $this->Description = $category_array[0][$db->fieldName( "Description" )];
153 }
154 }
155 }
156
162 function getAll()
163 {
164 $db =& eZDB::globalDatabase();
165
166 $return_array = array();
167 $category_array = array();
168
169 $db->array_query( $category_array, "SELECT ID FROM eZBug_Category ORDER BY Name" );
170
171 for ( $i = 0; $i < count( $category_array ); $i++ )
172 {
173 $return_array[$i] = new eZBugCategory( $category_array[$i][$db->fieldName( "ID" )], 0 );
174 }
175
176 return $return_array;
177 }
178
182 function id()
183 {
184 return $this->ID;
185 }
186
190 function name( $html = true )
191 {
192 if ( $html )
193 return htmlspecialchars( $this->Name );
194 else
195 return $this->Name;
196 }
197
201 function description( $html = true )
202 {
203 if( $html )
204 return htmlspecialchars( $this->Description );
205 else
206 return $this->Description;
207 }
208
212 function setName( $value )
213 {
214 $this->Name = $value;
215 }
216
220 function setDescription( $value )
221 {
222 $this->Description = $value;
223 }
224
228 function addBug( $value )
229 {
230 if ( is_a( $value, "eZBug" ) )
231 {
232 $bugID = $value->id();
233
234 $db =& eZDB::globalDatabase();
235 $db->begin();
236 $db->lock( "eZBug_BugCategoryLink" );
237 $nextID = $db->nextID( "eZBug_BugCategoryLink", "ID" );
238 $res = $query = "INSERT INTO eZBug_BugCategoryLink
239 (ID, CategoryID, BugID)
240 VALUES
241 ('$nextID','$this->ID','$bugID')";
242 echo $query; echo "<hr>";
243 $db->query( $query );
244 $db->unlock();
245 }
246 if ( $res == false )
247 $db->rollback();
248 else
249 $db->commit();
250 }
251
258 function bugs( $sortMode="time",
259 $fetchUnhandled=true,
260 $offset=0,
261 $limit=50 )
262 {
263 $db =& eZDB::globalDatabase();
264
265 // $OrderBy = "eZBug_Bug.Published DESC";
266 // switch( $sortMode )
267 // {
268 // case "alpha" :
269 // {
270 // $OrderBy = "eZBug_Bug.Name ASC";
271 // }
272 // break;
273 // }
274
275 $return_array = array();
276 $bug_array = array();
277
278 if ( $fetchUnhandled )
279 {
280 $excludedCode = " AND eZBug_Bug.IsHandled=0 ";
281 }
282 else
283 {
284 $excludedCode = "";
285 }
286
287 $db->array_query( $bug_array, "
288 SELECT eZBug_Bug.ID AS BugID,
289 eZBug_Category.ID,
290 FROM eZBug_Bug, eZBug_Category, eZBug_BugCategoryLink
291 WHERE
292 eZBug_BugCategoryLink.BugID = eZBug_Bug.ID
293 AND
294 eZBug_Category.ID = eZBug_BugCategoryLink.CategoryID
295 AND
296 eZBug_Category.ID='$this->ID'
297 $excludedCode
298 GROUP BY eZBug_Bug.ID, eZBug_Category.ID ORDER BY $OrderBy",
299 array( "Limit" => $limit, "Offset" => $offset ) );
300
301 for ( $i = 0; $i < count( $bug_array ); $i++ )
302 {
303 $return_array[$i] = new eZBug( $bug_array[$i][$db->fieldName( "BugID" )], false );
304 }
305
306 return $return_array;
307 }
308
309 var $ID;
310 var $Name;
311 var $Description;
312 }
313
314 ?>
$i
$i
Definition: admin/adlist.php:91
eZBugCategory
Definition: ezbugcategory.php:55
eZBugCategory\id
id()
Definition: ezbugcategory.php:182
eZBugCategory\description
description( $html=true)
Definition: ezbugcategory.php:201
eZBugCategory\setDescription
setDescription( $value)
Definition: ezbugcategory.php:220
eZBugCategory\setName
setName( $value)
Definition: ezbugcategory.php:212
eZBugCategory\__construct
__construct( $id=-1)
Definition: ezbugcategory.php:62
eZBugCategory\getAll
getAll()
Definition: ezbugcategory.php:162
eZBugCategory\$ID
$ID
Definition: ezbugcategory.php:309
eZBugCategory\store
store()
Definition: ezbugcategory.php:74
eZBugCategory\$Name
$Name
Definition: ezbugcategory.php:310
eZBugCategory\$Description
$Description
Definition: ezbugcategory.php:311
eZBugCategory\bugs
bugs( $sortMode="time", $fetchUnhandled=true, $offset=0, $limit=50)
Definition: ezbugcategory.php:258
eZBugCategory\addBug
addBug( $value)
Definition: ezbugcategory.php:228
eZBugCategory\name
name( $html=true)
Definition: ezbugcategory.php:190
eZBug
Definition: ezbug.php:80
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$category_array
$category_array
Definition: todoedit.php:604
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.