Run php-cs-fixer on src
This commit is contained in:
@@ -27,9 +27,9 @@ use pvv\side\Agenda;
|
|||||||
$agenda = new Agenda([
|
$agenda = new Agenda([
|
||||||
// new \pvv\side\social\NerdepitsaActivity,
|
// new \pvv\side\social\NerdepitsaActivity,
|
||||||
// new \pvv\side\social\AnimekveldActivity,
|
// new \pvv\side\social\AnimekveldActivity,
|
||||||
new pvv\side\social\HackekveldActivity(),
|
new pvv\side\social\HackekveldActivity(),
|
||||||
new pvv\side\social\BrettspillActivity(),
|
new pvv\side\social\BrettspillActivity(),
|
||||||
new pvv\side\social\DriftkveldActivity(),
|
new pvv\side\social\DriftkveldActivity(),
|
||||||
new pvv\side\DBActivity($pdo),
|
new pvv\side\DBActivity($pdo),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\admin;
|
namespace pvv\admin;
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class UserManager {
|
class UserManager {
|
||||||
private PDO $pdo;
|
private \PDO $pdo;
|
||||||
|
|
||||||
public array $usergroups = [
|
public array $usergroups = [
|
||||||
'admin' => 1,
|
'admin' => 1,
|
||||||
@@ -15,7 +13,7 @@ class UserManager {
|
|||||||
'aktiviteter' => 4,
|
'aktiviteter' => 4,
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(PDO $pdo) {
|
public function __construct(\PDO $pdo) {
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use pvv\side\Event;
|
|
||||||
|
|
||||||
interface Activity {
|
interface Activity {
|
||||||
public function getNextEventFrom(\DateTimeImmutable $date): ?Event;
|
public function getNextEventFrom(\DateTimeImmutable $date): ?Event;
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use DateTime;
|
|
||||||
use DateTimeImmutable;
|
|
||||||
|
|
||||||
class Agenda {
|
class Agenda {
|
||||||
private array $activities;
|
private array $activities;
|
||||||
|
|
||||||
@@ -24,8 +21,8 @@ class Agenda {
|
|||||||
$this->activities = $activities;
|
$this->activities = $activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFormattedDate(DateTime $date): string {
|
public static function getFormattedDate(\DateTime $date): string {
|
||||||
return $date->format("l j. M H.i");
|
return $date->format('l j. M H.i');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,7 +71,7 @@ class Agenda {
|
|||||||
$result = [[], [], [], [], [], []];
|
$result = [[], [], [], [], [], []];
|
||||||
$events = $this->getEventsBetween(
|
$events = $this->getEventsBetween(
|
||||||
new \DateTimeImmutable()->setTime(0, 0),
|
new \DateTimeImmutable()->setTime(0, 0),
|
||||||
new \DateTimeImmutable()->setTime(23, 59)->add(new \DateInterval("P1M")),
|
new \DateTimeImmutable()->setTime(23, 59)->add(new \DateInterval('P1M')),
|
||||||
);
|
);
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
$index = self::NEXT_MONTH;
|
$index = self::NEXT_MONTH;
|
||||||
@@ -108,8 +105,8 @@ class Agenda {
|
|||||||
);
|
);
|
||||||
usort(
|
usort(
|
||||||
$result,
|
$result,
|
||||||
static fn($a, $b) => $a->getStart()->getTimeStamp() <
|
static fn($a, $b) => $a->getStart()->getTimeStamp()
|
||||||
$b->getStart()->getTimeStamp()
|
< $b->getStart()->getTimeStamp()
|
||||||
? -1
|
? -1
|
||||||
: 1,
|
: 1,
|
||||||
);
|
);
|
||||||
@@ -118,22 +115,22 @@ class Agenda {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function isToday(\DateTimeImmutable $date): bool {
|
public static function isToday(\DateTimeImmutable $date): bool {
|
||||||
return $date->format("dmY") == date("dmY");
|
return $date->format('dmY') === date('dmY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isTomorrow(\DateTimeImmutable $date): bool {
|
public static function isTomorrow(\DateTimeImmutable $date): bool {
|
||||||
return $date->sub(new \DateInterval("P1D"))->format("dmY") == date("dmY");
|
return $date->sub(new \DateInterval('P1D'))->format('dmY') === date('dmY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isThisWeek(\DateTimeImmutable $date): bool {
|
public static function isThisWeek(\DateTimeImmutable $date): bool {
|
||||||
return $date->format("WY") == date("WY");
|
return $date->format('WY') === date('WY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isNextWeek(\DateTimeImmutable $date): bool {
|
public static function isNextWeek(\DateTimeImmutable $date): bool {
|
||||||
return $date->sub(new \DateInterval("P7D"))->format("WY") == date("WY");
|
return $date->sub(new \DateInterval('P7D'))->format('WY') === date('WY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isThisMonth(\DateTimeImmutable $date): bool {
|
public static function isThisMonth(\DateTimeImmutable $date): bool {
|
||||||
return $date->format("mY") == date("mY");
|
return $date->format('mY') === date('mY');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class DBActivity implements Activity {
|
class DBActivity implements Activity {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
|
|
||||||
public function __construct(PDO $pdo) {
|
public function __construct(\PDO $pdo) {
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,20 +15,20 @@ class DBActivity implements Activity {
|
|||||||
* @return SimpleEvent[]
|
* @return SimpleEvent[]
|
||||||
*/
|
*/
|
||||||
public function getAllEvents(): array {
|
public function getAllEvents(): array {
|
||||||
$query = "SELECT * FROM events ORDER BY id DESC";
|
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$events = [];
|
$events = [];
|
||||||
foreach ($statement->fetchAll() as $dbEvent) {
|
foreach ($statement->fetchAll() as $dbEvent) {
|
||||||
$event = new SimpleEvent(
|
$event = new SimpleEvent(
|
||||||
$dbEvent["id"],
|
$dbEvent['id'],
|
||||||
$dbEvent["name"],
|
$dbEvent['name'],
|
||||||
\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $dbEvent["start"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||||
\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $dbEvent["stop"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||||
$dbEvent["organiser"],
|
$dbEvent['organiser'],
|
||||||
$dbEvent["location"],
|
$dbEvent['location'],
|
||||||
$dbEvent["description"],
|
$dbEvent['description'],
|
||||||
);
|
);
|
||||||
$events[] = $event;
|
$events[] = $event;
|
||||||
}
|
}
|
||||||
@@ -40,56 +37,57 @@ class DBActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getEventByID(int $id): SimpleEvent {
|
public function getEventByID(int $id): SimpleEvent {
|
||||||
$query = "SELECT * FROM events WHERE id=:id LIMIT 1";
|
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":id", $id, PDO::PARAM_INT);
|
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$dbEvent = $statement->fetch();
|
$dbEvent = $statement->fetch();
|
||||||
|
|
||||||
return new SimpleEvent(
|
return new SimpleEvent(
|
||||||
$dbEvent["id"],
|
$dbEvent['id'],
|
||||||
$dbEvent["name"],
|
$dbEvent['name'],
|
||||||
\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $dbEvent["start"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||||
\DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $dbEvent["stop"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||||
$dbEvent["organiser"],
|
$dbEvent['organiser'],
|
||||||
$dbEvent["location"],
|
$dbEvent['location'],
|
||||||
$dbEvent["description"],
|
$dbEvent['description'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(\DateTimeImmutable $date): ?Event {
|
public function getNextEventFrom(\DateTimeImmutable $date): ?Event {
|
||||||
$query =
|
$query
|
||||||
"SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1";
|
= 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||||
|
|
||||||
return $this->retrieve($date, $query);
|
return $this->retrieve($date, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreviousEventFrom(\DateTimeImmutable $date): ?Event {
|
public function getPreviousEventFrom(\DateTimeImmutable $date): ?Event {
|
||||||
$query =
|
$query
|
||||||
"SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1";
|
= 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||||
|
|
||||||
return $this->retrieve($date, $query);
|
return $this->retrieve($date, $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function retrieve(
|
private function retrieve(
|
||||||
DateTimeImmutable $date,
|
\DateTimeImmutable $date,
|
||||||
string $query,
|
string $query,
|
||||||
): ?SimpleEvent {
|
): ?SimpleEvent {
|
||||||
$stmt = $this->pdo->prepare($query);
|
$stmt = $this->pdo->prepare($query);
|
||||||
$stmt->execute(["date" => $date->format("Y-m-d H:i:s")]);
|
$stmt->execute(['date' => $date->format('Y-m-d H:i:s')]);
|
||||||
if ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
if ($result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
||||||
return new SimpleEvent(
|
return new SimpleEvent(
|
||||||
$result["id"],
|
$result['id'],
|
||||||
$result["name"],
|
$result['name'],
|
||||||
DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $result["start"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['start']),
|
||||||
DateTimeImmutable::createFromFormat("Y-m-d H:i:s", $result["stop"]),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $result['stop']),
|
||||||
$result["organiser"],
|
$result['organiser'],
|
||||||
$result["location"],
|
$result['location'],
|
||||||
$result["description"],
|
$result['description'],
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class Door {
|
class Door {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
|
|
||||||
@@ -18,15 +15,15 @@ class Door {
|
|||||||
* @return array{time: int, open: bool}[]
|
* @return array{time: int, open: bool}[]
|
||||||
*/
|
*/
|
||||||
public function getAll(): array {
|
public function getAll(): array {
|
||||||
$query = "SELECT time, open FROM door ORDER BY time DESC";
|
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$doorEvents = [];
|
$doorEvents = [];
|
||||||
foreach ($statement->fetchAll() as $row) {
|
foreach ($statement->fetchAll() as $row) {
|
||||||
$doorEvents[] = [
|
$doorEvents[] = [
|
||||||
"time" => (int) $row["time"],
|
'time' => (int) $row['time'],
|
||||||
"open" => (bool) $row["open"],
|
'open' => (bool) $row['open'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,18 +33,18 @@ class Door {
|
|||||||
/**
|
/**
|
||||||
* @return array{time: int, open: bool}[]
|
* @return array{time: int, open: bool}[]
|
||||||
*/
|
*/
|
||||||
public function getEntriesAfter(DateTimeImmutable $startTime): array {
|
public function getEntriesAfter(\DateTimeImmutable $startTime): array {
|
||||||
$query =
|
$query
|
||||||
"SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC";
|
= 'SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":startTime", $startTime, \PDO::PARAM_STR);
|
$statement->bindParam(':startTime', $startTime, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$doorEvents = [];
|
$doorEvents = [];
|
||||||
foreach ($statement->fetchAll() as $row) {
|
foreach ($statement->fetchAll() as $row) {
|
||||||
$doorEvents[] = [
|
$doorEvents[] = [
|
||||||
"time" => (int) $row["time"],
|
'time' => (int) $row['time'],
|
||||||
"open" => (bool) $row["open"],
|
'open' => (bool) $row['open'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,30 +55,30 @@ class Door {
|
|||||||
* @return array{time: int, open: bool}
|
* @return array{time: int, open: bool}
|
||||||
*/
|
*/
|
||||||
public function getCurrent(): array {
|
public function getCurrent(): array {
|
||||||
$query = "SELECT time, open FROM door ORDER BY time DESC LIMIT 1";
|
$query = 'SELECT time, open FROM door ORDER BY time DESC LIMIT 1';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
$row = $statement->fetch();
|
$row = $statement->fetch();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"time" => (int) $row["time"],
|
'time' => (int) $row['time'],
|
||||||
"open" => (bool) $row["open"],
|
'open' => (bool) $row['open'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function removeOld(): void {
|
private function removeOld(): void {
|
||||||
$firstValidTime = time() - 60 * 60 * 24 * 7; // One week before now
|
$firstValidTime = time() - 60 * 60 * 24 * 7; // One week before now
|
||||||
$query = "DELETE FROM door WHERE time < :firstValid";
|
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":firstValid", $firstValidTime, \PDO::PARAM_STR);
|
$statement->bindParam(':firstValid', $firstValidTime, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createEvent(DateTimeImmutable $time, bool $open): void {
|
public function createEvent(\DateTimeImmutable $time, bool $open): void {
|
||||||
$query = "INSERT INTO door(time, open) VALUES (:time, :open)";
|
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":time", $time, \PDO::PARAM_STR);
|
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
||||||
$statement->bindParam(":open", $open, \PDO::PARAM_STR);
|
$statement->bindParam(':open', $open, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$this->removeOld();
|
$this->removeOld();
|
||||||
|
|||||||
@@ -4,44 +4,41 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use DateInterval;
|
|
||||||
|
|
||||||
abstract class Event {
|
abstract class Event {
|
||||||
private DateTimeImmutable $start;
|
private \DateTimeImmutable $start;
|
||||||
|
|
||||||
public function __construct(DateTimeImmutable $start) {
|
public function __construct(\DateTimeImmutable $start) {
|
||||||
$this->start = $start;
|
$this->start = $start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart(): DateTimeImmutable {
|
public function getStart(): \DateTimeImmutable {
|
||||||
return $this->start;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRelativeDate(): string {
|
public function getRelativeDate(): string {
|
||||||
if (Agenda::isToday($this->getStart())) {
|
if (Agenda::isToday($this->getStart())) {
|
||||||
return "i dag";
|
return 'i dag';
|
||||||
}
|
}
|
||||||
if (Agenda::isTomorrow($this->getStart())) {
|
if (Agenda::isTomorrow($this->getStart())) {
|
||||||
return "i morgen";
|
return 'i morgen';
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
Agenda::isThisWeek($this->getStart()) ||
|
Agenda::isThisWeek($this->getStart())
|
||||||
$this->getStart()->sub(new DateInterval("P4D"))->getTimestamp() < time()
|
|| $this->getStart()->sub(new \DateInterval('P4D'))->getTimestamp() < time()
|
||||||
) {
|
) {
|
||||||
return $this->getStart()->format("l");
|
return $this->getStart()->format('l');
|
||||||
}
|
}
|
||||||
if (Agenda::isNextWeek($this->getStart())) {
|
if (Agenda::isNextWeek($this->getStart())) {
|
||||||
return "neste uke";
|
return 'neste uke';
|
||||||
}
|
}
|
||||||
if (Agenda::isThisMonth($this->getStart())) {
|
if (Agenda::isThisMonth($this->getStart())) {
|
||||||
return "denne måneden";
|
return 'denne måneden';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getStart()->format("j. F");
|
return $this->getStart()->format('j. F');
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public function getStop(): DateTimeImmutable;
|
abstract public function getStop(): \DateTimeImmutable;
|
||||||
|
|
||||||
abstract public function getName(): string;
|
abstract public function getName(): string;
|
||||||
|
|
||||||
@@ -53,7 +50,7 @@ abstract class Event {
|
|||||||
|
|
||||||
abstract public function getImageURL(): string;
|
abstract public function getImageURL(): string;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
abstract public function getDescription(): array;
|
abstract public function getDescription(): array;
|
||||||
|
|||||||
@@ -4,23 +4,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class MOTD {
|
class MOTD {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
public function __construct(PDO $pdo) {
|
|
||||||
|
public function __construct(\PDO $pdo) {
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMOTD(string $title, string $content): void {
|
public function setMOTD(string $title, string $content): void {
|
||||||
if (\is_array($content)) {
|
if (\is_array($content)) {
|
||||||
$content = implode("_", $content);
|
$content = implode('_', $content);
|
||||||
}
|
}
|
||||||
$query = "INSERT INTO motd(title, content) VALUES (:title, :content);";
|
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
|
|
||||||
$statement->bindParam(":title", $title, \PDO::PARAM_STR);
|
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
|
||||||
$statement->bindParam(":content", $content, \PDO::PARAM_STR);
|
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
|
||||||
|
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
}
|
}
|
||||||
@@ -29,28 +28,28 @@ class MOTD {
|
|||||||
* @return array{title: string, content: string[]}
|
* @return array{title: string, content: string[]}
|
||||||
*/
|
*/
|
||||||
public function getMOTD(): array {
|
public function getMOTD(): array {
|
||||||
$query =
|
$query
|
||||||
"SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1";
|
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$data = $statement->fetch();
|
$data = $statement->fetch();
|
||||||
|
|
||||||
return ["title" => $data[0], "content" => explode("\n", $data[1])];
|
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array{title: string, content: string[]}
|
* @return array{title: string, content: string[]}
|
||||||
*/
|
*/
|
||||||
public function getMOTD_history(int $limit = 5): array {
|
public function getMOTD_history(int $limit = 5): array {
|
||||||
$query =
|
$query
|
||||||
"SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit";
|
= 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT :limit';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":limit", $limit, \PDO::PARAM_STR);
|
$statement->bindParam(':limit', $limit, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$data = $statement->fetch();
|
$data = $statement->fetch();
|
||||||
|
|
||||||
return ["title" => $data[0], "content" => explode("\n", $data[1])];
|
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class ProjectManager {
|
class ProjectManager {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
|
|
||||||
@@ -17,17 +15,17 @@ class ProjectManager {
|
|||||||
* @return Project[]
|
* @return Project[]
|
||||||
*/
|
*/
|
||||||
public function getAll(): array {
|
public function getAll(): array {
|
||||||
$query = "SELECT * FROM projects ORDER BY id ASC";
|
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$projects = [];
|
$projects = [];
|
||||||
foreach ($statement->fetchAll() as $dbProj) {
|
foreach ($statement->fetchAll() as $dbProj) {
|
||||||
$project = new Project(
|
$project = new Project(
|
||||||
$dbProj["id"],
|
$dbProj['id'],
|
||||||
$dbProj["name"],
|
$dbProj['name'],
|
||||||
$dbProj["description"],
|
$dbProj['description'],
|
||||||
$dbProj["active"],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
$projects[] = $project;
|
$projects[] = $project;
|
||||||
}
|
}
|
||||||
@@ -36,9 +34,9 @@ class ProjectManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getByID(int $id): ?Project {
|
public function getByID(int $id): ?Project {
|
||||||
$query = "SELECT * FROM projects WHERE id=:id LIMIT 1";
|
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":id", $id, \PDO::PARAM_INT);
|
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$dbProj = $statement->fetch();
|
$dbProj = $statement->fetch();
|
||||||
@@ -47,10 +45,10 @@ class ProjectManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Project(
|
return new Project(
|
||||||
$dbProj["id"],
|
$dbProj['id'],
|
||||||
$dbProj["name"],
|
$dbProj['name'],
|
||||||
$dbProj["description"],
|
$dbProj['description'],
|
||||||
$dbProj["active"],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,27 +56,27 @@ class ProjectManager {
|
|||||||
* @return Project[]
|
* @return Project[]
|
||||||
*/
|
*/
|
||||||
public function getByOwner(string $uname): array {
|
public function getByOwner(string $uname): array {
|
||||||
$query = "SELECT projectid FROM projectmembers WHERE uname=:uname";
|
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":uname", $uname, \PDO::PARAM_STR);
|
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$projectIDs = $statement->fetchAll();
|
$projectIDs = $statement->fetchAll();
|
||||||
$projects = [];
|
$projects = [];
|
||||||
foreach ($projectIDs as $id) {
|
foreach ($projectIDs as $id) {
|
||||||
$id = $id["projectid"];
|
$id = $id['projectid'];
|
||||||
|
|
||||||
$query = "SELECT * FROM projects WHERE id=:id";
|
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":id", $id, \PDO::PARAM_INT);
|
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
foreach ($statement->fetchAll() as $dbProj) {
|
foreach ($statement->fetchAll() as $dbProj) {
|
||||||
$project = new Project(
|
$project = new Project(
|
||||||
$dbProj["id"],
|
$dbProj['id'],
|
||||||
$dbProj["name"],
|
$dbProj['name'],
|
||||||
$dbProj["description"],
|
$dbProj['description'],
|
||||||
$dbProj["active"],
|
$dbProj['active'],
|
||||||
);
|
);
|
||||||
$projects[] = $project;
|
$projects[] = $project;
|
||||||
}
|
}
|
||||||
@@ -91,20 +89,20 @@ class ProjectManager {
|
|||||||
* @return array<int,array>
|
* @return array<int,array>
|
||||||
*/
|
*/
|
||||||
public function getProjectMembers(int $id): array {
|
public function getProjectMembers(int $id): array {
|
||||||
$query = "SELECT * FROM projectmembers WHERE projectid=:id";
|
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":id", $id, \PDO::PARAM_STR);
|
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$members = [];
|
$members = [];
|
||||||
foreach ($statement->fetchAll() as $dbUsr) {
|
foreach ($statement->fetchAll() as $dbUsr) {
|
||||||
$members[] = [
|
$members[] = [
|
||||||
"name" => $dbUsr["name"],
|
'name' => $dbUsr['name'],
|
||||||
"uname" => $dbUsr["uname"],
|
'uname' => $dbUsr['uname'],
|
||||||
"mail" => $dbUsr["mail"],
|
'mail' => $dbUsr['mail'],
|
||||||
"role" => $dbUsr["role"],
|
'role' => $dbUsr['role'],
|
||||||
"lead" => $dbUsr["lead"],
|
'lead' => $dbUsr['lead'],
|
||||||
"owner" => $dbUsr["owner"],
|
'owner' => $dbUsr['owner'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,20 +113,20 @@ class ProjectManager {
|
|||||||
* @return array<string,mixed>
|
* @return array<string,mixed>
|
||||||
*/
|
*/
|
||||||
public function getProjectOwner(int $id): array {
|
public function getProjectOwner(int $id): array {
|
||||||
$query = "SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)";
|
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(":id", $id, \PDO::PARAM_STR);
|
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$dbOwner = $statement->fetch();
|
$dbOwner = $statement->fetch();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"name" => $dbOwner["name"],
|
'name' => $dbOwner['name'],
|
||||||
"uname" => $dbOwner["uname"],
|
'uname' => $dbOwner['uname'],
|
||||||
"mail" => $dbOwner["mail"],
|
'mail' => $dbOwner['mail'],
|
||||||
"role" => $dbOwner["role"],
|
'role' => $dbOwner['role'],
|
||||||
"lead" => $dbOwner["lead"],
|
'lead' => $dbOwner['lead'],
|
||||||
"owner" => $dbOwner["owner"],
|
'owner' => $dbOwner['owner'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
|
|
||||||
class SimpleEvent extends Event {
|
class SimpleEvent extends Event {
|
||||||
private int $id;
|
private int $id;
|
||||||
private string $name;
|
private string $name;
|
||||||
private array $descr;
|
private array $descr;
|
||||||
private DateTimeImmutable $start;
|
private \DateTimeImmutable $start;
|
||||||
private DateTimeImmutable $end;
|
private \DateTimeImmutable $end;
|
||||||
private string $org;
|
private string $org;
|
||||||
private string $loc;
|
private string $loc;
|
||||||
|
|
||||||
@@ -38,11 +36,11 @@ class SimpleEvent extends Event {
|
|||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart(): DateTimeImmutable {
|
public function getStart(): \DateTimeImmutable {
|
||||||
return $this->start;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStop(): DateTimeImmutable {
|
public function getStop(): \DateTimeImmutable {
|
||||||
return $this->end;
|
return $this->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,11 +57,11 @@ class SimpleEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getURL(): string {
|
public function getURL(): string {
|
||||||
return "/hendelser/info.php?id=" . $this->id;
|
return '/hendelser/info.php?id=' . $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL(): string {
|
public function getImageURL(): string {
|
||||||
return "/";
|
return '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription(): array {
|
public function getDescription(): array {
|
||||||
@@ -71,6 +69,6 @@ class SimpleEvent extends Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getColor(): string {
|
public function getColor(): string {
|
||||||
return "#3b7";
|
return '#3b7';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,39 +4,38 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
|
|
||||||
class AnimekveldActivity implements Activity {
|
class AnimekveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) > 20 ||
|
(int) $date->format('H') > 20
|
||||||
(intval($date->format("H")) === 19 && intval($date->format("i")) > 30)
|
|| ((int) $date->format('H') === 19 && (int) $date->format('i') > 30)
|
||||||
) {
|
) {
|
||||||
return $this->nextDate(
|
return $this->nextDate(
|
||||||
$date->add(new \DateInterval("P1D"))->setTime(19, 30, 0),
|
$date->add(new \DateInterval('P1D'))->setTime(19, 30, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 30, 0);
|
$date = $date->setTime(19, 30, 0);
|
||||||
if (intval($date->format("N")) !== 5) {
|
if ((int) $date->format('N') !== 5) {
|
||||||
return $this->nextDate($date->add(new \DateInterval("P1D")));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) < 19 ||
|
(int) $date->format('H') < 19
|
||||||
(intval($date->format("H")) === 20 && intval($date->format("i")) < 30)
|
|| ((int) $date->format('H') === 20 && (int) $date->format('i') < 30)
|
||||||
) {
|
) {
|
||||||
return $this->prevDate(
|
return $this->prevDate(
|
||||||
$date->sub(new \DateInterval("P1D"))->setTime(19, 30, 0),
|
$date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 30, 0);
|
$date = $date->setTime(19, 30, 0);
|
||||||
if (intval($date->format("N")) !== 5) {
|
if ((int) $date->format('N') !== 5) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval("P1D")));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
|
|||||||
@@ -4,46 +4,45 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
class AnimekveldEvent extends Event {
|
class AnimekveldEvent extends Event {
|
||||||
public function getStop(): DateTimeImmutable {
|
public function getStop(): \DateTimeImmutable {
|
||||||
return $this->getStart()->add(new \DateInterval("PT4H1800S"));
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return "Animekveld";
|
return 'Animekveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation(): string {
|
public function getLocation(): string {
|
||||||
/* : Location */
|
/* : Location */
|
||||||
return "Koserommet";
|
return 'Koserommet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser(): string {
|
public function getOrganiser(): string {
|
||||||
return "Christoffer Viken";
|
return 'Christoffer Viken';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL(): string {
|
public function getURL(): string {
|
||||||
return "/anime/";
|
return '/anime/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL(): string {
|
public function getImageURL(): string {
|
||||||
return "/sosiale/animekveld.jpg";
|
return '/sosiale/animekveld.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription(): array {
|
public function getDescription(): array {
|
||||||
return [
|
return [
|
||||||
"Er du glad i japanske tegneserier eller bare nysgjerrig på hva anime er?",
|
'Er du glad i japanske tegneserier eller bare nysgjerrig på hva anime er?',
|
||||||
"Bli med oss hver fredag, der vi finner frem de nyeste episodene for sesongen!",
|
'Bli med oss hver fredag, der vi finner frem de nyeste episodene for sesongen!',
|
||||||
"",
|
'',
|
||||||
"Alle kan være med på å anbefale eller veto serier.",
|
'Alle kan være med på å anbefale eller veto serier.',
|
||||||
"",
|
'',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor(): string {
|
public function getColor(): string {
|
||||||
return "#35a";
|
return '#35a';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,19 @@ use pvv\side\Activity;
|
|||||||
class BrettspillActivity implements Activity {
|
class BrettspillActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) > 17 ||
|
(int) $date->format('H') > 17
|
||||||
(intval($date->format("H")) === 16 && intval($date->format("i")) > 15)
|
|| ((int) $date->format('H') === 16 && (int) $date->format('i') > 15)
|
||||||
) {
|
) {
|
||||||
return $this->nextDate(
|
return $this->nextDate(
|
||||||
$date->add(new \DateInterval("P1D"))->setTime(16, 15, 0),
|
$date->add(new \DateInterval('P1D'))->setTime(16, 15, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if (intval($date->format("N")) !== 7) {
|
if ((int) $date->format('N') !== 7) {
|
||||||
return $this->nextDate($date->add(new \DateInterval("P1D")));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ((intval($date->format("W")) % 2) - 1) {
|
if (((int) $date->format('W') % 2) - 1) {
|
||||||
return $this->nextDate($date->add(new \DateInterval("P7D")));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
@@ -29,19 +29,19 @@ class BrettspillActivity implements Activity {
|
|||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) < 16 ||
|
(int) $date->format('H') < 16
|
||||||
(intval($date->format("H")) === 17 && intval($date->format("i")) < 15)
|
|| ((int) $date->format('H') === 17 && (int) $date->format('i') < 15)
|
||||||
) {
|
) {
|
||||||
return $this->prevDate(
|
return $this->prevDate(
|
||||||
$date->sub(new \DateInterval("P1D"))->setTime(16, 15, 0),
|
$date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if (intval($date->format("N")) !== 7) {
|
if ((int) $date->format('N') !== 7) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval("P1D")));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ((intval($date->format("W")) % 2) - 1) {
|
if (((int) $date->format('W') % 2) - 1) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval("P7D")));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
|
|||||||
@@ -4,62 +4,61 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
class BrettspillEvent extends Event {
|
class BrettspillEvent extends Event {
|
||||||
public function getStop(): DateTimeImmutable {
|
public function getStop(): \DateTimeImmutable {
|
||||||
return $this->getStart()->add(new \DateInterval("PT4H1800S"));
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string {
|
public function getName(): string {
|
||||||
return "Brettspillkveld";
|
return 'Brettspillkveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation(): string {
|
public function getLocation(): string {
|
||||||
return "Programvareverkstedet";
|
return 'Programvareverkstedet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser(): string {
|
public function getOrganiser(): string {
|
||||||
return "Programvareverkstedet";
|
return 'Programvareverkstedet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL(): string {
|
public function getURL(): string {
|
||||||
return "/brettspill/";
|
return '/brettspill/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL(): string {
|
public function getImageURL(): string {
|
||||||
return "/sosiale/brettspill.jpg";
|
return '/sosiale/brettspill.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription(): array {
|
public function getDescription(): array {
|
||||||
return [
|
return [
|
||||||
"Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? " .
|
'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? '
|
||||||
"Da er vår brettspillkveld noe for deg! " .
|
. 'Da er vår brettspillkveld noe for deg! '
|
||||||
"Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!",
|
. 'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!',
|
||||||
"",
|
'',
|
||||||
"## Vår samling",
|
'## Vår samling',
|
||||||
"",
|
'',
|
||||||
"* Dominion\*",
|
'* Dominion\\*',
|
||||||
"* Three cheers for master",
|
'* Three cheers for master',
|
||||||
"* Avalon",
|
'* Avalon',
|
||||||
"* Hanabi",
|
'* Hanabi',
|
||||||
"* Cards aginst humanity\*",
|
'* Cards aginst humanity\\*',
|
||||||
"* Citadels",
|
'* Citadels',
|
||||||
"* Munchkin\*\*",
|
'* Munchkin\\*\\*',
|
||||||
"* Exploding kittens\*\*",
|
'* Exploding kittens\\*\\*',
|
||||||
"* Aye dark overlord",
|
'* Aye dark overlord',
|
||||||
"* Settlers of catan\*",
|
'* Settlers of catan\\*',
|
||||||
"* Risk\*\*",
|
'* Risk\\*\\*',
|
||||||
"* og mange flere...",
|
'* og mange flere...',
|
||||||
"",
|
'',
|
||||||
"\* Vi har flere ekspansjoner til spillet",
|
'\\* Vi har flere ekspansjoner til spillet',
|
||||||
"",
|
'',
|
||||||
"\*\* Vi har flere varianter av spillet",
|
'\\*\\* Vi har flere varianter av spillet',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor(): string {
|
public function getColor(): string {
|
||||||
return "#000";
|
return '#000';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,45 +4,44 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
|
|
||||||
class DriftkveldActivity implements Activity {
|
class DriftkveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) > 18 ||
|
(int) $date->format('H') > 18
|
||||||
(intval($date->format("H")) === 17 && intval($date->format("i")) > 30)
|
|| ((int) $date->format('H') === 17 && (int) $date->format('i') > 30)
|
||||||
) {
|
) {
|
||||||
return $this->nextDate(
|
return $this->nextDate(
|
||||||
$date->add(new \DateInterval("P1D"))->setTime(18, 15, 0),
|
$date->add(new \DateInterval('P1D'))->setTime(18, 15, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if (intval($date->format("N")) !== 6) {
|
if ((int) $date->format('N') !== 6) {
|
||||||
return $this->nextDate($date->add(new \DateInterval("P1D")));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ((intval($date->format("W")) % 2) - 1) {
|
if (((int) $date->format('W') % 2) - 1) {
|
||||||
return $this->nextDate($date->add(new \DateInterval("P7D")));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (
|
if (
|
||||||
intval($date->format("H")) < 17 ||
|
(int) $date->format('H') < 17
|
||||||
(intval($date->format("H")) === 18 && intval($date->format("i")) < 30)
|
|| ((int) $date->format('H') === 18 && (int) $date->format('i') < 30)
|
||||||
) {
|
) {
|
||||||
return $this->prevDate(
|
return $this->prevDate(
|
||||||
$date->sub(new \DateInterval("P1D"))->setTime(18, 15, 0),
|
$date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if (intval($date->format("N")) !== 6) {
|
if ((int) $date->format('N') !== 6) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval("P1D")));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if ((intval($date->format("W")) % 2) - 1) {
|
if (((int) $date->format('W') % 2) - 1) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval("P7D")));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
class DriftkveldEvent extends Event {
|
class DriftkveldEvent extends Event {
|
||||||
public function getStop(): DateTimeImmutable {
|
public function getStop(): \DateTimeImmutable {
|
||||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,34 +4,33 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
|
|
||||||
class HackekveldActivity implements Activity {
|
class HackekveldActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (intval($date->format('H')) > 18 || intval($date->format('H')) === 17 && intval($date->format('i')) > 30) {
|
if ((int) $date->format('H') > 18 || (int) $date->format('H') === 17 && (int) $date->format('i') > 30) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(16, 15, 0);
|
$date = $date->setTime(16, 15, 0);
|
||||||
if (intval($date->format('N')) !== 6) {
|
if ((int) $date->format('N') !== 6) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if (intval($date->format('W')) % 2) {
|
if ((int) $date->format('W') % 2) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date): DateTimeImmutable {
|
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (intval($date->format('H')) < 17 || intval($date->format('H')) === 18 && intval($date->format('i')) < 30) {
|
if ((int) $date->format('H') < 17 || (int) $date->format('H') === 18 && (int) $date->format('i') < 30) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(18, 15, 0);
|
$date = $date->setTime(18, 15, 0);
|
||||||
if (intval($date->format('N')) !== 6) {
|
if ((int) $date->format('N') !== 6) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if (intval($date->format('W')) % 2) {
|
if ((int) $date->format('W') % 2) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use DateTimeImmutable;
|
|
||||||
use pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
class HackekveldEvent extends Event {
|
class HackekveldEvent extends Event {
|
||||||
public function getStop(): DateTimeImmutable {
|
public function getStop(): \DateTimeImmutable {
|
||||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ use pvv\side\Event;
|
|||||||
|
|
||||||
class NerdepitsaActivity implements Activity {
|
class NerdepitsaActivity implements Activity {
|
||||||
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
public function nextDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (intval($date->format('H')) > 19) {
|
if ((int) $date->format('H') > 19) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 0, 0);
|
$date = $date->setTime(19, 0, 0);
|
||||||
if (intval($date->format('N')) !== 5) {
|
if ((int) $date->format('N') !== 5) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if (intval($date->format('W')) % 2) {
|
if ((int) $date->format('W') % 2) {
|
||||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@ class NerdepitsaActivity implements Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
public function prevDate(\DateTimeImmutable $date): \DateTimeImmutable {
|
||||||
if (intval($date->format('H')) < 19) {
|
if ((int) $date->format('H') < 19) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||||
}
|
}
|
||||||
$date = $date->setTime(19, 0, 0);
|
$date = $date->setTime(19, 0, 0);
|
||||||
if (intval($date->format('N')) !== 5) {
|
if ((int) $date->format('N') !== 5) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
if (intval($date->format('W')) % 2) {
|
if ((int) $date->format('W') % 2) {
|
||||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user