2006-12-02 04:36:16 +00:00
< ? php
/*
2009-11-15 17:38:05 +00:00
* e107 website system
*
2013-02-20 21:11:17 +00:00
* Copyright ( C ) 2008 - 2013 e107 Inc ( e107 . org )
2009-11-15 17:38:05 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
2010-01-10 11:01:29 +00:00
* Administration - Mailout
2009-11-15 17:38:05 +00:00
*
*/
2010-01-10 11:01:29 +00:00
/**
* e107 Mail handling - Admin
*
* @ package e107
* @ subpackage admin
*/
2009-11-15 17:38:05 +00:00
/*
2007-12-22 14:49:34 +00:00
Features :
2009-11-24 20:40:35 +00:00
1. Additional sources of email addresses for mailouts can be provided via plugins , and can be enabled via the mailout preferences page
2007-12-22 14:49:34 +00:00
2. Both list of email recipients and the email are separately stored in the DB using a documented interface ( allows alternative creation / mailout routines )
2009-11-24 20:40:35 +00:00
- see mail_manager_class . php
2007-12-22 14:49:34 +00:00
3. Can specify qmail in the sendmail path
$pref [ 'mailout_enabled' ][ plugin_path ] - array of flags determining which mailers are active
2009-11-15 17:38:05 +00:00
2007-12-22 14:49:34 +00:00
2009-11-24 20:40:35 +00:00
Extra mailout address handlers - these provide email addresses
------------------------------
1. The handler is called 'e_mailout.php' in the plugin directory .
2. Mailout options includes a facility to enable the individual handlers
3. Certain variables may be defined at load time to determine whether loading is exclusive or supplementary
4. Interface is implemented as a class , which must be called 'plugin_path_mailout'
5. see mailout_class . php in the handlers directory for an example ( also simpler examples in newsletter and event calendar plugins )
2007-12-22 14:49:34 +00:00
2006-12-02 04:36:16 +00:00
*/
2009-07-14 11:05:54 +00:00
2009-11-15 17:38:05 +00:00
/*
Valid actions ( $_GET [ 'mode' ]) :
'prefs' - Edit options
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
'makemail' - Create an email for use as a template , or to send
2008-11-14 06:01:06 +00:00
2009-11-15 17:38:05 +00:00
'saved' - email templates saved ( was 'list' )
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'sent' - list emails where sending process complete ( was 'mailouts' )
'pending' - list emails in queue or being sent
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'maildelete' - delete email whose 'handle' is in $mailID - shows confirmation page
'maildeleteconfirm' - does it
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'edit' - edit email whose 'handle' is in $mailID
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'detail' - show all the target recipients of a specific email
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'resend' - resend failures on a specific list
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
'debug' - not currently used ; may be useful to list other info
Valid subparameters ( where required ) :
$_GET [ 'm' ] - id of mail info in db
$_GET [ 't' ] - id of target info in db
*/
2014-10-12 02:37:43 -07:00
// header('Content-Encoding: none'); // turn off gzip.
2009-11-15 17:38:05 +00:00
require_once ( '../class2.php' );
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
if ( ! getperms ( 'W' ))
2007-12-22 14:49:34 +00:00
{
2009-11-15 17:38:05 +00:00
header ( 'location:' . e_BASE . 'index.php' );
exit ;
2006-12-02 04:36:16 +00:00
}
2014-10-10 20:16:11 -07:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_users.php' );
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_mailout.php' );
require_once ( e_HANDLER . 'ren_help.php' );
require_once ( e_HANDLER . 'userclass_class.php' );
require_once ( e_HANDLER . 'mailout_class.php' ); // Class handler for core mailout functions
require_once ( e_HANDLER . 'mailout_admin_class.php' ); // Admin tasks handler
require_once ( e_HANDLER . 'mail_manager_class.php' ); // Mail DB API
2014-10-12 02:37:43 -07:00
/**
* Display Progress - bar of real - time mail - out .
* @ return
*/
function sendProgress ( $id )
{
2014-10-12 18:01:19 -07:00
// return rand(92,100);
2014-10-12 02:37:43 -07:00
$pref = e107 :: getPref ();
2014-10-12 18:01:19 -07:00
ob_start ();
2014-10-12 02:37:43 -07:00
$mailManager = new e107MailManager ();
$mailManager -> doEmailTask ( varset ( $pref [ 'mail_workpertick' ], 5 ));
2014-10-12 18:01:19 -07:00
2014-10-12 02:37:43 -07:00
$sqld = e107 :: getDb ();
$sqld -> select ( " mail_content " , " mail_togo_count,mail_sent_count,mail_fail_count " , " mail_source_id= " . intval ( $id ) );
$row = $sqld -> fetch ();
$rand = ( $row [ 'mail_sent_count' ] + $row [ 'mail_fail_count' ]);
$total = ( $row [ 'mail_togo_count' ] + $row [ 'mail_sent_count' ] + $row [ 'mail_fail_count' ]);
2014-10-12 18:01:19 -07:00
$errors = ob_get_clean ();
e107 :: getMessage () -> addDebug ( $errors );
2014-10-12 02:37:43 -07:00
2014-10-12 18:01:19 -07:00
// file_put_contents(e_LOG.'send-mail-progress.txt',$errors);
2014-10-12 02:37:43 -07:00
$inc = round (( $rand / $total ) * 100 );
2014-10-12 18:01:19 -07:00
e107 :: getMessage () -> addDebug ( " Returned: " . $inc );
2014-10-12 02:37:43 -07:00
return $inc ;
}
if ( e_AJAX_REQUEST )
{
$id = intval ( $_GET [ 'mode' ]);
echo sendProgress ( $id );
exit ;
}
if ( vartrue ( $_GET [ 'mode' ]) == " progress " )
{
// session_write_close();
// sendProgress();
// exit;
}
$mes = e107 :: getMessage ();
$tp = e107 :: getParser ();
/*
if ( $_GET [ 'mode' ] == " process " )
{
session_write_close (); // allow other scripts to run in parallel.
header ( 'Content-Encoding: none' );
ignore_user_abort ( true );
set_time_limit ( 0 );
header ( " Content-Length: $size " );
header ( 'Connection: close' );
$mailManager = new e107MailManager ();
$mailManager -> doEmailTask ( 999999 );
echo " Completed Mailout ID: " . $_GET [ 'id' ];
exit ;
}
*/
2014-10-10 20:16:11 -07:00
class mailout_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'saved' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'pending' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'held' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'sent' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'prefs' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'maint' => array (
'controller' => 'mailout_main_ui' ,
'path' => null ,
'ui' => 'mailout_admin_form_ui' ,
'uipath' => null
),
'recipients' => array (
'controller' => 'mailout_recipients_ui' ,
'path' => null ,
'ui' => 'mailout_recipients_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
// 'makemail/makemail' => array('caption'=> LAN_MAILOUT_190, 'perm' => 'W', 'url'=>e_SELF),
'main/list' => array ( 'caption' => LAN_MANAGE , 'perm' => 'W' ),
2014-10-12 18:01:19 -07:00
'main/create' => array ( 'caption' => LAN_CREATE , 'perm' => 'W' ),
2014-10-10 22:58:47 -07:00
2014-10-10 20:16:11 -07:00
'recipients/list' => array ( 'caption' => " Recipients " , 'perm' => 'W' ),
2014-10-10 22:58:47 -07:00
// 'main/send' => array('caption'=> "Send", 'perm' => 'W'),
2014-10-10 20:16:11 -07:00
'other' => array ( 'divider' => true ),
2014-10-12 18:01:19 -07:00
// 'saved/list' => array('caption'=> LAN_MAILOUT_191, 'perm' => 'W'),
2014-10-10 20:16:11 -07:00
'pending/list' => array ( 'caption' => LAN_MAILOUT_193 , 'perm' => 'W' ),
'held/list' => array ( 'caption' => LAN_MAILOUT_194 , 'perm' => 'W' ),
'sent/list' => array ( 'caption' => LAN_MAILOUT_192 , 'perm' => 'W' ),
'other2' => array ( 'divider' => true ),
'prefs/prefs' => array ( 'caption' => LAN_PREFS , 'perm' => '0' ),
'maint/maint' => array ( 'caption' => ADLAN_40 , 'perm' => '0' ),
);
protected $adminMenuAliases = array (
2014-10-10 22:58:47 -07:00
'main/send' => 'main/create' ,
2014-10-10 20:16:11 -07:00
);
protected $menuTitle = LAN_MAILOUT_15 ;
}
class mailout_main_ui extends e_admin_ui
{
//TODO Move to Class above.
protected $pluginTitle = LAN_MAILOUT_15 ;
protected $pluginName = LAN_MAILOUT_15 ;
protected $table = " mail_content " ;
2014-10-12 18:01:19 -07:00
// protected $listQry = null;
2014-10-10 20:16:11 -07:00
// protected $editQry = "SELECT * FROM #mail_content WHERE cust_id = {ID}";
protected $pid = " mail_source_id " ;
protected $perPage = 10 ;
protected $listOrder = " mail_source_id desc " ;
protected $batchDelete = true ;
protected $batchCopy = true ;
protected $tabs = array ( 'Basic' , 'Advanced' ); //TODO Add LAN_BASIC and LAN_ADVANCED to lan_admin.php
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'mail_source_id' => array ( 'title' => LAN_MAILOUT_137 , 'width' => '5%' , 'thclass' => 'center' , 'class' => 'center' , 'forced' => TRUE ),
'mail_selectors' => array ( 'title' => LAN_MAILOUT_03 , 'type' => 'method' , 'data' => false , 'nolist' => true , 'writeParms' => 'nolabel=0' ),
'mail_title' => array ( 'title' => LAN_MAILOUT_135 , 'type' => 'text' , 'forced' => TRUE , 'data' => 'str' , 'inline' => true , 'writeParms' => 'size=xxlarge&required=1' , 'help' => 'whatever' ),
'mail_sender_name' => array ( 'title' => LAN_MAILOUT_150 , 'type' => 'method' , 'data' => false ),
'mail_sender_email' => array ( 'title' => LAN_MAILOUT_149 , 'type' => 'method' , 'data' => false ),
'mail_copy_to' => array ( 'title' => LAN_MAILOUT_151 , 'tab' => 1 , 'type' => 'method' , 'data' => false ),
'mail_bcopy_to' => array ( 'title' => LAN_MAILOUT_152 , 'tab' => 1 , 'type' => 'method' , 'data' => false ),
'mail_subject' => array ( 'title' => LAN_MAILOUT_06 , 'type' => 'text' , 'forced' => TRUE , 'data' => 'str' , 'inline' => true , 'writeParms' => 'size=xxlarge&required=1' ),
2014-10-12 18:01:19 -07:00
'mail_content_status' => array ( 'title' => LAN_MAILOUT_136 , 'tab' => 1 , 'type' => 'dropdown' , 'data' => 'int' , 'filter' => false , 'inline' => false , 'thclass' => 'left' , 'class' => 'left' ),
'mail_total_count' => array ( 'title' => " Total Recipients " , 'noedit' => true , 'type' => 'number' ),
2014-10-10 20:16:11 -07:00
'mail_sent_count' => array ( 'title' => LAN_MAILOUT_82 , 'noedit' => true , 'type' => 'number' ),
2014-10-12 18:01:19 -07:00
'mail_togo_count' => array ( 'title' => LAN_MAILOUT_83 , 'noedit' => true , 'type' => 'number' ),
2014-10-10 20:16:11 -07:00
'mail_fail_count' => array ( 'title' => LAN_MAILOUT_128 , 'noedit' => true , 'type' => 'number' ),
'mail_bounce_count' => array ( 'title' => LAN_MAILOUT_144 , 'noedit' => true , 'type' => 'number' ),
'mail_start_send' => array ( 'title' => LAN_MAILOUT_131 , 'noedit' => true , 'type' => 'number' , 'proc' => 'sdatetime' ),
'mail_end_send' => array ( 'title' => LAN_MAILOUT_132 , 'noedit' => true , 'type' => 'number' , 'proc' => 'sdatetime' ),
2014-10-10 22:58:47 -07:00
'mail_create_date' => array ( 'title' => LAN_MAILOUT_130 , 'type' => null , 'noedit' => true , 'data' => 'int' , 'type' => 'number' ),
'mail_creator' => array ( 'title' => LAN_MAILOUT_85 , 'type' => null , 'noedit' => true , 'data' => 'int' ),
'mail_create_app' => array ( 'title' => LAN_MAILOUT_133 , 'type' => null , 'noedit' => true , 'data' => 'str' ),
2014-10-10 20:16:11 -07:00
'mail_e107_priority' => array ( 'title' => LAN_MAILOUT_134 , 'noedit' => true ),
'mail_notify_complete' => array ( 'title' => LAN_MAILOUT_243 , 'noedit' => true , 'nolist' => true ),
'mail_last_date' => array ( 'title' => LAN_MAILOUT_129 , 'noedit' => true , 'type' => 'int' , 'proc' => 'sdatetime' ),
'mail_attach' => array ( 'title' => LAN_MAILOUT_153 , 'tab' => 1 , 'type' => 'method' , 'data' => false ),
'mail_include_images' => array ( 'title' => LAN_MAILOUT_224 , 'tab' => 1 , 'type' => 'boolean' , 'data' => false , 'proc' => 'yesno' ),
'mail_send_style' => array ( 'title' => LAN_MAILOUT_154 , 'type' => 'method' , 'data' => false ),
'mail_body' => array ( 'title' => LAN_MAILOUT_100 , 'type' => 'bbarea' , 'proc' => 'trunc200' ),
'mail_body_templated' => array ( 'title' => LAN_MAILOUT_257 , 'noedit' => true , 'proc' => 'chars' ),
'mail_other' => array ( 'title' => LAN_MAILOUT_84 , 'type' => null , 'noedit' => true , 'data' => 'array' , 'nolist' => true ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => 'method' , 'width' => '10%' , 'forced' => TRUE )
);
protected $fieldpref = array ( 'checkboxes' , 'mail_source_id' , 'mail_title' , 'mail_subject' , 'mail_content_status' , 'options' );
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array (
// 'after_submit' => array('title'=> 'Custom After Submit Text:', 'type'=>'bbarea')
// 'submit_question' => array('title'=> 'Allow submitting of Questions by:', 'type'=>'userclass'),
// 'classic_look' => array('title'=> 'Use Classic Layout', 'type'=>'boolean')
);
public $mailAdmin = null ;
private $selectFields = array ( 'email_to' ,
'extended_1_name' , 'extended_1_value' ,
'extended_2_name' , 'extended_2_value' ,
'user_search_name' , 'user_search_value' ,
'last_visit_match' , 'last_visit_date'
);
private $mailOtherFields = array (
'mail_sender_email' ,
'mail_sender_name' ,
'mail_copy_to' ,
'mail_bcopy_to' ,
'mail_attach' ,
'mail_send_style' , // HTML, text, template name etc
'mail_selectors' , // Only used internally
'mail_include_images' , // Used to determine whether to embed images, or link to them
'mail_body_alt' , // If non-empty, use for alternate email text (generally the 'plain text' alternative)
'mail_overrides'
);
function init ()
{
$action = varset ( $_GET [ 'mode' ], 'main' );
$this -> mailAdmin = new mailoutAdminClass ( $action );
if ( $this -> mailAdmin -> loadMailHandlers () == 0 )
{
e107 :: getMessage () -> addDebug ( 'No mail handlers loaded!!' );
}
/*
define ( 'MAIL_STATUS_SENT' , 0 ); // Mail sent. Email handler happy, but may have bounced (or may be yet to bounce)
define ( 'MAIL_STATUS_BOUNCED' , 1 );
define ( 'MAIL_STATUS_CANCELLED' , 2 );
define ( 'MAIL_STATUS_PARTIAL' , 3 ); // A run which was abandoned - errors, out of time etc
define ( 'MAIL_STATUS_FAILED' , 5 ); // Failure on initial send - rejected by selected email handler
// This must be the numerically highest 'processing complete' code
define ( 'MAIL_STATUS_PENDING' , 10 ); // Mail which is in the sending list (even if outside valid sending window)
// This must be the numerically lowest 'not sent' code
// E107_EMAIL_MAX_TRIES values used in here for retry counting
define ( 'MAIL_STATUS_MAX_ACTIVE' , 19 ); // Highest allowable 'not sent or processed' code
define ( 'MAIL_STATUS_SAVED' , 20 ); // Identifies an email which is just saved (or in process of update)
define ( 'MAIL_STATUS_HELD' , 21 ); // Held pending release
define ( 'MAIL_STATUS_TEMP' , 22 ); // Tags entries which aren't yet in any list
*/
$types = array ( 10 => 'Pending' , 20 => " Saved " , 21 => " Held " , 0 => 'Sent' , 1 => 'Bounced' , 2 => 'Cancelled' , 3 => 'Partial' , 5 => 'Failed' , 19 => " Max Active " , 22 => " Temp " );
$qr = array ( 'saved' => 20 , 'pending' => 10 , 'held' => 21 , 'sent' => 0 );
if ( $action !== 'main' )
{
$this -> listQry = " SELECT * FROM #mail_content WHERE mail_content_status = " . varset ( $qr [ $action ], 20 );
}
2014-10-12 18:01:19 -07:00
else
{
$this -> listQry = " SELECT * FROM #mail_content WHERE (mail_content_status = " . MAIL_STATUS_TEMP . " OR mail_content_status = " . MAIL_STATUS_SAVED . " ) " ;
}
if ( $action == 'sent' || $action == 'pending' || $action == 'held' )
2014-10-10 20:16:11 -07:00
{
2014-10-12 18:01:19 -07:00
$this -> fieldpref = array ( 'checkboxes' , 'mail_source_id' , 'mail_title' , 'mail_subject' , 'mail_total_count' , 'mail_togo_count' , 'mail_sent_count' , 'mail_fail_count' , 'mail_bounce_count' , 'options' );
2014-10-10 20:16:11 -07:00
}
$this -> fields [ 'mail_content_status' ][ 'writeParms' ] = $types ;
2014-10-10 22:58:47 -07:00
$this -> processSendActions ();
2014-10-10 20:16:11 -07:00
if ( getperms ( '0' ))
{
if ( isset ( $_POST [ 'testemail' ]))
{ // Send test email - uses standard 'single email' handler
if ( trim ( $_POST [ 'testaddress' ]) == '' )
{
$mes -> addError ( LAN_MAILOUT_19 );
$subAction = 'error' ;
}
else
{
$mailheader_e107id = USERID ;
require_once ( e_HANDLER . 'mail.php' );
$add = ( $pref [ 'mailer' ]) ? " ( " . strtoupper ( $pref [ 'mailer' ]) . " ) " : ' (PHP)' ;
$sendto = trim ( $_POST [ 'testaddress' ]);
if ( ! sendemail ( $sendto , LAN_MAILOUT_113 . " " . SITENAME . $add , str_replace ( " [br] " , " \n " , LAN_MAILOUT_114 ), LAN_MAILOUT_189 ))
{
$mes -> addError (( $pref [ 'mailer' ] == 'smtp' ) ? LAN_MAILOUT_67 : LAN_MAILOUT_106 );
}
else
{
$mes -> addSuccess ( LAN_MAILOUT_81 . ' (' . $sendto . ')' );
$admin_log -> log_event ( 'MAIL_01' , $sendto , E_LOG_INFORMATIVE , '' );
}
}
}
elseif ( isset ( $_POST [ 'updateprefs' ]))
{
$this -> saveMailPrefs ( $mes ); // TODO check if functional, $emessage -> $mes
}
}
}
public function beforeCreate ( $new_data , $old_data )
{
$ret = $this -> processData ( $new_data );
2014-10-12 02:37:43 -07:00
$ret [ 'mail_create_date' ] = time ();
$ret [ 'mail_creator' ] = USERID ;
$ret [ 'mail_create_app' ] = 'core' ;
$ret [ 'mail_content_status' ] = MAIL_STATUS_TEMP ;
2014-10-10 20:16:11 -07:00
return $ret ;
}
public function beforeUpdate ( $new_data , $old_data , $id )
{
2014-10-10 22:58:47 -07:00
$ret = $this -> processData ( $new_data );
return $ret ;
}
private function processSendActions ()
{
2014-10-12 18:01:19 -07:00
if (( vartrue ( $_POST [ 'email_send' ]) || vartrue ( $_POST [ 'email_hold' ]) || vartrue ( $_POST [ 'email_cancel' ])) && ! vartrue ( $_POST [ 'email_id' ]))
2014-10-10 22:58:47 -07:00
{
e107 :: getMessage () -> addError ( " No Message ID submitted " );
return ;
}
$id = intval ( $_POST [ 'email_id' ]);
2014-10-12 18:01:19 -07:00
2014-10-10 22:58:47 -07:00
if ( vartrue ( $_POST [ 'email_send' ]))
{
$this -> emailSend ( $id );
}
if ( vartrue ( $_POST [ 'email_hold' ]))
{
$this -> emailHold ( $id );
}
if ( vartrue ( $_POST [ 'email_cancel' ]))
{
$this -> emailCancel ( $id );
}
}
2014-10-12 02:37:43 -07:00
private function emailSendNow ( $id )
2014-10-10 22:58:47 -07:00
{
2014-10-12 18:01:19 -07:00
2014-10-10 20:16:11 -07:00
}
2014-10-10 22:58:47 -07:00
private function emailSend ( $mailId )
{
2014-10-11 12:54:16 -07:00
$log = e107 :: getAdminLog ();
2014-10-10 22:58:47 -07:00
2014-10-11 12:54:16 -07:00
$notify = isset ( $_POST [ 'mail_notify_complete' ]) ? 3 : 2 ;
$first = 0 ;
$last = 0 ; // Set defaults for earliest and latest send times.
2014-10-10 22:58:47 -07:00
if ( isset ( $_POST [ 'mail_earliest_time' ]))
{
$first = e107 :: getDateConvert () -> decodeDateTime ( $_POST [ 'mail_earliest_time' ], 'datetime' , CORE_DATE_ORDER , FALSE );
}
if ( isset ( $_POST [ 'mail_latest_time' ]))
{
$last = e107 :: getDateConvert () -> decodeDateTime ( $_POST [ 'mail_earliest_time' ], 'datetime' , CORE_DATE_ORDER , TRUE );
}
2014-10-11 12:54:16 -07:00
2014-10-10 22:58:47 -07:00
if ( $this -> mailAdmin -> activateEmail ( $mailId , FALSE , $notify , $first , $last ))
{
e107 :: getMessage () -> addSuccess ( LAN_MAILOUT_185 );
$log -> log_event ( 'MAIL_06' , 'ID: ' . $mailId , E_LOG_INFORMATIVE , '' );
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_188 );
}
}
private function emailHold ( $mailId )
{
if ( $this -> mailAdmin -> activateEmail ( $mailId , TRUE ))
{
e107 :: getMessage () -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_187 ));
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_166 );
}
}
private function emailCancel ( $mailId )
{
if ( $this -> mailAdmin -> cancelEmail ( $mailId ))
{
e107 :: getMessage () -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_220 ));
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_221 );
}
}
2014-10-10 20:16:11 -07:00
/**
* Process Posted Data
*/
private function processData ( $new_data )
{
$other = array ();
$ret = $new_data ;
foreach ( $new_data as $k => $v )
{
if ( in_array ( $k , $this -> mailOtherFields ))
{
$other [ $k ] = $v ;
unset ( $ret [ $k ]);
}
}
$other [ 'mail_selectors' ] = $this -> mailAdmin -> getAllSelectors ();
$ret [ 'mail_attach' ] = trim ( $new_data [ 'mail_attach' ]);
$ret [ 'mail_send_style' ] = varset ( $new_data [ 'mail_send_style' ], 'textonly' );
$ret [ 'mail_include_images' ] = ( isset ( $new_data [ 'mail_include_images' ]) ? 1 : 0 );
$ret [ 'mail_other' ] = $other ; // type is set to 'array' in $fields.
// e107::getMessage()->addInfo(print_a($ret,true));
return $ret ;
}
/*
function createPage ()
{
if ( ! isset ( $mailData ) || ! is_array ( $mailData ))
{
$mailData = array (); // Empty array just in case
}
if ( $id = $this -> getId ())
{
$mailData = e107 :: getDB () -> retrieve ( 'mail_content' , '*' , 'mail_source_id=' . $id );
}
return $this -> mailAdmin -> show_mailform ( $mailData );
}
*/
2014-10-12 18:01:19 -07:00
function sendnowPage ()
{
$id = $this -> getId ();
e107 :: getDb () -> update ( 'mail_content' , 'mail_content_status=' . MAIL_STATUS_PENDING . ' WHERE mail_source_id = ' . intval ( $id ));
e107 :: getDb () -> update ( 'mail_recipients' , 'mail_status=' . MAIL_STATUS_PENDING . ' WHERE mail_detail_id = ' . intval ( $id ));
if ( E107_DEBUG_LEVEL > 0 )
{
echo " <h4>Debug Mode : Mail is sent and data displayed below. </h4> " ;
sendProgress ( $id );
}
else
{
$text = " <h4>Ready to Process Mail Queue</h4> " ;
$text .= e107 :: getForm () -> progressBar ( 'mail-progress' , 1 , array ( 'btn-label' => 'Start' , 'url' => e_SELF ));
}
return $text ;
}
2014-10-10 20:16:11 -07:00
2014-10-12 18:01:19 -07:00
2014-10-10 22:58:47 -07:00
function sendPage ()
{
$id = $this -> getId ();
$mailData = e107 :: getDb () -> retrieve ( 'mail_content' , '*' , 'mail_source_id=' . intval ( $id ));
if ( empty ( $mailData ))
{
e107 :: getMessage () -> addError ( " Couldn't retrieve mail data for id: " . $id );
return '' ;
}
2014-10-10 20:16:11 -07:00
2014-10-11 12:54:16 -07:00
$fromHold = false ;
$mailData = $this -> mailAdmin -> dbToMail ( $mailData );
2014-10-12 18:01:19 -07:00
e107 :: getMessage () -> addDebug ( " Regenerating recipient list " );
e107 :: getDb () -> delete ( 'mail_recipients' , 'mail_detail_id=' . intval ( $id ));
2014-10-11 12:54:16 -07:00
return $this -> mailAdmin -> sendEmailCircular ( $mailData , $fromHold );
2014-10-10 22:58:47 -07:00
}
2014-10-10 20:16:11 -07:00
function maintPage ()
{
if ( ! getperms ( '0' ))
{
return ;
}
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
$frm = e107 :: getForm ();
$text = "
< form action = '".e_SELF."?mode=maint' id = 'email_maint' method = 'post' >
< fieldset id = 'email-maint' >
< table class = 'table adminlist' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody > " ;
$text .= " <tr><td> " . LAN_MAILOUT_182 . " </td><td>
" . $frm->admin_button ('email_dross','no-value','delete', LAN_RUN). "
< br />< span class = 'field-help' > " .LAN_MAILOUT_252. " </ span ></ td ></ tr > " ;
$text .= " </tbody></table> \n </fieldset></form> " ;
return $text ;
// return $ns->tablerender(ADLAN_136.SEP.ADLAN_40, $text, 'maint',true);
}
function prefsPage ()
{
if ( ! getperms ( '0' ))
{
return ;
}
$pref = e107 :: getPref ();
$e107 = e107 :: getInstance ();
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
e107 :: getCache () -> CachePageMD5 = '_' ;
$lastload = e107 :: getCache () -> retrieve ( 'emailLastBounce' , FALSE , TRUE , TRUE );
$lastBounce = round (( time () - $lastload ) / 60 );
$lastBounceText = ( $lastBounce > 1256474 ) ? " <b>Never</b> " : " <b> " . $lastBounce . " minutes </b>ago. " ;
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'mailsettingsform' >
< fieldset id = 'mail' >
< legend > " .LAN_MAILOUT_110. " </ legend >
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td > " .LAN_MAILOUT_110. " < br /></ td >
< td class = 'form-inline' > " . $frm->admin_button ('testemail', LAN_MAILOUT_112,'other'). " & nbsp ;
< input name = 'testaddress' class = 'tbox' type = 'text' size = '40' maxlength = '80' value = \ " " . ( varset ( $_POST [ 'testaddress' ]) ? $_POST [ 'testaddress' ] : USEREMAIL ) . " \" />
</ td >
</ tr >
< tr >
< td style = 'vertical-align:top' > " .LAN_MAILOUT_115. " < br /></ td >
< td >
< select class = 'tbox' name = 'mailer' onchange = 'disp(this.value)' > \n " ;
$mailers = array ( 'php' , 'smtp' , 'sendmail' );
foreach ( $mailers as $opt )
{
$sel = ( $pref [ 'mailer' ] == $opt ) ? " selected='selected' " : '' ;
$text .= " <option value=' { $opt } ' { $sel } > { $opt } </option> \n " ;
}
$text .= " </select> <span class='field-help'> " . LAN_MAILOUT_116 . " </span><br /> " ;
// SMTP. -------------->
$smtp_opts = explode ( ',' , varset ( $pref [ 'smtp_options' ], '' ));
$smtpdisp = ( $pref [ 'mailer' ] != 'smtp' ) ? " style='display:none;' " : '' ;
$text .= " <div id='smtp' { $smtpdisp } >
< table class = 'table adminlist' style = 'margin-right:auto;margin-left:0px;border:0px' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
" ;
$text .= "
< tr >
< td > " .LAN_MAILOUT_87. " :& nbsp ; & nbsp ; </ td >
< td >
< input class = 'tbox' type = 'text' name = 'smtp_server' size = '40' value = '".$pref[' smtp_server ']."' maxlength = '50' />
</ td >
</ tr >
< tr >
< td > " .LAN_MAILOUT_88. " :& nbsp ;( " .LAN_OPTIONAL. " ) & nbsp ; & nbsp ; </ td >
< td style = 'width:50%;' >
< input class = 'tbox' type = 'text' name = 'smtp_username' size = '40' value = \ " " . $pref [ 'smtp_username' ] . " \" maxlength='50' />
</ td >
</ tr >
< tr >
< td > " .LAN_MAILOUT_89. " :& nbsp ;( " .LAN_OPTIONAL. " ) & nbsp ; & nbsp ; </ td >
< td >
< input class = 'tbox' type = 'password' name = 'smtp_password' size = '40' value = '".$pref[' smtp_password ']."' maxlength = '50' />
</ td >
</ tr >
< tr >
< td > " .LAN_MAILOUT_90. " </ td >< td >
< select class = 'tbox' name = 'smtp_options' > \n
< option value = '' > " .LAN_MAILOUT_96. " </ option > \n " ;
$selected = ( in_array ( 'secure=SSL' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_ssl' { $selected } > " . LAN_MAILOUT_92 . " </option> \n " ;
$selected = ( in_array ( 'secure=TLS' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_tls' { $selected } > " . LAN_MAILOUT_93 . " </option> \n " ;
$selected = ( in_array ( 'pop3auth' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_pop3auth' { $selected } > " . LAN_MAILOUT_91 . " </option> \n " ;
$text .= " </select> \n <br /> " . LAN_MAILOUT_94 . " </td></tr> " ;
$text .= " <tr>
< td > " .LAN_MAILOUT_57. " </ td >< td >
" ;
$checked = ( varsettrue ( $pref [ 'smtp_keepalive' ]) ) ? " checked='checked' " : '' ;
$text .= " <input type='checkbox' name='smtp_keepalive' value='1' { $checked } />
</ td >
</ tr > " ;
$checked = ( in_array ( 'useVERP' , $smtp_opts ) ? " checked='checked' " : " " );
$text .= " <tr>
< td > " .LAN_MAILOUT_95. " </ td >< td >
< input type = 'checkbox' name = 'smtp_useVERP' value = '1' { $checked } />
</ td >
</ tr >
</ table ></ div > " ;
/* FIXME - posting SENDMAIL path triggers Mod - Security rules .
// Sendmail. -------------->
$senddisp = ( $pref [ 'mailer' ] != 'sendmail' ) ? " style='display:none;' " : '' ;
$text .= " <div id='sendmail' { $senddisp } ><table style='margin-right:0px;margin-left:auto;border:0px'> " ;
$text .= "
< tr >
< td > " .LAN_MAILOUT_20. " :& nbsp ; & nbsp ; </ td >
< td >
< input class = 'tbox' type = 'text' name = 'sendmail' size = '60' value = \ " " . ( ! $pref [ 'sendmail' ] ? " /usr/sbin/sendmail -t -i -r " . $pref [ 'siteadminemail' ] : $pref [ 'sendmail' ]) . " \" maxlength='80' />
</ td >
</ tr >
</ table ></ div > " ;
*/
$text .= " </td>
</ tr >
< tr >
< td > " .LAN_MAILOUT_222. " </ td >
< td > " ;
$text .= $this -> mailAdmin -> sendStyleSelect ( varset ( $pref [ 'mail_sendstyle' ], 'textonly' ), 'mail_sendstyle' );
$text .=
" <span class='field-help'> " . LAN_MAILOUT_223 . " </span>
</ td >
</ tr > \n
< tr >
< td > " .LAN_MAILOUT_25. " </ td >
< td class = 'form-inline' > " .LAN_MAILOUT_26. "
< input class = 'tbox e-spinner' size = '3' type = 'text' name = 'mail_pause' value = '".$pref[' mail_pause ']."' /> " .LAN_MAILOUT_27.
" <input class='tbox e-spinner' size='3' type='text' name='mail_pausetime' value=' " . $pref [ 'mail_pausetime' ] . " ' /> " . LAN_MAILOUT_29 . " .<br />
< span class = 'field-help' > " .LAN_MAILOUT_30. " </ span >
</ td >
</ tr > \n
< tr >
< td > " .LAN_MAILOUT_156. " </ td >
< td >< input class = 'tbox e-spinner' size = '3' type = 'text' name = 'mail_workpertick' value = '".varset($pref[' mail_workpertick '],5)."' />
< span class = 'field-help' > " .LAN_MAILOUT_157. " </ span >
</ td >
</ tr > \n " ;
if ( isset ( $pref [ 'e_mailout_list' ])) // Allow selection of email address sources
{
$text .= "
< tr >
< td > " .LAN_MAILOUT_77. " </ td >
< td > " ;
$mail_enable = explode ( ',' , $pref [ 'mailout_enabled' ]);
foreach ( $pref [ 'e_mailout_list' ] as $mailer => $v )
{
$check = ( in_array ( $mailer , $mail_enable )) ? " checked='checked' " : " " ;
$text .= " <input type='checkbox' name='mail_mailer_enabled[]' value=' { $mailer } ' { $check } /> { $mailer } <br /> " ;
}
$text .= " </td></tr> \n " ;
}
list ( $mail_log_option , $mail_log_email ) = explode ( ',' , varset ( $pref [ 'mail_log_options' ], '0,0' ));
$check = ( $mail_log_email == 1 ) ? " checked='checked' " : " " ;
$logOptions = array ( LAN_MAILOUT_73 , LAN_MAILOUT_74 , LAN_MAILOUT_75 , LAN_MAILOUT_119 );
$text .= " <tr>
< td > " .LAN_MAILOUT_72. " </ td >
< td class = 'form-inline' >
" . $frm->select ('mail_log_option', $logOptions , $mail_log_option );
$text .= " " . $frm -> checkbox ( 'mail_log_email' , 1 , $check , 'label=' . LAN_MAILOUT_76 );
$text .= " </td></tr> \n " ;
/*
$text .= "
< select class = 'tbox' name = 'mail_log_option' > \n
< option value = '0' " .(( $mail_log_option ==0) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_73. " </ option > \n
< option value = '1' " .(( $mail_log_option ==1) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_74. " </ option > \n
< option value = '2' " .(( $mail_log_option ==2) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_75. " </ option > \n
< option value = '3' " .(( $mail_log_option ==3) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_119. " </ option > \n
</ select > \n
< input type = 'checkbox' name = 'mail_log_email' value = '1' { $check } /> " .LAN_MAILOUT_76.
" </td>
</ tr > \n " ;
*/
$text .= " </table></fieldset>
< fieldset id = 'core-mail-prefs-bounce' >
< legend > " .LAN_MAILOUT_31. " </ legend >
< table class = 'table adminform' >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
< td > " .LAN_MAILOUT_231. " </ td >< td > " ;
// bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail
$autoDisp = ( $pref [ 'mail_bounce' ] != 'auto' ) ? " style='display:none;' " : '' ;
$autoMail = ( $pref [ 'mail_bounce' ] != 'mail' ) ? " style='display:none;' " : '' ;
$bounceOpts = array ( 'none' => LAN_MAILOUT_232 , 'auto' => LAN_MAILOUT_233 , 'mail' => LAN_MAILOUT_234 );
$text .= " <select name='mail_bounce' class='tbox' onchange='bouncedisp(this.value)'> \n <option value=''> </option> \n " ;
foreach ( $bounceOpts as $k => $v )
{
$selected = ( $pref [ 'mail_bounce' ] == $k ) ? " selected='selected' " : '' ;
$text .= " <option value=' { $k } ' { $selected } > { $v } </option> \n " ;
}
$text .= " </select> \n </td>
</ tr ></ tbody ></ table >
< table class = 'adminform' id = 'mail_bounce_auto' { $autoDisp } >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >< td > " .LAN_MAILOUT_32. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_email2' value = \ " " . $pref [ 'mail_bounce_email' ] . " \" /></td></tr>
< tr >
< td > " .LAN_MAILOUT_233. " </ td >< td >< b > " .(e_DOCROOT).e107::getFolder('handlers'). " bounce_handler . php </ b > " ;
if ( ! is_readable ( e_HANDLER . 'bounce_handler.php' ))
{
$text .= " <br /><span class='required'> " . LAN_MAILOUT_161 . '</span>' ;
}
elseif ( ! is_executable ( e_HANDLER . 'bounce_handler.php' )) // Seems to give wrong answers on Windoze
{
$text .= " <br /><span class='required'> " . LAN_MAILOUT_162 . '</span>' ;
}
$text .= " <br /><span class='field-help'> " . LAN_MAILOUT_235 . " </span></td></tr>
< tr >< td > " .LAN_MAILOUT_236. " </ td >< td > " . $lastBounceText . " </ td ></ tr >
</ tbody ></ table > " ;
// Parameters for mail-account based bounce processing
$text .= "
< table class = 'table adminform' id = 'mail_bounce_mail' { $autoMail } >
< colgroup >
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >< td > " .LAN_MAILOUT_32. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_email' value = \ " " . $pref [ 'mail_bounce_email' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_33. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_pop3' value = \ " " . $pref [ 'mail_bounce_pop3' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_34. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_user' value = \ " " . $pref [ 'mail_bounce_user' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_35. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_pass' value = \ " " . $pref [ 'mail_bounce_pass' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_120. " </ td >< td >< select class = 'tbox' name = 'mail_bounce_type' > \n
< option value = '' >& nbsp ; </ option > \n
< option value = 'pop3' " .(( $pref['mail_bounce_type'] =='pop3') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_121. " </ option > \n
< option value = 'pop3/notls' " .(( $pref['mail_bounce_type'] =='pop3/notls') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_122. " </ option > \n
< option value = 'pop3/tls' " .(( $pref['mail_bounce_type'] =='pop3/tls') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_123. " </ option > \n
< option value = 'imap' " .(( $pref['mail_bounce_type'] =='imap') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_124. " </ option > \n
</ select ></ td ></ tr > \n
" ;
$check = ( $pref [ 'mail_bounce_delete' ] == 1 ) ? " checked='checked' " : " " ;
$text .= " <tr><td> " . LAN_MAILOUT_36 . " </td><td><input type='checkbox' name='mail_bounce_delete' value='1' { $check } /></td></tr> " ;
$check = ( $pref [ 'mail_bounce_auto' ] == 1 ) ? " checked='checked' " : " " ;
$text .= " <tr><td> " . LAN_MAILOUT_245 . " </td><td><input type='checkbox' name='mail_bounce_auto' value='1' { $check } /><span class='field-help'> " . LAN_MAILOUT_246 . " </span></td></tr>
</ tbody >
</ table ></ fieldset >
< div class = 'buttons-bar center' > " . $frm->admin_button ('updateprefs',LAN_MAILOUT_28,'update'). " </ div >
</ form > " ;
return $text ;
// $caption = ADLAN_136.SEP.LAN_PREFS;
// $ns->tablerender($caption, $mes->render(). $text);
}
// Update Preferences. (security handled elsewhere)
function saveMailPrefs ( & $mes ) // $emessage to $mes, working?
{
if ( ! getperms ( '0' ))
{
return ;
}
//$pref = e107::getPref();
$e107 = e107 :: getInstance ();
$tp = e107 :: getParser ();
$mes = e107 :: getMessage ();
$bounceOpts = array ( 'none' => LAN_MAILOUT_232 , 'auto' => LAN_MAILOUT_233 , 'mail' => LAN_MAILOUT_234 );
unset ( $temp );
if ( ! in_array ( $_POST [ 'mailer' ], array ( 'smtp' , 'sendmail' , 'php' ))) $_POST [ 'mailer' ] = 'php' ;
$temp [ 'mailer' ] = $_POST [ 'mailer' ];
// Allow qmail as an option as well - works much as sendmail
if (( strpos ( $_POST [ 'sendmail' ], 'sendmail' ) !== FALSE ) || ( strpos ( $_POST [ 'sendmail' ], 'qmail' ) !== FALSE ))
{
$temp [ 'sendmail' ] = $tp -> toDB ( $_POST [ 'sendmail' ]);
}
else
{
$temp [ 'sendmail' ] = '' ;
}
$temp [ 'smtp_server' ] = $tp -> toDB ( $_POST [ 'smtp_server' ]);
$temp [ 'smtp_username' ] = $tp -> toDB ( $_POST [ 'smtp_username' ]);
$temp [ 'smtp_password' ] = $tp -> toDB ( $_POST [ 'smtp_password' ]);
$smtp_opts = array ();
switch ( trim ( $_POST [ 'smtp_options' ]))
{
case 'smtp_ssl' :
$smtp_opts [] = 'secure=SSL' ;
break ;
case 'smtp_tls' :
$smtp_opts [] = 'secure=TLS' ;
break ;
case 'smtp_pop3auth' :
$smtp_opts [] = 'pop3auth' ;
break ;
}
if ( varsettrue ( $_POST [ 'smtp_keepalive' ])) $smtp_opts [] = 'keepalive' ;
if ( varsettrue ( $_POST [ 'smtp_useVERP' ])) $smtp_opts [] = 'useVERP' ;
$temp [ 'smtp_options' ] = implode ( ',' , $smtp_opts );
$temp [ 'mail_sendstyle' ] = $tp -> toDB ( $_POST [ 'mail_sendstyle' ]);
$temp [ 'mail_pause' ] = intval ( $_POST [ 'mail_pause' ]);
$temp [ 'mail_pausetime' ] = intval ( $_POST [ 'mail_pausetime' ]);
$temp [ 'mail_workpertick' ] = intval ( $_POST [ 'mail_workpertick' ]);
$temp [ 'mail_workpertick' ] = min ( $temp [ 'mail_workpertick' ], 1000 );
$temp [ 'mail_bounce' ] = isset ( $bounceOpts [ $_POST [ 'mail_bounce' ]]) ? $_POST [ 'mail_bounce' ] : 'none' ;
$temp [ 'mail_bounce_auto' ] = 0 ; // Make sure this is always defined
switch ( $temp [ 'mail_bounce' ])
{
case 'none' :
$temp [ 'mail_bounce_email' ] = '' ;
break ;
case 'auto' :
$temp [ 'mail_bounce_email' ] = $tp -> toDB ( $_POST [ 'mail_bounce_email2' ]);
break ;
case 'mail' :
$temp [ 'mail_bounce_email' ] = $tp -> toDB ( $_POST [ 'mail_bounce_email' ]);
$temp [ 'mail_bounce_auto' ] = intval ( $_POST [ 'mail_bounce_auto' ]);
break ;
}
$temp [ 'mail_bounce_pop3' ] = $tp -> toDB ( $_POST [ 'mail_bounce_pop3' ]);
$temp [ 'mail_bounce_user' ] = $tp -> toDB ( $_POST [ 'mail_bounce_user' ]);
$temp [ 'mail_bounce_pass' ] = $tp -> toDB ( $_POST [ 'mail_bounce_pass' ]);
$temp [ 'mail_bounce_type' ] = $tp -> toDB ( $_POST [ 'mail_bounce_type' ]);
$temp [ 'mail_bounce_delete' ] = intval ( varset ( $_POST [ 'mail_bounce_delete' ], 0 ));
$temp [ 'mailout_enabled' ] = implode ( ',' , varset ( $_POST [ 'mail_mailer_enabled' ], '' ));
$temp [ 'mail_log_options' ] = intval ( $_POST [ 'mail_log_option' ]) . ',' . intval ( $_POST [ 'mail_log_email' ]);
foreach ( $temp as & $t )
{
if ( $t === NULL ) $t = '' ;
}
$pref = e107 :: pref ( 'core' ); // Core Prefs Array.
if ( e107 :: getAdminLog () -> logArrayDiffs ( $temp , $pref , 'MAIL_03' ))
{
e107 :: getConfig () -> updatePref ( $temp );
e107 :: getConfig () -> save ( false ); // Only save if changes - generates its own message
}
else
{
$mes -> addInfo ( LAN_NO_CHANGE );
}
}
}
class mailout_admin_form_ui extends e_admin_form_ui
{
public function mail_selectors ( $curval , $mode )
{
$val = stripslashes ( $this -> getController () -> getModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
switch ( $mode )
{
case 'read' :
return varset ( $data [ 'mail_send_style' ], '' );
break ;
case 'write' :
return $this -> getController () -> mailAdmin -> emailSelector ( 'all' , varset ( $data [ 'mail_selectors' ], FALSE ));
break ;
case 'filter' :
case 'batch' :
// return $controller->getcustCategoryTree();
break ;
}
}
public function mail_send_style ( $curVal , $mode )
{
$val = stripslashes ( $this -> getController () -> getModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
switch ( $mode )
{
case 'read' :
return varset ( $data [ 'mail_send_style' ], '' );
break ;
case 'write' :
return $this -> getController () -> mailAdmin -> sendStyleSelect ( varset ( $data [ 'mail_send_style' ], '' ), 'mail_send_style' );
break ;
case 'filter' :
case 'batch' :
// return $controller->getcustCategoryTree();
break ;
}
}
private function mailDetails ( $field , $mode )
{
switch ( $mode )
{
case 'read' :
$val = stripslashes ( $this -> getController () -> getListModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
return $data [ $field ];
break ;
case 'write' :
$val = stripslashes ( $this -> getController () -> getModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
if ( $field == 'mail_sender_name' && ! vartrue ( $data [ 'mail_sender_name' ]))
{
$data [ 'mail_sender_name' ] = USERNAME ;
}
if ( $field == 'mail_sender_email' && ! vartrue ( $data [ 'mail_sender_email' ]))
{
$data [ 'mail_sender_email' ] = USEREMAIL ;
}
return $this -> text ( $field , $data [ $field ], 70 , 'size=xxlarge' );
break ;
case 'filter' :
case 'batch' :
// return $controller->getcustCategoryTree();
break ;
}
}
public function mail_sender_name ( $curVal , $mode )
{
return $this -> mailDetails ( 'mail_sender_name' , $mode );
}
public function mail_sender_email ( $curVal , $mode )
{
return $this -> mailDetails ( 'mail_sender_email' , $mode );
}
public function mail_copy_to ( $curVal , $mode )
{
return $this -> mailDetails ( 'mail_copy_to' , $mode );
}
public function mail_bcopy_to ( $curVal , $mode )
{
return $this -> mailDetails ( 'mail_bcopy_to' , $mode );
}
public function mail_attach ( $curVal , $mode )
{
if ( $mode == 'read' )
{
$val = stripslashes ( $this -> getController () -> getListModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
return basename ( $data [ 'mail_attach' ]);
}
if ( $mode == 'write' )
{
$val = stripslashes ( $this -> getController () -> getModel () -> get ( 'mail_other' ));
$data = e107 :: unserialize ( $val );
return $this -> filepicker ( 'mail_attach' , $data [ 'mail_attach' ], $mode );
}
}
2014-10-10 22:58:47 -07:00
function options ( $parms , $value , $id , $attributes )
2014-10-10 20:16:11 -07:00
{
$controller = $this -> getController ();
2014-10-10 22:58:47 -07:00
$mode = $this -> getController () -> getMode ();
if ( $mode == 'main' )
{
$text = " " ;
$link = e_SELF . " ?mode=main&action=send&id= " . $id ;
$text .= " <a href=' " . $link . " ' class='btn' title='Send Mail'> " . E_32_MAIL . " </a> " ;
$text .= $this -> renderValue ( 'options' , $value , $att , $id );
return $text ;
}
2014-10-12 18:01:19 -07:00
if ( $mode == 'sent' || $mode == 'pending' || $mode == 'held' )
{
$link = e_SELF . " ?searchquery=&filter_options=mail_detail_id__ " . $id . " &mode=recipients&action=list " ;
$text .= " <a href=' " . $link . " ' class='btn' title='Recipients'> " . E_32_USER . " </a> " ;
$att [ 'readParms' ][ 'editClass' ] = e_UC_NOBODY ;
$text .= $this -> renderValue ( 'options' , $value , $att , $id );
return $text ;
}
2014-10-10 22:58:47 -07:00
2014-10-10 20:16:11 -07:00
$mode = $controller -> getMode ();
$mailData = $controller -> getListModel () -> getData ();
return $controller -> mailAdmin -> makeMailOptions ( $mode , $mailData );
}
}
class mailout_recipients_ui extends e_admin_ui
{
//TODO Move to Class above.
protected $pluginTitle = LAN_MAILOUT_15 ;
protected $pluginName = LAN_MAILOUT_15 ;
protected $table = " mail_recipients " ;
// protected $listQry = "SELECT * FROM #mail_content WHERE mail_content_status = 20 ";
// protected $editQry = "SELECT * FROM #mail_content WHERE cust_id = {ID}";
protected $pid = " mail_target_id " ;
protected $perPage = 10 ;
protected $listOrder = " mail_target_id desc " ;
protected $batchDelete = true ;
// protected $tabs = array('General','Details', 'Questionnaire', 'Correspondence');
protected $fields = array (
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
'mail_target_id' => array ( 'title' => LAN_MAILOUT_143 , 'thclass' => 'center' , 'forced' => TRUE ),
'mail_recipient_id' => array ( 'title' => LAN_MAILOUT_142 , 'thclass' => 'center' ),
'mail_recipient_name' => array ( 'title' => LAN_MAILOUT_141 , 'forced' => TRUE ),
'mail_recipient_email' => array ( 'title' => LAN_MAILOUT_140 , 'thclass' => 'left' , 'forced' => TRUE ),
2014-10-12 02:37:43 -07:00
'mail_status' => array ( 'title' => LAN_MAILOUT_138 , 'type' => 'method' , 'thclass' => 'left' , 'class' => 'left' , 'proc' => 'contentstatus' ),
2014-10-10 20:16:11 -07:00
'mail_detail_id' => array ( 'title' => LAN_MAILOUT_137 , 'type' => 'dropdown' , 'filter' => true ),
'mail_send_date' => array ( 'title' => LAN_MAILOUT_139 , 'proc' => 'sdatetime' ),
'mail_target_info' => array ( 'title' => LAN_MAILOUT_148 , 'proc' => 'array' ),
'options' => array ( 'title' => LAN_OPTIONS , 'width' => '10%' , 'forced' => TRUE )
);
protected $fieldpref = array ( 'checkboxes' , 'mail_target_id' , 'mail_recipient_name' , 'mail_recipient_email' , 'mail_detail_id' , 'mail_status' , 'options' );
2014-10-12 02:37:43 -07:00
public $mailManager = null ;
2014-10-10 20:16:11 -07:00
function init ()
{
2014-10-12 02:37:43 -07:00
$this -> mailManager = new e107MailManager ;
2014-10-10 20:16:11 -07:00
$sql = e107 :: getDb ();
$sql -> gen ( " SELECT r.mail_detail_id,c.mail_title FROM #mail_recipients AS r LEFT JOIN #mail_content as c ON r.mail_detail_id = c.mail_source_id GROUP BY r.mail_detail_id " );
2014-10-12 02:37:43 -07:00
2014-10-10 20:16:11 -07:00
while ( $row = $sql -> fetch ())
{
2014-10-12 02:37:43 -07:00
$id = $row [ 'mail_detail_id' ];
2014-10-12 18:01:19 -07:00
$array [ $id ] = vartrue ( $row [ 'mail_title' ], " (No Name) " );
2014-10-10 20:16:11 -07:00
}
$this -> fields [ 'mail_detail_id' ][ 'writeParms' ] = $array ;
if ( strpos ( $_GET [ 'filter_options' ], 'mail_detail_id__' ) === false )
{
$ns = e107 :: getRender ();
e107 :: getMessage () -> addInfo ( " Please select a mailing list from the filter menu below to view recipients. " );
$this -> listQry = " SELECT * FROM #mail_recipients WHERE mail_target_id = 0 " ; // simulated empty result.
return false ;
}
}
}
class mailout_recipients_form_ui extends e_admin_form_ui
{
2014-10-12 02:37:43 -07:00
public function mail_status ( $curVal , $mode )
{
if ( $mode == 'read' )
{
return $this -> getController () -> mailManager -> statusToText ( $curVal );
}
if ( $mode == 'write' )
{
return $curVal ;
}
}
2014-10-10 20:16:11 -07:00
}
new mailout_admin ();
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$e_sub_cat = 'mail' ;
2007-12-22 14:49:34 +00:00
2011-04-08 05:11:38 +00:00
2013-02-25 21:28:26 +01:00
$action = $tp -> toDB ( varset ( $_GET [ 'mode' ], 'makemail' ));
2009-12-01 20:05:54 +00:00
$pageMode = varset ( $_GET [ 'savepage' ], $action ); // Sometimes we need to know what brought us here - $action gets changed
$mailId = intval ( varset ( $_GET [ 'm' ], 0 ));
$targetId = intval ( varset ( $_GET [ 't' ], 0 ));
2009-11-15 17:38:05 +00:00
// Create mail admin object, load all mail handlers
$mailAdmin = new mailoutAdminClass ( $action ); // This decodes parts of the query using $_GET syntax
2009-12-01 20:05:54 +00:00
e107 :: setRegistry ( '_mailout_admin' , $mailAdmin );
2009-11-15 17:38:05 +00:00
if ( $mailAdmin -> loadMailHandlers () == 0 )
{ // No mail handlers loaded
echo 'No mail handlers loaded!!' ;
exit ;
2007-12-22 14:49:34 +00:00
}
2009-11-27 21:42:46 +00:00
require_once ( e_ADMIN . 'auth.php' );
2014-10-10 20:16:11 -07:00
e107 :: getAdminUI () -> runPage ();
require_once ( e_ADMIN . 'footer.php' );
2009-11-27 21:42:46 +00:00
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$errors = array ();
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$subAction = '' ;
$midAction = '' ;
2009-11-30 20:40:03 +00:00
$fromHold = FALSE ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
if ( isset ( $_POST [ 'mailaction' ]))
2007-12-22 14:49:34 +00:00
{
2009-11-15 17:38:05 +00:00
if ( is_array ( $_POST [ 'mailaction' ]))
{
foreach ( $_POST [ 'mailaction' ] as $k => $v )
{
if ( $v ) // Look for non-empty action
{
$mailId = $k ;
$action = $v ;
break ;
}
}
}
2007-12-22 14:49:34 +00:00
}
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
if ( isset ( $_POST [ 'targetaction' ]))
{
if ( is_array ( $_POST [ 'targetaction' ]))
2007-12-22 14:49:34 +00:00
{
2009-11-15 17:38:05 +00:00
foreach ( $_POST [ 'targetaction' ] as $k => $v )
{
if ( $v ) // Look for non-empty action
{
$targetId = $k ;
$action = $v ;
break ;
}
}
}
}
2007-12-22 14:49:34 +00:00
2014-10-10 20:16:11 -07:00
// e107::getMessage()->addDebug("Action=".$action);
2009-11-15 17:38:05 +00:00
//echo "Action: {$action} MailId: {$mailId} Target: {$targetId}<br />";
2009-11-24 20:40:35 +00:00
// ----------------- Actions ------------------->
2011-04-08 05:11:38 +00:00
//TODO - replace code sections with class/functions.
2009-11-15 17:38:05 +00:00
switch ( $action )
{
2014-10-10 20:16:11 -07:00
/*
2009-11-15 17:38:05 +00:00
case 'prefs' :
if ( getperms ( '0' ))
{
if ( isset ( $_POST [ 'testemail' ]))
{ // Send test email - uses standard 'single email' handler
if ( trim ( $_POST [ 'testaddress' ]) == '' )
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( LAN_MAILOUT_19 );
2009-11-15 17:38:05 +00:00
$subAction = 'error' ;
}
else
{
$mailheader_e107id = USERID ;
require_once ( e_HANDLER . 'mail.php' );
$add = ( $pref [ 'mailer' ]) ? " ( " . strtoupper ( $pref [ 'mailer' ]) . " ) " : ' (PHP)' ;
$sendto = trim ( $_POST [ 'testaddress' ]);
2013-03-24 19:44:14 +01:00
if ( ! sendemail ( $sendto , LAN_MAILOUT_113 . " " . SITENAME . $add , str_replace ( " [br] " , " \n " , LAN_MAILOUT_114 ), LAN_MAILOUT_189 ))
2009-11-15 17:38:05 +00:00
{
2013-02-25 21:28:26 +01:00
$mes -> addError (( $pref [ 'mailer' ] == 'smtp' ) ? LAN_MAILOUT_67 : LAN_MAILOUT_106 );
2009-11-15 17:38:05 +00:00
}
else
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( LAN_MAILOUT_81 . ' (' . $sendto . ')' );
2009-11-15 17:38:05 +00:00
$admin_log -> log_event ( 'MAIL_01' , $sendto , E_LOG_INFORMATIVE , '' );
}
}
}
elseif ( isset ( $_POST [ 'updateprefs' ]))
{
2013-02-25 21:28:26 +01:00
saveMailPrefs ( $mes ); // TODO check if functional, $emessage -> $mes
2009-11-15 17:38:05 +00:00
}
}
break ;
2014-10-10 20:16:11 -07:00
*/
/*
2009-11-30 20:40:03 +00:00
case 'mailcopy' : // Copy existing email and go to edit screen
if ( isset ( $_POST [ 'mailaction' ]))
{
$action = 'makemail' ;
$mailData = $mailAdmin -> retrieveEmail ( $mailId );
if ( $mailData === FALSE )
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( LAN_MAILOUT_164 . ':' . $mailId );
2009-11-30 20:40:03 +00:00
break ;
}
unset ( $mailData [ 'mail_source_id' ]);
}
break ;
2014-10-10 20:16:11 -07:00
*/
2014-10-10 22:58:47 -07:00
/*
2009-11-15 17:38:05 +00:00
case 'mailedit' : // Edit existing mail
if ( isset ( $_POST [ 'mailaction' ]))
{
$action = 'makemail' ;
$mailData = $mailAdmin -> retrieveEmail ( $mailId );
if ( $mailData === FALSE )
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( LAN_MAILOUT_164 . ':' . $mailId );
2009-11-15 17:38:05 +00:00
break ;
}
}
break ;
2014-10-10 22:58:47 -07:00
*/
2009-11-15 17:38:05 +00:00
case 'makemail' :
$newMail = TRUE ;
2010-01-10 06:20:46 +00:00
2009-11-15 17:38:05 +00:00
if ( isset ( $_POST [ 'save_email' ]))
{
$subAction = 'new' ;
}
elseif ( isset ( $_POST [ 'update_email' ]))
{
$subAction = 'update' ;
$newMail = FALSE ;
}
elseif ( isset ( $_POST [ 'send_email' ]))
{ // Send bulk email
$subAction = 'send' ;
}
if ( $subAction != '' )
{
$mailData = $mailAdmin -> parseEmailPost ( $newMail );
$errors = $mailAdmin -> checkEmailPost ( $mailData , $subAction == 'send' ); // Full check if sending email
if ( $errors !== TRUE )
{
$subAction = 'error' ;
break ;
}
$mailData [ 'mail_selectors' ] = $mailAdmin -> getAllSelectors (); // Add in the selection criteria
}
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
// That's the checking over - now do something useful!
switch ( $subAction )
{
case 'send' : // This actually creates the list of recipients in the display routine
$action = 'marksend' ;
break ;
case 'new' :
// TODO: Check all fields created - maybe
$mailData [ 'mail_content_status' ] = MAIL_STATUS_SAVED ;
$mailData [ 'mail_create_app' ] = 'core' ;
$result = $mailAdmin -> saveEmail ( $mailData , TRUE );
if ( is_numeric ( $result ))
{
$mailData [ 'mail_source_id' ] = $result ;
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( LAN_MAILOUT_145 );
2009-11-15 17:38:05 +00:00
}
else
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( LAN_MAILOUT_146 );
2009-11-15 17:38:05 +00:00
}
break ;
case 'update' :
$mailData [ 'mail_content_status' ] = MAIL_STATUS_SAVED ;
$result = $mailAdmin -> saveEmail ( $mailData , FALSE );
if ( is_numeric ( $result ))
{
$mailData [ 'mail_source_id' ] = $result ;
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( LAN_MAILOUT_147 );
2009-11-15 17:38:05 +00:00
}
else
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( LAN_MAILOUT_146 );
2009-11-15 17:38:05 +00:00
}
break ;
}
break ;
2007-09-29 17:24:43 +00:00
2009-11-16 20:40:39 +00:00
case 'mailhold' :
2009-11-24 20:40:35 +00:00
$action = 'held' ;
if ( $mailAdmin -> holdEmail ( $mailId ))
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_229 ));
2009-11-24 20:40:35 +00:00
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_230 );
}
2009-11-16 20:40:39 +00:00
break ;
2009-11-15 17:38:05 +00:00
case 'mailcancel' :
$action = $pageMode ; // Want to return to some other page
if ( $mailAdmin -> cancelEmail ( $mailId ))
2007-12-22 14:49:34 +00:00
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_220 ));
2007-12-22 14:49:34 +00:00
}
else
{
2009-11-15 17:38:05 +00:00
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_221 );
2006-12-02 04:36:16 +00:00
}
2009-11-15 17:38:05 +00:00
break ;
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
case 'maildelete' :
break ;
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
case 'marksend' : // Actually do something with an email and list of recipients - entry from email confirm page
$action = 'saved' ;
if ( isset ( $_POST [ 'email_cancel' ])) // 'Cancel' in this context means 'delete' - don't want it any more
{
$midAction = 'midDeleteEmail' ;
}
elseif ( isset ( $_POST [ 'email_hold' ]))
{
if ( $mailAdmin -> activateEmail ( $mailId , TRUE ))
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_187 ));
2009-11-15 17:38:05 +00:00
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_166 );
}
$action = 'held' ;
}
elseif ( isset ( $_POST [ 'email_send' ]))
{
$midAction = 'midMoveToSend' ;
$action = 'pending' ;
}
2011-04-08 05:11:38 +00:00
if ( isset ( $_POST [ 'email_sendnow' ]))
{
$midAction = 'midMoveToSend' ;
//$action = 'pending';
}
2009-11-15 17:38:05 +00:00
break ;
2007-12-22 14:49:34 +00:00
2009-11-30 20:40:03 +00:00
case 'mailsendnow' : // Send mail previously on 'held' list. Need to give opportunity to change time/date etc
$action = 'marksend' ; // This shows the email details for confirmation
$fromHold = TRUE ;
$mailData [ 'mail_source_id' ] = $mailId ;
2009-11-15 17:38:05 +00:00
break ;
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
case 'maildeleteconfirm' :
$action = $pageMode ; // Want to return to some other page
$midAction = 'midDeleteEmail' ;
if ( ! isset ( $_POST [ 'mailIDConf' ]) || ( intval ( $_POST [ 'mailIDConf' ]) != $mailId ))
{
$errors [] = str_replace ( array ( '--ID--' , '--CHECK--' ), array ( $mailId , intval ( $_POST [ 'mailIDConf' ])), LAN_MAILOUT_174 );
break ;
}
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'mailonedelete' :
case 'debug' :
2013-02-25 21:28:26 +01:00
$mes -> addError ( 'Not implemented yet' );
2009-11-15 17:38:05 +00:00
break ;
2006-12-02 04:36:16 +00:00
2009-11-24 20:40:35 +00:00
case 'mailtargets' :
$action = 'recipients' ;
// Intentional fall-through
case 'recipients' :
2009-11-15 17:38:05 +00:00
case 'saved' : // Show template emails - probably no actions
case 'sent' :
case 'pending' :
case 'held' :
2013-02-20 21:11:17 +00:00
case 'mailshowtemplate' :
2009-11-15 17:38:05 +00:00
if ( isset ( $_POST [ 'etrigger_ecolumns' ]))
{
2014-10-10 20:16:11 -07:00
// $mailAdmin->mailbodySaveColumnPref($action);
2009-11-15 17:38:05 +00:00
}
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'maint' : // Perform any maintenance actions required
if ( isset ( $_POST [ 'email_dross' ]))
2009-11-24 20:40:35 +00:00
if ( $mailAdmin -> dbTidy ()) // Admin logging done in this routine
2009-11-15 17:38:05 +00:00
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( LAN_MAILOUT_184 );
2009-11-15 17:38:05 +00:00
}
else
{
$errors [] = LAN_MAILOUT_183 ;
}
break ;
2006-12-02 04:36:16 +00:00
2011-04-08 05:11:38 +00:00
// Send Emails Immediately using Ajax
case 'mailsendimmediately' :
$id = array_keys ( $_POST [ 'mailaction' ]);
sendImmediately ( $id [ 0 ]);
break ;
2009-11-15 17:38:05 +00:00
default :
2014-10-10 20:16:11 -07:00
// $mes->addError('Code malfunction 23! ('.$action.')');
// $ns->tablerender(LAN_MAILOUT_97, $mes->render());
2009-11-15 17:38:05 +00:00
exit ; // Could be a hack attempt
} // switch($action) - end of 'executive' tasks
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
// ------------------------ Intermediate actions ---------------------------
// (These have more than one route to trigger them)
switch ( $midAction )
{
case 'midDeleteEmail' :
// $emessage->add($pageMode.': Would delete here: '.$mailId, E_MESSAGE_SUCCESS);
// break; // Delete this
$result = $mailAdmin -> deleteEmail ( $mailId , 'all' );
2009-11-24 20:40:35 +00:00
$admin_log -> log_event ( 'MAIL_04' , 'ID: ' . $mailId , E_LOG_INFORMATIVE , '' );
2009-11-15 17:38:05 +00:00
if (( $result === FALSE ) || ! is_array ( $result ))
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_166 );
}
else
{
if ( isset ( $result [ 'content' ]))
{
if ( $result [ 'content' ] === FALSE )
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_167 );
}
else
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( str_replace ( '--ID--' , $mailId , LAN_MAILOUT_167 ));
2009-11-15 17:38:05 +00:00
}
}
if ( isset ( $result [ 'recipients' ]))
{
if ( $result [ 'recipients' ] === FALSE )
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_169 );
}
else
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( str_replace ( array ( '--ID--' , '--NUM--' ), array ( $mailId , $result [ 'recipients' ]), LAN_MAILOUT_170 ));
2009-11-15 17:38:05 +00:00
}
}
}
break ;
case 'midMoveToSend' :
2009-11-27 21:42:46 +00:00
$notify = isset ( $_POST [ 'mail_notify_complete' ]) ? 3 : 2 ;
$first = 0 ;
$last = 0 ; // Set defaults for earliest and latest send times.
// TODO: Save these fields
if ( isset ( $_POST [ 'mail_earliest_time' ]))
{
2009-12-01 20:05:54 +00:00
$first = e107 :: getDateConvert () -> decodeDateTime ( $_POST [ 'mail_earliest_time' ], 'datetime' , CORE_DATE_ORDER , FALSE );
2009-11-27 21:42:46 +00:00
}
if ( isset ( $_POST [ 'mail_latest_time' ]))
{
2009-12-01 20:05:54 +00:00
$last = e107 :: getDateConvert () -> decodeDateTime ( $_POST [ 'mail_earliest_time' ], 'datetime' , CORE_DATE_ORDER , TRUE );
2009-11-27 21:42:46 +00:00
}
if ( $mailAdmin -> activateEmail ( $mailId , FALSE , $notify , $first , $last ))
2009-11-15 17:38:05 +00:00
{
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( LAN_MAILOUT_185 );
2009-11-24 20:40:35 +00:00
$admin_log -> log_event ( 'MAIL_06' , 'ID: ' . $mailId , E_LOG_INFORMATIVE , '' );
2009-11-15 17:38:05 +00:00
}
else
{
$errors [] = str_replace ( '--ID--' , $mailId , LAN_MAILOUT_188 );
}
break ;
}
2006-12-02 04:36:16 +00:00
2011-04-08 05:11:38 +00:00
if ( isset ( $_POST [ 'email_sendnow' ]))
{
2014-10-12 18:01:19 -07:00
// sendImmediately($mailId);
2011-04-08 05:11:38 +00:00
}
2009-11-15 17:38:05 +00:00
// --------------------- Display errors and results ------------------------
if ( is_array ( $errors ) && ( count ( $errors ) > 0 ))
{
foreach ( $errors as $e )
2007-12-22 14:49:34 +00:00
{
2013-02-25 21:28:26 +01:00
$mes -> addError ( $e );
2007-12-22 14:49:34 +00:00
}
2009-11-15 17:38:05 +00:00
unset ( $errors );
}
2013-02-25 21:28:26 +01:00
if ( $mes -> hasMessage ())
2009-11-15 17:38:05 +00:00
{
2013-02-25 21:28:26 +01:00
$ns -> tablerender ( LAN_MAILOUT_97 , $mes -> render ());
2009-11-15 17:38:05 +00:00
}
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
// ---------------------- Display required page ----------------------------
// At this point $action determines which page display is required - one of a
// fairly limited number of choices
$mailAdmin -> newMode ( $action );
//echo "Action: {$action} MailId: {$mailId} Target: {$targetId}<br />";
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
switch ( $action )
{
case 'prefs' :
if ( getperms ( '0' ))
{
show_prefs ( $mailAdmin );
}
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'maint' :
if ( getperms ( '0' ))
{
show_maint ( FALSE );
}
break ;
case 'debug' :
if ( getperms ( '0' ))
{
show_maint ( TRUE );
}
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'saved' : // Show template emails
case 'sent' :
case 'pending' :
case 'held' :
2014-10-10 20:16:11 -07:00
// $mailAdmin->showEmailList($action, -1, -1);
2009-11-15 17:38:05 +00:00
break ;
2006-12-02 04:36:16 +00:00
2013-02-20 21:11:17 +00:00
case 'mailshowtemplate' : // Show the templated email
$mailAdmin -> showEmailTemplate ( $mailId );
break ;
2009-11-15 17:38:05 +00:00
case 'maildelete' : // NOTE:: need to set previous page in form
$mailAdmin -> showDeleteConfirm ( $mailId , $pageMode );
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'marksend' : // Show the send confirmation page
2009-11-30 20:40:03 +00:00
$mailAdmin -> sendEmailCircular ( $mailData , $fromHold );
2009-11-15 17:38:05 +00:00
break ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
case 'recipients' :
2014-10-10 20:16:11 -07:00
// $mailAdmin->showmailRecipients($mailId, $action);
2009-11-15 17:38:05 +00:00
break ;
case 'makemail' :
default :
2010-01-10 11:01:29 +00:00
if ( ! isset ( $mailData ) || ! is_array ( $mailData ))
2009-11-15 17:38:05 +00:00
{
$mailData = array (); // Empty array just in case
}
2014-10-12 18:01:19 -07:00
// $mailAdmin->show_mailform($mailData);
2009-11-15 17:38:05 +00:00
break ;
}
2006-12-02 04:36:16 +00:00
2010-01-11 21:09:52 +00:00
require_once ( e_ADMIN . 'footer.php' );
2009-11-15 17:38:05 +00:00
2011-04-08 05:11:38 +00:00
/**
* Real - time Immediate Mail - out . Browser may be closed and will continue .
* @ param integer $id ( mailing id )
* @ return
*/
2014-10-12 02:37:43 -07:00
/*
2011-04-08 05:11:38 +00:00
function sendImmediately ( $id )
{
2013-02-25 21:28:26 +01:00
$mes = e107 :: getMessage ();
2011-04-08 05:11:38 +00:00
$text = " <div id='mstatus'>Processing Mailout ID: " . $id . " </div> " ;
$text .= " <div id='progress' style='margin-bottom:30px'> </div> " ;
2006-12-02 04:36:16 +00:00
2011-04-08 05:11:38 +00:00
//Initiate the Function in the Background.
$text .= "
< script type = 'text/javascript' >
//<![CDATA[
new Ajax . Updater ( 'mstatus' , '".e_SELF."?mode=process&id=".intval($id)."' , {
method : 'get' ,
evalScripts : true
});
// ]]>
</ script > " ;
// Update the Progress in real-time.
$text .= "
< script type = 'text/javascript' >
//<![CDATA[
x = new Ajax . PeriodicalUpdater ( 'progress' , '".e_SELF."?mode=progress&id=".intval($id)."' ,
{
method : 'post' ,
frequency : 3 ,
decay : 1 ,
evalScripts : true
});
// ]]>
</ script > " ;
2013-02-25 21:28:26 +01:00
$mes -> addSuccess ( $text );
2011-04-08 05:11:38 +00:00
2013-02-25 21:28:26 +01:00
e107 :: getRender () -> tablerender ( " Sending... " , $mes -> render ());
2011-04-08 05:11:38 +00:00
}
2014-10-12 02:37:43 -07:00
*/
2011-04-08 05:11:38 +00:00
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
//----------------------------------------------------
// MAILER OPTIONS
//----------------------------------------------------
2014-10-10 20:16:11 -07:00
/*
2009-11-15 17:38:05 +00:00
function show_prefs ( $mailAdmin )
2007-12-22 14:49:34 +00:00
{
2014-10-10 20:16:11 -07:00
return ;
2013-02-25 21:28:26 +01:00
$pref = e107 :: getPref ();
2009-09-03 19:32:33 +00:00
$e107 = e107 :: getInstance ();
2009-10-26 01:04:06 +00:00
$frm = e107 :: getForm ();
$mes = e107 :: getMessage ();
2013-02-25 21:28:26 +01:00
$ns = e107 :: getRender ();
2009-10-26 01:04:06 +00:00
2006-12-02 04:36:16 +00:00
2009-10-25 15:05:27 +00:00
e107 :: getCache () -> CachePageMD5 = '_' ;
$lastload = e107 :: getCache () -> retrieve ( 'emailLastBounce' , FALSE , TRUE , TRUE );
$lastBounce = round (( time () - $lastload ) / 60 );
$lastBounceText = ( $lastBounce > 1256474 ) ? " <b>Never</b> " : " <b> " . $lastBounce . " minutes </b>ago. " ;
2009-09-03 19:32:33 +00:00
$text = "
< form method = 'post' action = '".e_SELF."?".e_QUERY."' id = 'mailsettingsform' >
2012-11-03 00:57:29 +00:00
< fieldset id = 'mail' >
< legend > " .LAN_MAILOUT_110. " </ legend >
2012-11-27 14:32:40 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-09-03 19:32:33 +00:00
< col class = 'col-label' />
2009-10-26 01:04:06 +00:00
< col class = 'col-control' />
2009-09-03 19:32:33 +00:00
</ colgroup >
2012-11-03 00:57:29 +00:00
< tbody >
2009-09-03 19:32:33 +00:00
< tr >
2009-10-25 15:05:27 +00:00
< td > " .LAN_MAILOUT_110. " < br /></ td >
2014-10-10 20:16:11 -07:00
< td class = 'form-inline' > " . $frm->admin_button ('testemail', LAN_MAILOUT_112,'other'). " & nbsp ;
2009-11-15 17:38:05 +00:00
< input name = 'testaddress' class = 'tbox' type = 'text' size = '40' maxlength = '80' value = \ " " . ( varset ( $_POST [ 'testaddress' ]) ? $_POST [ 'testaddress' ] : USEREMAIL ) . " \" />
2009-10-25 15:05:27 +00:00
</ td >
2009-09-03 19:32:33 +00:00
</ tr >
< tr >
2009-10-26 01:04:06 +00:00
< td style = 'vertical-align:top' > " .LAN_MAILOUT_115. " < br /></ td >
< td >
2009-09-03 19:32:33 +00:00
< select class = 'tbox' name = 'mailer' onchange = 'disp(this.value)' > \n " ;
2009-11-15 17:38:05 +00:00
$mailers = array ( 'php' , 'smtp' , 'sendmail' );
foreach ( $mailers as $opt )
{
2010-01-11 21:09:52 +00:00
$sel = ( $pref [ 'mailer' ] == $opt ) ? " selected='selected' " : '' ;
2009-11-15 17:38:05 +00:00
$text .= " <option value=' { $opt } ' { $sel } > { $opt } </option> \n " ;
}
$text .= " </select> <span class='field-help'> " . LAN_MAILOUT_116 . " </span><br /> " ;
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
// SMTP. -------------->
$smtp_opts = explode ( ',' , varset ( $pref [ 'smtp_options' ], '' ));
2009-11-15 17:38:05 +00:00
$smtpdisp = ( $pref [ 'mailer' ] != 'smtp' ) ? " style='display:none;' " : '' ;
$text .= " <div id='smtp' { $smtpdisp } >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' style = 'margin-right:auto;margin-left:0px;border:0px' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-11-15 17:38:05 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
" ;
$text .= "
< tr >
2009-10-26 01:04:06 +00:00
< td > " .LAN_MAILOUT_87. " :& nbsp ; & nbsp ; </ td >
2009-11-15 17:38:05 +00:00
< td >
2009-09-03 19:32:33 +00:00
< input class = 'tbox' type = 'text' name = 'smtp_server' size = '40' value = '".$pref[' smtp_server ']."' maxlength = '50' />
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
< tr >
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_88. " :& nbsp ;( " .LAN_OPTIONAL. " ) & nbsp ; & nbsp ; </ td >
< td style = 'width:50%;' >
2009-09-03 19:32:33 +00:00
< input class = 'tbox' type = 'text' name = 'smtp_username' size = '40' value = \ " " . $pref [ 'smtp_username' ] . " \" maxlength='50' />
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
< tr >
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_89. " :& nbsp ;( " .LAN_OPTIONAL. " ) & nbsp ; & nbsp ; </ td >
< td >
2009-09-03 19:32:33 +00:00
< input class = 'tbox' type = 'password' name = 'smtp_password' size = '40' value = '".$pref[' smtp_password ']."' maxlength = '50' />
</ td >
</ tr >
2006-12-02 04:36:16 +00:00
2009-09-03 19:32:33 +00:00
< tr >
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_90. " </ td >< td >
2009-09-03 19:32:33 +00:00
< select class = 'tbox' name = 'smtp_options' > \n
< option value = '' > " .LAN_MAILOUT_96. " </ option > \n " ;
2009-11-15 17:38:05 +00:00
$selected = ( in_array ( 'secure=SSL' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_ssl' { $selected } > " . LAN_MAILOUT_92 . " </option> \n " ;
$selected = ( in_array ( 'secure=TLS' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_tls' { $selected } > " . LAN_MAILOUT_93 . " </option> \n " ;
$selected = ( in_array ( 'pop3auth' , $smtp_opts ) ? " selected='selected' " : '' );
$text .= " <option value='smtp_pop3auth' { $selected } > " . LAN_MAILOUT_91 . " </option> \n " ;
$text .= " </select> \n <br /> " . LAN_MAILOUT_94 . " </td></tr> " ;
2007-12-22 14:49:34 +00:00
$text .= " <tr>
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_57. " </ td >< td >
2009-09-03 19:32:33 +00:00
" ;
2010-01-11 21:09:52 +00:00
$checked = ( varsettrue ( $pref [ 'smtp_keepalive' ]) ) ? " checked='checked' " : '' ;
2006-12-02 04:36:16 +00:00
$text .= " <input type='checkbox' name='smtp_keepalive' value='1' { $checked } />
2009-09-03 19:32:33 +00:00
</ td >
</ tr > " ;
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
$checked = ( in_array ( 'useVERP' , $smtp_opts ) ? " checked='checked' " : " " );
$text .= " <tr>
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_95. " </ td >< td >
2007-12-22 14:49:34 +00:00
< input type = 'checkbox' name = 'smtp_useVERP' value = '1' { $checked } />
2009-09-03 19:32:33 +00:00
</ td >
</ tr >
</ table ></ div > " ;
2014-10-10 20:16:11 -07:00
*/
2011-04-08 05:11:38 +00:00
/* FIXME - posting SENDMAIL path triggers Mod - Security rules .
2007-12-22 14:49:34 +00:00
// Sendmail. -------------->
2010-01-11 21:09:52 +00:00
$senddisp = ( $pref [ 'mailer' ] != 'sendmail' ) ? " style='display:none;' " : '' ;
2009-11-15 17:38:05 +00:00
$text .= " <div id='sendmail' { $senddisp } ><table style='margin-right:0px;margin-left:auto;border:0px'> " ;
2006-12-02 04:36:16 +00:00
$text .= "
< tr >
2009-11-15 17:38:05 +00:00
< td > " .LAN_MAILOUT_20. " :& nbsp ; & nbsp ; </ td >
< td >
2006-12-02 04:36:16 +00:00
< input class = 'tbox' type = 'text' name = 'sendmail' size = '60' value = \ " " . ( ! $pref [ 'sendmail' ] ? " /usr/sbin/sendmail -t -i -r " . $pref [ 'siteadminemail' ] : $pref [ 'sendmail' ]) . " \" maxlength='80' />
</ td >
</ tr >
</ table ></ div > " ;
2011-04-08 05:11:38 +00:00
*/
2014-10-10 20:16:11 -07:00
/*
2006-12-02 04:36:16 +00:00
$text .= " </td>
</ tr >
2009-11-15 17:38:05 +00:00
< tr >
< td > " .LAN_MAILOUT_222. " </ td >
< td > " ;
$text .= $mailAdmin -> sendStyleSelect ( varset ( $pref [ 'mail_sendstyle' ], 'textonly' ), 'mail_sendstyle' );
$text .=
" <span class='field-help'> " . LAN_MAILOUT_223 . " </span>
</ td >
</ tr > \n
2006-12-02 04:36:16 +00:00
< tr >
2009-07-15 09:38:00 +00:00
< td > " .LAN_MAILOUT_25. " </ td >
2009-10-26 01:04:06 +00:00
< td > " .LAN_MAILOUT_26. "
2012-11-03 00:57:29 +00:00
< input class = 'tbox e-spinner' size = '3' type = 'text' name = 'mail_pause' value = '".$pref[' mail_pause ']."' /> " .LAN_MAILOUT_27.
" <input class='tbox e-spinner' size='3' type='text' name='mail_pausetime' value=' " . $pref [ 'mail_pausetime' ] . " ' /> " . LAN_MAILOUT_29 . " .<br />
2009-10-26 01:04:06 +00:00
< span class = 'field-help' > " .LAN_MAILOUT_30. " </ span >
2006-12-02 04:36:16 +00:00
</ td >
2009-11-15 17:38:05 +00:00
</ tr > \n
2009-10-26 01:04:06 +00:00
2009-11-15 17:38:05 +00:00
< tr >
< td > " .LAN_MAILOUT_156. " </ td >
2012-11-03 00:57:29 +00:00
< td >< input class = 'tbox e-spinner' size = '3' type = 'text' name = 'mail_workpertick' value = '".varset($pref[' mail_workpertick '],5)."' />
2009-11-15 17:38:05 +00:00
< span class = 'field-help' > " .LAN_MAILOUT_157. " </ span >
</ td >
</ tr > \n " ;
2013-03-20 04:13:18 -07:00
if ( isset ( $pref [ 'e_mailout_list' ])) // Allow selection of email address sources
{
$text .= "
< tr >
< td > " .LAN_MAILOUT_77. " </ td >
< td > " ;
$mail_enable = explode ( ',' , $pref [ 'mailout_enabled' ]);
foreach ( $pref [ 'e_mailout_list' ] as $mailer => $v )
{
$check = ( in_array ( $mailer , $mail_enable )) ? " checked='checked' " : " " ;
$text .= " <input type='checkbox' name='mail_mailer_enabled[]' value=' { $mailer } ' { $check } /> { $mailer } <br /> " ;
}
$text .= " </td></tr> \n " ;
2007-12-22 14:49:34 +00:00
}
2006-12-02 04:36:16 +00:00
2007-12-22 14:49:34 +00:00
list ( $mail_log_option , $mail_log_email ) = explode ( ',' , varset ( $pref [ 'mail_log_options' ], '0,0' ));
2013-03-20 04:13:18 -07:00
2007-12-22 14:49:34 +00:00
$check = ( $mail_log_email == 1 ) ? " checked='checked' " : " " ;
2013-03-20 04:13:18 -07:00
2007-12-22 14:49:34 +00:00
$text .= " <tr>
2009-07-15 09:38:00 +00:00
< td > " .LAN_MAILOUT_72. " </ td >
2009-11-15 17:38:05 +00:00
< td >
2007-12-22 14:49:34 +00:00
< select class = 'tbox' name = 'mail_log_option' > \n
2010-01-11 21:09:52 +00:00
< option value = '0' " .(( $mail_log_option ==0) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_73. " </ option > \n
< option value = '1' " .(( $mail_log_option ==1) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_74. " </ option > \n
< option value = '2' " .(( $mail_log_option ==2) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_75. " </ option > \n
< option value = '3' " .(( $mail_log_option ==3) ? " selected = 'selected' " : ''). " > " .LAN_MAILOUT_119. " </ option > \n
2009-11-15 17:38:05 +00:00
</ select > \n
< input type = 'checkbox' name = 'mail_log_email' value = '1' { $check } /> " .LAN_MAILOUT_76.
" </td>
2007-12-22 14:49:34 +00:00
</ tr > \n " ;
2006-12-02 04:36:16 +00:00
2012-11-03 00:57:29 +00:00
$text .= " </table></fieldset>
2009-10-26 01:04:06 +00:00
< fieldset id = 'core-mail-prefs-bounce' >
2009-11-24 20:40:35 +00:00
< legend > " .LAN_MAILOUT_31. " </ legend >
2012-11-27 14:32:40 -08:00
< table class = 'table adminform' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-10-26 01:04:06 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >
2009-11-24 20:40:35 +00:00
< td > " .LAN_MAILOUT_231. " </ td >< td > " ;
// bounce divs = mail_bounce_none, mail_bounce_auto, mail_bounce_mail
2010-01-11 21:09:52 +00:00
$autoDisp = ( $pref [ 'mail_bounce' ] != 'auto' ) ? " style='display:none;' " : '' ;
$autoMail = ( $pref [ 'mail_bounce' ] != 'mail' ) ? " style='display:none;' " : '' ;
2009-11-24 20:40:35 +00:00
$bounceOpts = array ( 'none' => LAN_MAILOUT_232 , 'auto' => LAN_MAILOUT_233 , 'mail' => LAN_MAILOUT_234 );
$text .= " <select name='mail_bounce' class='tbox' onchange='bouncedisp(this.value)'> \n <option value=''> </option> \n " ;
foreach ( $bounceOpts as $k => $v )
{
$selected = ( $pref [ 'mail_bounce' ] == $k ) ? " selected='selected' " : '' ;
$text .= " <option value=' { $k } ' { $selected } > { $v } </option> \n " ;
}
$text .= " </select> \n </td>
</ tr ></ tbody ></ table >
2012-11-27 14:32:40 -08:00
< table class = 'adminform' id = 'mail_bounce_auto' { $autoDisp } >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-11-24 20:40:35 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
< tr >< td > " .LAN_MAILOUT_32. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_email2' value = \ " " . $pref [ 'mail_bounce_email' ] . " \" /></td></tr>
2009-10-26 01:04:06 +00:00
< tr >
2011-04-08 05:11:38 +00:00
< td > " .LAN_MAILOUT_233. " </ td >< td >< b > " .(e_DOCROOT).e107::getFolder('handlers'). " bounce_handler . php </ b > " ;
2009-11-15 17:38:05 +00:00
if ( ! is_readable ( e_HANDLER . 'bounce_handler.php' ))
2009-10-26 01:23:19 +00:00
{
2010-01-11 21:09:52 +00:00
$text .= " <br /><span class='required'> " . LAN_MAILOUT_161 . '</span>' ;
2009-10-26 01:23:19 +00:00
}
2009-11-15 17:38:05 +00:00
elseif ( ! is_executable ( e_HANDLER . 'bounce_handler.php' )) // Seems to give wrong answers on Windoze
{
2010-01-11 21:09:52 +00:00
$text .= " <br /><span class='required'> " . LAN_MAILOUT_162 . '</span>' ;
2009-11-15 17:38:05 +00:00
}
2009-11-24 20:40:35 +00:00
$text .= " <br /><span class='field-help'> " . LAN_MAILOUT_235 . " </span></td></tr>
< tr >< td > " .LAN_MAILOUT_236. " </ td >< td > " . $lastBounceText . " </ td ></ tr >
</ tbody ></ table > " ;
2009-11-15 17:38:05 +00:00
2009-11-24 20:40:35 +00:00
// Parameters for mail-account based bounce processing
$text .= "
2012-11-27 14:32:40 -08:00
< table class = 'table adminform' id = 'mail_bounce_mail' { $autoMail } >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-11-24 20:40:35 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody >
2009-11-15 17:38:05 +00:00
< tr >< td > " .LAN_MAILOUT_32. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_email' value = \ " " . $pref [ 'mail_bounce_email' ] . " \" /></td></tr>
2009-10-26 01:04:06 +00:00
< tr >< td > " .LAN_MAILOUT_33. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_pop3' value = \ " " . $pref [ 'mail_bounce_pop3' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_34. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_user' value = \ " " . $pref [ 'mail_bounce_user' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_35. " </ td >< td >< input class = 'tbox' size = '40' type = 'text' name = 'mail_bounce_pass' value = \ " " . $pref [ 'mail_bounce_pass' ] . " \" /></td></tr>
< tr >< td > " .LAN_MAILOUT_120. " </ td >< td >< select class = 'tbox' name = 'mail_bounce_type' > \n
< option value = '' >& nbsp ; </ option > \n
< option value = 'pop3' " .(( $pref['mail_bounce_type'] =='pop3') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_121. " </ option > \n
< option value = 'pop3/notls' " .(( $pref['mail_bounce_type'] =='pop3/notls') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_122. " </ option > \n
< option value = 'pop3/tls' " .(( $pref['mail_bounce_type'] =='pop3/tls') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_123. " </ option > \n
< option value = 'imap' " .(( $pref['mail_bounce_type'] =='imap') ? " selected = 'selected' " : " " ). " > " .LAN_MAILOUT_124. " </ option > \n
</ select ></ td ></ tr > \n
" ;
$check = ( $pref [ 'mail_bounce_delete' ] == 1 ) ? " checked='checked' " : " " ;
2009-11-27 21:42:46 +00:00
$text .= " <tr><td> " . LAN_MAILOUT_36 . " </td><td><input type='checkbox' name='mail_bounce_delete' value='1' { $check } /></td></tr> " ;
$check = ( $pref [ 'mail_bounce_auto' ] == 1 ) ? " checked='checked' " : " " ;
$text .= " <tr><td> " . LAN_MAILOUT_245 . " </td><td><input type='checkbox' name='mail_bounce_auto' value='1' { $check } /><span class='field-help'> " . LAN_MAILOUT_246 . " </span></td></tr>
2009-10-26 01:04:06 +00:00
</ tbody >
</ table ></ fieldset >
2012-11-27 14:32:40 -08:00
< div class = 'buttons-bar center' > " . $frm->admin_button ('updateprefs',LAN_MAILOUT_28,'update'). " </ div >
2006-12-02 04:36:16 +00:00
2012-11-03 00:57:29 +00:00
</ form > " ;
2006-12-02 04:36:16 +00:00
2013-02-25 21:28:26 +01:00
$caption = ADLAN_136 . SEP . LAN_PREFS ;
$ns -> tablerender ( $caption , $mes -> render () . $text );
2006-12-02 04:36:16 +00:00
}
2014-10-10 20:16:11 -07:00
*/
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
//-----------------------------------------------------------
// MAINTENANCE OPTIONS
//-----------------------------------------------------------
function show_maint ( $debug = FALSE )
2007-12-22 14:49:34 +00:00
{
2014-10-10 20:16:11 -07:00
return ;
2010-01-10 03:56:28 +00:00
$mes = e107 :: getMessage ();
$ns = e107 :: getRender ();
2012-11-27 14:32:40 -08:00
$frm = e107 :: getForm ();
2010-01-10 03:56:28 +00:00
2013-02-25 21:28:26 +01:00
$text = "
2009-11-15 17:38:05 +00:00
< form action = '".e_SELF."?mode=maint' id = 'email_maint' method = 'post' >
< fieldset id = 'email-maint' >
2012-11-26 14:41:32 -08:00
< table class = 'table adminlist' >
2012-05-13 05:50:32 +00:00
< colgroup >
2009-11-15 17:38:05 +00:00
< col class = 'col-label' />
< col class = 'col-control' />
</ colgroup >
< tbody > " ;
2006-12-02 04:36:16 +00:00
2012-11-27 14:32:40 -08:00
$text .= " <tr><td> " . LAN_MAILOUT_182 . " </td><td>
2013-03-18 14:20:14 +01:00
" . $frm->admin_button ('email_dross','no-value','delete', LAN_RUN). "
2012-11-27 14:32:40 -08:00
< br />< span class = 'field-help' > " .LAN_MAILOUT_252. " </ span ></ td ></ tr > " ;
2013-02-25 21:28:26 +01:00
$text .= " </tbody></table> \n </fieldset></form> " ;
2006-12-02 04:36:16 +00:00
2013-02-25 21:28:26 +01:00
$ns -> tablerender ( ADLAN_136 . SEP . ADLAN_40 , $mes -> render () . $text );
2009-11-15 17:38:05 +00:00
}
2006-12-02 04:36:16 +00:00
2014-10-10 20:16:11 -07:00
/*
2007-12-22 14:49:34 +00:00
function mailout_adminmenu ()
{
2013-02-25 21:28:26 +01:00
$tp = e107 :: getParser ();
$action = $tp -> toDB ( varset ( $_GET [ 'mode' ], 'makemail' ));
2009-11-15 17:38:05 +00:00
if ( $action == 'mailedit' )
2007-12-22 14:49:34 +00:00
{
2009-11-15 17:38:05 +00:00
$action = 'makemail' ;
2006-12-02 04:36:16 +00:00
}
2009-11-15 17:38:05 +00:00
$var [ 'post' ][ 'text' ] = LAN_MAILOUT_190 ;
2006-12-02 04:36:16 +00:00
$var [ 'post' ][ 'link' ] = e_SELF ;
2009-11-15 17:38:05 +00:00
$var [ 'post' ][ 'perm' ] = 'W' ;
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
$var [ 'saved' ][ 'text' ] = LAN_MAILOUT_191 ; // Saved emails
$var [ 'saved' ][ 'link' ] = e_SELF . '?mode=saved' ;
$var [ 'saved' ][ 'perm' ] = 'W' ;
2007-12-22 14:49:34 +00:00
2009-11-15 17:38:05 +00:00
$var [ 'pending' ][ 'text' ] = LAN_MAILOUT_193 ; // Pending email runs
$var [ 'pending' ][ 'link' ] = e_SELF . '?mode=pending' ;
$var [ 'pending' ][ 'perm' ] = 'W' ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$var [ 'held' ][ 'text' ] = LAN_MAILOUT_194 ; // Held email runs
$var [ 'held' ][ 'link' ] = e_SELF . '?mode=held' ;
$var [ 'held' ][ 'perm' ] = 'W' ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$var [ 'sent' ][ 'text' ] = LAN_MAILOUT_192 ; // Completed email runs
$var [ 'sent' ][ 'link' ] = e_SELF . '?mode=sent' ;
$var [ 'sent' ][ 'perm' ] = 'W' ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
if ( getperms ( " 0 " ))
{
$var [ 'prefs' ][ 'text' ] = LAN_PREFS ;
$var [ 'prefs' ][ 'link' ] = e_SELF . '?mode=prefs' ;
$var [ 'prefs' ][ 'perm' ] = '0' ;
2006-12-02 04:36:16 +00:00
2009-11-15 17:38:05 +00:00
$var [ 'maint' ][ 'text' ] = ADLAN_40 ;
$var [ 'maint' ][ 'link' ] = e_SELF . '?mode=maint' ;
$var [ 'maint' ][ 'perm' ] = '0' ;
}
show_admin_menu ( LAN_MAILOUT_15 , $action , $var );
2006-12-02 04:36:16 +00:00
}
2014-10-10 20:16:11 -07:00
*/
2006-12-02 04:36:16 +00:00
function headerjs ()
{
$text = "
< script type = 'text/javascript' >
2011-04-08 05:11:38 +00:00
2009-11-15 17:38:05 +00:00
function disp ( type )
{
if ( type == 'smtp' )
{
2006-12-02 04:36:16 +00:00
document . getElementById ( 'smtp' ) . style . display = '' ;
document . getElementById ( 'sendmail' ) . style . display = 'none' ;
return ;
}
2009-11-15 17:38:05 +00:00
if ( type == 'sendmail' )
{
2006-12-02 04:36:16 +00:00
document . getElementById ( 'smtp' ) . style . display = 'none' ;
document . getElementById ( 'sendmail' ) . style . display = '' ;
return ;
}
document . getElementById ( 'smtp' ) . style . display = 'none' ;
document . getElementById ( 'sendmail' ) . style . display = 'none' ;
}
2009-11-24 20:40:35 +00:00
function bouncedisp ( type )
{
if ( type == 'auto' )
{
document . getElementById ( 'mail_bounce_auto' ) . style . display = '' ;
document . getElementById ( 'mail_bounce_mail' ) . style . display = 'none' ;
return ;
}
if ( type == 'mail' )
{
document . getElementById ( 'mail_bounce_auto' ) . style . display = 'none' ;
document . getElementById ( 'mail_bounce_mail' ) . style . display = '' ;
return ;
}
document . getElementById ( 'mail_bounce_auto' ) . style . display = 'none' ;
document . getElementById ( 'mail_bounce_mail' ) . style . display = 'none' ;
}
2006-12-02 04:36:16 +00:00
</ script > " ;
2009-11-27 21:42:46 +00:00
$mailAdmin = e107 :: getRegistry ( '_mailout_admin' );
2012-11-26 03:23:20 -08:00
// $text .= $mailAdmin->_cal->load_files();
2009-11-27 21:42:46 +00:00
2006-12-02 04:36:16 +00:00
return $text ;
}
2011-04-08 05:11:38 +00:00
?>