-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrisks.class.php
More file actions
103 lines (91 loc) · 2.29 KB
/
Copy pathrisks.class.php
File metadata and controls
103 lines (91 loc) · 2.29 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php /* CONTACTS $Id: risks.class.php,v 1.3 2007/05/21 02:15:14 caseydk Exp $ */
if (!defined('DP_BASE_DIR')){
die('You should not access this file directly.');
}
##
## Risks Class
##
class dotProject_AddOn_Risks {
var $risk_id = NULL;
var $risk_project = NULL;
var $risk_task = NULL;
var $risk_owner = NULL;
var $risk_name = NULL;
var $risk_description = NULL;
var $risk_probability = NULL;
var $risk_status = NULL;
var $risk_impact = NULL;
var $risk_notes = NULL;
function CRisk($riskId = 0) {
$this->risk_id = $riskId;
}
function load( $oid ) {
$q = new DBQuery();
$q->addQuery('*');
$q->addTable('risks');
$q->addWhere('risk_id = ' . $oid);
return db_loadObject( $q->prepare(), $this );
}
function bind( $hash ) {
if (!is_array( $hash )) {
return get_class( $this )."::bind failed";
} else {
bindHashToObject( $hash, $this );
return NULL;
}
}
function check() {
return NULL;
}
function store() {
$msg = $this->check();
if( $msg ) {
return get_class( $this )."::store-check failed";
}
if( $this->risk_id ) {
$ret = db_updateObject( 'risks', $this, 'risk_id' );
} else {
$ret = db_insertObject( 'risks', $this, 'risk_id' );
}
if( !$ret ) {
return get_class( $this )."::store failed <br />" . db_error();
} else {
return NULL;
}
}
function delete() {
$q = new DBQuery();
$q->setDelete('risks');
$q->addWhere('risk_id = ' . $this->risk_id);
if (!$q->exec()) {
return db_error();
} else {
return null;
}
}
function saveNote($riskId, $userId, $riskDescription) {
$q = new DBQuery();
$q->addTable('risk_notes');
$q->addInsert('risk_note_risk', $riskId);
$q->addInsert('risk_note_creator', $userId);
$q->addInsert('risk_note_date', 'NOW()', false, true);
$q->addInsert('risk_note_description', $riskDescription);
if (!$q->exec()) {
return db_error();
} else {
return true;
}
}
function getNotes($riskId) {
$q = new DBQuery();
$q->addQuery('risk_notes.*');
$q->addQuery('CONCAT(contact_first_name, " ", contact_last_name) as risk_note_owner');
$q->addTable('risk_notes');
$q->leftJoin('users', 'u', 'risk_note_creator = user_id');
$q->leftJoin('contacts', 'c', 'user_contact = contact_id');
$q->addWhere('risk_note_risk = ' . $riskId);
$notes = $q->loadList();
return $notes;
}
}
?>