/**
	 * Executes the action
	 *
	 * @param cbautoactionsActionTable $trigger
	 * @param UserTable                $user
	 * @param string                   $rawPassword
	 * @param array                    $vars
	 * @param array                    $extras
	 * @return mixed
	 */
	public function getAction( $trigger, $user, $rawPassword = null, $vars = array(), $extras = array() )
	{
		$cbUser				=	new CBuser();
		$cbUser->_cbuser	=	$user;

		$extras				=	array_merge( $extras, $this->getExtras( $vars ) );

		$vars['self']		=	$trigger;
		$vars['user']		=	$user;

		$trigger->set( '_cbuser', $cbUser );
		$trigger->set( '_password', ( $rawPassword ? $rawPassword : $user->get( 'password' ) ) );
		$trigger->set( '_extras', $extras );
		$trigger->set( '_vars', $vars );

		if ( $user->get( 'id' ) ) {
			$gids			=	Application::User( (int) $user->get( 'id' ) )->getAuthorisedGroups( false );

			array_unshift( $gids, -3 );

			if ( Application::User( (int) $user->get( 'id' ) )->isGlobalModerator() ) {
				array_unshift( $gids, -5 );
			} else {
				array_unshift( $gids, -4 );
			}
		} else {
			$gids			=	$user->get( 'gids', array() );

			array_unshift( $gids, -2 );
		}

		if ( $user->get( 'id' ) == Application::MyUser()->getUserId() ) {
			array_unshift( $gids, -7 );
		} else {
			array_unshift( $gids, -6 );
		}

		array_unshift( $gids, -1 );

		$trigger->set( '_gids', $gids );

		$access				=	explode( '|*|', $trigger->get( 'access' ) );

		if ( ! array_intersect( $access, $gids ) ) {
			if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
				var_dump( CBTxt::T( 'AUTO_ACTION_ACCESS_FAILED', ':: Action [action] :: Access check for [user_id] failed: looking for [access] in [groups]', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ), '[access]' => implode( ', ', $access ), '[groups]' => implode( ', ', $gids ) ) ) );
			}

			return null;
		}

		foreach ( $trigger->getConditions() as $i => $conditional ) {
			/** @var ParamsInterface $conditional */
			$condTranslate	=	$conditional->get( 'translate', 0, GetterInterface::BOOLEAN );
			$condField		=	$trigger->getSubstituteString( $conditional->get( 'field', null, GetterInterface::HTML ), true, $condTranslate );
			$condOperator	=	$conditional->get( 'operator', '0', GetterInterface::STRING );
			$condValue		=	$trigger->getSubstituteString( $conditional->get( 'value', null, GetterInterface::HTML ), true, $condTranslate );

			if ( ! cbautoactionsClass::getFieldMatch( $condField, $condOperator, $condValue, $vars ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_CONDITIONAL_FAILED', ':: Action [action] :: Conditional [cond] failed for [user_id]: [field] [operator] [value]', array( '[action]' => (int) $trigger->get( 'id' ), '[cond]' => ( $i + 1 ), '[user_id]' => (int) $user->get( 'id' ), '[field]' => cbautoactionsClass::formatCondition( $condField ), '[operator]' => cbautoactionsClass::getOperatorTitle( $condOperator ), '[value]' => cbautoactionsClass::formatCondition( $condValue ) ) ) );
				}

				return null;
			}
		}

		$excludeGlobal		=	explode( ',', $this->params->get( 'exclude', null, GetterInterface::STRING ) );
		$excludeTrigger		=	explode( ',', $trigger->getParams()->get( 'exclude', null, GetterInterface::STRING ) );
		$exclude			=	array_filter( array_merge( $excludeGlobal, $excludeTrigger ) );

		if ( $exclude ) {
			cbArrayToInts( $exclude );

			$exclude		=	array_unique( $exclude );

			if ( in_array( (int) $user->get( 'id' ), $exclude ) ) {
				if ( $trigger->getParams()->get( 'debug', false, GetterInterface::BOOLEAN ) ) {
					var_dump( CBTxt::T( 'AUTO_ACTION_USER_EXCLUDED', ':: Action [action] :: User [user_id] excluded', array( '[action]' => (int) $trigger->get( 'id' ), '[user_id]' => (int) $user->get( 'id' ) ) ) );
				}

				return null;
			}
		}

		return $trigger->call( 'execute', array( $user ) );
	}