The formattening, part 1
This commit is contained in:
parent
ece3c8ab80
commit
b6697e5750
18
dist/config.local.php
vendored
18
dist/config.local.php
vendored
@ -1,24 +1,24 @@
|
||||
<?php
|
||||
|
||||
$DB_DSN = 'sqlite:'.__DIR__.DIRECTORY_SEPARATOR.'pvv.sqlite';
|
||||
declare(strict_types=1);
|
||||
|
||||
$DB_DSN = 'sqlite:' . __DIR__ . \DIRECTORY_SEPARATOR . 'pvv.sqlite';
|
||||
$DB_USER = null;
|
||||
$DB_PASS = null;
|
||||
|
||||
$DOOR_SECRET = "changeme";
|
||||
$DOOR_SECRET = 'changeme';
|
||||
|
||||
$GALLERY_DIR = __DIR__.DIRECTORY_SEPARATOR.'www'.DIRECTORY_SEPARATOR.'galleri'.DIRECTORY_SEPARATOR.'bilder'.DIRECTORY_SEPARATOR.'gallery';
|
||||
$GALLERY_DIR = __DIR__ . \DIRECTORY_SEPARATOR . 'www' . \DIRECTORY_SEPARATOR . 'galleri' . \DIRECTORY_SEPARATOR . 'bilder' . \DIRECTORY_SEPARATOR . 'gallery';
|
||||
$GALLERY_SERVER_PATH = '/images/gallery/';
|
||||
|
||||
$SLIDESHOW_DIR = __DIR__.DIRECTORY_SEPARATOR.'www'.DIRECTORY_SEPARATOR.'galleri'.DIRECTORY_SEPARATOR.'bilder'.DIRECTORY_SEPARATOR.'slideshow';
|
||||
$SLIDESHOW_DIR = __DIR__ . \DIRECTORY_SEPARATOR . 'www' . \DIRECTORY_SEPARATOR . 'galleri' . \DIRECTORY_SEPARATOR . 'bilder' . \DIRECTORY_SEPARATOR . 'slideshow';
|
||||
$SLIDESHOW_SERVER_PATH = '/images/slideshow/';
|
||||
|
||||
$SAML_COOKIE_SALT = 'changeme';
|
||||
$SAML_COOKIE_SECURE = false;
|
||||
$SAML_TRUSTED_DOMAINS = array("localhost:1080");
|
||||
$SAML_ADMIN_PASSWORD = "changeme";
|
||||
$SAML_TRUSTED_DOMAINS = ['localhost:1080'];
|
||||
$SAML_ADMIN_PASSWORD = 'changeme';
|
||||
$SAML_ADMIN_NAME = 'PVV Drift';
|
||||
$SAML_ADMIN_EMAIL = 'drift@pvv.ntnu.no';
|
||||
|
||||
$CACHE_DIRECTORY = __DIR__.DIRECTORY_SEPARATOR.'cache';
|
||||
|
||||
?>
|
||||
$CACHE_DIRECTORY = __DIR__ . \DIRECTORY_SEPARATOR . 'cache';
|
||||
|
6
dist/config.source-env.php
vendored
6
dist/config.source-env.php
vendored
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once($configFile);
|
||||
declare(strict_types=1);
|
||||
|
||||
?>
|
||||
$configFile = getenv('PVV_CONFIG_FILE');
|
||||
require_once $configFile;
|
||||
|
16
dist/simplesamlphp-authsources.php
vendored
16
dist/simplesamlphp-authsources.php
vendored
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
$config = array(
|
||||
|
||||
/* This is the name of this authentication source, and will be used to access it later. */
|
||||
'default-sp' => array(
|
||||
'saml:SP',
|
||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||
),
|
||||
);
|
||||
declare(strict_types=1);
|
||||
$config = [
|
||||
|
||||
/* This is the name of this authentication source, and will be used to access it later. */
|
||||
'default-sp' => [
|
||||
'saml:SP',
|
||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
||||
],
|
||||
];
|
||||
|
657
dist/simplesamlphp-config.php
vendored
657
dist/simplesamlphp-config.php
vendored
File diff suppressed because it is too large
Load Diff
26
dist/simplesamlphp-idp.php
vendored
26
dist/simplesamlphp-idp.php
vendored
@ -1,23 +1,21 @@
|
||||
<?php
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = array (
|
||||
|
||||
declare(strict_types=1);
|
||||
$metadata['https://idp.pvv.ntnu.no/'] = [
|
||||
'metadata-set' => 'saml20-idp-remote',
|
||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
||||
'SingleSignOnService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'SingleSignOnService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
||||
),
|
||||
),
|
||||
'SingleLogoutService' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
],
|
||||
],
|
||||
'SingleLogoutService' => [
|
||||
0 => [
|
||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
|
||||
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
||||
);
|
||||
];
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
require __DIR__ . '/../src/_autoload.php';
|
||||
require __DIR__ . '/../config.php';
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
new \pvv\side\social\NerdepitsaActivity,
|
||||
new \pvv\side\social\AnimekveldActivity,
|
||||
new \pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
$agenda = new pvv\side\Agenda([
|
||||
new pvv\side\social\NerdepitsaActivity(),
|
||||
new pvv\side\social\AnimekveldActivity(),
|
||||
new pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
|
@ -1,33 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
// Set up database and user system,
|
||||
// and include common files such as HTML includes or SimplSAMLphp.
|
||||
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'agenda.php';
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'navbar.php';
|
||||
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'agenda.php';
|
||||
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'navbar.php';
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'config.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'config.php']);
|
||||
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'src', '_autoload.php']);
|
||||
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||
|
||||
date_default_timezone_set('Europe/Oslo');
|
||||
setlocale(LC_ALL, 'nb_NO');
|
||||
setlocale(\LC_ALL, 'nb_NO');
|
||||
|
||||
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
|
||||
$sp = 'default-sp';
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
$as = new SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
use \pvv\side\Agenda;
|
||||
$agenda = new \pvv\side\Agenda([
|
||||
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\DBActivity($pdo),
|
||||
new pvv\side\social\HackekveldActivity(),
|
||||
new pvv\side\social\BrettspillActivity(),
|
||||
new pvv\side\social\DriftkveldActivity(),
|
||||
new pvv\side\DBActivity($pdo),
|
||||
]);
|
||||
|
||||
$months_translations = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember'];
|
||||
|
116
inc/navbar.php
116
inc/navbar.php
@ -1,70 +1,74 @@
|
||||
<?php
|
||||
function navbar($depth, $active = NULL) {
|
||||
$result = "\n\t<ul id=\"menu\">\n";
|
||||
$menuItems = [
|
||||
'Hjem' => '',
|
||||
'Hendelser' => 'hendelser',
|
||||
//'Kalender' => 'kalender',
|
||||
//'Aktiviteter' => 'aktiviteter',
|
||||
'Prosjekter' => 'prosjekt',
|
||||
'Kontakt' => 'kontakt',
|
||||
'Webmail' => 'https://webmail.pvv.ntnu.no/roundcube/',
|
||||
'Galleri' => 'galleri',
|
||||
'Wiki' => 'https://wiki.pvv.ntnu.no/',
|
||||
'Git' => 'https://git.pvv.ntnu.no/',
|
||||
'Tjenester' => 'tjenester',
|
||||
];
|
||||
foreach($menuItems as $caption => $link) {
|
||||
$isActive = $active === $link;
|
||||
if (substr( $link, 0, 4 ) != "http") {
|
||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||
}
|
||||
|
||||
//if ($isActive) $link = '#';
|
||||
|
||||
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||
. '<a href="' . $link . '">'
|
||||
. $caption
|
||||
. "</a></li>\n"
|
||||
;
|
||||
}
|
||||
return $result . "\t</ul>\n";
|
||||
|
||||
declare(strict_types=1);
|
||||
function navbar($depth, $active = null) {
|
||||
$result = "\n\t<ul id=\"menu\">\n";
|
||||
$menuItems = [
|
||||
'Hjem' => '',
|
||||
'Hendelser' => 'hendelser',
|
||||
// 'Kalender' => 'kalender',
|
||||
// 'Aktiviteter' => 'aktiviteter',
|
||||
'Prosjekter' => 'prosjekt',
|
||||
'Kontakt' => 'kontakt',
|
||||
'Webmail' => 'https://webmail.pvv.ntnu.no/roundcube/',
|
||||
'Galleri' => 'galleri',
|
||||
'Wiki' => 'https://wiki.pvv.ntnu.no/',
|
||||
'Git' => 'https://git.pvv.ntnu.no/',
|
||||
'Tjenester' => 'tjenester',
|
||||
];
|
||||
foreach ($menuItems as $caption => $link) {
|
||||
$isActive = $active === $link;
|
||||
if (substr($link, 0, 4) != 'http') {
|
||||
$link = rtrim(str_repeat('../', $depth) . $link, '/') . '/';
|
||||
}
|
||||
|
||||
// if ($isActive) $link = '#';
|
||||
|
||||
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||
. '<a href="' . $link . '">'
|
||||
. $caption
|
||||
. "</a></li>\n";
|
||||
}
|
||||
|
||||
return $result . "\t</ul>\n";
|
||||
}
|
||||
|
||||
function loginBar($sp = null, $pdo = null) {
|
||||
if (is_null($sp)) $sp = 'default-sp';
|
||||
$result = "\n";
|
||||
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
||||
if (null === $sp) {
|
||||
$sp = 'default-sp';
|
||||
}
|
||||
$result = "\n";
|
||||
require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
|
||||
$as = new SimpleSAML\Auth\Simple($sp);
|
||||
|
||||
$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 64 64">
|
||||
$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 64 64">
|
||||
<circle cx="32" cy="27" r="14" stroke-width="0" />
|
||||
<ellipse cx="32" cy="66" rx="24" ry="28" stroke-width="0" />
|
||||
</svg>
|
||||
';
|
||||
|
||||
$attr = $as->getAttributes();
|
||||
if($attr) {
|
||||
$uname = $attr['uid'][0];
|
||||
$isAdmin = false;
|
||||
if (isset($pdo)) {
|
||||
$userManager = new \pvv\admin\UserManager($pdo);
|
||||
$isAdmin = $userManager->isAdmin($uname);
|
||||
}
|
||||
$result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">{$svg}" . htmlspecialchars($uname) . "</a>\n";
|
||||
$attr = $as->getAttributes();
|
||||
if ($attr) {
|
||||
$uname = $attr['uid'][0];
|
||||
$isAdmin = false;
|
||||
if (isset($pdo)) {
|
||||
$userManager = new pvv\admin\UserManager($pdo);
|
||||
$isAdmin = $userManager->isAdmin($uname);
|
||||
}
|
||||
$result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">{$svg}" . htmlspecialchars($uname) . "</a>\n";
|
||||
|
||||
$result .= "\n\t<ul id=\"usermenu\">\n";
|
||||
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
||||
if ($isAdmin) {
|
||||
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
|
||||
}
|
||||
$result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
|
||||
$result .= "\n\t</ul>\n";
|
||||
} else {
|
||||
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">{$svg}Logg inn</a>\n";
|
||||
}
|
||||
$result .= "\n\t<ul id=\"usermenu\">\n";
|
||||
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
||||
if ($isAdmin) {
|
||||
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
|
||||
}
|
||||
$result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
|
||||
$result .= "\n\t</ul>\n";
|
||||
} else {
|
||||
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">{$svg}Logg inn</a>\n";
|
||||
}
|
||||
|
||||
$result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>☰ </big>MENU</a>\n";
|
||||
$result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>☰ </big>MENU</a>\n";
|
||||
|
||||
return $result;
|
||||
return $result;
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* Copyright (c) 2014-2015, Jørn Åne de Jong <@jornane>
|
||||
*
|
||||
@ -14,7 +16,7 @@
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
/**
|
||||
/*
|
||||
* Register SPL autoloading for classes and interfaces. Put this file in your
|
||||
* namespace root and make sure it gets included from your PHP entry-point.
|
||||
*
|
||||
@ -34,6 +36,6 @@
|
||||
* @link http://php.net/manual/en/function.spl-autoload.php
|
||||
* @license http://choosealicense.com/licenses/isc/ ISC license
|
||||
*/
|
||||
spl_autoload_extensions( '.php' );
|
||||
spl_autoload_register( 'spl_autoload' );
|
||||
set_include_path( realpath( __DIR__ ) . PATH_SEPARATOR . get_include_path() );
|
||||
spl_autoload_extensions('.php');
|
||||
spl_autoload_register('spl_autoload');
|
||||
set_include_path(realpath(__DIR__) . \PATH_SEPARATOR . get_include_path());
|
||||
|
@ -1,134 +1,138 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\admin;
|
||||
|
||||
use \PDO;
|
||||
class UserManager {
|
||||
private $pdo;
|
||||
|
||||
class UserManager{
|
||||
private $pdo;
|
||||
public $usergroups = [
|
||||
'admin' => 1,
|
||||
'prosjekt' => 2,
|
||||
'aktiviteter' => 4,
|
||||
];
|
||||
|
||||
public $usergroups = [
|
||||
'admin' => 1,
|
||||
'prosjekt' => 2,
|
||||
'aktiviteter' => 4
|
||||
];
|
||||
public function __construct($pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function __construct($pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function setupUser($uname, $groups = 0): void {
|
||||
$query = 'INSERT INTO users (uname, groups) VALUES (:uname, :groups)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function setupUser($uname, $groups=0){
|
||||
$query = 'INSERT INTO users (uname, groups) VALUES (:uname, :groups)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
}
|
||||
public function updateFlags($uname, $flags): void {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $flags, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
public function updateFlags($uname, $flags){
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $flags, PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
}
|
||||
public function addGroup($uname, $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
public function addGroup($uname, $group){
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
if ($userFlags) {
|
||||
$newFlags = ($group | $userFlags);
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
if($userFlags){
|
||||
$newFlags = ($group | $userFlags);
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
public function removeGroup($uname, $group): void {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
public function removeGroup($uname, $group){
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
if ($userFlags) {
|
||||
$newFlags = ($userFlags & (~ $group));
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
|
||||
if($userFlags){
|
||||
$newFlags = ($userFlags & (~ $group));
|
||||
$this->updateFlags($uname, $newFlags);
|
||||
}
|
||||
}
|
||||
public function setGroups($uname, $groups): void {
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
public function setGroups($uname, $groups){
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
if ($row) {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
} else {
|
||||
$this->setupUser($uname, $groups);
|
||||
}
|
||||
}
|
||||
|
||||
if($row){
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $groups, PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}else{
|
||||
$this->setupUser($uname, $groups);
|
||||
}
|
||||
}
|
||||
public function hasGroup($uname, $groupName) {
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
public function hasGroup($uname, $groupName){
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
return $userFlags & $this->usergroups[$groupName];
|
||||
}
|
||||
|
||||
return ($userFlags & $this->usergroups[$groupName]);
|
||||
}
|
||||
// for convenience
|
||||
public function isAdmin($uname) {
|
||||
return $this->hasGroup($uname, 'admin');
|
||||
}
|
||||
|
||||
// for convenience
|
||||
public function isAdmin($uname){
|
||||
return $this->hasGroup($uname, 'admin');
|
||||
}
|
||||
public function getFlagfromNames($names) {
|
||||
$resultFlag = 0;
|
||||
|
||||
public function getFlagfromNames($names){
|
||||
$resultFlag = 0;
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if (\in_array($name, $names, true)) {
|
||||
$resultFlag = ($resultFlag | $flag);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if(in_array($name, $names)){
|
||||
$resultFlag = ($resultFlag | $flag);
|
||||
}
|
||||
}
|
||||
return $resultFlag;
|
||||
}
|
||||
|
||||
return $resultFlag;
|
||||
}
|
||||
public function getUsergroups($uname) {
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
public function getUsergroups($uname){
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
if ($row == false) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$row = $statement->fetch();
|
||||
if ($row == false) return 0;
|
||||
return $row[0];
|
||||
}
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
public function getUsergroupNames($uname){
|
||||
$usersGroups = [];
|
||||
public function getUsergroupNames($uname) {
|
||||
$usersGroups = [];
|
||||
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
$userFlags = $this->getUsergroups($uname);
|
||||
|
||||
foreach($this->usergroups as $name => $flag){
|
||||
if($userFlags & $flag){
|
||||
$usersGroups[] = $name;
|
||||
}
|
||||
}
|
||||
foreach ($this->usergroups as $name => $flag) {
|
||||
if ($userFlags & $flag) {
|
||||
$usersGroups[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return $usersGroups;
|
||||
}
|
||||
return $usersGroups;
|
||||
}
|
||||
|
||||
public function getAllUserData(){
|
||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function getAllUserData() {
|
||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$users = [];
|
||||
foreach($statement->fetchAll() as $userData){
|
||||
$uname = $userData['uname'];
|
||||
$users[] = [
|
||||
'name' => $uname,
|
||||
'groups' => $this->getUsergroupNames($uname)
|
||||
];
|
||||
}
|
||||
$users = [];
|
||||
foreach ($statement->fetchAll() as $userData) {
|
||||
$uname = $userData['uname'];
|
||||
$users[] = [
|
||||
'name' => $uname,
|
||||
'groups' => $this->getUsergroupNames($uname),
|
||||
];
|
||||
}
|
||||
|
||||
return $users;
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
|
||||
interface Activity {
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */;
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) /* : Event */;
|
||||
}
|
||||
|
@ -1,108 +1,114 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
|
||||
class Agenda {
|
||||
|
||||
private $activities;
|
||||
|
||||
const TODAY = 0;
|
||||
const TOMORROW = 1;
|
||||
const THIS_WEEK = 2;
|
||||
const NEXT_WEEK = 3;
|
||||
const THIS_MONTH = 4;
|
||||
const NEXT_MONTH = 5;
|
||||
public const TODAY = 0;
|
||||
public const TOMORROW = 1;
|
||||
public const THIS_WEEK = 2;
|
||||
public const NEXT_WEEK = 3;
|
||||
public const THIS_MONTH = 4;
|
||||
public const NEXT_MONTH = 5;
|
||||
|
||||
public function __construct($activities) {
|
||||
$this->activities = $activities;
|
||||
}
|
||||
public function __construct($activities) {
|
||||
$this->activities = $activities;
|
||||
}
|
||||
|
||||
public static function getFormattedDate($date) {
|
||||
return $date->format("l j. M H.i");
|
||||
public static function getFormattedDate($date) {
|
||||
return $date->format('l j. M H.i');
|
||||
}
|
||||
|
||||
public function getEventsBetween(\DateTimeImmutable $from, \DateTimeImmutable $to) {
|
||||
$results = [];
|
||||
for ($i = 0; $i < \count($this->activities); ++$i) {
|
||||
$result = [];
|
||||
do {
|
||||
$run = false;
|
||||
if (\count($result)) {
|
||||
$date = end($result)->getStop();
|
||||
} else {
|
||||
$date = $from;
|
||||
}
|
||||
$next = $this->activities[$i]->getNextEventFrom($date);
|
||||
if (isset($next) && $next->getStart() < $to) {
|
||||
$result[] = $this->activities[$i]->getNextEventFrom($date);
|
||||
$run = true;
|
||||
}
|
||||
} while ($run);
|
||||
$results[] = $result;
|
||||
}
|
||||
$result = [];
|
||||
foreach ($results as $a) {
|
||||
foreach ($a as $b) {
|
||||
$result[] = $b;
|
||||
}
|
||||
}
|
||||
usort($result, static fn($a, $b) => ($a->getStart() < $b->getStart()) ? -1 : 1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextDays() {
|
||||
$result = [[], [], [], [], [], []];
|
||||
$events = $this->getEventsBetween(
|
||||
(new \DateTimeImmutable())->setTime(0, 0),
|
||||
(new \DateTimeImmutable())->setTime(23, 59)->add(new \DateInterval('P1M'))
|
||||
);
|
||||
foreach ($events as $event) {
|
||||
$index = self::NEXT_MONTH;
|
||||
if (self::isToday($event->getStart())) {
|
||||
$index = self::TODAY;
|
||||
} elseif (self::isTomorrow($event->getStart())) {
|
||||
$index = self::TOMORROW;
|
||||
} elseif (self::isThisWeek($event->getStart())) {
|
||||
$index = self::THIS_WEEK;
|
||||
} elseif (self::isNextWeek($event->getStart())) {
|
||||
$index = self::NEXT_WEEK;
|
||||
} elseif (self::isThisMonth($event->getStart())) {
|
||||
$index = self::THIS_MONTH;
|
||||
}
|
||||
$result[$index][] = $event;
|
||||
}
|
||||
|
||||
public function getEventsBetween(DateTimeImmutable $from, DateTimeImmutable $to) {
|
||||
$results = [];
|
||||
for($i = 0; $i < sizeof($this->activities); $i++) {
|
||||
$result = [];
|
||||
do {
|
||||
$run = false;
|
||||
if (sizeof($result)) {
|
||||
$date = end($result)->getStop();
|
||||
} else {
|
||||
$date = $from;
|
||||
}
|
||||
$next = $this->activities[$i]->getNextEventFrom($date);
|
||||
if (isset($next) && $next->getStart() < $to) {
|
||||
$result[] = $this->activities[$i]->getNextEventFrom($date);
|
||||
$run = true;
|
||||
}
|
||||
} while ($run);
|
||||
$results[] = $result;
|
||||
}
|
||||
$result = [];
|
||||
foreach($results as $a) foreach($a as $b) $result[] = $b;
|
||||
usort($result, function($a, $b) {
|
||||
return ($a->getStart() < $b->getStart()) ? -1 : 1;
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextDays() {
|
||||
$result = [[], [], [], [], [], []];
|
||||
$events = $this->getEventsBetween(
|
||||
(new DateTimeImmutable)->setTime(0, 0),
|
||||
(new DateTimeImmutable)->setTime(23, 59)->add(new DateInterval('P1M'))
|
||||
);
|
||||
foreach ($events as $event) {
|
||||
$index = self::NEXT_MONTH;
|
||||
if (self::isToday($event->getStart())) $index = self::TODAY;
|
||||
elseif (self::isTomorrow($event->getStart())) $index = self::TOMORROW;
|
||||
elseif (self::isThisWeek($event->getStart())) $index = self::THIS_WEEK;
|
||||
elseif (self::isNextWeek($event->getStart())) $index = self::NEXT_WEEK;
|
||||
elseif (self::isThisMonth($event->getStart())) $index = self::THIS_MONTH;
|
||||
$result[$index][] = $event;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
public function getNextOfEach(\DateTimeImmutable $startDate) {
|
||||
$result = array_filter(array_map(
|
||||
static fn($a) => $a->getNextEventFrom($startDate),
|
||||
$this->activities
|
||||
), static fn($a) => isset($a));
|
||||
usort(
|
||||
$result,
|
||||
static fn($a, $b) => ($a->getStart()->getTimeStamp() < $b->getStart()->getTimeStamp())
|
||||
? -1
|
||||
: 1
|
||||
);
|
||||
|
||||
public function getNextOfEach(DateTimeImmutable $startDate) {
|
||||
$result = array_filter(array_map(
|
||||
function($a) use ($startDate){
|
||||
return $a->getNextEventFrom($startDate);
|
||||
}, $this->activities
|
||||
), function($a){
|
||||
return isset($a);
|
||||
});
|
||||
usort($result, function($a, $b) {
|
||||
return ($a->getStart()->getTimeStamp() < $b->getStart()->getTimeStamp())
|
||||
? -1
|
||||
: 1
|
||||
;
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function isToday(DateTimeImmutable $date) {
|
||||
return $date->format('dmY') == date('dmY');
|
||||
}
|
||||
public static function isToday(\DateTimeImmutable $date) {
|
||||
return $date->format('dmY') == date('dmY');
|
||||
}
|
||||
|
||||
public static function isTomorrow(DateTimeImmutable $date) {
|
||||
return $date->sub(new DateInterval('P1D'))->format('dmY') == date('dmY');
|
||||
}
|
||||
public static function isTomorrow(\DateTimeImmutable $date) {
|
||||
return $date->sub(new \DateInterval('P1D'))->format('dmY') == date('dmY');
|
||||
}
|
||||
|
||||
public static function isThisWeek(DateTimeImmutable $date) {
|
||||
return $date->format('WY') == date('WY');
|
||||
}
|
||||
public static function isThisWeek(\DateTimeImmutable $date) {
|
||||
return $date->format('WY') == date('WY');
|
||||
}
|
||||
|
||||
public static function isNextWeek(DateTimeImmutable $date) {
|
||||
return $date->sub(new DateInterval('P7D'))->format('WY') == date('WY');
|
||||
}
|
||||
|
||||
public static function isThisMonth(DateTimeImmutable $date) {
|
||||
return $date->format('mY') == date('mY');
|
||||
}
|
||||
public static function isNextWeek(\DateTimeImmutable $date) {
|
||||
return $date->sub(new \DateInterval('P7D'))->format('WY') == date('WY');
|
||||
}
|
||||
|
||||
public static function isThisMonth(\DateTimeImmutable $date) {
|
||||
return $date->format('mY') == date('mY');
|
||||
}
|
||||
}
|
||||
|
@ -1,85 +1,83 @@
|
||||
<?php
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \PDO;
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class DBActivity implements Activity {
|
||||
private $pdo;
|
||||
|
||||
public function __construct(PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function getAllEvents() {
|
||||
$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']
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
$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']
|
||||
);
|
||||
$events[] = $event;
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
return $events;
|
||||
}
|
||||
|
||||
public function getEventByID($id) {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
public function getEventByID($id) {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbEvent = $statement->fetch();
|
||||
$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 = $statement->fetch();
|
||||
|
||||
return $event;
|
||||
}
|
||||
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']
|
||||
);
|
||||
}
|
||||
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) {
|
||||
$query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1';
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) {
|
||||
$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);
|
||||
}
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) {
|
||||
$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);
|
||||
}
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) {
|
||||
$query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1';
|
||||
|
||||
private function retrieve($date, $query) {
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$stmt->execute(['date' => $date->format('Y-m-d H:i:s')]);
|
||||
if ($result = $stmt->fetch(PDO::FETCH_ASSOC)){
|
||||
$ev = 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']
|
||||
);
|
||||
return $ev;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return $this->retrieve($date, $query);
|
||||
}
|
||||
|
||||
private function retrieve($date, $query) {
|
||||
$stmt = $this->pdo->prepare($query);
|
||||
$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']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,74 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
class Door {
|
||||
private $pdo;
|
||||
|
||||
class Door{
|
||||
private $pdo;
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function __construct(PDO $pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function getAll() {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
public function getAll() {
|
||||
$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'],
|
||||
];
|
||||
}
|
||||
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
];
|
||||
}
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
public function getEntriesAfter($startTime) {
|
||||
$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->execute();
|
||||
|
||||
public function getEntriesAfter($startTime) {
|
||||
$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->execute();
|
||||
$doorEvents = [];
|
||||
foreach ($statement->fetchAll() as $row) {
|
||||
$doorEvents[] = [
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
|
||||
$doorEvents = [];
|
||||
foreach($statement->fetchAll() as $row){
|
||||
$doorEvents[] = [
|
||||
'time' => (int)$row['time'],
|
||||
'open' => (bool)$row['open']
|
||||
];
|
||||
}
|
||||
return $doorEvents;
|
||||
}
|
||||
|
||||
return $doorEvents;
|
||||
}
|
||||
public function getCurrent() {
|
||||
$query = 'SELECT time, open FROM door ORDER BY time DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
public function getCurrent() {
|
||||
$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']
|
||||
];
|
||||
}
|
||||
return [
|
||||
'time' => (int) $row['time'],
|
||||
'open' => (bool) $row['open'],
|
||||
];
|
||||
}
|
||||
|
||||
private function removeOld() {
|
||||
$firstValidTime = time() - 60*60*24*7; //One week before now
|
||||
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':firstValid', $firstValidTime, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}
|
||||
private function removeOld(): void {
|
||||
$firstValidTime = time() - 60 * 60 * 24 * 7; // One week before now
|
||||
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':firstValid', $firstValidTime, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function createEvent($time, $open) {
|
||||
$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->execute();
|
||||
public function createEvent($time, $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->execute();
|
||||
|
||||
$this->removeOld();
|
||||
}
|
||||
$this->removeOld();
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +1,55 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use DateTimeImmutable;
|
||||
|
||||
abstract class Event {
|
||||
private $start;
|
||||
|
||||
private $start;
|
||||
public function __construct(\DateTimeImmutable $start) {
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
public function __construct(DateTimeImmutable $start) {
|
||||
$this->start = $start;
|
||||
}
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
public function getRelativeDate() {
|
||||
if (Agenda::isToday($this->getStart())) {
|
||||
return 'i dag';
|
||||
}
|
||||
if (Agenda::isTomorrow($this->getStart())) {
|
||||
return 'i morgen';
|
||||
}
|
||||
if (Agenda::isThisWeek($this->getStart()) || $this->getStart()->sub(new \DateInterval('P4D'))->getTimestamp() < time()) {
|
||||
return $this->getStart()->format('l');
|
||||
}
|
||||
if (Agenda::isNextWeek($this->getStart())) {
|
||||
return 'neste uke';
|
||||
}
|
||||
if (Agenda::isThisMonth($this->getStart())) {
|
||||
return 'denne måneden';
|
||||
}
|
||||
|
||||
public function getRelativeDate() {
|
||||
if (Agenda::isToday($this->getStart())) {
|
||||
return 'i dag';
|
||||
}
|
||||
if (Agenda::isTomorrow($this->getStart())) {
|
||||
return 'i morgen';
|
||||
}
|
||||
if (Agenda::isThisWeek($this->getStart()) || $this->getStart()->sub(new DateInterval('P4D'))->getTimestamp() < time()) {
|
||||
return $this->getStart()->format("l");
|
||||
}
|
||||
if (Agenda::isNextWeek($this->getStart())) {
|
||||
return 'neste uke';
|
||||
}
|
||||
if (Agenda::isThisMonth($this->getStart())) {
|
||||
return 'denne måneden';
|
||||
}
|
||||
return $this->getStart()->format("j. F");
|
||||
}
|
||||
return $this->getStart()->format('j. F');
|
||||
}
|
||||
|
||||
public abstract function getStop(); /* : DateTimeImmutable */
|
||||
abstract public function getStop(); /* : DateTimeImmutable */
|
||||
|
||||
public abstract function getName();
|
||||
abstract public function getName();
|
||||
|
||||
public abstract function getLocation();
|
||||
abstract public function getLocation();
|
||||
|
||||
public abstract function getOrganiser();
|
||||
abstract public function getOrganiser();
|
||||
|
||||
public abstract function getURL(); /* : string */
|
||||
abstract public function getURL(); /* : string */
|
||||
|
||||
public abstract function getImageURL(); /* : string */
|
||||
abstract public function getImageURL(); /* : string */
|
||||
|
||||
public abstract function getDescription(); /* : string */
|
||||
abstract public function getDescription(); /* : string */
|
||||
|
||||
public abstract function getColor(); /* : string */
|
||||
abstract public function getColor(); /* : string */
|
||||
}
|
||||
|
@ -1,49 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
class MOTD {
|
||||
private $pdo;
|
||||
|
||||
class MOTD{
|
||||
private $pdo;
|
||||
public function __construct($pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function __construct($pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function setMOTD($title, $content): void {
|
||||
if (\is_array($content)) {
|
||||
$content = implode('_', $content);
|
||||
}
|
||||
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content);';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
|
||||
public function setMOTD($title, $content) {
|
||||
if (is_array($content)) {
|
||||
$content = implode("_", $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();
|
||||
}
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function getMOTD() {
|
||||
$query = 'SELECT motd.title, motd.content FROM motd ORDER BY motd.id DESC LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
public function getMOTD() {
|
||||
$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();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
$data = $statement->fetch();
|
||||
|
||||
return $motd;
|
||||
}
|
||||
|
||||
public function getMOTD_history($limit = 5) {
|
||||
$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->execute();
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
|
||||
$data = $statement->fetch();
|
||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
||||
public function getMOTD_history($limit = 5) {
|
||||
$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->execute();
|
||||
|
||||
return $motd;
|
||||
}
|
||||
|
||||
$data = $statement->fetch();
|
||||
|
||||
return ['title' => $data[0], 'content' => explode("\n", $data[1])];
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class Project{
|
||||
private $id, $name, $descr, $active;
|
||||
class Project {
|
||||
private $id;
|
||||
private $name;
|
||||
private $descr;
|
||||
private $active;
|
||||
|
||||
public function __construct($id, $name, $descr, $active){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
}
|
||||
public function __construct($id, $name, $descr, $active) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
public function getID() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDescription(){
|
||||
return $this->descr;
|
||||
}
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
public function getActive() {
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
|
@ -1,121 +1,120 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
use \PDO;
|
||||
class ProjectManager {
|
||||
private $pdo;
|
||||
|
||||
class ProjectManager{
|
||||
private $pdo;
|
||||
public function __construct(\PDO $pdo) {
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
|
||||
public function __construct(PDO $pdo){
|
||||
$this->pdo = $pdo;
|
||||
}
|
||||
public function getAll() {
|
||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
public function getAll() {
|
||||
$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']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
|
||||
$projects = [];
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
return $projects;
|
||||
}
|
||||
|
||||
return $projects;
|
||||
}
|
||||
public function getByID($id) {
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
public function getByID($id){
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
$dbProj = $statement->fetch();
|
||||
if (!$dbProj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dbProj = $statement->fetch();
|
||||
if (!$dbProj) {
|
||||
return false;
|
||||
}
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
return new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
}
|
||||
|
||||
return $project;
|
||||
}
|
||||
public function getByOwner($uname) {
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
public function getByOwner($uname){
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
foreach ($projectIDs as $id) {
|
||||
$id = $id['projectid'];
|
||||
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
foreach($projectIDs as $id){
|
||||
$id = $id['projectid'];
|
||||
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$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']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
}
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
}
|
||||
|
||||
public function getProjectMembers($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
return $projects;
|
||||
}
|
||||
|
||||
$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']
|
||||
];
|
||||
}
|
||||
public function getProjectMembers($id) {
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
return $members;
|
||||
}
|
||||
$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'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getProjectOwner($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
return $members;
|
||||
}
|
||||
|
||||
$dbOwner = $statement->fetch();
|
||||
$owner = [
|
||||
'name' => $dbOwner['name'],
|
||||
'uname' => $dbOwner['uname'],
|
||||
'mail' => $dbOwner['mail'],
|
||||
'role' => $dbOwner['role'],
|
||||
'lead' => $dbOwner['lead'],
|
||||
'owner' => $dbOwner['owner']
|
||||
];
|
||||
public function getProjectOwner($id) {
|
||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
return $owner;
|
||||
}
|
||||
$dbOwner = $statement->fetch();
|
||||
|
||||
return [
|
||||
'name' => $dbOwner['name'],
|
||||
'uname' => $dbOwner['uname'],
|
||||
'mail' => $dbOwner['mail'],
|
||||
'role' => $dbOwner['role'],
|
||||
'lead' => $dbOwner['lead'],
|
||||
'owner' => $dbOwner['owner'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side;
|
||||
|
||||
class SimpleEvent extends Event {
|
||||
private $id;
|
||||
private $name;
|
||||
private $descr;
|
||||
private $start;
|
||||
private $end;
|
||||
private $org;
|
||||
private $loc;
|
||||
|
||||
private $id, $name, $descr, $start, $end, $org, $loc;
|
||||
public function __construct($id, $name, \DateTimeImmutable $start, \DateTimeImmutable $end, $org, $loc, $descr, $_isDBEvent = false) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
}
|
||||
|
||||
public function __construct($id, $name,\DateTimeImmutable $start,\DateTimeImmutable $end,$org, $loc, $descr, $_isDBEvent = false){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
$this->org = $org;
|
||||
$this->loc = $loc;
|
||||
$this->descr = explode("\n", $descr);
|
||||
}
|
||||
public function getID() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
public function getStart() {
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function getStart(){
|
||||
return $this->start;
|
||||
}
|
||||
public function getStop() {
|
||||
return $this->end;
|
||||
}
|
||||
|
||||
public function getStop(){
|
||||
return $this->end;
|
||||
}
|
||||
public function getOrganiser() {
|
||||
return $this->org;
|
||||
}
|
||||
|
||||
public function getOrganiser(){
|
||||
return $this->org;
|
||||
}
|
||||
public function getLocation() {
|
||||
return $this->loc;
|
||||
}
|
||||
|
||||
public function getLocation(){
|
||||
return $this->loc;
|
||||
}
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->name;
|
||||
}
|
||||
public function getURL() {
|
||||
return '/hendelser/info.php?id=' . $this->id;
|
||||
}
|
||||
|
||||
public function getURL() {
|
||||
return ('/hendelser/info.php?id=' . $this->id);
|
||||
}
|
||||
public function getImageURL(): void {}
|
||||
|
||||
public function getImageURL() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#3b7";
|
||||
}
|
||||
public function getDescription() {
|
||||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#3b7';
|
||||
}
|
||||
}
|
||||
|
@ -1,36 +1,41 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class AnimekveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 20 || $date->format('H') == 19 && $date->format('i') > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 20 || $date->format('H') == 19 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19 || $date->format('H') == 20 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
return $date;
|
||||
}
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19 || $date->format('H') == 20 && $date->format('i') < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 30, 0);
|
||||
if ($date->format('N') != 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new AnimekveldEvent($this->nextDate($date));
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new AnimekveldEvent($this->prevDate($date));
|
||||
}
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new AnimekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new AnimekveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class AnimekveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
public function getName() { /* : string */
|
||||
return 'Animekveld';
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Animekveld";
|
||||
}
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Koserommet';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Koserommet";
|
||||
}
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Christoffer Viken';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Christoffer Viken";
|
||||
}
|
||||
public function getURL() { /* : string */
|
||||
return '/anime/';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
return '/anime/';
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/animekveld.jpg';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/animekveld.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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.',
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
}
|
||||
public function getDescription() {
|
||||
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.',
|
||||
'',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class BrettspillActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 17 || $date->format('H') == 16 && $date->format('i') > 15) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2 - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 17 || $date->format('H') == 16 && $date->format('i') > 15)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 16 || $date->format('H') == 17 && $date->format('i') < 15)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 16 || $date->format('H') == 17 && $date->format('i') < 15) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 7) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2 - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new BrettspillEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new BrettspillEvent($this->prevDate($date));
|
||||
}
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new BrettspillEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new BrettspillEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,65 +1,64 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class BrettspillEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
public function getName() { /* : string */
|
||||
return 'Brettspillkveld';
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Brettspillkveld";
|
||||
}
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Programvareverkstedet";
|
||||
}
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Programvareverkstedet';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Programvareverkstedet";
|
||||
}
|
||||
public function getURL() { /* : string */
|
||||
return '/brettspill/';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
return '/brettspill/';
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/brettspill.jpg';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/brettspill.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
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',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#000";
|
||||
}
|
||||
public function getDescription() {
|
||||
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',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#000';
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class DriftkveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2 - 1) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2 - 1)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2 - 1) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new DriftkveldEvent($this->nextDate($date));
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new DriftkveldEvent($this->prevDate($date));
|
||||
}
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new DriftkveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new DriftkveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +1,48 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class DriftkveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
public function getName() { /* : string */
|
||||
return 'Driftkveld';
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Driftkveld";
|
||||
}
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Terminalrommet / Discord / IRC";
|
||||
}
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Torstein Nordgård-Hansen';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Torstein Nordgård-Hansen";
|
||||
}
|
||||
public function getURL() { /* : string */
|
||||
return '/driftkveld/';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
return '/driftkveld/';
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/drift.jpg';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/drift.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Vil du drifte?',
|
||||
'Vil du være kul kis TM?',
|
||||
'Kom på driftkveld!',
|
||||
'',
|
||||
'Vi møtes annenhver uke for å ta unna driftarbeid og drikke kaffe.',
|
||||
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
}
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Vil du drifte?',
|
||||
'Vil du være kul kis TM?',
|
||||
'Kom på driftkveld!',
|
||||
'',
|
||||
'Vi møtes annenhver uke for å ta unna driftarbeid og drikke kaffe.',
|
||||
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class HackekveldActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 6) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 18 || $date->format('H') == 17 && $date->format('i') > 30)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
$date = $date->setTime(16, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||
}
|
||||
$date = $date->setTime(18, 15, 0);
|
||||
if ($date->format('N') != 6) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new HackekveldEvent($this->nextDate($date));
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new HackekveldEvent($this->prevDate($date));
|
||||
}
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new HackekveldEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new HackekveldEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +1,44 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class HackekveldEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
||||
}
|
||||
public function getName() { /* : string */
|
||||
return 'Hackekveld';
|
||||
}
|
||||
|
||||
public function getName() /* : string */ {
|
||||
return "Hackekveld";
|
||||
}
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Terminalrommet / Discord / IRC';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Terminalrommet / Discord / IRC";
|
||||
}
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'PVV';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "PVV";
|
||||
}
|
||||
public function getURL() { /* : string */
|
||||
return '#';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
return '#';
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/pvv-logo.png';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/pvv-logo.png';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Mange PVV-medlemmer liker å programmere.',
|
||||
'Hvis du også liker å programmere, så bli med! Her kan du jobbe med dine egne prosjekter eller starte noe med andre nerder her på huset. Vi møtes for en hyggelig prat, mye god programmering og delsponset pizza.'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#35a";
|
||||
}
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Mange PVV-medlemmer liker å programmere.',
|
||||
'Hvis du også liker å programmere, så bli med! Her kan du jobbe med dine egne prosjekter eller starte noe med andre nerder her på huset. Vi møtes for en hyggelig prat, mye god programmering og delsponset pizza.',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#35a';
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,47 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Activity;
|
||||
use \DateTimeImmutable;
|
||||
use \DateInterval;
|
||||
use pvv\side\Activity;
|
||||
|
||||
class NerdepitsaActivity implements Activity {
|
||||
public function nextDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 19) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2) {
|
||||
return $this->nextDate($date->add(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function nextDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') > 19)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->nextDate($date->add(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->nextDate($date->add(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function prevDate(DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5)
|
||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
||||
if ($date->format('W') % 2)
|
||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
||||
return $date;
|
||||
}
|
||||
public function prevDate(\DateTimeImmutable $date) {
|
||||
if ($date->format('H') < 19) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||
}
|
||||
$date = $date->setTime(19, 0, 0);
|
||||
if ($date->format('N') != 5) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||
}
|
||||
if ($date->format('W') % 2) {
|
||||
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||
}
|
||||
|
||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new NerdepitsaEvent($this->nextDate($date));
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
||||
return new NerdepitsaEvent($this->prevDate($date));
|
||||
}
|
||||
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new NerdepitsaEvent($this->nextDate($date));
|
||||
}
|
||||
|
||||
public function getPreviousEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||
return new NerdepitsaEvent($this->prevDate($date));
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,49 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
use \pvv\side\Event;
|
||||
|
||||
use \DateInterval;
|
||||
use pvv\side\Event;
|
||||
|
||||
class NerdepitsaEvent extends Event {
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new \DateInterval('PT2H1800S'));
|
||||
}
|
||||
|
||||
public function getStop() {
|
||||
return $this->getStart()->add(new DateInterval('PT2H1800S'));
|
||||
}
|
||||
public function getName() {
|
||||
return 'Nerdepitsa';
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return "Nerdepitsa";
|
||||
}
|
||||
public function getLocation() { /* : Location */
|
||||
return 'Peppes Kjøpmansgata';
|
||||
}
|
||||
|
||||
public function getLocation() /* : Location */ {
|
||||
return "Peppes Kjøpmansgata";
|
||||
}
|
||||
public function getOrganiser() { /* : User */
|
||||
return 'Anders Christensen';
|
||||
}
|
||||
|
||||
public function getOrganiser() /* : User */ {
|
||||
return "Anders Christensen";
|
||||
}
|
||||
public function getURL() { /* : string */
|
||||
return '/nerdepitsa/';
|
||||
}
|
||||
|
||||
public function getURL() /* : string */ {
|
||||
return '/nerdepitsa/';
|
||||
}
|
||||
public function getImageURL() {
|
||||
return '/sosiale/nerdepitsa.jpg';
|
||||
}
|
||||
|
||||
public function getImageURL() {
|
||||
return '/sosiale/nerdepitsa.jpg';
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Hei, har du lyst til å bli med på pizzaspising annenhver fredag? Vi møtes på Peppes i Kjøpmannsgata fredag klokken 19.00 hver partallsuke!',
|
||||
'',
|
||||
'Vi er en trivelig gjeng hvis der fellestrekk er en viss interesse for data, samt har eller har hatt en tilknytning til studentmiljøet ved NTNU. For å treffe andre som også faller inn under disse kriteriene treffes vi over pizza på Peppes annenhver fredag. (Definisjon: En fredag er annenhver dersom den ligger i en partallsuke). Vi har reservasjon under navnet Christensen med storkunderabatt.',
|
||||
'',
|
||||
'Det er ikke noe krav at du er nerd... noen av oss virker faktisk nesten normale! Det er heller ikke noe krav at du kjenner noen fra før. Det er ikke engang et krav at du må like pizza! (selv om det hjelper) Dersom du har lyst til å treffe personer fra datamiljøet ved NTNU så bare still opp! Vi biter ikke, vel, bortsett fra pizzaen da.',
|
||||
'',
|
||||
'Vi bestiller så mye pizza som vi i fellesskap klarer å stappe i oss, og splitter dermed pizza-regningen broderlig, mens hver enkelt betaler for sin egen drikke, dessert mm. Vell møtt!'
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return "#c35";
|
||||
}
|
||||
public function getDescription() {
|
||||
return [
|
||||
'Hei, har du lyst til å bli med på pizzaspising annenhver fredag? Vi møtes på Peppes i Kjøpmannsgata fredag klokken 19.00 hver partallsuke!',
|
||||
'',
|
||||
'Vi er en trivelig gjeng hvis der fellestrekk er en viss interesse for data, samt har eller har hatt en tilknytning til studentmiljøet ved NTNU. For å treffe andre som også faller inn under disse kriteriene treffes vi over pizza på Peppes annenhver fredag. (Definisjon: En fredag er annenhver dersom den ligger i en partallsuke). Vi har reservasjon under navnet Christensen med storkunderabatt.',
|
||||
'',
|
||||
'Det er ikke noe krav at du er nerd... noen av oss virker faktisk nesten normale! Det er heller ikke noe krav at du kjenner noen fra før. Det er ikke engang et krav at du må like pizza! (selv om det hjelper) Dersom du har lyst til å treffe personer fra datamiljøet ved NTNU så bare still opp! Vi biter ikke, vel, bortsett fra pizzaen da.',
|
||||
'',
|
||||
'Vi bestiller så mye pizza som vi i fellesskap klarer å stappe i oss, og splitter dermed pizza-regningen broderlig, mens hver enkelt betaler for sin egen drikke, dessert mm. Vell møtt!',
|
||||
];
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
return '#c35';
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
ini_set('date.timezone', 'Europe/Oslo');
|
||||
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
require implode(\DIRECTORY_SEPARATOR, [\dirname(__DIR__, 3), '', '_autoload.php']);
|
||||
|
||||
$c = new AnimekveldActivity;
|
||||
die($c->nextDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
$c = new AnimekveldActivity();
|
||||
exit($c->nextDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
|
@ -1,9 +1,12 @@
|
||||
<?php //declare(strict_types=1);
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pvv\side\social;
|
||||
|
||||
ini_set('date.timezone', 'Europe/Oslo');
|
||||
|
||||
require implode(DIRECTORY_SEPARATOR, [dirname(dirname(dirname(__DIR__))), '', '_autoload.php']);
|
||||
require implode(\DIRECTORY_SEPARATOR, [\dirname(__DIR__, 3), '', '_autoload.php']);
|
||||
|
||||
$c = new NerdepitsaActivity;
|
||||
die($c->prevDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
||||
$c = new NerdepitsaActivity();
|
||||
exit($c->prevDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||
|
Loading…
x
Reference in New Issue
Block a user