Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
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;
 }