示例#1
0
 /**
  * Declares an association between this object and a User object.
  *
  * @param                  User $v
  * @return                 Watchlist The current object (for fluent API support)
  * @throws PropelException
  */
 public function setUser(User $v = null)
 {
     if ($v === null) {
         $this->setUserId(NULL);
     } else {
         $this->setUserId($v->getId());
     }
     $this->aUser = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the User object, it will not be re-added.
     if ($v !== null) {
         $v->addWatchlist($this);
     }
     return $this;
 }
示例#2
0
 /**
  * Filter the query by a related User object
  *
  * @param   User|PropelObjectCollection $user The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   WatchlistQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof User) {
         return $this->addUsingAlias(WatchlistPeer::USER_ID, $user->getId(), $comparison);
     } elseif ($user instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(WatchlistPeer::USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type User or PropelCollection');
     }
 }
示例#3
0
                     $error = "Password can't contain whitespaces";
                 } else {
                     if (!($password2 = $request->get('password2'))) {
                         $error = "Repeating your password is required";
                     } else {
                         if ($password != $password2) {
                             $error = "Please repeat your password";
                         }
                     }
                 }
             }
         }
     }
 }
 if (!$error) {
     $user = new User();
     $user->setUsername($username);
     $user->setEmail($email);
     // save encoded passwd
     $encoder = $app['security.encoder_factory']->getEncoder($user);
     $user->setPassword($encoder->encodePassword($password, $user->getSalt()));
     if ($user->validate()) {
         $user->save();
         // force login
         $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
         $app['security']->setToken($token);
         $response = $app->redirect($app['url_generator']->generate('homepage'));
         $response->headers->setCookie(new Cookie('logged_in', true));
         return $response;
     } else {
         foreach ($user->getValidationFailures() as $failure) {
示例#4
0
 /**
  * Validates all modified columns of given User object.
  * If parameter $columns is either a single column name or an array of column names
  * than only those columns are validated.
  *
  * NOTICE: This does not apply to primary or foreign keys for now.
  *
  * @param      User $obj The object to validate.
  * @param      mixed $cols Column name or array of column names.
  *
  * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
  */
 public static function doValidate($obj, $cols = null)
 {
     $columns = array();
     if ($cols) {
         $dbMap = Propel::getDatabaseMap(UserPeer::DATABASE_NAME);
         $tableMap = $dbMap->getTable(UserPeer::TABLE_NAME);
         if (!is_array($cols)) {
             $cols = array($cols);
         }
         foreach ($cols as $colName) {
             if ($tableMap->hasColumn($colName)) {
                 $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
                 $columns[$colName] = $obj->{$get}();
             }
         }
     } else {
         if ($obj->isNew() || $obj->isColumnModified(UserPeer::USERNAME)) {
             $columns[UserPeer::USERNAME] = $obj->getUsername();
         }
         if ($obj->isNew() || $obj->isColumnModified(UserPeer::EMAIL)) {
             $columns[UserPeer::EMAIL] = $obj->getEmail();
         }
     }
     return BasePeer::doValidate(UserPeer::DATABASE_NAME, UserPeer::TABLE_NAME, $columns);
 }
示例#5
0
 /**
  * Exclude object from result
  *
  * @param   User $user Object to remove from the list of results
  *
  * @return UserQuery The current query, for fluid interface
  */
 public function prune($user = null)
 {
     if ($user) {
         $this->addUsingAlias(UserPeer::ID, $user->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }