1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
//------------------------------------------------------------------------------ |
4
|
|
|
// |
5
|
|
|
// eTraxis - Records tracking web-based system |
6
|
|
|
// Copyright (C) 2010-2011 Artem Rodygin |
7
|
|
|
// |
8
|
|
|
// This program is free software: you can redistribute it and/or modify |
9
|
|
|
// it under the terms of the GNU General Public License as published by |
10
|
|
|
// the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
// (at your option) any later version. |
12
|
|
|
// |
13
|
|
|
// This program is distributed in the hope that it will be useful, |
14
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
// GNU General Public License for more details. |
17
|
|
|
// |
18
|
|
|
// You should have received a copy of the GNU General Public License |
19
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
// |
21
|
|
|
//------------------------------------------------------------------------------ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @package eTraxis |
25
|
|
|
* @ignore |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
/**#@+ |
29
|
|
|
* Dependency. |
30
|
|
|
*/ |
31
|
|
|
require_once('../engine/engine.php'); |
32
|
|
|
require_once('../dbo/groups.php'); |
33
|
|
|
require_once('../dbo/reminders.php'); |
34
|
|
|
/**#@-*/ |
35
|
|
|
|
36
|
|
|
init_page(LOAD_TAB); |
37
|
|
|
|
38
|
|
|
if (!EMAIL_NOTIFICATIONS_ENABLED) |
39
|
|
|
{ |
40
|
|
|
debug_write_log(DEBUG_NOTICE, 'Email Notifications functionality is disabled.'); |
41
|
|
|
exit; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
if (!can_reminder_be_created()) |
45
|
|
|
{ |
46
|
|
|
debug_write_log(DEBUG_NOTICE, 'Reminders are denied.'); |
47
|
|
|
exit; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// check that requested reminder exists |
51
|
|
|
|
52
|
|
|
$id = ustr2int(try_request('id')); |
53
|
|
|
$reminder = reminder_find($id); |
54
|
|
|
|
55
|
|
|
if (!$reminder) |
56
|
|
|
{ |
57
|
|
|
debug_write_log(DEBUG_NOTICE, 'Reminder cannot be found.'); |
58
|
|
|
exit; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// local JS functions |
62
|
|
|
|
63
|
|
|
$resTitle1 = ustrprocess(get_js_resource(RES_REMINDER_X_ID), ustr2js($reminder['reminder_name'])); |
64
|
|
|
$resTitle2 = get_js_resource(RES_REMINDERS_ID); |
65
|
|
|
$resMessage = get_js_resource(RES_ALERT_REMINDER_IS_SENT_ID); |
66
|
|
|
$resOK = get_js_resource(RES_OK_ID); |
67
|
|
|
$resCancel = get_js_resource(RES_CANCEL_ID); |
68
|
|
|
|
69
|
|
|
$xml = <<<JQUERY |
70
|
|
|
<script> |
71
|
|
|
|
72
|
|
|
function reminderModify () |
73
|
|
|
{ |
74
|
|
|
jqModal("{$resTitle1}", "modify.php?id={$id}", "{$resOK}", "{$resCancel}", "$('#modifyform').submit()"); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
function reminderSend () |
78
|
|
|
{ |
79
|
|
|
$.post("send.php?id={$id}", function () { |
80
|
|
|
jqAlert("{$resTitle2}", "{$resMessage}", "{$resOK}"); |
81
|
|
|
}); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
</script> |
85
|
|
|
JQUERY; |
86
|
|
|
|
87
|
|
|
// generate buttons |
88
|
|
|
|
89
|
|
|
$xml .= '<button url="index.php">' . get_html_resource(RES_BACK_ID) . '</button>' |
90
|
|
|
. '<buttonset>' |
91
|
|
|
. '<button action="reminderModify()">' . get_html_resource(RES_MODIFY_ID) . '</button>' |
92
|
|
|
. '<button action="reminderSend()" prompt="' . get_html_resource(RES_CONFIRM_SEND_REMINDER_ID) . '">' . get_html_resource(RES_SEND_ID) . '</button>' |
93
|
|
|
. '<button url="delete.php?id=' . $id . '" prompt="' . get_html_resource(RES_CONFIRM_DELETE_REMINDER_ID) . '">' . get_html_resource(RES_DELETE_ID) . '</button>' |
94
|
|
|
. '</buttonset>'; |
95
|
|
|
|
96
|
|
|
// generate reminder information |
97
|
|
|
|
98
|
|
|
if ($reminder['group_flag'] == REMINDER_FLAG_AUTHOR) |
99
|
|
|
{ |
100
|
|
|
$recipients = sprintf('%s (%s)', get_html_resource(RES_AUTHOR_ID), get_html_resource(RES_ROLE_ID)); |
101
|
|
|
} |
102
|
|
|
elseif ($reminder['group_flag'] == REMINDER_FLAG_RESPONSIBLE) |
103
|
|
|
{ |
104
|
|
|
$recipients = sprintf('%s (%s)', get_html_resource(RES_RESPONSIBLE_ID), get_html_resource(RES_ROLE_ID)); |
105
|
|
|
} |
106
|
|
|
else |
107
|
|
|
{ |
108
|
|
|
$group = group_find($reminder['group_id']); |
109
|
|
|
|
110
|
|
|
$recipients = $group |
111
|
|
|
? sprintf('%s (%s)', ustr2html($group['group_name']), get_html_resource($group['is_global'] ? RES_GLOBAL_ID : RES_LOCAL_ID)) |
112
|
|
|
: get_html_resource(RES_NONE_ID); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
$xml .= '<group>' |
116
|
|
|
. '<text label="' . get_html_resource(RES_PROJECT_ID) . '">' . ustr2html($reminder['project_name']) . '</text>' |
117
|
|
|
. '<text label="' . get_html_resource(RES_TEMPLATE_ID) . '">' . ustr2html($reminder['template_name']) . '</text>' |
118
|
|
|
. '<text label="' . get_html_resource(RES_STATE_ID) . '">' . ustr2html($reminder['state_name']) . '</text>' |
119
|
|
|
. '<text label="' . get_html_resource(RES_REMINDER_NAME_ID) . '">' . ustr2html($reminder['reminder_name']) . '</text>' |
120
|
|
|
. '<text label="' . get_html_resource(RES_REMINDER_SUBJECT_ID) . '">' . ustr2html($reminder['subject_text']) . '</text>' |
121
|
|
|
. '<text label="' . get_html_resource(RES_REMINDER_RECIPIENTS_ID) . '">' . $recipients . '</text>' |
122
|
|
|
. '</group>'; |
123
|
|
|
|
124
|
|
|
echo(xml2html($xml)); |
125
|
|
|
|
126
|
|
|
?> |
|
|
|
|
127
|
|
|
|
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.