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,50 +11,84 @@
|
||||
namespace IPS\core\modules\front\system;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function implode;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe
|
||||
*/
|
||||
class _unsubscribe extends \IPS\Dispatcher\Controller
|
||||
class unsubscribe extends Controller
|
||||
{
|
||||
/**
|
||||
* Unsubscribe the user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Prevent the email and secure key from being exposed in referrers */
|
||||
\IPS\Output::i()->sendHeader( "Referrer-Policy: origin" );
|
||||
Output::i()->sendHeader( "Referrer-Policy: origin" );
|
||||
|
||||
/* Get the member being requested */
|
||||
if( empty( \IPS\Request::i()->email ) )
|
||||
if( empty( Request::i()->email ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_user_to_unsubscribe', '2S127/3', 404, '' );
|
||||
Output::i()->error( 'no_user_to_unsubscribe', '2S127/3', 404, '' );
|
||||
}
|
||||
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->email, 'email' );
|
||||
$member = Member::load( Request::i()->email, 'email' );
|
||||
|
||||
if( !$member->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_user_to_unsubscribe', '2S127/2', 404, '' );
|
||||
Output::i()->error( 'no_user_to_unsubscribe', '2S127/2', 404, '' );
|
||||
}
|
||||
|
||||
/* Verify the key is correct */
|
||||
if ( \IPS\Login::compareHashes( md5( $member->email . ':' . $member->members_pass_hash ), (string) \IPS\Request::i()->key ) )
|
||||
if ( Login::compareHashes( md5( $member->email . ':' . $member->members_pass_hash ), (string) Request::i()->key ) )
|
||||
{
|
||||
$action = 'bulkEmail';
|
||||
if ( isset( \IPS\Request::i()->action ) and \IPS\Request::i()->action === 'markSolved' )
|
||||
if ( isset( Request::i()->action ) and Request::i()->action === 'markSolved' )
|
||||
{
|
||||
$action = 'markSolved';
|
||||
$member->members_bitoptions['no_solved_reenage'] = 1;
|
||||
$member->save();
|
||||
}
|
||||
elseif ( isset( Request::i()->action ) and Request::i()->action === 'expertNudge' )
|
||||
{
|
||||
$action = 'expertNudge';
|
||||
|
||||
/* Update the core_notification_preferences entry to remove email */
|
||||
try
|
||||
{
|
||||
$pref = Db::i()->select( '*', 'core_notification_preferences', array( "member_id=? and notification_key=?", $member->member_id, 'new_topics_to_review' ) )->first();
|
||||
$methods = explode( ',', $pref['preference'] );
|
||||
$methods = array_diff( $methods, array( 'email' ) );
|
||||
|
||||
Db::i()->update( 'core_notification_preferences', array( 'preference' => implode( ',', $methods ) ), array( "member_id=? and notification_key=?", $member->member_id, 'new_topics_to_review' ) );
|
||||
}
|
||||
catch( UnderflowException )
|
||||
{
|
||||
Db::i()->insert( 'core_notification_preferences', array(
|
||||
'member_id' => $member->member_id,
|
||||
'notification_key' => 'new_topics_to_review',
|
||||
'preference' => 'inline,push'
|
||||
), TRUE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the member not to receive future emails */
|
||||
@@ -66,14 +100,14 @@ class _unsubscribe extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* And then show them a confirmation screen */
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'system' )->unsubscribed( $action );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('unsubscribed');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'system' )->unsubscribed( $action );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('unsubscribed');
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Key did not match */
|
||||
\IPS\Output::i()->error( 'no_user_to_unsubscribe', '3S127/4', 403, '' );
|
||||
Output::i()->error( 'no_user_to_unsubscribe', '3S127/4', 403, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user