Pre subscriber add checks

@param Event $e
771056
public function preAdd(Event $e)
    {
        $form = $e->getParam('form');
        /* @var $inputFilter \UthandoUser\InputFilter\UserInputFilter */
        $inputFilter = $form->getInputFilter();
        $inputFilter->addEmailNoRecordExists();
    }
994839
private void addEPStatementListener(UpdateListener listener) {
		if (this.subscriber == null) {
			if (epStatement != null) {
				epStatement.addListener(listener);
			}
		}
	}
164245
public function setExceptionMessages(Exception $e)
    {
        $this->flashMessenger()->addErrorMessage([
            'message' => $e->getMessage(),
            'title' => 'Error!'
        ]);

        $prevException = $e->getPrevious();

        if ($prevException) {
            while ($prevException) {
                $this->flashMessenger()->addErrorMessage($prevException->getMessage());
                $prevException = $prevException->getPrevious();
            }
        }
    }
546040
public function add($e)
    {
        $this->exceptions[] = $e;
        if ($this->message) {
            $this->message .= "\n";
        }

        $this->message .= $this->getExceptionMessage($e, 0);

        return $this;
    }
625476
public function beforeFilter(\Cake\Event\Event $event)
    {
        // notifications for index-action have to be loaded here because of the loaded count of unread notifications.
        $this->set('notifications', $this->Notifier->getNotifications());
        $this->Notifier->markAsRead();

        parent::beforeFilter($event);
    }
713723
public function handleExcludeAnnotation($e)
    {
        $annotation = $e->getParam('annotation');
        if (!$annotation instanceof Annotation\Exclude) {
            return;
        }
    
        $spec = $e->getParam($this->getEventParamName());
        $spec['exclude'] = $annotation->getExclude();
    }
60729
public function onPending(SubscriberEvent $event)
    {
        $this->listRepository->pending(
            $event->getListId(),
            $event->getSubscriber()
        );
    }
1205514
protected function beforeValidate($event)
    {
        if ($this->autoSave) {
            $this->owner->{$this->uploadAttribute} = $this->getUploadedFile();
        }
    }
25942
public function addSubscription( $email, $user, $contentID, $languageID, $subscriptionType, $currentTime, $activate = true )
    {
        //1. insert into subscriber
        $ezcommentsINI = eZINI::instance( 'ezcomments.ini' );
        $subscriber = ezcomSubscriber::fetchByEmail( $email );
        //if there is no data in subscriber for same email, save it
        if ( is_null( $subscriber ) )
        {
            $subscriber = ezcomSubscriber::create();
            $subscriber->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
            $subscriber->setAttribute( 'email', $email );
            if ( $user->isAnonymous() )
            {
                $util = ezcomUtility::instance();
                $hashString = $util->generateSusbcriberHashString( $subscriber );
                $subscriber->setAttribute( 'hash_string', $hashString );
            }
            $subscriber->store();
            eZDebugSetting::writeNotice( 'extension-ezcomments', 'Subscriber does not exist, added one', __METHOD__ );
            $subscriber = ezcomSubscriber::fetchByEmail( $email );
        }
        else
        {
            if ( $subscriber->attribute( 'enabled' ) == false )
            {
                throw new Exception('Subscription can not be added because the subscriber is disabled.', self::ERROR_SUBSCRIBER_DISABLED );
            }
        }
        //3 insert into subscription table
        // if there is no data in ezcomment_subscription with given contentobject_id and subscriber_id
        $hasSubscription = ezcomSubscription::exists( $contentID,
                                                      $languageID,
                                                      $subscriptionType,
                                                      $email );
        if ( $hasSubscription === false )
        {
            $subscription = ezcomSubscription::create();
            $subscription->setAttribute( 'user_id', $user->attribute( 'contentobject_id' ) );
            $subscription->setAttribute( 'subscriber_id', $subscriber->attribute( 'id' ) );
            $subscription->setAttribute( 'subscription_type', $subscriptionType );
            $subscription->setAttribute( 'content_id', $contentID );
            $subscription->setAttribute( 'language_id', $languageID );
            $subscription->setAttribute( 'subscription_time', $currentTime );
            $defaultActivated = $ezcommentsINI->variable( 'CommentSettings', 'SubscriptionActivated' );

            if ( $user->isAnonymous() && $defaultActivated !== 'true' && $activate === true )
            {
                $subscription->setAttribute( 'enabled', 0 );
                $utility = ezcomUtility::instance();
                $subscription->setAttribute( 'hash_string', $utility->generateSubscriptionHashString( $subscription ) );
                $subscription->store();

                $result = ezcomSubscriptionManager::sendActivationEmail( eZContentObject::fetch( $contentID ),
                                                                         $subscriber,
                                                                         $subscription );
                if ( !$result )
                {
                    eZDebug::writeError( "Error sending mail to '$email'", __METHOD__ );
                }
            }
            else
            {
                $subscription->setAttribute( 'enabled', 1 );
                $subscription->store();
            }
            eZDebugSetting::writeNotice( 'extension-ezcomments', 'No existing subscription for this content and user, added one', __METHOD__ );
        }
    }
1001099
public function addException($e)
    {
        if ($e instanceof \Exception) {
            try {
                $this->bar->getCollector('exceptions')->addException($e);
            } catch (\Exception $ie) {
            } // mute exceptions there
        }
    }
641891
public function beforeValidationOnUpdate(Event $event, Model $model)
    {
        if($model instanceof ITimestampable) {
            $now = $this->getNow();
            $model->setUpdatedAt($now);
        }
    }
1316273
function(e){
      $('#ep_email_form_popup').submit(function(){
        sendEmailToServer('ep_email_form_popup');
        return false;
      });

      // Prepare subscription before submit form
      $('#ep_email_form_popup [name=ep_email_subscribe]').on('click', function(e) {
        $('#ep_email_form_popup [name=ep_email_option]').val('subscribe');
        checkAndSend(e);
      });

      // Prepare unsubscription before submit form
      $('#ep_email_form_popup [name=ep_email_unsubscribe]').on('click', function(e) {
        $('#ep_email_form_popup [name=ep_email_option]').val('unsubscribe');
        checkAndSend(e);
      });

      if (optionsAlreadyRecovered == false) {
        getDataForUserId('ep_email_form_popup');
      } else {
        // Get datas from form in mysettings menu
        $('#ep_email_form_popup [name=ep_email]').val($('#ep_email_form_mysettings [name=ep_email]').val());
        $('#ep_email_form_popup [name=ep_email_onStart]').prop('checked', $('#ep_email_form_mysettings [name=ep_email_onStart]').prop('checked'));
        $('#ep_email_form_popup [name=ep_email_onEnd]').prop('checked', $('#ep_email_form_mysettings [name=ep_email_onEnd]').prop('checked'));
      }
    }
1149625
public function addThrowable($e)
    {
        if ($this->hasCollector('exceptions')) {
            /** @var \DebugBar\DataCollector\ExceptionsCollector $collector */
            $collector = $this->getCollector('exceptions');
            $collector->addThrowable($e);
        }
    }
1092993
public function subscribe($event, $listener, $priority = ListenerAcceptorInterface::P_NORMAL)
    {
        $this->addListener($event, $listener, $priority);
    }
531968
public function beforeUpdate($event)
    {
        $fields = $this->fields;
        $nowDate = gmdate($this->databaseTimeFormat);
        if (!$this->isActuallyDirty()) {
            return;
        }

        if (isset($this->fields['modifiedField']) && !$this->owner->isAttributeChanged($this->fields['modifiedField'])) {
            $this->owner->{$this->fields['modifiedField']} = $nowDate;
        }
        if (isset($this->fields['modifiedByField']) && !$this->owner->isAttributeChanged($this->fields['modifiedByField'])) {
            $this->owner->{$this->fields['modifiedByField']} = self::_getUserId();
        }
    }
410632
public function beforeInsert($event)
    {
        $fields = $this->fields;
        $nowDate = gmdate($this->databaseTimeFormat);
        if (!$this->isActuallyDirty()) {
            return;
        }

        if (isset($this->fields['createdField']) && !$this->owner->isAttributeChanged($this->fields['createdField'])) {
            $this->owner->{$this->fields['createdField']} = $nowDate;
        }
        if (isset($this->fields['createdByField']) && !$this->owner->isAttributeChanged($this->fields['createdByField'])) {
            $this->owner->{$this->fields['createdByField']} = self::_getUserId();
        }

        if (isset($this->fields['modifiedField']) && !$this->owner->isAttributeChanged($this->fields['modifiedField'])) {
            $this->owner->{$this->fields['modifiedField']} = $nowDate;
        }
        if (isset($this->fields['modifiedByField']) && !$this->owner->isAttributeChanged($this->fields['modifiedByField'])) {
            $this->owner->{$this->fields['modifiedByField']} = self::_getUserId();
        }
    }
622390
public function beforeFilter(Event $event)
    {
        parent::beforeFilter($event);
        $this->Crud->addListener('Users.Users', ['mailer' => 'Users.User']);
        $this->Crud->mapAction('signup', [
            'className' => 'CrudUsers.Register',
            'view' => 'Users.signup',
            'saveOptions' => [
                'fieldList' => ['username', 'email', 'password']
            ],
            'messages' => [
                'success' => [
                    'text' => __('Please check your e-mail to validate your account')
                ],
                'error' => [
                    'text' => __('An error occurred while creating the account')
                ]
            ],
        ]);

        $this->Crud->mapAction('signin', [
            'className' => 'CrudUsers.Login',
            'view' => 'Users.signin',
            'messages' => [
                'success' => [
                    'text' => __('Login successful. Please validate your email address.')
                ],
                'error' => [
                    'text' => __('Your username or password is incorrect.')
                ]
            ],
        ]);

        $this->Crud->mapAction('signout', [
            'className' => 'CrudUsers.Logout',
            'messages' => [
                'success' => [
                    'text' => __('You are now signed out.')
                ],
            ],
        ]);

        $this->Crud->mapAction('sendRecovery', [
            'className' => 'CrudUsers.ForgotPassword',
        ]);

        $this->Crud->mapAction('changePassword', [
            'className' => 'CrudUsers.ResetPassword',
            'findMethod' => 'token',
        ]);

        $this->Crud->mapAction('verify', [
            'className' => 'CrudUsers.Verify',
            'findMethod' => 'token',
        ]);
    }