forked from howest-wsde/owaes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.mailalert.php
99 lines (86 loc) · 2.92 KB
/
class.mailalert.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
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
<?php
class mailalert {
private $iID = NULL;
private $iUser = NULL;
private $arLink = NULL;
private $strMessage = NULL;
private $iDeadline = NULL;
private $iSent = NULL;
private $strSleutel = NULL;
private $bUniekeSleutel = FALSE;
public function mailalert() {
// $this->iUser = $iUser;
}
public function cancel($strSleutel) {
$oDB = new database();
$strSQL = "update tblMailalerts set sent = 0 where (sent is NULL or sent = 0) and sleutel = '" . $oDB->escape($strSleutel) . "'; ";
$oDB->execute($strSQL);
}
public function id($iID = NULL) { // get / set ID (enkel set via DB)
if (!is_null($iID)) $this->iID = $iID;
return $this->iID;
}
public function link($strType=NULL, $iID=NULL) {
if (!is_null($iID)) $this->arLink = array("type" => $strType, "id" => $iID);
switch($this->arLink["type"]) {
case "market":
return owaesitem($this->arLink["id"])->url();
break;
case "user":
return user($this->arLink["id"])->getURL();
break;
}
return false;
}
public function message($strMessage = NULL) {
if (!is_null($strMessage)) $this->strMessage = $strMessage;
return $this->strMessage;
}
public function sleutel($strSleutel = NULL, $bUnique = NULL) {
if (!is_null($strSleutel)) $this->strSleutel = $strSleutel;
if (!is_null($bUnique)) $this->bUniekeSleutel = $bUnique;
return $this->strSleutel;
}
public function deadline($iDeadline = NULL) {
if (!is_null($iDeadline)) $this->iDeadline = ($iDeadline > 943920000) ? $iDeadline : owaestime()+$iDeadline;
return $this->iDeadline;
}
public function sent($iSent = NULL) {
if (!is_null($iSent)) $this->iSent = $iSent;
return $this->iSent;
}
public function user($iUser = NULL) {
if (!is_null($iUser)) $this->iUser = $iUser;
return $this->iUser;
}
public function update() {
$oDB = new database();
$arVelden = array(
"id" => $this->iID,
"user" => $this->iUser,
"sleutel" => $this->strSleutel,
"link" => json_encode($this->arLink),
"message" => $this->strMessage,
"deadline" => $this->iDeadline,
"sent" => $this->iSent,
);
if (is_null($this->iID)) {
$arVeldKeys = array();
$arWaarden = array();
foreach ($arVelden as $strVeld=>$strWaarde) {
$arVeldKeys[] = $strVeld;
$arWaarden[] = $oDB->escape($strWaarde, TRUE);
}
$strSQL = "insert into tblMailalerts (" . implode(", ", $arVeldKeys) . ") values (" . implode(", ", $arWaarden) . ");";
$oDB->execute($strSQL);
$this->id($oDB->lastInsertID());
} else {
$arUpdates = array();
foreach ($arVelden as $strVeld=>$strWaarde) {
$arUpdates[] = $strVeld . " = " . $oDB->escape($strWaarde, TRUE);
}
$strSQL = "update tblMailalerts set " . implode(", ", $arUpdates) . " where id = " . $this->id() . ";";
$oDB->execute($strSQL);
}
}
}