/**
  * Created a new record in EMAILS collection
  *
  * @return object $this
  */
 protected function createEmailRecord()
 {
     $coll = $this->Registry->Mongo->EMAILS;
     $coll->ensureIndex(array('email' => 1), array('unique' => true));
     $a = array('email' => $this->email, 'i_uid' => $this->Registry->Viewer->getUid(), 'has_gravatar' => \Lampcms\Gravatar::factory($this->email)->hasGravatar(), 'ehash' => hash('md5', $this->email), 'i_code_ts' => time(), 'code' => \substr(hash('md5', \uniqid(\mt_rand())), 0, 12));
     $this->oEmail = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS', $a);
     $res = $this->oEmail->save();
     d('$res: ' . $res);
     return $this;
 }
 public function setUp()
 {
     $this->Registry = new Registry();
     $this->oMongoDoc = \Lampcms\Mongo\Doc::factory($this->Registry, $this->COLLNAME);
 }
Beispiel #3
0
 /**
  * Create new record in EMAILS table for this new user
  * but only if user has provided email address
  *
  * @return object $this
  */
 protected function saveEmailAddress()
 {
     if (!empty($this->aFbUserData['email'])) {
         $coll = $this->Registry->Mongo->EMAILS;
         $coll->ensureIndex(array('email' => 1), array('unique' => true));
         $a = array('email' => \mb_strtolower($this->aFbUserData['email']), 'i_uid' => $this->User->getUid(), 'has_gravatar' => \Lampcms\Gravatar::factory($this->aFbUserData['email'])->hasGravatar(), 'ehash' => hash('md5', $this->aFbUserData['email']));
         try {
             $o = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS', $a)->insert();
         } catch (\Exception $e) {
             e('Unable to save email address from Facebook to our EMAILS: ' . $e->getMessage() . ' in ' . $e->getFile() . ' on ' . $e->getLine());
         }
     }
     return $this;
 }
 /**
  *
  * Create object representing email address
  * of current Viewer
  *
  * @throws \Lampcms\NoemailException if unable to find email address
  * of current Viewer
  *
  * @return object $this
  */
 protected function getEmailObject()
 {
     $this->email = strtolower($this->Registry->Viewer->email);
     if (empty($this->email)) {
         /**
          * @todo
          * Translate String
          */
         throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
     }
     try {
         $this->oEmail = \Lampcms\Mongo\Doc::factory($this->Registry, 'EMAILS')->byEmail($this->email);
         if ('' == $this->oEmail['email']) {
             /**
              * @todo
              * Translate String
              */
             throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
         }
     } catch (\MongoException $e) {
         /**
          * @todo
          * Translate String
          */
         throw new \Lampcms\NoemailException($this->_('You have not selected any email address for your account yet'));
     }
     return $this;
 }