public function emailAddSendVerify($email_id, $iUserId = null)
    {
        //  Fetch the email and the user's group
        $oDb = Factory::service('Database');
        $oDb->select(
            [
                $this->tableEmailAlias . '.id',
                $this->tableEmailAlias . '.code',
                $this->tableEmailAlias . '.is_verified',
                $this->tableEmailAlias . '.user_id',
                $this->tableAlias . '.group_id',
            ]
        );

        if (is_numeric($email_id)) {
            $oDb->where($this->tableEmailAlias . '.id', $email_id);
        } else {
            $oDb->where($this->tableEmailAlias . '.email', $email_id);
        }

        if (!empty($iUserId)) {
            $oDb->where($this->tableEmailAlias . '.user_id', $iUserId);
        }

        $oDb->join(
            $this->table . ' ' . $this->tableAlias,
            $this->tableAlias . '.id = ' . $this->tableEmailAlias . '.user_id'
        );

        $oEmailRow = $oDb->get($this->tableEmail . ' ' . $this->tableEmailAlias)->row();

        if (!$oEmailRow) {
            $this->setError('Invalid Email.');
            return false;
        }

        if ($oEmailRow->is_verified) {
            $this->setError('Email is already verified.');
            return false;
        }

        // --------------------------------------------------------------------------

        $oEmailer                = Factory::service('Emailer', 'nails/module-email');
        $oEmail                  = new \stdClass();
        $oEmail->type            = 'verify_email_' . $oEmailRow->group_id;
        $oEmail->to_id           = $oEmailRow->user_id;
        $oEmail->data            = new \stdClass();
        $oEmail->data->verifyUrl = site_url('email/verify/' . $oEmailRow->user_id . '/' . $oEmailRow->code);

        if (!$oEmailer->send($oEmail, true)) {

            //  Failed to send using the group email, try using the generic email template
            $oEmail->type = 'verify_email';

            if (!$oEmailer->send($oEmail, true)) {
                //  Email failed to send, for now, do nothing.
                $this->setError('The verification email failed to send.');
                return false;
            }
        }

        return true;
    }
public function emailAddSendVerify($email_id, $iUserId = null)
    {
        //  Fetch the email and the user's group
        $oDb = Factory::service('Database');
        $oDb->select(
            [
                $this->tableEmailAlias . '.id',
                $this->tableEmailAlias . '.code',
                $this->tableEmailAlias . '.is_verified',
                $this->tableEmailAlias . '.user_id',
                $this->tableAlias . '.group_id',
            ]
        );

        if (is_numeric($email_id)) {
            $oDb->where($this->tableEmailAlias . '.id', $email_id);
        } else {
            $oDb->where($this->tableEmailAlias . '.email', $email_id);
        }

        if (!empty($iUserId)) {
            $oDb->where($this->tableEmailAlias . '.user_id', $iUserId);
        }

        $oDb->join(
            $this->table . ' ' . $this->tableAlias,
            $this->tableAlias . '.id = ' . $this->tableEmailAlias . '.user_id'
        );

        $oEmailRow = $oDb->get($this->tableEmail . ' ' . $this->tableEmailAlias)->row();

        if (!$oEmailRow) {
            $this->setError('Invalid Email.');
            return false;
        }

        if ($oEmailRow->is_verified) {
            $this->setError('Email is already verified.');
            return false;
        }

        // --------------------------------------------------------------------------

        $oEmailer                = Factory::service('Emailer', 'nails/module-email');
        $oEmail                  = new \stdClass();
        $oEmail->type            = 'verify_email_' . $oEmailRow->group_id;
        $oEmail->to_id           = $oEmailRow->user_id;
        $oEmail->data            = new \stdClass();
        $oEmail->data->verifyUrl = site_url('email/verify/' . $oEmailRow->user_id . '/' . $oEmailRow->code);

        if (!$oEmailer->send($oEmail, true)) {

            //  Failed to send using the group email, try using the generic email template
            $oEmail->type = 'verify_email';

            if (!$oEmailer->send($oEmail, true)) {
                //  Email failed to send, for now, do nothing.
                $this->setError('The verification email failed to send.');
                return false;
            }
        }

        return true;
    }
public function emailAddSendVerify ( $ email_id , $ iUserId = null ) { //  Fetch the email and the user's group $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( [ $ this -> tableEmailAlias . '.id' , $ this -> tableEmailAlias . '.code' , $ this -> tableEmailAlias . '.is_verified' , $ this -> tableEmailAlias . '.user_id' , $ this -> tableAlias . '.group_id' , ] ) ; if ( is_numeric ( $ email_id ) ) { $ oDb -> where ( $ this -> tableEmailAlias . '.id' , $ email_id ) ; } else { $ oDb -> where ( $ this -> tableEmailAlias . '.email' , $ email_id ) ; } if ( ! empty ( $ iUserId ) ) { $ oDb -> where ( $ this -> tableEmailAlias . '.user_id' , $ iUserId ) ; } $ oDb -> join ( $ this -> table . ' ' . $ this -> tableAlias , $ this -> tableAlias . '.id = ' . $ this -> tableEmailAlias . '.user_id' ) ; $ oEmailRow = $ oDb -> get ( $ this -> tableEmail . ' ' . $ this -> tableEmailAlias ) -> row ( ) ; if ( ! $ oEmailRow ) { $ this -> setError ( 'Invalid Email.' ) ; return false ; } if ( $ oEmailRow -> is_verified ) { $ this -> setError ( 'Email is already verified.' ) ; return false ; } // -------------------------------------------------------------------------- $ oEmailer = Factory :: service ( 'Emailer' , 'nails/module-email' ) ; $ oEmail = new \ stdClass ( ) ; $ oEmail -> type = 'verify_email_' . $ oEmailRow -> group_id ; $ oEmail -> to_id = $ oEmailRow -> user_id ; $ oEmail -> data = new \ stdClass ( ) ; $ oEmail -> data -> verifyUrl = site_url ( 'email/verify/' . $ oEmailRow -> user_id . '/' . $ oEmailRow -> code ) ; if ( ! $ oEmailer -> send ( $ oEmail , true ) ) { //  Failed to send using the group email, try using the generic email template $ oEmail -> type = 'verify_email' ; if ( ! $ oEmailer -> send ( $ oEmail , true ) ) { //  Email failed to send, for now, do nothing. $ this -> setError ( 'The verification email failed to send.' ) ; return false ; } } return true ; }
Send, or resend, the verify email for a particular email address

@param integer $email_id The email's ID
@param integer $iUserId  The user's ID

@return boolean
Send or resend the verify email for a particular email address