示例#1
0
 public function login()
 {
     $user = UserQuery::create()->joinWith("Image")->filterByUsername($_POST['inputUsername'])->filterByPassword(sha1($_POST['inputPassword']))->findOne();
     if ($user == NULL) {
         $_SESSION['user'] = NULL;
         $this->addPopup('danger', 'Zadali jste nesprávné přihlašovací údaje. Zkuste to prosím znovu.');
     } else {
         $bans = BanQuery::create()->filterByIdUser($user->getId())->find();
         foreach ($bans as $b) {
             if ($b->getEndingDate()->format("U") > time()) {
                 $this->addPopup('danger', 'Váš účet byl zablokován uživatelem ' . $b->getUserBy()->getUsername() . ' z důvodu: "' . $b->getReason() . '". Zákaz skončí ' . $b->getEndingDate()->format("d.m.Y") . ' ve ' . $b->getEndingDate()->format("H:i:s") . '.');
                 redirectTo('/');
             }
         }
         $_SESSION['user'] = $user;
         $user->signInUpdate();
         $this->addPopup('success', 'Byli jste úspěšně přihlášeni!');
         if ($user->getEmailConfirmedAt() == NULL) {
             $this->addPopup('warning', 'Vaše emailová adresa nebyla doposud ověřena. Nepřišel Vám potvrzovací email? <a href=/nastaveni/potvrzovaci-email class=alert-link>Nechte si jej zaslat znovu.</a>');
         }
     }
     redirectTo('/');
 }
示例#2
0
文件: User.php 项目: OneTimeCZ/DofE
 /**
  * Returns the number of related Ban objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      ConnectionInterface $con
  * @return int             Count of related Ban objects.
  * @throws PropelException
  */
 public function countBansRelatedByBannedBy(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
 {
     $partial = $this->collBansRelatedByBannedByPartial && !$this->isNew();
     if (null === $this->collBansRelatedByBannedBy || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collBansRelatedByBannedBy) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getBansRelatedByBannedBy());
         }
         $query = ChildBanQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByUserBy($this)->count($con);
     }
     return count($this->collBansRelatedByBannedBy);
 }