Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\modules\admin\bulkmail;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -21,7 +21,12 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* Bulk mail management
|
||||
*/
|
||||
class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
@@ -117,18 +122,8 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$return['cancel'] = array(
|
||||
'icon' => 'minus-circle',
|
||||
'title' => 'cancel',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=cancel&id=' ) . $row['mail_id'],
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=cancel&id=' . $row['mail_id'] )->csrf(),
|
||||
);
|
||||
|
||||
$classToUse = \IPS\Email::classToUse( \IPS\Email::TYPE_BULK );
|
||||
if( !$classToUse::REQUIRES_TIME_BREAK )
|
||||
{
|
||||
$return['resend'] = array(
|
||||
'icon' => 'share',
|
||||
'title' => 'continue_sending',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&resetTask=1&do=sendImmediately&id=' ) . $row['mail_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,6 +191,8 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Retrieve the bulk mail details for the log */
|
||||
try
|
||||
{
|
||||
@@ -302,13 +299,13 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$content = $mail->content;
|
||||
foreach ( $mail->returnTagValues( 0, \IPS\Member::loggedIn() ) as $k => $v )
|
||||
{
|
||||
$content = str_replace( $k, $v, $content );
|
||||
$content = str_replace( array( $k, urlencode( $k ) ), $v, $content );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
$email = \IPS\Email::buildFromContent( $mail->subject, \IPS\Email::staticParseTextForEmail( $content, \IPS\Member::loggedIn()->language() ), NULL, \IPS\Email::TYPE_BULK )->setUnsubscribe( 'core', 'unsubscribeBulk' );
|
||||
|
||||
\IPS\Output::i()->sendOutput( $email->compileContent( 'html', \IPS\Member::loggedIn() ) );
|
||||
\IPS\Output::i()->sendOutput( $email->compileContent( 'html', \IPS\Member::loggedIn(), NULL, FALSE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,6 +343,8 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
@@ -365,72 +364,8 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
\IPS\Session::i()->log( 'acplogs__bulkmail_sent', array( $mail->subject => FALSE ) );
|
||||
|
||||
/* And redirect */
|
||||
$classToUse = \IPS\Email::classToUse( \IPS\Email::TYPE_BULK );
|
||||
if( !$classToUse::REQUIRES_TIME_BREAK )
|
||||
{
|
||||
return $this->sendImmediately();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'Bulkmail', array( 'mail_id' => $mail->id ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'bm_initiated' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send bulk mails immediately
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendImmediately()
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('bm_initiated');
|
||||
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
|
||||
\IPS\Http\Url::internal( "app=core&module=bulkmail&controller=bulkmail&do=sendImmediately&id=" . intval( \IPS\Request::i()->id ) ),
|
||||
function( $data )
|
||||
{
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id, NULL, 'mail_active=1' );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* On first cycle return data */
|
||||
if ( !is_array( $data ) )
|
||||
{
|
||||
return array( array( 'total' => $mail->getQuery( \IPS\core\BulkMail\Bulkmailer::GET_COUNT_ONLY )->first() ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack('bulkmail_sent_sofar', FALSE, array( 'sprintf' => array( $mail->subject, \IPS\Member::loggedIn()->language()->addToStack( 'bm_users', FALSE, array( 'pluralize' => array( 0 ) ) ) ) ) ),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
/* Send the bulk mail */
|
||||
$result = $mail->send();
|
||||
|
||||
/* If response is NULL there were no recipients. If response is 0 no emails were sent. Either way we're done. */
|
||||
if( $result === NULL OR $result === 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( $data,
|
||||
\IPS\Member::loggedIn()->language()->addToStack('bulkmail_sent_sofar', FALSE, array( 'sprintf' => array( $mail->subject, \IPS\Member::loggedIn()->language()->addToStack( 'bm_users', FALSE, array( 'pluralize' => array( $mail->sentto ) ) ) ) ) ),
|
||||
min( ( 100 / $data['total'] * $mail->offset ), 100 )
|
||||
);
|
||||
}
|
||||
},
|
||||
function()
|
||||
{
|
||||
/* We don't have to do anything special because BulkMailer will have already updated the task and disabled the bulk mail */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'bm_sent_succesfull' );
|
||||
}
|
||||
);
|
||||
\IPS\Task::queue( 'core', 'Bulkmail', array( 'mail_id' => $mail->id ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'bm_initiated' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user