/** * Get the associated ChildMember object * * @param ConnectionInterface $con Optional Connection object. * @return ChildMember The associated ChildMember object. * @throws PropelException */ public function getMember(ConnectionInterface $con = null) { if ($this->aMember === null && $this->id_member !== null) { $this->aMember = ChildMemberQuery::create()->findPk($this->id_member, $con); /* 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->aMember->addUsers($this); */ } return $this->aMember; }
public function acceptMembershipApplication($id) { $app = MembershipApplicationQuery::create()->findPk($id); if ($app == NULL) { $this->addPopup("danger", "Žádost o členství se zadaným identifikačním číslem se v databázi nenachází."); redirectTo("/administrace/zadosti-o-clenstvi"); } if ($app->getState() != "pending") { $this->addPopup("danger", "Žádost o členství se zadaným identifikačním číslem již byla schválena nebo zamítnuta."); redirectTo("/administrace/zadosti-o-clenstvi"); } $app->setState('accepted'); $app->setAcceptedAt(time()); $app->save(); $token = token(30); $member = new Member(); $member->setName($app->getName()); $member->setSurname($token); $member->setMemberFrom($app->getCreatedAt()); $member->save(); $member_id = MemberQuery::create()->filterBySurname($token)->findOne(); $member_id->setSurname($app->getSurname()); $member_id->save(); $user = UserQuery::create()->findPk($app->getIdUser()); $user->setIdMember($member_id->getId()); if ($user->getPermissions() == 0) { $user->setPermissions(1); } $user->save(); $this->addPopup("success", "Žádost o členství byla úspěšně přijata. Uživateli byl vytvořen DofE účet."); redirectTo("/administrace/zadosti-o-clenstvi"); }