comments-bundle/src/Resources/contao/classes/Comments.php
public static function changeSubscriptionStatus(FrontendTemplate $objTemplate)
	{
		if (strncmp(Input::get('token'), 'com-', 4) === 0)
		{
			/** @var OptIn $optIn */
			$optIn = System::getContainer()->get('contao.opt-in');

			// Find an unconfirmed token with only one related record
			if ((!$optInToken = $optIn->find(Input::get('token'))) || !$optInToken->isValid() || \count($arrRelated = $optInToken->getRelatedRecords()) != 1 || key($arrRelated) != 'tl_comments_notify' || \count($arrIds = current($arrRelated)) != 1 || (!$objNotify = CommentsNotifyModel::findByPk($arrIds[0])))
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['invalidToken'];

				return;
			}

			if ($optInToken->isConfirmed())
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['tokenConfirmed'];

				return;
			}

			if ($optInToken->getEmail() != $objNotify->email)
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['tokenEmailMismatch'];

				return;
			}

			$objNotify->active = '1';
			$objNotify->save();

			$optInToken->confirm();

			$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_optInConfirm'];
		}
		elseif (strncmp(Input::get('token'), 'cor-', 4) === 0)
		{
			$objNotify = CommentsNotifyModel::findOneByTokenRemove(Input::get('token'));

			if ($objNotify === null)
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['invalidToken'];

				return;
			}

			$objNotify->delete();
			$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_optInCancel'];
		}
	}
public static function changeSubscriptionStatus(FrontendTemplate $objTemplate)
	{
		if (strncmp(Input::get('token'), 'com-', 4) === 0)
		{
			/** @var OptIn $optIn */
			$optIn = System::getContainer()->get('contao.opt-in');

			// Find an unconfirmed token with only one related record
			if ((!$optInToken = $optIn->find(Input::get('token'))) || !$optInToken->isValid() || \count($arrRelated = $optInToken->getRelatedRecords()) != 1 || key($arrRelated) != 'tl_comments_notify' || \count($arrIds = current($arrRelated)) != 1 || (!$objNotify = CommentsNotifyModel::findByPk($arrIds[0])))
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['invalidToken'];

				return;
			}

			if ($optInToken->isConfirmed())
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['tokenConfirmed'];

				return;
			}

			if ($optInToken->getEmail() != $objNotify->email)
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['tokenEmailMismatch'];

				return;
			}

			$objNotify->active = '1';
			$objNotify->save();

			$optInToken->confirm();

			$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_optInConfirm'];
		}
		elseif (strncmp(Input::get('token'), 'cor-', 4) === 0)
		{
			$objNotify = CommentsNotifyModel::findOneByTokenRemove(Input::get('token'));

			if ($objNotify === null)
			{
				$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['invalidToken'];

				return;
			}

			$objNotify->delete();
			$objTemplate->confirm = $GLOBALS['TL_LANG']['MSC']['com_optInCancel'];
		}
	}
public static function changeSubscriptionStatus ( FrontendTemplate $ objTemplate ) { if ( strncmp ( Input :: get ( 'token' ) , 'com-' , 4 ) === 0 ) { /** @var OptIn $optIn */ $ optIn = System :: getContainer ( ) -> get ( 'contao.opt-in' ) ; // Find an unconfirmed token with only one related record if ( ( ! $ optInToken = $ optIn -> find ( Input :: get ( 'token' ) ) ) || ! $ optInToken -> isValid ( ) || \ count ( $ arrRelated = $ optInToken -> getRelatedRecords ( ) ) != 1 || key ( $ arrRelated ) != 'tl_comments_notify' || \ count ( $ arrIds = current ( $ arrRelated ) ) != 1 || ( ! $ objNotify = CommentsNotifyModel :: findByPk ( $ arrIds [ 0 ] ) ) ) { $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'invalidToken' ] ; return ; } if ( $ optInToken -> isConfirmed ( ) ) { $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tokenConfirmed' ] ; return ; } if ( $ optInToken -> getEmail ( ) != $ objNotify -> email ) { $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'tokenEmailMismatch' ] ; return ; } $ objNotify -> active = '1' ; $ objNotify -> save ( ) ; $ optInToken -> confirm ( ) ; $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'com_optInConfirm' ] ; } elseif ( strncmp ( Input :: get ( 'token' ) , 'cor-' , 4 ) === 0 ) { $ objNotify = CommentsNotifyModel :: findOneByTokenRemove ( Input :: get ( 'token' ) ) ; if ( $ objNotify === null ) { $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'invalidToken' ] ; return ; } $ objNotify -> delete ( ) ; $ objTemplate -> confirm = $ GLOBALS [ 'TL_LANG' ] [ 'MSC' ] [ 'com_optInCancel' ] ; } }
Change the subscription status

@param FrontendTemplate $objTemplate
Change the subscription status