Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezbuglog.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezbuglog.php 6409 2001-08-09 14:17:42Z jhe $
5 //
6 // Definition of eZBugLog class
7 //
8 // Created on: <28-Nov-2000 21:44:41 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
38 // include_once( "classes/ezdb.php" );
39 // include_once( "ezuser/classes/ezuser.php" );
40
41 class eZBugLog
42 {
49 function __construct( $id = -1 )
50 {
51 if ( $id != -1 )
52 {
53 $this->get( $id );
54 }
55 }
56
60 function store()
61 {
62 $db =& eZDB::globalDatabase();
63 $description = $db->escapeString( $this->Description );
64
65 $db->begin();
66
67 if ( !isset( $this->ID ) )
68 {
69 $db->lock( "eZBug_Log" );
70 $timestamp = (new eZDateTime())->timeStamp( true );
71 $this->ID = $db->nextID( "eZBug_Log", "ID" );
72 $res = $db->query( "INSERT INTO eZBug_Log
73 (ID, Description, BugID, UserID, Created)
74 VALUES
75 ('$this->ID','$description','$this->BugID','$this->UserID', '$timestamp')" );
76 $db->unlock();
77 }
78 else
79 {
80 $res = $db->query( "UPDATE eZBug_Log SET
81 Description='$description',
82 BugID='$this->BugID',
83 UserID='$this->UserID'
84 WHERE ID='$this->ID'" );
85 }
86
87 if ( $res == false )
88 $db->rollback();
89 else
90 $db->commit();
91
92 return true;
93 }
94
98 function delete()
99 {
100 $db =& eZDB::globalDatabase();
101 $db->begin();
102
103 if ( isset( $this->ID ) )
104 {
105 $res[] = $db->query( "DELETE FROM eZBug_Log WHERE ID='$this->ID'" );
106 }
107 eZDB::finish( $res, $db );
108 return true;
109 }
110
114 function get( $id = "" )
115 {
116 $db =& eZDB::globalDatabase();
117 if ( $id != "" )
118 {
119 $db->array_query( $module_array, "SELECT * FROM eZBug_Log WHERE ID='$id'" );
120 if ( count( $module_array ) > 1 )
121 {
122 die( "Error: BugLogs with the same ID was found in the database. This shouldent happen." );
123 }
124 else if ( count( $module_array ) == 1 )
125 {
126 $this->ID = $module_array[0][$db->fieldName( "ID" )];
127 $this->Description = $module_array[0][$db->fieldName( "Description" )];
128 $this->UserID = $module_array[0][$db->fieldName( "UserID" )];
129 $this->BugID = $module_array[0][$db->fieldName( "BugID" )];
130 $this->Created = $module_array[0][$db->fieldName( "Created" )];
131 }
132 }
133 }
134
140 function getAll()
141 {
142 $db =& eZDB::globalDatabase();
143
144 $return_array = array();
145 $module_array = array();
146
147 $db->array_query( $module_array, "SELECT ID FROM eZBug_Log ORDER BY Created" );
148
149 for ( $i = 0; $i < count( $module_array ); $i++ )
150 {
151 $return_array[$i] = new eZBug( $module_array[$i][$db->fieldName( "ID" )], 0 );
152 }
153
154 return $return_array;
155 }
156
163 static public function getByBug( $bug )
164 {
165 $db =& eZDB::globalDatabase();
166
167 $return_array = array();
168 $module_array = array();
169
170 if ( is_a( $bug, "eZBug" ) )
171 {
172 $bugID = $bug->id();
173 $db->array_query( $module_array, "SELECT ID FROM eZBug_Log
174 WHERE BugID='$bugID'
175 ORDER BY Created" );
176
177 for ( $i = 0; $i < count( $module_array ); $i++ )
178 {
179 $return_array[$i] = new eZBugLog( $module_array[$i][$db->fieldName( "ID" )] );
180 }
181 }
182 return $return_array;
183 }
184
188 function id()
189 {
190 return $this->ID;
191 }
192
196 function description( $html = true )
197 {
198 if ( $html )
199 return htmlspecialchars( $this->Description );
200 else
201 return $this->Description;
202 }
203
209 function &created()
210 {
211 $dateTime = new eZDateTime();
212 $dateTime->setTimeStamp( $this->Created );
213 return $dateTime;
214 }
215
219 function &user()
220 {
221 $user = new eZUser( $this->UserID );
222 return $user;
223 }
224
228 function &bug()
229 {
230 $bug = new eZBug( $this->BugID );
231 return $bug;
232 }
233
237 function setDescription( $value )
238 {
239 $this->Description = $value;
240 }
241
245 function setUser( $user )
246 {
247 if ( is_a( $user, "eZUser" ) )
248 {
249 $this->UserID = $user->id();
250 }
251 }
252
256 function setBug( $bug )
257 {
258 if ( is_a( $bug, "eZBug" ) )
259 {
260 $this->BugID = $bug->id();
261 }
262 }
263
264 var $ID;
265 var $Description;
266 var $IsHandled;
267 var $Created;
268 var $UserID;
269 var $BugID;
270 }
271
272 ?>
$i
$i
Definition: admin/adlist.php:91
$dateTime
$dateTime
Definition: authorview.php:77
$bug
$bug
Definition: bugpreview.php:59
eZBugLog
Definition: ezbuglog.php:42
eZBugLog\setUser
setUser( $user)
Definition: ezbuglog.php:245
eZBugLog\setBug
setBug( $bug)
Definition: ezbuglog.php:256
eZBugLog\$Created
$Created
Definition: ezbuglog.php:267
eZBugLog\id
id()
Definition: ezbuglog.php:188
eZBugLog\description
description( $html=true)
Definition: ezbuglog.php:196
eZBugLog\__construct
__construct( $id=-1)
Definition: ezbuglog.php:49
eZBugLog\bug
& bug()
Definition: ezbuglog.php:228
eZBugLog\user
& user()
Definition: ezbuglog.php:219
eZBugLog\getByBug
static getByBug( $bug)
Definition: ezbuglog.php:163
eZBugLog\getAll
getAll()
Definition: ezbuglog.php:140
eZBugLog\$UserID
$UserID
Definition: ezbuglog.php:268
eZBugLog\$BugID
$BugID
Definition: ezbuglog.php:269
eZBugLog\store
store()
Definition: ezbuglog.php:60
eZBugLog\$ID
$ID
Definition: ezbuglog.php:264
eZBugLog\created
& created()
Definition: ezbuglog.php:209
eZBugLog\$Description
$Description
Definition: ezbuglog.php:265
eZBugLog\setDescription
setDescription( $value)
Definition: ezbuglog.php:237
eZBugLog\$IsHandled
$IsHandled
Definition: ezbuglog.php:266
eZBug
Definition: ezbug.php:80
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZUser
Definition: ezuser.php:76
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$timestamp
$timestamp
Definition: ezstats/admin/cron.php:35
$res
$res
Definition: ezstats/admin/cron.php:45
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.