sent_confirmation/ 0040755 0000000 0000000 00000000000 10022457007 013276 5 ustar root root sent_confirmation/setup.php 0100644 0000000 0000000 00000004417 10022456676 015165 0 ustar root root * This program is licensed under GPL. See COPYING for details * */ function squirrelmail_plugin_init_sent_confirmation() { global $squirrelmail_plugin_hooks; $squirrelmail_plugin_hooks['compose_send']['sent_confirmation'] = 'sent_conf_message_sent'; $squirrelmail_plugin_hooks['generic_header']['sent_confirmation'] = 'sent_conf_check_is_sent'; // This was causing PHP warnings when replying so don't use // it for now - it wasn't really necessary, just to be extra // extra safe anyway (turn off sent flag) // Update: it does provide an erroneous "message sent" notification // when SMTP errors occur, so instead, the sent_conf_status is reset // in the check_is_sent_do function whenever the sent_conf screen // isn't being shown - seems to work fine // $squirrelmail_plugin_hooks['compose_bottom']['sent_confirmation'] = 'sent_conf_compose_bottom'; $squirrelmail_plugin_hooks['options_display_inside']['sent_confirmation'] = 'sent_conf_show_options'; $squirrelmail_plugin_hooks['options_display_save']['sent_confirmation'] = 'sent_conf_save_options'; } // Version information // function sent_confirmation_version() { return '1.6'; } if (!defined('SM_PATH')) define('SM_PATH', '../'); // This is the text that appears on the option page // function sent_conf_show_options() { include_once(SM_PATH . 'plugins/sent_confirmation/options.php'); sent_conf_options(); } // Here we save the user's sent_confirmation preferences // function sent_conf_save_options() { include_once(SM_PATH . 'plugins/sent_confirmation/options.php'); sent_conf_options_save(); } // set flag indicating message was sent function sent_conf_message_sent() { include_once(SM_PATH . 'plugins/sent_confirmation/functions.php'); sent_conf_message_sent_do(); } // // function sent_conf_check_is_sent() { include_once(SM_PATH . 'plugins/sent_confirmation/functions.php'); sent_conf_check_is_sent_do(); } // // function sent_conf_compose_bottom() { include_once(SM_PATH . 'plugins/sent_confirmation/functions.php'); sent_conf_compose_bottom_do(); } ?> sent_confirmation/functions.php 0100644 0000000 0000000 00000130030 10022456725 016017 0 ustar root root * This program is licensed under GPL. See COPYING for details * */ global $sent_confirmation_debug; $sent_confirmation_debug = 0; // include compatibility plugin // if (defined('SM_PATH')) include_once(SM_PATH . 'plugins/compatibility/functions.php'); else if (file_exists('../plugins/compatibility/functions.php')) include_once('../plugins/compatibility/functions.php'); else if (file_exists('./plugins/compatibility/functions.php')) include_once('./plugins/compatibility/functions.php'); // Very simple place to indicate that the message was sent // function sent_conf_message_sent_do() { // if saving as a draft, this plugin should be ignored // global $draft; if ($draft) return; // first, check if the restrict_senders plugin // is installed and if so, it needs to run first // global $plugins; if (in_array('restrict_senders', $plugins)) { global $restrict_senders_finished, $sent_confirmation_was_delayed; if (!$restrict_senders_finished) { $sent_confirmation_was_delayed = 1; return; } } global $sent_confirmation_debug, $sent_conf_message_sent_status, $sent_conf_include_recip_addr, $send_to, $send_to_cc, $send_to_bcc, $sent_conf_show_only_first_recip_addr, $sent_conf_enable, $sent_conf_allow_user_override, $data_dir, $username, $sent_conf_include_cc, $sent_conf_include_bcc, $sent_conf_message_style, $sent_conf_show_headers, $mailbox, $passed_id, $action, $sort, $sent_conf_orig_reply_msg, $username, $imapServerAddress, $key, $imapPort, $sent_conf_orig_subject, $sent_conf_orig_sender, $sent_conf_enable_orig_msg_options, $lastTargetMailbox, $sent_conf_mbox_list; compatibility_sqextractGlobalVar('lastTargetMailbox'); if (compatibility_check_sm_version(1, 3)) include_once (SM_PATH . 'plugins/sent_confirmation/config.php'); else include_once ('../plugins/sent_confirmation/config.php'); $sent_conf_enable = ($sent_conf_message_style == 'off' ? 0 : 1); // get all our config set up // if ($sent_conf_allow_user_override) { $sent_conf_enable = getPref($data_dir, $username, 'sent_conf_enable', $sent_conf_enable); $sent_conf_message_style = getPref($data_dir, $username, 'sent_conf_style', $sent_conf_message_style); $sent_conf_include_recip_addr = getPref($data_dir, $username, 'sent_conf_incl_recip', $sent_conf_include_recip_addr); $sent_conf_show_only_first_recip_addr = getPref($data_dir, $username, 'sent_conf_show_only_first_recip_addr', $sent_conf_show_only_first_recip_addr); $sent_conf_include_cc = getPref($data_dir, $username, 'sent_conf_include_cc', $sent_conf_include_cc); $sent_conf_include_bcc = getPref($data_dir, $username, 'sent_conf_include_bcc', $sent_conf_include_bcc); $sent_conf_show_headers = getPref($data_dir, $username, 'sent_conf_show_headers', $sent_conf_show_headers); $sent_conf_enable_orig_msg_options = getPref($data_dir, $username, 'sent_conf_enable_orig_msg_options', $sent_conf_enable_orig_msg_options); } // if not enabled, just quit // if (!$sent_conf_enable) return; // build information to be passed to display function below // $sent_conf_message_sent_status = 'sent'; if ($sent_conf_include_recip_addr) { if ($sent_conf_show_only_first_recip_addr) { preg_match('/\s*([\'"].*?[\'"]){0,1}(.*?)([,;]|$)/', trim($send_to), $matches); if (isset($matches[2])) { if (isset($matches[1])) $sent_conf_message_sent_status = $matches[1] . $matches[2] . ($sent_conf_message_style < 3 ? ', et al' : ''); else $sent_conf_message_sent_status = $matches[2] . ($sent_conf_message_style < 3 ? ', et al' : ''); } // failsafe // else $sent_conf_message_sent_status = $send_to; } else { if ($sent_conf_show_headers) //$sent_conf_message_sent_status = 'To: '; $sent_conf_message_sent_status = ''; else $sent_conf_message_sent_status = ''; $sent_conf_message_sent_status .= $send_to; $send_to_cc = trim($send_to_cc); $send_to_bcc = trim($send_to_bcc); if ($sent_conf_include_cc && !empty($send_to_cc)) { if ($sent_conf_show_headers) $sent_conf_message_sent_status .= ', Cc: ' . $send_to_cc; else $sent_conf_message_sent_status .= ', ' . $send_to_cc; } if ($sent_conf_include_bcc && !empty($send_to_bcc)) { if ($sent_conf_show_headers) $sent_conf_message_sent_status .= ', Bcc: ' . $send_to_bcc; else $sent_conf_message_sent_status .= ', ' . $send_to_bcc; } } } // get reply info for deletion, move, back-to options // $sent_conf_orig_reply_msg = ''; $sent_conf_orig_subject = ''; $sent_conf_orig_sender = ''; $sent_conf_mbox_list = ''; if ($sent_conf_message_style > 2 && $sent_conf_enable_orig_msg_options && (strpos($action, 'reply') !== FALSE || strpos($action, 'forward') !== FALSE)) { $sent_conf_orig_reply_msg = $mailbox . '|' . $passed_id . '|' . $sort; $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); sqimap_mailbox_select($imapConnection, $mailbox); $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); $header = $message->rfc822_header; $sent_conf_orig_subject = decodeHeader($header->subject,false,true); $orig_from = (is_array($header->from)) ? $header->from[0] : $header->from; if (is_object($orig_from)) { $sent_conf_orig_sender = $orig_from->getAddress(); } else { $sent_conf_orig_sender = ''; } $sent_conf_mbox_list = sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox))); } compatibility_sqsession_register($sent_conf_orig_sender, 'sent_conf_orig_sender'); compatibility_sqsession_register($sent_conf_orig_subject, 'sent_conf_orig_subject'); compatibility_sqsession_register($sent_conf_orig_reply_msg, 'sent_conf_orig_reply_msg'); compatibility_sqsession_register($sent_conf_mbox_list, 'sent_conf_mbox_list'); compatibility_sqsession_register($sent_conf_message_sent_status, 'sent_conf_message_sent_status'); if ($sent_confirmation_debug == 1) { echo "just before sending
"; print_r($_SESSION); echo ""; exit; } } // Determine if there was a message just sent, if so, display message // function sent_conf_check_is_sent_do() { // get global variable for versions of PHP < 4.1 // if (!compatibility_check_php_version(4,1)) { global $HTTP_SERVER_VARS; $_SERVER = $HTTP_SERVER_VARS; } // strange, but on replies, the session doesn't seem // to be getting started before output is being sent // so we force it here // // if (stristr($_SERVER['SCRIPT_NAME'], 'compose.php')) // compatibility_sqsession_is_active(); // Nope, doesn't do the trick; seems that even though the // session is started, it throughs up errors... whatever! // this is called in the generic header, so we // only want to do this when we are on the right_main // page (unless "compose in new window" is on, in // which case we want to do it in the compose page, // or we are on the compose page and we have "mail_sent", // meaning that a draft was just resumed and sent) // global $compose_new_win, $mail_sent; if (($compose_new_win && !stristr($_SERVER['SCRIPT_NAME'], 'compose.php')) || (!$compose_new_win && !stristr($_SERVER['SCRIPT_NAME'], 'right_main.php') && !($mail_sent && stristr($_SERVER['SCRIPT_NAME'], 'compose.php')))) { /* // make sure sent flag is off // Note: this clears flag when most any page is loaded; whereas the only problem it is meant to solve is when SMTP errors occur upon sending, the next time this plugin runs, it displays the sent confirmation, even though the message DID NOT get sent due to the SMTP errors. This is an architectural compromise. It could be solved by adding a new hook just after the message was sent in the SM core, but for now, I'll assume that most SM installations actually have working SMTP or sendmail servers. sent_conf_compose_bottom_do(); */ return; } global $sent_conf_message_sent_status, $color, $sent_confirmation_debug, $sent_conf_message_style, $sent_conf_include_recip_addr, $sent_conf_allow_user_override, $data_dir, $username, $sent_conf_enable, $sent_conf_show_headers, $sent_conf_orig_reply_msg, $pp_noPageHeader, $sent_conf_orig_subject, $sent_conf_orig_sender, $pp_forceTopURL, $sent_conf_enable_orig_msg_options, $compose_new_win, $sent_conf_mbox_list, $blockedAddresses, $mailbox, $plugins; compatibility_sqextractGlobalVar('sent_conf_message_sent_status'); compatibility_sqextractGlobalVar('sent_conf_orig_reply_msg'); compatibility_sqextractGlobalVar('sent_conf_orig_subject'); compatibility_sqextractGlobalVar('sent_conf_orig_sender'); compatibility_sqextractGlobalVar('sent_conf_mbox_list'); compatibility_sqextractGlobalVar('blockedAddresses'); if (compatibility_check_sm_version(1, 3)) include_once (SM_PATH . 'plugins/sent_confirmation/config.php'); else include_once ('../plugins/sent_confirmation/config.php'); $sent_conf_enable = ($sent_conf_message_style == 'off' ? 0 : 1); if ($sent_conf_allow_user_override) { $sent_conf_enable = getPref($data_dir, $username, 'sent_conf_enable', $sent_conf_enable); $sent_conf_message_style = getPref($data_dir, $username, 'sent_conf_style', $sent_conf_message_style); $sent_conf_include_recip_addr = getPref($data_dir, $username, 'sent_conf_incl_recip', $sent_conf_include_recip_addr); $sent_conf_show_headers = getPref($data_dir, $username, 'sent_conf_show_headers', $sent_conf_show_headers); $sent_conf_enable_orig_msg_options = getPref($data_dir, $username, 'sent_conf_enable_orig_msg_options', $sent_conf_enable_orig_msg_options); } if ($sent_confirmation_debug == 2) { echo "session...
"; print_r($_SESSION); echo ""; } // if not enabled, just quit // if (!$sent_conf_enable) return; // if we should be showing a notification, then do it // if (isset($sent_conf_message_sent_status) && !empty($sent_conf_message_sent_status) && $sent_conf_message_sent_status != 'not_sent' && $sent_conf_message_style != 'off') { // if using preview pane plugin and it hasn't run // first, go run it now // if (in_array('preview_pane', $plugins)) { if (!(isset($pp_forceTopURL) && !empty($pp_forceTopURL))) { if (compatibility_check_sm_version(1, 3)) include_once (SM_PATH . 'plugins/preview_pane/functions.php'); else include_once ('../plugins/preview_pane/functions.php'); preview_pane_check_frames_do(); } // if preview_pane is redirecting us, don't do anything here // if ($pp_forceTopURL == "yes") return; } else $pp_noPageHeader = FALSE; // a little trickery to get the page header // printed out... the problem is that this // function is called in a hook that is part // of displayPageHeader(), so we need to avoid // an endless recursion loop here // if ($sent_conf_message_style > 2) { global $color, $sent_conf_count; if (!$sent_conf_count) { $sent_conf_count = 1; if (!empty($mailbox)) ($pp_noPageHeader ? pp_displayPageHeader($color, $mailbox) : displayPageHeader($color, $mailbox)); else ($pp_noPageHeader ? pp_displayPageHeader($color, 'None') : displayPageHeader($color, 'None')); } else { return; } } echo '
';
bindtextdomain('sent_confirmation', SM_PATH . 'plugins/sent_confirmation/locale');
textdomain('sent_confirmation');
//-------------------------------------------------------------
// STYLE 1
//-------------------------------------------------------------
if ($sent_conf_message_style == 1)
{
if ($sent_conf_include_recip_addr)
{
$addresses = sc_parseEmailAddresses($sent_conf_message_sent_status);
$output = '';
$firstTime = TRUE;
foreach ($addresses as $addressAndNick)
{
$address = trim($addressAndNick[0]);
if (!empty($address))
{
if (!$firstTime)
$output .= ', ';
$firstTime = FALSE;
$output .= $address;
}
}
echo '' . _("Message Sent To: ")
. $output;
// if any disallowed addresses from the
// restrict senders plugin, display them
//
if ($blockedAddresses)
{
echo ' BLOCKED ADDRESSES: '; $first = 1; foreach ($blockedAddresses as $badAddr) { if (!$first) echo ', '; $first = 0; echo $badAddr; } echo ''; } echo ''; } else echo '' . _("Message Sent") . ''; } //------------------------------------------------------------- // STYLE 2 //------------------------------------------------------------- else if ($sent_conf_message_style == 2) { if ($sent_conf_include_recip_addr) { $addresses = sc_parseEmailAddresses($sent_conf_message_sent_status); $output = ''; $firstTime = TRUE; foreach ($addresses as $addressAndNick) { $address = trim($addressAndNick[0]); if (!empty($address)) { if (!$firstTime) $output .= ', '; $firstTime = FALSE; $output .= $address; } } echo ' BLOCKED ADDRESSES: '; $first = 1; foreach ($blockedAddresses as $badAddr) { if (!$first) echo ', '; $first = 0; echo $badAddr; } echo ''; } echo '
|