Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,35 +11,58 @@
|
||||
namespace IPS\core\modules\admin\bulkmail;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\core\BulkMail\Bulkmailer;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Email;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk mail management
|
||||
*/
|
||||
class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
class bulkmail extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'bulkmail_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'bulkmail_manage' );
|
||||
|
||||
/* Make sure we have a community outgoing email */
|
||||
if ( !\IPS\Settings::i()->email_out )
|
||||
if ( !Settings::i()->email_out )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_outgoing_address', '1C125/9', 403, '' );
|
||||
Output::i()->error( 'no_outgoing_address', '1C125/9', 403, '' );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
@@ -50,10 +73,10 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_bulk_mail', \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_bulk_mail', Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ) );
|
||||
$table->langPrefix = 'bulkmail_';
|
||||
$table->mainColumn = 'mail_subject';
|
||||
$table->include = array( 'mail_subject', 'mail_start', 'mail_sentto', 'mail_taken' );
|
||||
@@ -69,38 +92,38 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if( !$val )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('bulkmail_notstarted');
|
||||
return Member::loggedIn()->language()->addToStack('bulkmail_notstarted');
|
||||
}
|
||||
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'mail_sentto' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'bulkmail_sentto_members', FALSE, array( 'pluralize' => array( (int) $val ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'bulkmail_sentto_members', FALSE, array( 'pluralize' => array( (int) $val ) ) );
|
||||
},
|
||||
'mail_taken' => function( $val, $row )
|
||||
{
|
||||
if( !$row['mail_updated'] )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('bulkmail_notstarted');
|
||||
return Member::loggedIn()->language()->addToStack('bulkmail_notstarted');
|
||||
}
|
||||
|
||||
$started = \IPS\DateTime::ts( $row['mail_start'] );
|
||||
$updated = \IPS\DateTime::ts( $row['mail_updated'] );
|
||||
$started = DateTime::ts( $row['mail_start'] );
|
||||
$updated = DateTime::ts( $row['mail_updated'] );
|
||||
|
||||
return \IPS\DateTime::formatInterval( $updated->diff( $started ) );
|
||||
return DateTime::formatInterval( $updated->diff( $started ) );
|
||||
}
|
||||
);
|
||||
|
||||
/* Specify the buttons */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_add' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'add' => array(
|
||||
'primary' => TRUE,
|
||||
'icon' => 'plus',
|
||||
'title' => 'bulkmail_add',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=form' ),
|
||||
'link' => Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=form' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -109,12 +132,12 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_edit' ) )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'icon' => 'pencil',
|
||||
'title' => 'edit',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=form&id=' ) . $row['mail_id'],
|
||||
'link' => Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=form&id=' ) . $row['mail_id'],
|
||||
);
|
||||
|
||||
if( $row['mail_active'] )
|
||||
@@ -122,7 +145,7 @@ 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'] )->csrf(),
|
||||
'link' => Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=cancel&id=' . $row['mail_id'] )->csrf(),
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -130,17 +153,17 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$return['resend'] = array(
|
||||
'icon' => 'refresh',
|
||||
'title' => 'resend',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=resend&id=' ) . $row['mail_id'],
|
||||
'link' => Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=resend&id=' ) . $row['mail_id'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_delete' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'bulkmail', 'bulkmail_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=delete&id=' ) . $row['mail_id'],
|
||||
'link' => Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=delete&id=' ) . $row['mail_id'],
|
||||
'data' => array( 'delete' => '' ),
|
||||
);
|
||||
}
|
||||
@@ -149,8 +172,8 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('manage_bulk_mail');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('manage_bulk_mail');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,30 +181,30 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
/* Retrieve the bulk mail details for the log */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/7', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/7', 404, '' );
|
||||
}
|
||||
|
||||
/* Unclaim attachments */
|
||||
\IPS\File::unclaimAttachments( 'core_Admin', $mail->id, NULL, 'bulkmail' );
|
||||
File::unclaimAttachments( 'core_Admin', $mail->id, NULL, 'bulkmail' );
|
||||
|
||||
/* Delete the bulk mail */
|
||||
$mail->delete();
|
||||
|
||||
/* Log and redirect */
|
||||
\IPS\Session::i()->log( 'acplog__bulkmail_deleted', array( $mail->subject => FALSE ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'deleted' );
|
||||
Session::i()->log( 'acplog__bulkmail_deleted', array( $mail->subject => FALSE ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'deleted' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,18 +212,18 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Retrieve the bulk mail details for the log */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/8', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/8', 404, '' );
|
||||
}
|
||||
|
||||
/* Cancel the bulk mail */
|
||||
@@ -209,18 +232,18 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$mail->save();
|
||||
|
||||
/* Remove any queue tasks */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_queue', array( "`key`=?", 'Bulkmail' ) ) AS $task )
|
||||
foreach( Db::i()->select( '*', 'core_queue', array( "`key`=?", 'Bulkmail' ) ) AS $task )
|
||||
{
|
||||
$data = json_decode( $task['data'], TRUE );
|
||||
if ( isset( $data['mail_id'] ) AND $data['mail_id'] == $mail->id )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_queue', array( "id=?", $task['id'] ) );
|
||||
Db::i()->delete( 'core_queue', array( "id=?", $task['id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Log and redirect */
|
||||
\IPS\Session::i()->log( 'acplog__bulkmail_cancelled', array( $mail->subject => FALSE ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'cancelled' );
|
||||
Session::i()->log( 'acplog__bulkmail_cancelled', array( $mail->subject => FALSE ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'cancelled' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,9 +253,9 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
* @see _bulkmail::send()
|
||||
* @note This method simply redirects to the preview() method
|
||||
*/
|
||||
public function resend()
|
||||
public function resend() : void
|
||||
{
|
||||
return $this->preview();
|
||||
$this->preview();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,23 +264,23 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
* @return void
|
||||
* @note The resend() method redirects here. Additionally, upon successfully saving a bulk mail the user is redirected here.
|
||||
*/
|
||||
public function preview()
|
||||
public function preview() : void
|
||||
{
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/1', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/1', 404, '' );
|
||||
}
|
||||
|
||||
/* Get the members */
|
||||
$results = $mail->getQuery( array( 0, 1000 ) );
|
||||
|
||||
/* Get a count of the members */
|
||||
$total = $mail->getQuery( \IPS\core\BulkMail\Bulkmailer::GET_COUNT_ONLY )->first();
|
||||
$total = $mail->getQuery( Bulkmailer::GET_COUNT_ONLY )->first();
|
||||
|
||||
/* Do we have anyone to send to? */
|
||||
if( !$total )
|
||||
@@ -269,13 +292,13 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$mail->save();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( 'no_members_to_send_to', '1C125/3', 400, '' );
|
||||
Output::i()->error( 'no_members_to_send_to', '1C125/3', 400, '' );
|
||||
}
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('bm_send_preview');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->message( 'bulkmail_send_info', 'information' );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'members' )->bulkMailPreview( $mail, $results, $total );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('bm_send_preview');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->message( 'bulkmail_send_info', 'information' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'members' )->bulkMailPreview( $mail, $results, $total );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,76 +306,48 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function iframePreview()
|
||||
public function iframePreview() : void
|
||||
{
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/2', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/2', 404, '' );
|
||||
}
|
||||
|
||||
/* For the preview we need to display the tags replaced with this member's data */
|
||||
$content = $mail->content;
|
||||
foreach ( $mail->returnTagValues( 0, \IPS\Member::loggedIn() ) as $k => $v )
|
||||
foreach ( $mail->returnTagValues( 0, Member::loggedIn() ) as $k => $v )
|
||||
{
|
||||
$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' );
|
||||
$email = Email::buildFromContent( $mail->subject, Email::staticParseTextForEmail( $content, Member::loggedIn()->language() ), NULL, Email::TYPE_BULK )->setUnsubscribe( 'core', 'unsubscribeBulk' );
|
||||
|
||||
\IPS\Output::i()->sendOutput( $email->compileContent( 'html', \IPS\Member::loggedIn(), NULL, FALSE ) );
|
||||
Output::i()->sendOutput( $email->compileContent( 'html', Member::loggedIn(), NULL, FALSE ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a bulk mail by replacing out the tags with the proper values
|
||||
*
|
||||
* @param \IPS\Member $member Member data
|
||||
* @return string
|
||||
*/
|
||||
public function formatBody( $member )
|
||||
{
|
||||
if( empty($this->_data['content']) )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Default tags */
|
||||
$tags = $this->returnTagValues( 0, $member );
|
||||
|
||||
/* Work on a copy rather than the original template */
|
||||
$body = $this->_data['content'];
|
||||
|
||||
/* Loop over the tags and swap out as appropriate */
|
||||
foreach( $tags as $key => $value )
|
||||
{
|
||||
$body = str_replace( $key, $value, $body );
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually send the bulk mail. We end up here once the preview has been confirmed the admin continues.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send()
|
||||
public function send() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/5', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/5', 404, '' );
|
||||
}
|
||||
|
||||
/* Make this bulk mail active */
|
||||
@@ -361,11 +356,11 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$mail->sentto = 0;
|
||||
$mail->save();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__bulkmail_sent', array( $mail->subject => FALSE ) );
|
||||
Session::i()->log( 'acplogs__bulkmail_sent', array( $mail->subject => FALSE ) );
|
||||
|
||||
/* And redirect */
|
||||
\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' );
|
||||
Task::queue( 'core', 'Bulkmail', array( 'mail_id' => $mail->id ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=bulkmail&controller=bulkmail' ), 'bm_initiated' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,49 +368,49 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
public function form() : void
|
||||
{
|
||||
/* Are we editing? */
|
||||
$mail = array( '_options' => array() );
|
||||
|
||||
if( (int) \IPS\Request::i()->id )
|
||||
if( (int) Request::i()->id )
|
||||
{
|
||||
/* Retrieve the bulk mail details */
|
||||
try
|
||||
{
|
||||
$mail = \IPS\core\BulkMail\Bulkmailer::load( (int) \IPS\Request::i()->id );
|
||||
$mail = Bulkmailer::load( (int) Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'couldnt_find_bulkmail', '2C125/6', 404, '' );
|
||||
Output::i()->error( 'couldnt_find_bulkmail', '2C125/6', 404, '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail = new \IPS\core\BulkMail\Bulkmailer;
|
||||
$mail = new Bulkmailer;
|
||||
}
|
||||
|
||||
/* Get tags */
|
||||
$tags = \IPS\core\BulkMail\Bulkmailer::getTags();
|
||||
$tags = Bulkmailer::getTags();
|
||||
$autoSaveKey = 'bulkmail' . ( $mail->id ? '-' . $mail->id : '' );
|
||||
|
||||
/* Start the form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$form->class = '';
|
||||
$form->addTab( 'bulkmail__main', NULL, NULL, 'ipsForm_vertical' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'mail_subject', $mail->subject, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'mail_body', $mail->content ?: '', TRUE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => $autoSaveKey, 'tags' => $tags, 'attachIds' => $mail->id ? array( $mail->id, NULL, 'bulkmail' ) : NULL ) ) );
|
||||
$form->addTab( 'bulkmail__main', NULL, NULL, 'ipsForm--vertical ipsForm--bulk-mail' );
|
||||
$form->add( new Text( 'mail_subject', $mail->subject, TRUE ) );
|
||||
$form->add( new Editor( 'mail_body', $mail->content ?: '', TRUE, array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => $autoSaveKey, 'tags' => $tags, 'attachIds' => $mail->id ? array( $mail->id, NULL, 'bulkmail' ) : NULL ) ) );
|
||||
|
||||
/* Add the filters tab and the "generic filters" header */
|
||||
$form->addTab( 'bulkmail__filters', NULL, NULL, 'ipsForm_horizontal' );
|
||||
$form->addTab( 'bulkmail__filters', NULL, NULL, 'ipsForm--horizontal' );
|
||||
$form->addHeader( 'generic_bm_filters' );
|
||||
|
||||
$lastApp = 'core';
|
||||
|
||||
/* Now grab bulk mail extensions */
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'MemberFilter', TRUE, 'core' ) as $key => $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'MemberFilter', TRUE, 'core' ) as $key => $extension )
|
||||
{
|
||||
if( method_exists( $extension, 'getSettingField' ) AND $extension->availableIn( 'bulkmail' ) )
|
||||
if( $extension->availableIn( 'bulkmail' ) )
|
||||
{
|
||||
/* See if we need a new form header - one per app */
|
||||
$_key = explode( '_', $key );
|
||||
@@ -449,9 +444,9 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
$_options = array();
|
||||
|
||||
/* Loop over bulk mail extensions to format the options */
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'MemberFilter', TRUE, 'core' ) as $key => $extension )
|
||||
foreach ( Application::allExtensions( 'core', 'MemberFilter', TRUE, 'core' ) as $key => $extension )
|
||||
{
|
||||
if( method_exists( $extension, 'save' ) AND $extension->availableIn( 'bulkmail' ) )
|
||||
if( $extension->availableIn( 'bulkmail' ) )
|
||||
{
|
||||
/* Grab our fields and add to the form */
|
||||
$_value = $extension->save( $values );
|
||||
@@ -469,24 +464,24 @@ class _bulkmail extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$mail->save();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__bulkmail_edited', array( $mail->subject => FALSE ) );
|
||||
Session::i()->log( 'acplogs__bulkmail_edited', array( $mail->subject => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$mail->save();
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__bulkmail_added', array( $mail->subject => FALSE ) );
|
||||
Session::i()->log( 'acplogs__bulkmail_added', array( $mail->subject => FALSE ) );
|
||||
}
|
||||
|
||||
/* Claim attachments */
|
||||
\IPS\File::claimAttachments( $autoSaveKey, $mail->id, NULL, 'bulkmail' );
|
||||
File::claimAttachments( $autoSaveKey, $mail->id, NULL, 'bulkmail' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=preview&id=' . $mail->id ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=bulkmail&controller=bulkmail&do=preview&id=' . $mail->id ), 'saved' );
|
||||
}
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('mail_configuration');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->message( 'unsubscribed_users_mail', 'information' );
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global' )->block( 'mail_configuration', $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('mail_configuration');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->message( 'unsubscribed_users_mail', 'information' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global' )->block( 'mail_configuration', $form );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user