Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezbugmodule.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezbugmodule.php 7766 2001-10-10 20:18:53Z fh $
5 //
6 // Definition of eZBugModule 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 // include_once( "ezbug/classes/ezbug.php" );
53 // include_once( "ezuser/classes/ezusergroup.php" );
54
55 class eZBugModule
56 {
63 function __construct( $id=-1 )
64 {
65 $this->OwnerGroupID = 0;
66
67 if ( $id != -1 )
68 {
69 $this->ID = $id;
70 $this->get( $this->ID );
71 }
72 }
73
77 function store()
78 {
79 $db =& eZDB::globalDatabase();
80 $name = $db->escapeString( $this->Name );
81 $description = $db->escapeString( $this->Description );
82 $db->begin();
83
84 if ( !isset( $this->ID ) )
85 {
86 $db->lock( "eZBug_Module", "ID" );
87 $this->ID = $db->nextID( "eZBug_Module", "ID" );
88 $res = $db->query( "INSERT INTO eZBug_Module
89 (ID, Name, Description, ParentID, OwnerGroupID)
90 VALUES
91 ('$this->ID',
92 '$name',
93 '$description',
94 '$this->ParentID',
95 '$this->OwnerGroupID')" );
96 $db->unlock();
97 }
98 else
99 {
100 $res = $db->query( "UPDATE eZBug_Module SET
101 Name='$name',
102 Description='$description',
103 ParentID='$this->ParentID',
104 OwnerGroupID='$this->OwnerGroupID'
105 WHERE ID='$this->ID'" );
106 }
107
108 if ( $res == false )
109 $db->rollback();
110 else
111 $db->commit();
112
113 return true;
114 }
115
120 function delete()
121 {
122 $db =& eZDB::globalDatabase();
123 $db->begin();
124 if ( isset( $this->ID ) )
125 {
126 // delete all bugs!
127 $bugs = array();
128 $db->array_query( $bugs, "SELECT eZBug_BugModuleLink.BugID FROM eZBug_BugModuleLink WHERE ModuleID='$this->ID'" );
129 foreach ( $bugs as $bugID )
130 {
131 $doomedBug = new eZBug( $bugID[ $db->fieldName( "BugID" ) ] );
132 $doomedBug->delete();
133 }
134
135 // delete the modules that have this module as parent.
136 $doomedModules = $this->getByParent( $this );
137 if ( count( $doomedModules ) > 0 )
138 {
139 foreach ( $doomedModules as $module )
140 {
141 $module->delete();
142 }
143 }
144
145 $res[] = $db->query( "DELETE FROM eZBug_ModulePermission WHERE ObjectID='$this->ID'" );
146 $res[] = $db->query( "DELETE FROM eZBug_BugModuleLink WHERE ModuleID='$this->ID'" );
147 $res[] = $db->query( "DELETE FROM eZBug_Module WHERE ID='$this->ID'" );
148 }
149
150 eZDB::finish( $res, $db );
151 return true;
152 }
153
157 function get( $id = -1 )
158 {
159 $db =& eZDB::globalDatabase();
160
161 if ( $id != "" )
162 {
163 $db->array_query( $module_array, "SELECT * FROM eZBug_Module WHERE ID='$id'" );
164 if ( count( $module_array ) > 1 )
165 {
166 die( "Error: Module's with the same ID was found in the database. This should not happen." );
167 }
168 else if ( count( $module_array ) == 1 )
169 {
170 $this->ID = $module_array[0][$db->fieldName( "ID" )];
171 $this->Name = $module_array[0][$db->fieldName( "Name" )];
172 $this->Description = $module_array[0][$db->fieldName( "Description" )];
173 $this->ParentID = $module_array[0][$db->fieldName( "ParentID" )];
174 $this->OwnerGroupID = $module_array[0][$db->fieldName( "OwnerGroupID" )];
175 }
176 }
177 }
178
184 function getAll()
185 {
186 $db =& eZDB::globalDatabase();
187
188 $return_array = array();
189 $module_array = array();
190
191 $db->array_query( $module_array, "SELECT ID FROM eZBug_Module ORDER BY Name" );
192
193 for ( $i = 0; $i < count( $module_array ); $i++ )
194 {
195 $return_array[$i] = new eZBugModule( $module_array[$i][$db->fieldName( "ID" )], 0 );
196 }
197
198 return $return_array;
199 }
200
206 function getByParent( $parent, $sortby="name", $recursive=false )
207 {
208 $db =& eZDB::globalDatabase();
209
210 $return_array = array();
211 $module_array = array();
212
213 $parentID = $parent->id();
214
215 $db->array_query( $module_array, "SELECT ID, Name FROM eZBug_Module
216 WHERE ParentID='$parentID'
217 ORDER BY Name" );
218
219 if ( is_array( $recursive ) )
220 {
221 $recursive[] = $parentID;
222 }
223
224 for ( $i = 0; $i < count( $module_array); $i++ )
225 {
226 if ( is_array( $recursive ) )
227 {
228 $mod = new eZBugModule( $module_array[$i][$db->fieldName( "ID" )] );
229 $recursive = $mod->getByParent( $mod, "name", $recursive );
230 }
231 else
232 {
233 $return_array[$i] = new eZBugModule( $module_array[$i][$db->fieldName( "ID" )], 0 );
234 }
235 }
236
237 if ( !is_array( $recursive ) )
238 {
239 return $return_array;
240 }
241 else
242 {
243 return $recursive;
244 }
245 }
246
247 function path( $moduleID=0 )
248 {
249 if ( $moduleID == 0 )
250 {
251 $moduleID = $this->ID;
252 }
253
254 $module = new eZBugModule( $moduleID );
255
256 $path = array();
257
258 $parent = $module->parent();
259
260 if ( $parent != 0 )
261 {
262 $path = array_merge( $path, $this->path( $parent->id() ) );
263 }
264 else
265 {
266 // array_push( $path, $module->name() );
267 }
268
269 if ( $moduleID != 0 )
270 array_push( $path, array( $module->id(), $module->name() ) );
271
272 return $path;
273 }
274
278 function id()
279 {
280 return $this->ID;
281 }
282
283
287 function name( $html = true )
288 {
289 if ( $this->Name == false )
290 return "";
291 else if ( $html )
292 return htmlspecialchars( $this->Name );
293 else
294 return $this->Name;
295 }
296
300 function description( $html = true )
301 {
302 if ( !is_null( $this->Description ) && $html )
303 return htmlspecialchars( $this->Description );
304 else
305 return $this->Description;
306 }
307
311 function parent()
312 {
313 if ( $this->ParentID != 0 )
314 {
315 return new eZBugModule( $this->ParentID );
316 }
317 else
318 {
319 return 0;
320 }
321 }
322
327 function ownerGroup()
328 {
329 $group = new eZUserGroup( $this->OwnerGroupID );
330 return $group;
331 }
332
336 function setName( $value )
337 {
338 $this->Name = $value;
339 }
340
344 function setDescription( $value )
345 {
346 $this->Description = $value;
347 }
348
353 function setParent( $value )
354 {
355 if ( is_a( $value, "eZBugModule" ) )
356 {
357 $this->ParentID = $value->id();
358 }
359 }
360
366 function setOwnerGroup( $newOwner, $recursive = false )
367 {
368 if( is_a( $newOwner, "eZUserGroup" ) )
369 {
370 $this->OwnerGroupID = $newOwner->id();
371 if( $recursive == true )
372 {
373 $modules = $this->getByParent( $this );
374 foreach( $modules as $moduleItem )
375 {
376 $moduleItem->setOwnerGroup( $newOwner, true );
377 $moduleItem->store();
378 }
379 }
380 }
381 }
382
386 function addBug( $value )
387 {
388 if ( is_a( $value, "eZBug" ) )
389 {
390 $db =& eZDB::globalDatabase();
391
392 $bugID = $value->id();
393
394 $db->begin();
395 $db->lock( "eZBug_BugModuleLink" );
396 $nextID = $db->nextID( "eZBug_BugModuleLink", "ID" );
397
398 $res = $query = "INSERT INTO eZBug_BugModuleLink
399 (ID, ModuleID, BugID) VALUES
400 ('$nextID', '$this->ID', '$bugID')";
401
402 $db->query( $query );
403 $db->unlock();
404
405 if ( $res == false )
406 $db->rollback();
407 else
408 $db->commit();
409 }
410 }
411
418 function &bugs( $sortMode="time",
419 $fetchUnhandled=true,
420 $withPrivate=false,
421 $offset=0,
422 $limit=50)
423 {
424 $db =& eZDB::globalDatabase();
425
426 $OrderBy = "eZBug_Bug.Created DESC";
427 switch( $sortMode )
428 {
429 case "alpha" :
430 {
431 $OrderBy = "eZBug_Bug.Name ASC";
432 }
433 break;
434 }
435
436 $return_array = array();
437 $bug_array = array();
438
439 $unhandledSQL = "";
440 if ( $fetchUnhandled == false )
441 {
442 $unhandledSQL = "AND IsHandled='0'";
443 }
444 $privateSQL = "";
445 if( $withPrivate == false )
446 {
447 $privateSQL="AND IsPrivate='0'";
448 }
449
450 $db->array_query( $bug_array, "
451 SELECT eZBug_Bug.ID AS BugID, eZBug_Bug.Name, eZBug_Module.ID, eZBug_Module.Name
452 FROM eZBug_Bug, eZBug_Module, eZBug_BugModuleLink
453 WHERE
454 eZBug_BugModuleLink.BugID = eZBug_Bug.ID
455 AND
456 eZBug_Module.ID = eZBug_BugModuleLink.ModuleID
457 $unhandledSQL
458 $privateSQL
459 AND
460 eZBug_Module.ID='$this->ID'
461 GROUP BY eZBug_Bug.ID ORDER BY $OrderBy LIMIT $offset,$limit" );
462
463 for ( $i=0; $i < count( $bug_array ); $i++ )
464 {
465 $return_array[$i] = new eZBug( $bug_array[$i][ $db->fieldName( "BugID" ) ], false );
466 }
467
468 return $return_array;
469 }
470
481 function countBugs( $countUnhandled=true, $excludeClosed=false, $recursive=false, $withPrivate=false )
482 {
483 $db =& eZDB::globalDatabase();
484
485 $unhandledSQL = "";
486 if ( $countUnhandled == false )
487 {
488 $unhandledSQL = "AND eZBug_Bug.IsHandled='1'";
489 }
490
491 $openSQL = "";
492 if ( $excludeClosed == true )
493 {
494 $openSQL = "AND eZBug_Bug.IsClosed!='1'";
495 }
496
497 $privateSQL = "";
498 if( $withPrivate == false )
499 {
500 $privateSQL = "AND eZBug_Bug.IsPrivate!='1'";
501 }
502
503 $query = "
504 SELECT count( * ) AS Count
505 FROM eZBug_Bug, eZBug_Module, eZBug_BugModuleLink
506 WHERE
507 eZBug_BugModuleLink.BugID = eZBug_Bug.ID
508 AND
509 eZBug_Module.ID = eZBug_BugModuleLink.ModuleID
510 $unhandledSQL
511 $openSQL
512 $privateSQL
513 AND
514 eZBug_Module.ID='$this->ID'
515 ";
516
517 $db->array_query( $bug_array, $query );
518 $ret =& $bug_array[0][ $db->fieldName( "Count" ) ];
519
520 if( $recursive == true ) // Count bugs in modules under this one.
521 {
522 $query = "
523 SELECT ID
524 FROM eZBug_Module
525 WHERE
526 eZBug_Module.ParentID = '$this->ID'
527 ";
528 $db->array_query( $modules, $query );
529 for ( $i = 0; $i < count( $modules ); $i++ )
530 {
531 $mod = new eZBugModule( $modules[$i][ $db->fieldName( "ID" ) ] );
532 $ret += $mod->countBugs( $countUnhandled, $excludeClosed, true );
533 }
534 }
535 return $ret;
536 }
537
542 function isChild( $moduleID, $check_for_self = false )
543 {
544 $return_value = false;
545 $db =& eZDB::globalDatabase();
546
547 if ( is_a( $moduleID, "eZBugModule" ) )
548 $moduleID = $moduleID->id();
549
550 if ( $check_for_self == true && $moduleID == $this->ID )
551 return true;
552
553 while ( $moduleID != 0 )
554 {
555 $db->query_single( $result, "SELECT ParentID FROM eZBug_Module WHERE ID='$moduleID'" );
556 $moduleID = $result[ $db->fieldName( "ParentID" ) ];
557 if ( $moduleID == $this->ID )
558 return true;
559 }
560 return $return_value;
561 }
562
563 var $ID;
564 var $Name;
565 var $ParentID;
566 var $Description;
567 var $OwnerGroupID;
568 }
569
570 ?>
$i
$i
Definition: admin/adlist.php:91
$group
$group
Definition: admin/articleedit.php:799
$modules
foreach( $categories as $category) $modules
Definition: bugedit.php:496
eZBugModule
Definition: ezbugmodule.php:56
eZBugModule\$Name
$Name
Definition: ezbugmodule.php:564
eZBugModule\setOwnerGroup
setOwnerGroup( $newOwner, $recursive=false)
Definition: ezbugmodule.php:366
eZBugModule\store
store()
Definition: ezbugmodule.php:77
eZBugModule\id
id()
Definition: ezbugmodule.php:278
eZBugModule\path
path( $moduleID=0)
Definition: ezbugmodule.php:247
eZBugModule\countBugs
countBugs( $countUnhandled=true, $excludeClosed=false, $recursive=false, $withPrivate=false)
Definition: ezbugmodule.php:481
eZBugModule\__construct
__construct( $id=-1)
Definition: ezbugmodule.php:63
eZBugModule\parent
parent()
Definition: ezbugmodule.php:311
eZBugModule\$ParentID
$ParentID
Definition: ezbugmodule.php:565
eZBugModule\$ID
$ID
Definition: ezbugmodule.php:563
eZBugModule\description
description( $html=true)
Definition: ezbugmodule.php:300
eZBugModule\setParent
setParent( $value)
Definition: ezbugmodule.php:353
eZBugModule\ownerGroup
ownerGroup()
Definition: ezbugmodule.php:327
eZBugModule\name
name( $html=true)
Definition: ezbugmodule.php:287
eZBugModule\bugs
& bugs( $sortMode="time", $fetchUnhandled=true, $withPrivate=false, $offset=0, $limit=50)
Definition: ezbugmodule.php:418
eZBugModule\getByParent
getByParent( $parent, $sortby="name", $recursive=false)
Definition: ezbugmodule.php:206
eZBugModule\isChild
isChild( $moduleID, $check_for_self=false)
Definition: ezbugmodule.php:542
eZBugModule\addBug
addBug( $value)
Definition: ezbugmodule.php:386
eZBugModule\getAll
getAll()
Definition: ezbugmodule.php:184
eZBugModule\$OwnerGroupID
$OwnerGroupID
Definition: ezbugmodule.php:567
eZBugModule\setName
setName( $value)
Definition: ezbugmodule.php:336
eZBugModule\$Description
$Description
Definition: ezbugmodule.php:566
eZBugModule\setDescription
setDescription( $value)
Definition: ezbugmodule.php:344
eZBug
Definition: ezbug.php:80
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZUserGroup
Definition: ezusergroup.php:66
$module
$module
Definition: classes/admin/linkselect.php:219
$result
$result
Definition: companysearch.php:94
$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
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$OrderBy
$OrderBy
Definition: reciverpopup.php:21
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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.