Пример #1
0
 /**
  * Create record of new user
  *
  * @return \Lampcms\User object User object
  */
 protected function createUser()
 {
     $sid = false === ($sid = Cookie::getSidCookie()) ? String::makeSid() : $sid;
     if (false !== ($tzn = Cookie::get('tzn'))) {
         $timezone = $tzn;
     } else {
         $timezone = $this->Registry->Ini->SERVER_TIMEZONE;
     }
     $aUser = array();
     $aUser[Schema::EMAIL] = $this->email;
     $aUser[Schema::REPUTATION] = 1;
     $aUser[Schema::REGISTRATION_TIMESTAMP] = time();
     $aUser[Schema::REGISTRATION_TIME] = date('r');
     $aUser[Schema::FIRST_VISIT_TIMESTAMP] = false !== ($intFv = Cookie::getSidCookie(true)) ? $intFv : time();
     $aUser[Schema::SID] = $sid;
     $aUser['google_id'] = (string) $this->userInfo['id'];
     $aUser['google_token'] = $this->token;
     if (!empty($this->userInfo['given_name'])) {
         $aUser[Schema::FIRST_NAME] = $this->userInfo['given_name'];
     }
     if (!empty($this->userInfo['family_name'])) {
         $aUser[Schema::LAST_NAME] = $this->userInfo['family_name'];
     }
     if (!empty($this->userInfo['locale'])) {
         $aUser[Schema::LOCALE] = $this->userInfo['locale'];
     }
     if (!empty($this->userInfo['link'])) {
         $aUser[Schema::URL] = $this->userInfo['link'];
     }
     if (!empty($this->userInfo['gender'])) {
         $aUser[Schema::GENDER] = 'male' === $this->userInfo['gender'] ? 'M' : 'F';
     }
     if (!empty($this->userInfo['name'])) {
         $username = $this->userInfo['name'];
     } elseif (!empty($this->userInfo['family_name'])) {
         $username = !empty($this->userInfo['family_name']);
         if (!empty($this->userInfo['family_name'])) {
             $username = '******' . $this->userInfo['family_name'];
         }
     }
     $oEA = \Lampcms\ExternalAuth::factory($this->Registry);
     $username = $oEA->makeUsername($username);
     $aUser[Schema::USERNAME] = $username;
     $aUser[Schema::USERNAME_LOWERCASE] = \mb_strtolower($username);
     $aUser[Schema::ROLE] = Role::EXTERNAL_USER;
     $aUser[Schema::TIMEZONE] = $timezone;
     $aUser[Schema::EXTERNAL_AVATAR] = $this->userInfo['picture'] . '?sz=50';
     $aUser = \array_merge($this->Registry->Geo->Location->data, $aUser);
     d('creating new googlge aUser: '******'new user _id: ' . $User['_id']);
     \Lampcms\PostRegistration::createReferrerRecord($this->Registry, $User);
     try {
         $this->createEmailRecord($User['_id']);
     } catch (\Lampcms\DevException $e) {
         e('Unable to create email record: ' . $e->getMessage());
     }
     $this->addContacts($User->getUid());
     $this->Registry->Dispatcher->post($User, 'onNewUser');
     return $User;
 }
Пример #2
0
 /**
  * Create new record in the USERS collection
  * also set the $this->User to the newly created
  * instance of UserLinkedin object
  *
  *
  */
 protected function createNewUser()
 {
     d('$this->aData: ' . print_r($this->aData, 1));
     $ln = !empty($this->aData['ln']) ? $this->aData['ln'] : '';
     $oEA = \Lampcms\ExternalAuth::factory($this->Registry);
     $u = $this->aData['fn'] . '_' . $ln;
     d('$u: ' . $u);
     $username = $oEA->makeUsername($u);
     $sid = \Lampcms\Cookie::getSidCookie();
     d('sid is: ' . $sid);
     $this->aData['username'] = $username;
     $this->aData['username_lc'] = \mb_strtolower($username, 'utf-8');
     $this->aData['i_reg_ts'] = time();
     $this->aData['date_reg'] = date('r');
     $this->aData['role'] = 'external_auth';
     $this->aData['rs'] = false !== $sid ? $sid : \Lampcms\String::makeSid();
     $this->aData['i_rep'] = 1;
     $this->aData['lang'] = $this->Registry->getCurrentLang();
     $this->aData['locale'] = $this->Registry->Locale->getLocale();
     if (empty($this->aData['cc']) && empty($this->aData['city'])) {
         $this->aData = array_merge($this->Registry->Geo->Location->data, $this->aData);
     }
     $this->User = \Lampcms\UserLinkedin::factory($this->Registry, $this->aData);
     /**
      * This will mark this userobject is new user
      * and will be persistent for the duration of this session ONLY
      * This way we can know it's a newsly registered user
      * and ask the user to provide email address but only
      * during the same session
      */
     $this->User->setNewUser();
     d('isNewUser: '******'onNewUser');
     return $this;
 }
Пример #3
0
 /**
  * Create new record in the USERS collection
  * also set the $this->User to the newly created
  * instance of UserLinkedin object
  *
  *
  */
 protected function createNewUser()
 {
     d('creating new user');
     /**
      * Need to call /people/~/email-address to get email address
      * and /people/~ to get data that includes avatar among other things
      */
     if (false !== ($tzn = Cookie::get('tzn'))) {
         $timezone = $tzn;
     } else {
         $timezone = $this->Registry->Ini->SERVER_TIMEZONE;
     }
     $ln = !empty($this->aData['ln']) ? $this->aData['ln'] : '';
     $oEA = \Lampcms\ExternalAuth::factory($this->Registry);
     $u = $this->aData['fn'] . ' ' . $ln;
     d('$u: ' . $u);
     $username = $oEA->makeUsername($u);
     $sid = \Lampcms\Cookie::getSidCookie();
     d('sid is: ' . $sid);
     $this->aData[Schema::USERNAME] = $username;
     $this->aData[Schema::USERNAME_LOWERCASE] = \mb_strtolower($username, 'utf-8');
     $this->aData[Schema::REGISTRATION_TIMESTAMP] = time();
     $this->aData[Schema::REGISTRATION_TIME] = date('r');
     $this->aData[Schema::ROLE] = Role::EXTERNAL_USER;
     $this->aData[Schema::SID] = false !== $sid ? $sid : \Lampcms\String::makeSid();
     $this->aData[Schema::REPUTATION] = 1;
     $this->aData[Schema::LANG] = $this->Registry->getCurrentLang();
     $this->aData[Schema::LOCALE] = $this->Registry->Locale->getLocale();
     $this->aData[Schema::TIMEZONE] = $timezone;
     if (!empty($this->email)) {
         $this->aData[Schema::EMAIL] = $this->email;
     }
     if (empty($this->aData['cc']) && empty($this->aData['city'])) {
         $this->aData = array_merge($this->Registry->Geo->Location->data, $this->aData);
     }
     $this->User = \Lampcms\UserLinkedin::userFactory($this->Registry, $this->aData);
     /**
      * This will mark this user object is new user
      * and will be persistent for the duration of this session ONLY
      * This way we can know it's a newly registered user
      * and ask the user to provide email address but only
      * during the same session
      */
     $this->User->setNewUser();
     d('isNewUser: '******'onNewUser');
     return $this;
 }