/**
  * @see sfFilter
  */
 public function execute($filterChain)
 {
     $cookieName = sfConfig::get('app_sf_guard_plugin_remember_cookie_name', 'sfRemember');
     if ($this->isFirstCall() && $this->context->getUser()->isAnonymous() && ($cookie = $this->context->getRequest()->getCookie($cookieName))) {
         $criteria = new Criteria();
         $criteria->add(sfGuardRememberKeyPeer::REMEMBER_KEY, $cookie);
         if ($rk = sfGuardRememberKeyPeer::doSelectOne($criteria)) {
             $smintUserId = $this->context->getRequest()->getCookie('sfSmintUserId');
             $currentSmintUser = SmintUserPeer::retrieveByPK($smintUserId);
             if (!is_null($currentSmintUser)) {
                 // add smint user info to session
                 $this->context->getUser()->setAttribute('userid', $currentSmintUser->getId());
                 $this->context->getUser()->setAttribute('username', $currentSmintUser->getUsername());
                 $this->context->getUser()->setAttribute('name', $currentSmintUser->getName());
                 $this->context->getUser()->setAttribute('email', $currentSmintUser->getEmail());
                 $this->context->getUser()->setAttribute('organization', $currentSmintUser->getOrganization());
                 $this->context->getUser()->setAttribute('ip', $this->context->getRequest()->getHttpHeader('addr', 'remote'));
                 // log user login
                 UserLoginsPeer::login();
                 // sfGuard login check
                 $this->context->getUser()->signIn($rk->getsfGuardUser());
             }
         }
     }
     $filterChain->execute();
 }
Example #2
0
 /**
  * Retrieve a single object by unique constraint fields.
  *
  * @param      string $username
  * @param      string $name
  * @param      string $email
  * @param      string $organization
  * @param      PropelPDO $con the connection to use
  * @return     SmintUser
  */
 public static function retrieveByUniqueColumnValues($username, $name, $email, $organization, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(SmintUserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(SmintUserPeer::DATABASE_NAME);
     $criteria->add(SmintUserPeer::USERNAME, $username);
     $criteria->add(SmintUserPeer::NAME, $name);
     $criteria->add(SmintUserPeer::EMAIL, $email);
     $criteria->add(SmintUserPeer::ORGANIZATION, $organization);
     $v = SmintUserPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
 protected function doClean($values)
 {
     $username = isset($values['username']) ? $values['username'] : '';
     $name = isset($values['name']) ? $values['name'] : '';
     $email = isset($values['email']) ? $values['email'] : '';
     $organization = isset($values['organization']) ? $values['organization'] : '';
     $reuse = isset($values['reuse']) && $values['reuse'] == 1 ? true : false;
     $newuser = $user = sfContext::getInstance()->getUser()->getAttribute('newuser');
     $newuser = is_null($newuser) ? false : true;
     if (!$newuser) {
         $existingUser = SmintUserPeer::retrieveByUniqueColumnValues($username, $name, $email, $organization);
     }
     $confirmExisting = mysfConfig::get('app_login_settings_confirm_existing_users', true);
     // if the user exists show warning/question to reuse user
     if (!$newuser && !$reuse && isset($existingUser) && $confirmExisting) {
         throw new sfValidatorErrorSchema($this, array('reuse' => new sfValidatorError($this, 'user already exists !!! change name / email / organization or activate option to reuse the same user.'), 'name' => new sfValidatorError($this, ''), 'email' => new sfValidatorError($this, ''), 'organization' => new sfValidatorError($this, '')));
     } else {
         // check username/password
         return parent::doClean($values);
     }
     // $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
     // $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
     // $remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : '';
     //
     // // user exists?
     // if ($user = sfGuardUserPeer::retrieveByUsername($username))
     // {
     //   // password is ok?
     //   if ($user->checkPassword($password))
     //   {
     //     return array_merge($values, array('user' => $user));
     //   }
     // }
     //
     // if ($this->getOption('throw_global_error'))
     // {
     //   throw new sfValidatorError($this, 'invalid');
     // }
     //
     // throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
 }
Example #4
0
 /**
  * Get the associated SmintUser object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     SmintUser The associated SmintUser object.
  * @throws     PropelException
  */
 public function getSmintUser(PropelPDO $con = null)
 {
     if ($this->aSmintUser === null && $this->smint_user_id !== null) {
         $this->aSmintUser = SmintUserPeer::retrieveByPk($this->smint_user_id);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aSmintUser->addUserLoginss($this);
         		 */
     }
     return $this->aSmintUser;
 }
Example #5
0
 /**
  * Selects a collection of GeneralComment objects pre-filled with all related objects.
  *
  * @param      Criteria  $criteria
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of GeneralComment objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     $criteria = clone $criteria;
     // Set the correct dbName if it has not been overridden
     if ($criteria->getDbName() == Propel::getDefaultDB()) {
         $criteria->setDbName(self::DATABASE_NAME);
     }
     GeneralCommentPeer::addSelectColumns($criteria);
     $startcol2 = GeneralCommentPeer::NUM_COLUMNS - GeneralCommentPeer::NUM_LAZY_LOAD_COLUMNS;
     SmintUserPeer::addSelectColumns($criteria);
     $startcol3 = $startcol2 + (SmintUserPeer::NUM_COLUMNS - SmintUserPeer::NUM_LAZY_LOAD_COLUMNS);
     $criteria->addJoin(GeneralCommentPeer::SMINT_USER_ID, SmintUserPeer::ID, $join_behavior);
     // symfony_behaviors behavior
     foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) {
         call_user_func($sf_hook, 'BaseGeneralCommentPeer', $criteria, $con);
     }
     $stmt = BasePeer::doSelect($criteria, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = GeneralCommentPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = GeneralCommentPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $cls = GeneralCommentPeer::getOMClass(false);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             GeneralCommentPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined SmintUser rows
         $key2 = SmintUserPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = SmintUserPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $cls = SmintUserPeer::getOMClass(false);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 SmintUserPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (GeneralComment) to the collection in $obj2 (SmintUser)
             $obj2->addGeneralComment($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Example #6
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = SmintUserPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setSfGuardUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setUsername($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEmail($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setOrganization($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setRole($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setIndustry($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setValidate($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setCreatedAt($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setUpdatedAt($arr[$keys[10]]);
     }
 }
Example #7
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(SmintUserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(SmintUserPeer::DATABASE_NAME);
         $criteria->add(SmintUserPeer::ID, $pks, Criteria::IN);
         $objs = SmintUserPeer::doSelect($criteria, $con);
     }
     return $objs;
 }