Exemple #1
0
 /**
  * Add contact info fieldset
  *
  * @return void
  */
 private function _addContactInfoFieldset()
 {
     $this->addElement('text', 'firstName', array('filters' => array('HtmlEntities', 'StringTrim'), 'validators' => array(array('StringLength', false, array(2, 40))), 'required' => true, 'label' => 'First name:', 'value' => $this->_user->getProfile()->getFirstName()));
     $this->addElement('text', 'lastName', array('filters' => array('HtmlEntities', 'StringTrim'), 'validators' => array(array('StringLength', false, array(2, 40))), 'required' => true, 'label' => 'Last name:', 'value' => $this->_user->getProfile()->getLastName()));
     // @todo Need to confirm email: 2nd input field and send verification email
     $this->addElement('text', 'email', array('filters' => array('HtmlEntities', 'StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(1, 255)), 'EmailAddress'), 'required' => true, 'label' => 'Email address:', 'value' => $this->_user->getEmail()));
     $this->addElement('text', 'phone', array('filters' => array('HtmlEntities', 'StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', false, array(10, 20))), 'required' => false, 'label' => 'Phone number:', 'value' => $this->_user->getProfile()->getPhone()));
     $fields = $this->_addSocial();
     $fields = array_merge(array('firstName', 'lastName', 'email', 'phone', 'social1'), $fields);
     $this->addDisplayGroup($fields, 'contactInfo', array('legend' => 'Contact Information', 'decorators' => array('FormElements', array('HtmlTag', array('tag' => 'ol')), 'Fieldset')));
 }
Exemple #2
0
 /**
  * Set form field default values
  *
  * @param User $user
  * @return void
  */
 public function setDefaults(User $user)
 {
     $profile = $user->getProfile();
     parent::setDefaults(array('userId' => $user->getId(), 'username' => $user->getUsername(), 'role' => $user->getRole()->getId(), 'firstName' => $profile->getFirstName(), 'lastName' => $profile->getLastName(), 'email' => $user->getEmail(), 'phone' => $profile->getPhone(), 'active' => $user->getActive(), 'locked' => $user->getLocked()));
 }
Exemple #3
0
    /**
     * Send email address verification email to user
     *
     * @param User $user
     * @param Zend_Mail_Transport_Abstract $transport [Optional] Zend mail transport class
     * @return void
     */
    public static function sendVerificationEmail(User $user, Zend_Mail_Transport_Abstract $transport = null)
    {
        $serverUrlHelper = new Zend_View_Helper_ServerUrl();
        $urlHelper = HelperBroker::getStaticHelper('url');
        $siteDomain = preg_replace('/^https?:\\/\\//', '', $serverUrlHelper->serverUrl());
        $siteName = Zend_Registry::get('siteName');
        $config = Zend_Registry::get('config');
        $from = 'noreply@' . $siteDomain;
        if (!empty($config->mail) && !empty($config->mail->from)) {
            $from = $config->mail->from;
        }
        if (null === $transport) {
            if (Zend_Session::$_unitTestEnabled) {
                $transport = new MockMailTransport();
            } else {
                if (!empty($config->mail) && !empty($config->mail->smtp) && !empty($config->mail->smtp->host)) {
                    $options = $config->mail->smtp->toArray();
                    unset($options['host']);
                    $transport = new Zend_Mail_Transport_Smtp($config->mail->smtp->host, $options);
                }
            }
        }
        UserEmailVerificationService::collectGarbage();
        // @todo cronjob?; should also remove any unverified user accounts
        $verificationToken = sha1(mt_rand() . $user->getEmail() . mt_rand());
        if (APPLICATION_ENV === 'testing') {
            $verificationLink = $serverUrlHelper->serverUrl() . '/verifyEmail/' . $verificationToken;
        } else {
            // @codeCoverageIgnoreStart
            $verificationLink = $serverUrlHelper->serverUrl() . $urlHelper->url(array('token' => $verificationToken), 'verifyEmail');
        }
        // @codeCoverageIgnoreEnd
        UserEmailVerificationService::create(new UserEmailVerification(array('user' => $user, 'token' => $verificationToken, 'requestDate' => new DateTime())));
        $text = 'Hello ' . $user->getUsername() . ',
Thank you for registering with ' . $siteName . '. To activate your account and complete the registration process, please click the
 following link: ' . $verificationLink . '.

You are receiving this email because someone recently registered on our site and provided <' . $user->getEmail() . '> as their ema
il address. If you did not recently register at ' . $siteDomain . ', then please ignore this email. Your information will be remov
ed from our system within 24 hours.

Thank you,
The ' . $siteName . ' Team
';
        $html = '<p>Hello ' . $user->getUsername() . ',</p>
<p>Thank you for registering with ' . $siteName . '. To activate your account and complete the registration process, please click 
the following link: <a href="' . $verificationLink . '" title="Verify your email address">' . $verificationLink . '</a>.</p>

<p>You are receiving this email because someone recently registered on our site and provided &lt;' . $user->getEmail() . '&gt; as 
their email address. If you did not recently register at ' . $siteDomain . ', then please ignore this email. Your information will
 be removed from our system within 24 hours.</p>

<p>Thank you,<br>
The ' . $siteName . ' Team</p>
';
        try {
            Logger::info('Attempting to send email to \'' . $user->getEmail() . '\'.');
            $mail = new Zend_Mail('utf-8');
            $mail->setFrom($from, $siteName)->setSubject('[' . $siteName . '] Email Verification')->setBodyText($text)->setBodyHtml($html)->addTo($user->getEmail());
            $mail->send($transport);
        } catch (Exception $e) {
            Logger::crit($e->getMessage());
            throw $e;
        }
    }