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