From: <vb...@us...> - 2003-09-12 06:56:30
|
Update of /cvsroot/webnotes/webnotes/core In directory sc8-pr-cvs1:/tmp/cvs-serv8997/core Modified Files: email_api.php Log Message: M core\email_api.php Started working on the email notifications. Index: email_api.php =================================================================== RCS file: /cvsroot/webnotes/webnotes/core/email_api.php,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- email_api.php 6 Oct 2002 15:23:36 -0000 1.5 +++ email_api.php 12 Sep 2003 06:56:27 -0000 1.6 @@ -33,8 +33,7 @@ # this function sends the actual email function email_send( $p_recipient, $p_subject, $p_message, $p_header='' ) { global $g_from_email, $g_enable_email_notification, - $g_return_path_email, $g_use_x_priority, - $g_use_phpMailer, $g_phpMailer_method, $g_smtp_host; + $g_return_path_email, $g_use_x_priority; # short-circuit if no emails should be sent if ( OFF == $g_enable_email_notification ) { @@ -45,20 +44,10 @@ $t_subject = trim( $p_subject ); $t_message = trim( $p_message ); - # for debugging only - #echo $t_recipient."<br />".$t_subject."<br />".$t_message."<br />".$t_headers; - #exit; - #echo "<br />xxxRecipient =".$t_recipient."<br />"; - #echo "Headers =".nl2br($t_headers)."<br />"; - #echo $t_subject."<br />"; - #echo nl2br($t_message)."<br />"; - #exit; - # Visit http://www.php.net/manual/function.mail.php # if you have problems with mailing $t_headers = "From: $g_from_email\n"; - #$t_headers .= "Reply-To: $p_reply_to_email\n"; $t_headers .= "X-Sender: <$g_from_email>\n"; $t_headers .= "X-Mailer: phpWebNotes $g_phpWebNotes_version\n"; @@ -66,6 +55,7 @@ $t_headers .= "X-Priority: 0\n"; # Urgent = 1, Not Urgent = 5, Disable = 0 } $t_headers .= "Return-Path: <$g_return_path_email>\n"; # return email if error + # If you want to send foreign charsets # $t_headers .= "Content-Type: text/html; charset=iso-8859-1\n"; @@ -96,4 +86,48 @@ return str_replace( "\r\r\n", "\r\n", $p_string ); } # -------------------- + # email build note message + function email_build_note_message( $p_note_id, &$subject, &$content ) { + $note = note_get_info( note_where_id_equals( $p_note_id ) ); + if ( $note === false ) { + return false; + } + extract( $note, EXTR_PREFIX_ALL, 'note' ); + + $page = page_get_info( page_where_id_equals( $v_page_id ) ); + if ( $page === false ) { + return false; + } + extract( $page, EXTR_PREFIX_ALL, 'page' ); + + $subject = '[$page_page] $note_email'; + + $content = ''; + $content .= str_pad( '', 70, '=' ); + $content .= $page_url; + $content .= str_pad( '', 70, '-' ); + $content .= "Note Id: $note_id\n"; + $content .= "Email: $note_email\n"; + $content .= "IP: $note_ip\n"; + $content .= "Date Submitted: " . date( 'd-M-Y', $note_date_submitted ) . "\n"; + $content .= "Visible: " . ( $note_visible ? "Yes" : "No" ); + $content .= str_pad( '', 70, '-' ); + $content .= $v_note_note; + $content .= str_pad( '', 70, '=' ); + + return true; + } + + # -------------------- + # email note to administrator + # @@@ Query the database to send to moderators / administrators, rather than + # just the administrator in the configs. + function email_note_added( $p_note_id ) { + $subject = ''; + $content = ''; + email_build_note_message( $p_note_id, $subject, $content ); + + global $g_administrator_email; + email_send( $g_administrator_email, $subject, $content ); + } ?> |