/**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeEveApi($this);
     }
     $this->id = null;
     $this->userid = null;
     $this->keyid = null;
     $this->vcode = null;
     $this->status = null;
     $this->lastcomputed = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * Filter the query by a related \ECP\User object
  *
  * @param \ECP\User|ObjectCollection $user The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildGroupPersonQuery The current query, for fluid interface
  */
 public function filterByUser($user, $comparison = null)
 {
     if ($user instanceof \ECP\User) {
         return $this->addUsingAlias(GroupPersonTableMap::COL_USERID, $user->getId(), $comparison);
     } elseif ($user instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(GroupPersonTableMap::COL_USERID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByUser() only accepts arguments of type \\ECP\\User or Collection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   ChildUser $user Object to remove from the list of results
  *
  * @return $this|ChildUserQuery The current query, for fluid interface
  */
 public function prune($user = null)
 {
     if ($user) {
         $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aGroup) {
         $this->aGroup->removeGroupPerson($this);
     }
     if (null !== $this->aGroupPersonType) {
         $this->aGroupPersonType->removeGroupPerson($this);
     }
     if (null !== $this->aGroupEvePerson) {
         $this->aGroupEvePerson->removeGroupPerson($this);
     }
     if (null !== $this->aUser) {
         $this->aUser->removeGroupPerson($this);
     }
     $this->id = null;
     $this->groupid = null;
     $this->grouppersontypeid = null;
     $this->groupevepersonid = null;
     $this->userid = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 public function __construct($app)
 {
     $this->app = $app;
     $app->group('/user', function () use($app) {
         $app->get('/autocomplete', function () {
             $userService = new \Core\Service\UserService();
             echo json_encode($userService->getAutocomplete($_GET['s']));
         });
         $app->get('/check', function () {
             $userAvailible = ECP\UserQuery::create()->filterByName($_GET['name'])->count() == 0;
             echo json_encode((object) array('isAvailible' => $userAvailible));
         });
         $app->get('/status', function () {
             $userService = new \Core\Service\UserService();
             $isLoggedIn = $userService->isLoggedIn();
             if (!$isLoggedIn) {
                 die(json_encode((object) array('isLoggedIn' => false)));
             }
             $user = $userService->getLoggedInUser();
             echo json_encode((object) array('isLoggedIn' => true, 'id' => $user->id, 'username' => $user->username));
         });
         $app->post('/login', function () {
             $p = getPost();
             $user = ECP\UserQuery::create()->filterByName($p->username)->filterByPassword(sha1($p->password))->filterByConfirmationCode('')->findOne();
             if (!$user) {
                 die(json_encode((object) array('status' => 'incorrect credentials')));
             }
             $_SESSION['ecp'] = (object) array('id' => $user->getId(), 'username' => $user->getName());
             echo $this->getBoolStatus(true);
         });
         $app->post('/register', function () {
             $userService = new \Core\Service\UserService();
             $p = getPost();
             if (strpos($p->username, '/') !== false) {
                 die_err('Slashes are not allowed in names!');
             }
             $code = generateCode();
             $user = new ECP\User();
             $user->setName($p->username);
             $user->setPassword(sha1($p->password));
             $user->setEmail($p->email);
             $user->setCreated(time());
             $user->setConfirmationCode($code);
             $user->save();
             $userService->sendRegistrationMail($user);
             echo $this->getBoolStatus(true);
         });
         $app->post('/logout', function () {
             unset($_SESSION['ecp']);
             echo '{}';
         });
         $app->post('/recover-password', function () {
             $userService = new \Core\Service\UserService();
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByEmail($p->email)->filterByConfirmationCode('')->find();
             foreach ($users as $user) {
                 $code = generateCode();
                 $user->setRecoverPasswordCode($code);
                 $user->save();
                 $userService->sendRecoverPassword($user);
             }
             echo $this->getBoolStatus(true);
         });
         $app->get('/reset-password-check', function () {
             $userCount = ECP\UserQuery::create()->filterByRecoverPasswordCode($_GET['code'])->count();
             echo $this->getBoolStatus($userCount != 0);
         });
         $app->post('/reset-password', function () {
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByRecoverPasswordCode($p->code)->find();
             $found = false;
             foreach ($users as $user) {
                 $user->setRecoverPasswordCode('');
                 $user->setPassword(sha1($p->password));
                 $user->save();
                 $found = true;
             }
             echo $this->getBoolStatus($found);
         });
         $app->post('/confirm-registration', function () {
             $p = getPost();
             $users = ECP\UserQuery::create()->filterByConfirmationCode($p->code)->find();
             $found = false;
             foreach ($users as $user) {
                 $user->setConfirmationCode('');
                 $user->save();
                 $found = true;
             }
             echo $this->getBoolStatus($found);
         });
     });
 }
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeCompositionEntity($this);
     }
     if (null !== $this->aCompositionEntityRelatedByForkedid) {
         $this->aCompositionEntityRelatedByForkedid->removeCompositionEntityRelatedById($this);
     }
     if (null !== $this->aRulesetEntity) {
         $this->aRulesetEntity->removeCompositionEntity($this);
     }
     $this->id = null;
     $this->name = null;
     $this->userid = null;
     $this->islisted = null;
     $this->forkedid = null;
     $this->rulesetentityid = null;
     $this->lastmodified = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeFittingRuleEntity($this);
     }
     if (null !== $this->aFittingRuleEntityRelatedByForkedid) {
         $this->aFittingRuleEntityRelatedByForkedid->removeFittingRuleEntityRelatedById($this);
     }
     $this->id = null;
     $this->name = null;
     $this->userid = null;
     $this->isglobal = null;
     $this->islisted = null;
     $this->forkedid = null;
     $this->isfiltertypeuptodate = null;
     $this->lastmodified = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }