-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailMonitor.API.php
More file actions
71 lines (57 loc) · 1.89 KB
/
EmailMonitor.API.php
File metadata and controls
71 lines (57 loc) · 1.89 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
<?php
# Copyright (c) 2012 Anderson Fortaleza
# Licensed under the MIT license
/**
* Retrieves a list of emails given the bug_id
* @param int Bug ID
* @return array Emails associated to the bug
*/
function EmailMonitor_List($t_bug_id)
{
$t_emails = array();
$t_email_table = plugin_table('email', 'EmailMonitor');
$t_query = "SELECT email FROM $t_email_table WHERE bug_id = $t_bug_id";
$t_result = db_query($t_query);
while($t_row = db_fetch_array($t_result))
{
array_push($t_emails, $t_row['email']);
}
return $t_emails;
}
/**
* Check if email already monitors the issue
* @param int Bug ID
* @param string Email address to be checked
* @return bool True if email is already monitoring the issue
*/
function EmailMonitor_Exists($t_bug_id, $t_email)
{
$t_email_table = plugin_table('email', 'EmailMonitor');
$t_query = "SELECT id FROM $t_email_table WHERE bug_id=".db_param()." AND email=".db_param();
$t_results = db_query_bound($t_query, array($t_bug_id, $t_email));
return db_num_rows($t_results) > 0;
}
/**
* Adds email to issue monitor list
* @param int Bug ID
* @param string Email address to be added to the issue monitor list
* @return int The ID of the database record added
*/
function EmailMonitor_Add($t_bug_id, $t_email)
{
$t_email_table = plugin_table('email', 'EmailMonitor');
$t_query = "INSERT INTO $t_email_table (bug_id, email) VALUES (".db_param().", ".db_param().")";
db_query_bound($t_query, array($t_bug_id, $t_email));
return db_insert_id($t_email_table);
}
/**
* Deletes email from the issue monitor list
* @param int EmailMonitor ID
*/
function EmailMonitor_Delete($t_bug_id, $t_email)
{
$t_email_table = plugin_table('email', 'EmailMonitor');
$t_query = "DELETE FROM $t_email_table WHERE bug_id=".db_param()." AND email=".db_param();
db_query_bound($t_query, array($t_bug_id, $t_email));
}
?>