Add ability to ban forever

This commit is contained in:
Alexander Burakovskiy 2016-05-04 13:14:10 +03:00
parent 0edc9657b4
commit 4d32e942a3
2 changed files with 3 additions and 3 deletions

View File

@ -243,7 +243,7 @@ class Ban
*/ */
public function isExpired() public function isExpired()
{ {
return ($this->till < time()); return ($this->till > 0 && $this->till < time());
} }
/** /**

View File

@ -129,7 +129,7 @@ class BanController extends AbstractController
$page['banId'] = $ban->id; $page['banId'] = $ban->id;
$page['formaddress'] = $ban->address; $page['formaddress'] = $ban->address;
$page['formdays'] = round(($ban->till - time()) / 86400); $page['formdays'] = $ban->till > 0 ? round(($ban->till - time()) / 86400) : 0;
$page['formcomment'] = $ban->comment; $page['formcomment'] = $ban->comment;
} elseif ($request->query->has('thread')) { } elseif ($request->query->has('thread')) {
// Prepopulate form using thread data // Prepopulate form using thread data
@ -231,7 +231,7 @@ class BanController extends AbstractController
throw new NotFoundException('The ban is not found.'); throw new NotFoundException('The ban is not found.');
} }
} }
$ban->till = time() + $days * 24 * 60 * 60; $ban->till = $days > 0 ? time() + $days * 24 * 60 * 60 : 0;
$ban->address = $address; $ban->address = $address;
$ban->comment = $comment; $ban->comment = $comment;
$ban->save(); $ban->save();