Beispiel #1
0
 /**
  * Filter the query by a related \Models\Ban object
  *
  * @param \Models\Ban|ObjectCollection $ban the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByBanRelatedByBannedBy($ban, $comparison = null)
 {
     if ($ban instanceof \Models\Ban) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $ban->getBannedBy(), $comparison);
     } elseif ($ban instanceof ObjectCollection) {
         return $this->useBanRelatedByBannedByQuery()->filterByPrimaryKeys($ban->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByBanRelatedByBannedBy() only accepts arguments of type \\Models\\Ban or Collection');
     }
 }
Beispiel #2
0
 /**
  * @param ChildBan $banRelatedByBannedBy The ChildBan object to add.
  */
 protected function doAddBanRelatedByBannedBy(ChildBan $banRelatedByBannedBy)
 {
     $this->collBansRelatedByBannedBy[] = $banRelatedByBannedBy;
     $banRelatedByBannedBy->setUserBy($this);
 }
Beispiel #3
0
 public function banUser($id)
 {
     if (!$this->isAdmin()) {
         $this->addPopup('danger', 'Pro zakázání přístupu nemáte dostatečná práva.');
         redirectTo('/administrace/nahlaseni-uzivatele');
     }
     $user = UserQuery::create()->findPk($id);
     if ($user == NULL) {
         $this->addPopup('danger', 'Uživatel se zadaným identifikačním číslem se v databázi nenachází.');
         redirectTo('/administrace/nahlaseni-uzivatele');
     }
     $ban = new Ban();
     $ban->setReason($_POST["reason"]);
     $ban->setIdUser($id);
     $end_date = new DateTime();
     $end_date->setTimestamp($end_date->format('U') + $_POST["length"]);
     $ban->setEndingDate($end_date->format('U'));
     $ban->setBannedBy($_SESSION["user"]->getId());
     $ban->save();
     $reports = UserReportQuery::create()->filterByIdUserReported($id)->find();
     foreach ($reports as $r) {
         $r->delete();
     }
     $this->addPopup('success', 'Uživateli ' . $user->getUsername() . ' byl úspěšně zakázán přístup.');
     redirectTo('/administrace/nahlaseni-uzivatele');
 }