forked from pedro3005/whube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug.php
72 lines (63 loc) · 1.81 KB
/
bug.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Bug class file, All bug model work lies herein
*
* Base bug class to do bug CRUD work.
* @author Paul Tagliamonte <paultag@whube.com>
* @version 1.0
* @license: AGPLv3
*/
if ( ! class_exists ( "bug" ) ) { // if we've included twice
if ( ! class_exists( "dbobj" ) ) { // ensure we have the superclass
$model_root = dirname( __FILE__ ) . "/";
include( $model_root . "dbobj.php" );
}
include ( $model_root . "user.php" ); // we need the user
include ( $model_root . "project.php" ); // and project models
class bug extends dbobj {
function bug() {
dbobj::dbobj("bugs", "bID"); // SQL table `bugs', PK `bID'
// this just calls the super-class's constructor
// this tells the dbobj sutff to use the the
// `bugs' table, with a primary key of `bID'.
}
// Let's add in some functionallity for user stuff.
function getOwner( $bID ) {
$this->getAllByPK( $bID ); // get everything
// that matches the PK
// being = to $bID
$row = $this->getNext();
// get the next (and hopefully
// only ) row
$u = new user();
$u->getAllByPK( $row['owner'] );
return $u->getNext(); // ( first row :P )
}
function getReporter( $bID ) {
$this->getAllByPK( $bID );
$row = $this->getNext();
$u = new user();
$u->getAllByPK( $row['reporter'] );
return $u->getNext(); // ( first row :D )
}
function getProject( $pID ) {
$this->getAllByPK( $pID );
$row = $this->getNext();
$p = new project();
$p->getAllByPK( $row['package'] );
return $p->getNext(); // ( first row :) )
}
function getAllBugs() {
global $TABLE_PREFIX;
$sql = new sql();
$sql->query("SELECT * FROM " . $TABLE_PREFIX . "bugs ORDER BY bID DESC;" );
$ret = array();
while ( $row = $sql->getNextRow() ) {
array_push( $ret, $row );
}
return $ret;
}
}
}
$BUG_OBJECT = new bug();
?>