public function applyForMembership() { if ($_SESSION["user"]->getIdMember() != NULL) { $this->addPopup('danger', 'Nemůžete žádat o členství, protože již jste členem organizace.'); redirectTo('/nastaveni'); } $existing = MembershipApplicationQuery::create()->filterByIdUser($_SESSION["user"]->getId())->filterByState("pending")->find(); if (!$existing->isEmpty()) { $this->addPopup('danger', 'Nemůžete žádat o členství, protože jste již o členství zažádali.'); redirectTo('/nastaveni'); } $app = new MembershipApplication(); $app->setName(strip_tags($_POST["name"])); $app->setSurname(strip_tags($_POST["surname"])); $app->setIdUser($_SESSION["user"]->getId()); $app->setState("pending"); $app->save(); $this->addPopup("success", "Vaše žádost byla úspěšně odeslána."); redirectTo("/nastaveni"); }
/** * Returns the number of related MembershipApplication objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con * @return int Count of related MembershipApplication objects. * @throws PropelException */ public function countMembershipApplications(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collMembershipApplicationsPartial && !$this->isNew(); if (null === $this->collMembershipApplications || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collMembershipApplications) { return 0; } if ($partial && !$criteria) { return count($this->getMembershipApplications()); } $query = ChildMembershipApplicationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByUser($this)->count($con); } return count($this->collMembershipApplications); }
public function rejectMembershipApplication($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('rejected'); $app->save(); $this->addPopup("success", "Žádost o členství byla úspěšně zamítnuta."); redirectTo("/administrace/zadosti-o-clenstvi"); }