Revision: 1256
http://mrbs.svn.sourceforge.net/mrbs/?rev=1256&view=rev
Author: cimorrison
Date: 2009-11-11 14:36:47 +0000 (Wed, 11 Nov 2009)
Log Message:
-----------
Email notifications implemented on provisional booking more info requests
Modified Paths:
--------------
mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
mrbs/branches/provisional_bookings/web/functions_mail.inc
mrbs/branches/provisional_bookings/web/lang.en
Modified: mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
===================================================================
--- mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
2009-11-11 13:15:13 UTC (rev 1255)
+++ mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
2009-11-11 14:36:47 UTC (rev 1256)
@@ -17,6 +17,7 @@
$series = get_form_var('series', 'int');
$returl = get_form_var('returl', 'string');
$room_id = get_form_var('room_id', 'int');
+$note = get_form_var('note', 'string');
// If we dont know the right date then make it up
if (!isset($day) or !isset($month) or !isset($year))
@@ -66,11 +67,11 @@
$status = $row['status'];
$starttime = $row['start_time'];
$endtime = $row['end_time'];
- $repeat_id = $row['repeat_id'];
$room_name = $row['room_name'];
$area_name = $row['area_name'];
$duration = ($row['end_time'] - $row['start_time']) -
cross_dst($row['start_time'], $row['end_time']);
$rep_type = $row['rep_type'];
+ $repeat_id = isset($row['repeat_id']) ? $row['repeat_id'] :
NULL;
$rep_enddate = isset($row['rep_enddate']) ? $row['rep_enddate'] :
NULL;
$rep_opt = isset($row['rep_opt']) ? $row['rep_opt'] :
NULL;
$rep_num_weeks = isset($row['rep_num_weeks']) ? $row['rep_num_weeks'] :
NULL;
@@ -112,6 +113,16 @@
$result = notifyAdminOnBooking(TRUE, $id, $action);
}
}
+
+ // ACTION = "MORE_INFO"
+ if ($action == "more_info")
+ {
+ if ($need_to_send_mail)
+ {
+ $result = notifyAdminOnBooking(TRUE, $id, $action);
+ }
+ }
+
}
// Now it's all done go back to the previous view
Modified: mrbs/branches/provisional_bookings/web/functions_mail.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/functions_mail.inc 2009-11-11
13:15:13 UTC (rev 1255)
+++ mrbs/branches/provisional_bookings/web/functions_mail.inc 2009-11-11
14:36:47 UTC (rev 1256)
@@ -159,6 +159,31 @@
return $string;
}
+// get the email address of a user
+// returns an empty string in the event of an error
+function get_email_address($user)
+{
+ global $mail_settings, $auth, $tbl_users;
+
+ if ('db' == $auth['type'])
+ {
+ $email = sql_query1("SELECT email
+ FROM $tbl_users
+ WHERE name='" . addslashes($user) . "'
+ LIMIT 1");
+ if ($email == -1)
+ {
+ $email = "";
+ }
+ }
+ else
+ {
+ $email = str_replace($mail_settings['username_suffix'], '', $user);
+ $email .= $mail_settings['domain'];
+ }
+ return $email;
+}
+
// }}}
// {{{ notifyAdminOnBooking()
@@ -176,7 +201,7 @@
global $rep_enddate, $typel, $type, $status, $create_by, $rep_type,
$enable_periods;
global $rep_opt, $rep_num_weeks;
global $tbl_room, $tbl_area, $tbl_entry, $tbl_users, $tbl_repeat;
- global $mail_previous, $auth;
+ global $mail_previous, $auth, $note;
global $mail_settings, $weekstarts, $provisional_enabled;
// We will treat Accept, Reject and More_info mailings as new entries
because the
@@ -190,6 +215,22 @@
$cc = array();
$cc[] = $mail_settings['cc'];
+ // set the from address
+ $user = getUserName();
+ if (isset($user) && (($action == "remind") || ($action == "more_info")))
+ {
+ $from = get_email_address($user);
+ if (empty($from))
+ {
+ // there was an error: use a sensible default
+ $from = $mail_settings['from'];
+ }
+ }
+ else
+ {
+ $from = $mail_settings['from'];
+ }
+
$id_table = ($rep_type > 0) ? "rep" : "e";
($mail_settings['admin_on_bookings']) ? $recipients[] =
$mail_settings['recipients'] : '';
if ($mail_settings['area_admin_on_bookings'])
@@ -253,53 +294,19 @@
if ($mail_settings['booker'])
{
- if ($action == "accept")
+ if (($action == "accept") || ($action == "more_info"))
{
// Put the recipients on the cc line and the booker will go
// on the to line
$cc = array_merge($cc, $recipients);
$recipients = array();
}
- if ('db' == $auth['type'])
+ $booker = ($new_entry) ? $create_by : $mail_previous['createdby'];
+ $booker_email = get_email_address($booker);
+ if (!empty($booker_email))
{
- /* It would be possible to move this query within the query in
- getPreviousEntryData to have all in one central place and to
- reduce database hits by one. However this is a bad idea. If a
- user is deleted from your user database, this will prevent all
- mails to admins when this user previously booked entries will
- be changed, as no user name will match the booker name */
- $sql = "SELECT email FROM $tbl_users WHERE name='";
- $sql .= ($new_entry) ? $create_by : $mail_previous['createdby'];
- $sql .= "'";
- $res = sql_query($sql);
- (! $res) ? fatal_error(0, sql_error()) : '';
- $row = sql_row_keyed($res, 0);
- if (!empty($row['email']))
- {
- $recipients[] = $row['email'];
- }
+ $recipients[] = $booker_email;
}
- else
- {
- if ($new_entry)
- {
- if (!empty($create_by))
- {
- $recipients[] = str_replace($mail_settings['username_suffix'], '',
- $create_by) .
- $mail_settings['domain'];
- }
- }
- else
- {
- if (!empty($mail_previous['createdby']))
- {
- $recipients[] = str_replace($mail_settings['username_suffix'], '',
- $mail_previous['createdby']) .
- $mail_settings['domain'];
- }
- }
- }
}
// In case $recipients is empty, no need to go further
if (empty($recipients))
@@ -316,6 +323,12 @@
$subject = get_mail_vocab("mail_subject_accepted");
$body = get_mail_vocab("mail_body_accepted") . "\n\n";
break;
+ case "more_info":
+ $subject = get_mail_vocab("mail_subject_more_info");
+ $body = get_mail_vocab("mail_body_more_info") . "\n\n";
+ $body .= get_mail_vocab("info_requested") . ": ";
+ $body .= convertToMailCharset($note) . "\n\n";
+ break;
default:
$subject = get_mail_vocab("mail_subject_entry");
if ($new_entry)
@@ -523,6 +536,7 @@
$subject,
$body,
get_mail_charset(),
+ $from,
$cc_list);
return $result;
}
@@ -549,6 +563,22 @@
$cc = array();
$cc[] = $mail_settings['cc'];
+ // set the from address
+ $user = getUserName();
+ if (isset($user) && ($action == "reject"))
+ {
+ $from = get_email_address($user);
+ if (empty($from))
+ {
+ // there was an error: use a sensible default
+ $from = $mail_settings['from'];
+ }
+ }
+ else
+ {
+ $from = $mail_settings['from'];
+ }
+
($mail_settings['admin_on_bookings']) ? $recipients[] =
$mail_settings['recipients'] : '';
if ($mail_settings['area_admin_on_bookings'] &&
!empty($mail_previous['area_admin_email']))
{
@@ -567,31 +597,11 @@
$cc = array_merge($cc, $recipients);
$recipients = array();
}
- if ('db' == $auth['type'])
+ $booker_email = get_email_address($mail_previous['createdby']);
+ if (!empty($booker_email))
{
- /* It would be possible to move this query within the query in
- getPreviousEntryData to have all in one central place and to
- reduce database hits by one. However this is a bad idea. If a
- user is deleted from your user database, this will prevent all
- mails to admins when this user previously booked entries will
- be changed, as no user name will match the booker name */
- $sql = "SELECT email
- FROM $tbl_users
- WHERE name='" . $mail_previous['createdby'] . "'";
- $res = sql_query($sql);
- (! $res) ? fatal_error(0, sql_error()) : '';
- $row = sql_row_keyed($res, 0);
- if (!empty($row['email']))
- {
- $recipients[] = $row['email'];
- }
+ $recipients[] = $booker_email;
}
- elseif (!empty($mail_previous['createdby']))
- {
- $recipients[] = str_replace($mail_settings['username_suffix'], '',
- $mail_previous['createdby']) .
- $mail_settings['domain'];
- }
}
// In case mail is allowed but someone forgot to supply email addresses...
if (empty($recipients))
@@ -673,7 +683,7 @@
}
$body .= "\n";
// End of mail details
- $result = sendMail($recipient_list, $subject, $body, get_mail_charset(),
$cc_list);
+ $result = sendMail($recipient_list, $subject, $body, get_mail_charset(),
$from, $cc_list);
return $result;
}
@@ -916,7 +926,7 @@
* @return bool TRUE or PEAR error object if fails
*/
function sendMail($recipients, $subject, $body,
- $charset = 'us-ascii', $cc = NULL, $bcc = NULL)
+ $charset = 'us-ascii', $from, $cc = NULL, $bcc = NULL)
{
require_once "Mail.php";
@@ -934,7 +944,10 @@
}
// Set up configuration settings
- $from = $mail_settings['from'];
+ if (empty($from))
+ {
+ $from = $mail_settings['from'];
+ }
$backend = $mail_settings['admin_backend'];
$sendmail_path = $sendmail_settings['path'];
$sendmail_args = $sendmail_settings['args'];
Modified: mrbs/branches/provisional_bookings/web/lang.en
===================================================================
--- mrbs/branches/provisional_bookings/web/lang.en 2009-11-11 13:15:13 UTC
(rev 1255)
+++ mrbs/branches/provisional_bookings/web/lang.en 2009-11-11 14:36:47 UTC
(rev 1256)
@@ -140,6 +140,7 @@
$vocab["mail_body_changed_entry"] = "An entry has been modified, here are the
details:";
$vocab["mail_subject_delete"] = "Entry deleted for $mrbs_company MRBS";
$vocab["reason"] = "Reason";
+$vocab["info_requested"] = "Information requested";
// Authentication stuff
$vocab["accessdenied"] = "Access Denied";
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits