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
|
<?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_USER = null;
|
||||||
$DB_PASS = 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/';
|
$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/';
|
$SLIDESHOW_SERVER_PATH = '/images/slideshow/';
|
||||||
|
|
||||||
$SAML_COOKIE_SALT = 'changeme';
|
$SAML_COOKIE_SALT = 'changeme';
|
||||||
$SAML_COOKIE_SECURE = false;
|
$SAML_COOKIE_SECURE = false;
|
||||||
$SAML_TRUSTED_DOMAINS = array("localhost:1080");
|
$SAML_TRUSTED_DOMAINS = ['localhost:1080'];
|
||||||
$SAML_ADMIN_PASSWORD = "changeme";
|
$SAML_ADMIN_PASSWORD = 'changeme';
|
||||||
$SAML_ADMIN_NAME = 'PVV Drift';
|
$SAML_ADMIN_NAME = 'PVV Drift';
|
||||||
$SAML_ADMIN_EMAIL = 'drift@pvv.ntnu.no';
|
$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
|
<?php
|
||||||
|
|
||||||
$configFile = getenv('PVV_CONFIG_FILE');
|
declare(strict_types=1);
|
||||||
require_once($configFile);
|
|
||||||
|
|
||||||
?>
|
$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
|
<?php
|
||||||
$config = array(
|
|
||||||
|
|
||||||
/* This is the name of this authentication source, and will be used to access it later. */
|
declare(strict_types=1);
|
||||||
'default-sp' => array(
|
$config = [
|
||||||
'saml:SP',
|
|
||||||
'idp' => 'https://idp.pvv.ntnu.no/',
|
/* 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
|
<?php
|
||||||
$metadata['https://idp.pvv.ntnu.no/'] = array (
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
$metadata['https://idp.pvv.ntnu.no/'] = [
|
||||||
'metadata-set' => 'saml20-idp-remote',
|
'metadata-set' => 'saml20-idp-remote',
|
||||||
'entityid' => 'https://idp.pvv.ntnu.no/',
|
'entityid' => 'https://idp.pvv.ntnu.no/',
|
||||||
'SingleSignOnService' =>
|
'SingleSignOnService' => [
|
||||||
array (
|
0 => [
|
||||||
0 =>
|
|
||||||
array (
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
|
||||||
),
|
],
|
||||||
),
|
],
|
||||||
'SingleLogoutService' =>
|
'SingleLogoutService' => [
|
||||||
array (
|
0 => [
|
||||||
0 =>
|
|
||||||
array (
|
|
||||||
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
|
||||||
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
|
'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==',
|
'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',
|
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
|
||||||
);
|
];
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
require __DIR__ . '/../src/_autoload.php';
|
require __DIR__ . '/../src/_autoload.php';
|
||||||
require __DIR__ . '/../config.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);
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
$agenda = new \pvv\side\Agenda([
|
$agenda = new pvv\side\Agenda([
|
||||||
new \pvv\side\social\NerdepitsaActivity,
|
new pvv\side\social\NerdepitsaActivity(),
|
||||||
new \pvv\side\social\AnimekveldActivity,
|
new pvv\side\social\AnimekveldActivity(),
|
||||||
new \pvv\side\DBActivity($pdo),
|
new pvv\side\DBActivity($pdo),
|
||||||
]);
|
]);
|
||||||
|
@ -1,33 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
// Set up database and user system,
|
// Set up database and user system,
|
||||||
// and include common files such as HTML includes or SimplSAMLphp.
|
// and include common files such as HTML includes or SimplSAMLphp.
|
||||||
|
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'agenda.php';
|
require_once __DIR__ . \DIRECTORY_SEPARATOR . 'agenda.php';
|
||||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'navbar.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, ['', 'src', '_autoload.php']);
|
||||||
require_once dirname(__DIR__) . implode(DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
require_once dirname(__DIR__) . implode(\DIRECTORY_SEPARATOR, ['', 'vendor', 'simplesamlphp', 'simplesamlphp', 'lib', '_autoload.php']);
|
||||||
|
|
||||||
date_default_timezone_set('Europe/Oslo');
|
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);
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
$userManager = new \pvv\admin\UserManager($pdo);
|
$userManager = new pvv\admin\UserManager($pdo);
|
||||||
|
|
||||||
$sp = 'default-sp';
|
$sp = 'default-sp';
|
||||||
$as = new \SimpleSAML\Auth\Simple($sp);
|
$as = new SimpleSAML\Auth\Simple($sp);
|
||||||
|
|
||||||
use \pvv\side\Agenda;
|
use pvv\side\Agenda;
|
||||||
$agenda = new \pvv\side\Agenda([
|
|
||||||
|
$agenda = new Agenda([
|
||||||
// new \pvv\side\social\NerdepitsaActivity,
|
// new \pvv\side\social\NerdepitsaActivity,
|
||||||
// new \pvv\side\social\AnimekveldActivity,
|
// new \pvv\side\social\AnimekveldActivity,
|
||||||
new \pvv\side\social\HackekveldActivity,
|
new pvv\side\social\HackekveldActivity(),
|
||||||
new \pvv\side\social\BrettspillActivity,
|
new pvv\side\social\BrettspillActivity(),
|
||||||
new \pvv\side\social\DriftkveldActivity,
|
new pvv\side\social\DriftkveldActivity(),
|
||||||
new \pvv\side\DBActivity($pdo),
|
new pvv\side\DBActivity($pdo),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$months_translations = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember'];
|
$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
|
<?php
|
||||||
function navbar($depth, $active = NULL) {
|
|
||||||
$result = "\n\t<ul id=\"menu\">\n";
|
declare(strict_types=1);
|
||||||
$menuItems = [
|
function navbar($depth, $active = null) {
|
||||||
'Hjem' => '',
|
$result = "\n\t<ul id=\"menu\">\n";
|
||||||
'Hendelser' => 'hendelser',
|
$menuItems = [
|
||||||
//'Kalender' => 'kalender',
|
'Hjem' => '',
|
||||||
//'Aktiviteter' => 'aktiviteter',
|
'Hendelser' => 'hendelser',
|
||||||
'Prosjekter' => 'prosjekt',
|
// 'Kalender' => 'kalender',
|
||||||
'Kontakt' => 'kontakt',
|
// 'Aktiviteter' => 'aktiviteter',
|
||||||
'Webmail' => 'https://webmail.pvv.ntnu.no/roundcube/',
|
'Prosjekter' => 'prosjekt',
|
||||||
'Galleri' => 'galleri',
|
'Kontakt' => 'kontakt',
|
||||||
'Wiki' => 'https://wiki.pvv.ntnu.no/',
|
'Webmail' => 'https://webmail.pvv.ntnu.no/roundcube/',
|
||||||
'Git' => 'https://git.pvv.ntnu.no/',
|
'Galleri' => 'galleri',
|
||||||
'Tjenester' => 'tjenester',
|
'Wiki' => 'https://wiki.pvv.ntnu.no/',
|
||||||
];
|
'Git' => 'https://git.pvv.ntnu.no/',
|
||||||
foreach($menuItems as $caption => $link) {
|
'Tjenester' => 'tjenester',
|
||||||
$isActive = $active === $link;
|
];
|
||||||
if (substr( $link, 0, 4 ) != "http") {
|
foreach ($menuItems as $caption => $link) {
|
||||||
$link = rtrim(str_repeat('../', $depth) . $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"' : '') . '>'
|
// if ($isActive) $link = '#';
|
||||||
. '<a href="' . $link . '">'
|
|
||||||
. $caption
|
$result .= "\t\t<li" . ($isActive ? ' class="active"' : '') . '>'
|
||||||
. "</a></li>\n"
|
. '<a href="' . $link . '">'
|
||||||
;
|
. $caption
|
||||||
}
|
. "</a></li>\n";
|
||||||
return $result . "\t</ul>\n";
|
}
|
||||||
|
|
||||||
|
return $result . "\t</ul>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginBar($sp = null, $pdo = null) {
|
function loginBar($sp = null, $pdo = null) {
|
||||||
if (is_null($sp)) $sp = 'default-sp';
|
if (null === $sp) {
|
||||||
$result = "\n";
|
$sp = 'default-sp';
|
||||||
require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
}
|
||||||
$as = new \SimpleSAML\Auth\Simple($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" />
|
<circle cx="32" cy="27" r="14" stroke-width="0" />
|
||||||
<ellipse cx="32" cy="66" rx="24" ry="28" stroke-width="0" />
|
<ellipse cx="32" cy="66" rx="24" ry="28" stroke-width="0" />
|
||||||
</svg>
|
</svg>
|
||||||
';
|
';
|
||||||
|
|
||||||
$attr = $as->getAttributes();
|
$attr = $as->getAttributes();
|
||||||
if($attr) {
|
if ($attr) {
|
||||||
$uname = $attr['uid'][0];
|
$uname = $attr['uid'][0];
|
||||||
$isAdmin = false;
|
$isAdmin = false;
|
||||||
if (isset($pdo)) {
|
if (isset($pdo)) {
|
||||||
$userManager = new \pvv\admin\UserManager($pdo);
|
$userManager = new pvv\admin\UserManager($pdo);
|
||||||
$isAdmin = $userManager->isAdmin($uname);
|
$isAdmin = $userManager->isAdmin($uname);
|
||||||
}
|
}
|
||||||
$result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">{$svg}" . htmlspecialchars($uname) . "</a>\n";
|
$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<ul id=\"usermenu\">\n";
|
||||||
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
|
||||||
if ($isAdmin) {
|
if ($isAdmin) {
|
||||||
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
|
$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\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
|
||||||
$result .= "\n\t</ul>\n";
|
$result .= "\n\t</ul>\n";
|
||||||
} else {
|
} else {
|
||||||
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">{$svg}Logg inn</a>\n";
|
$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
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014-2015, Jørn Åne de Jong <@jornane>
|
* 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
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/**
|
/*
|
||||||
* Register SPL autoloading for classes and interfaces. Put this file in your
|
* 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.
|
* 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
|
* @link http://php.net/manual/en/function.spl-autoload.php
|
||||||
* @license http://choosealicense.com/licenses/isc/ ISC license
|
* @license http://choosealicense.com/licenses/isc/ ISC license
|
||||||
*/
|
*/
|
||||||
spl_autoload_extensions( '.php' );
|
spl_autoload_extensions('.php');
|
||||||
spl_autoload_register( 'spl_autoload' );
|
spl_autoload_register('spl_autoload');
|
||||||
set_include_path( realpath( __DIR__ ) . PATH_SEPARATOR . get_include_path() );
|
set_include_path(realpath(__DIR__) . \PATH_SEPARATOR . get_include_path());
|
||||||
|
@ -1,134 +1,138 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\admin;
|
namespace pvv\admin;
|
||||||
|
|
||||||
use \PDO;
|
class UserManager {
|
||||||
|
private $pdo;
|
||||||
|
|
||||||
class UserManager{
|
public $usergroups = [
|
||||||
private $pdo;
|
'admin' => 1,
|
||||||
|
'prosjekt' => 2,
|
||||||
|
'aktiviteter' => 4,
|
||||||
|
];
|
||||||
|
|
||||||
public $usergroups = [
|
public function __construct($pdo) {
|
||||||
'admin' => 1,
|
$this->pdo = $pdo;
|
||||||
'prosjekt' => 2,
|
}
|
||||||
'aktiviteter' => 4
|
|
||||||
];
|
|
||||||
|
|
||||||
public function __construct($pdo){
|
public function setupUser($uname, $groups = 0): void {
|
||||||
$this->pdo = $pdo;
|
$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){
|
public function updateFlags($uname, $flags): void {
|
||||||
$query = 'INSERT INTO users (uname, groups) VALUES (:uname, :groups)';
|
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
$statement->bindParam(':groups', $flags, \PDO::PARAM_INT);
|
||||||
$statement->bindParam(':groups', $groups, PDO::PARAM_INT);
|
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function updateFlags($uname, $flags){
|
public function addGroup($uname, $group): void {
|
||||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
$userFlags = $this->getUsergroups($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){
|
if ($userFlags) {
|
||||||
$userFlags = $this->getUsergroups($uname);
|
$newFlags = ($group | $userFlags);
|
||||||
|
$this->updateFlags($uname, $newFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($userFlags){
|
public function removeGroup($uname, $group): void {
|
||||||
$newFlags = ($group | $userFlags);
|
$userFlags = $this->getUsergroups($uname);
|
||||||
$this->updateFlags($uname, $newFlags);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function removeGroup($uname, $group){
|
if ($userFlags) {
|
||||||
$userFlags = $this->getUsergroups($uname);
|
$newFlags = ($userFlags & (~ $group));
|
||||||
|
$this->updateFlags($uname, $newFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($userFlags){
|
public function setGroups($uname, $groups): void {
|
||||||
$newFlags = ($userFlags & (~ $group));
|
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||||
$this->updateFlags($uname, $newFlags);
|
$statement = $this->pdo->prepare($query);
|
||||||
}
|
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||||
}
|
$statement->execute();
|
||||||
|
$row = $statement->fetch();
|
||||||
|
|
||||||
public function setGroups($uname, $groups){
|
if ($row) {
|
||||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||||
$statement->execute();
|
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||||
$row = $statement->fetch();
|
$statement->execute();
|
||||||
|
} else {
|
||||||
|
$this->setupUser($uname, $groups);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($row){
|
public function hasGroup($uname, $groupName) {
|
||||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
$userFlags = $this->getUsergroups($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){
|
return $userFlags & $this->usergroups[$groupName];
|
||||||
$userFlags = $this->getUsergroups($uname);
|
}
|
||||||
|
|
||||||
return ($userFlags & $this->usergroups[$groupName]);
|
// for convenience
|
||||||
}
|
public function isAdmin($uname) {
|
||||||
|
return $this->hasGroup($uname, 'admin');
|
||||||
|
}
|
||||||
|
|
||||||
// for convenience
|
public function getFlagfromNames($names) {
|
||||||
public function isAdmin($uname){
|
$resultFlag = 0;
|
||||||
return $this->hasGroup($uname, 'admin');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFlagfromNames($names){
|
foreach ($this->usergroups as $name => $flag) {
|
||||||
$resultFlag = 0;
|
if (\in_array($name, $names, true)) {
|
||||||
|
$resultFlag = ($resultFlag | $flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach($this->usergroups as $name => $flag){
|
return $resultFlag;
|
||||||
if(in_array($name, $names)){
|
}
|
||||||
$resultFlag = ($resultFlag | $flag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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){
|
$row = $statement->fetch();
|
||||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
if ($row == false) {
|
||||||
$statement = $this->pdo->prepare($query);
|
return 0;
|
||||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
}
|
||||||
$statement->execute();
|
|
||||||
|
|
||||||
$row = $statement->fetch();
|
return $row[0];
|
||||||
if ($row == false) return 0;
|
}
|
||||||
return $row[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUsergroupNames($uname){
|
public function getUsergroupNames($uname) {
|
||||||
$usersGroups = [];
|
$usersGroups = [];
|
||||||
|
|
||||||
$userFlags = $this->getUsergroups($uname);
|
$userFlags = $this->getUsergroups($uname);
|
||||||
|
|
||||||
foreach($this->usergroups as $name => $flag){
|
foreach ($this->usergroups as $name => $flag) {
|
||||||
if($userFlags & $flag){
|
if ($userFlags & $flag) {
|
||||||
$usersGroups[] = $name;
|
$usersGroups[] = $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $usersGroups;
|
return $usersGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllUserData(){
|
public function getAllUserData() {
|
||||||
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
$query = 'SELECT uname FROM users ORDER BY uname ASC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$users = [];
|
$users = [];
|
||||||
foreach($statement->fetchAll() as $userData){
|
foreach ($statement->fetchAll() as $userData) {
|
||||||
$uname = $userData['uname'];
|
$uname = $userData['uname'];
|
||||||
$users[] = [
|
$users[] = [
|
||||||
'name' => $uname,
|
'name' => $uname,
|
||||||
'groups' => $this->getUsergroupNames($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;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \DateTimeImmutable;
|
|
||||||
|
|
||||||
interface Activity {
|
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;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class Agenda {
|
class Agenda {
|
||||||
|
|
||||||
private $activities;
|
private $activities;
|
||||||
|
|
||||||
const TODAY = 0;
|
public const TODAY = 0;
|
||||||
const TOMORROW = 1;
|
public const TOMORROW = 1;
|
||||||
const THIS_WEEK = 2;
|
public const THIS_WEEK = 2;
|
||||||
const NEXT_WEEK = 3;
|
public const NEXT_WEEK = 3;
|
||||||
const THIS_MONTH = 4;
|
public const THIS_MONTH = 4;
|
||||||
const NEXT_MONTH = 5;
|
public const NEXT_MONTH = 5;
|
||||||
|
|
||||||
public function __construct($activities) {
|
public function __construct($activities) {
|
||||||
$this->activities = $activities;
|
$this->activities = $activities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFormattedDate($date) {
|
public static function getFormattedDate($date) {
|
||||||
return $date->format("l j. M H.i");
|
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) {
|
return $result;
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNextDays() {
|
public function getNextOfEach(\DateTimeImmutable $startDate) {
|
||||||
$result = [[], [], [], [], [], []];
|
$result = array_filter(array_map(
|
||||||
$events = $this->getEventsBetween(
|
static fn($a) => $a->getNextEventFrom($startDate),
|
||||||
(new DateTimeImmutable)->setTime(0, 0),
|
$this->activities
|
||||||
(new DateTimeImmutable)->setTime(23, 59)->add(new DateInterval('P1M'))
|
), static fn($a) => isset($a));
|
||||||
);
|
usort(
|
||||||
foreach ($events as $event) {
|
$result,
|
||||||
$index = self::NEXT_MONTH;
|
static fn($a, $b) => ($a->getStart()->getTimeStamp() < $b->getStart()->getTimeStamp())
|
||||||
if (self::isToday($event->getStart())) $index = self::TODAY;
|
? -1
|
||||||
elseif (self::isTomorrow($event->getStart())) $index = self::TOMORROW;
|
: 1
|
||||||
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) {
|
return $result;
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function isToday(DateTimeImmutable $date) {
|
public static function isToday(\DateTimeImmutable $date) {
|
||||||
return $date->format('dmY') == date('dmY');
|
return $date->format('dmY') == date('dmY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isTomorrow(DateTimeImmutable $date) {
|
public static function isTomorrow(\DateTimeImmutable $date) {
|
||||||
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) {
|
public static function isThisWeek(\DateTimeImmutable $date) {
|
||||||
return $date->format('WY') == date('WY');
|
return $date->format('WY') == date('WY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isNextWeek(DateTimeImmutable $date) {
|
public static function isNextWeek(\DateTimeImmutable $date) {
|
||||||
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) {
|
|
||||||
return $date->format('mY') == date('mY');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static function isThisMonth(\DateTimeImmutable $date) {
|
||||||
|
return $date->format('mY') == date('mY');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,85 +1,83 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace pvv\side;
|
|
||||||
|
|
||||||
use \DateTimeImmutable;
|
declare(strict_types=1);
|
||||||
use \PDO;
|
|
||||||
|
namespace pvv\side;
|
||||||
|
|
||||||
class DBActivity implements Activity {
|
class DBActivity implements Activity {
|
||||||
private $pdo;
|
private $pdo;
|
||||||
|
|
||||||
public function __construct(PDO $pdo) {
|
public function __construct(\PDO $pdo) {
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllEvents() {
|
public function getAllEvents() {
|
||||||
$query = 'SELECT * FROM events ORDER BY id DESC';
|
$query = 'SELECT * FROM events ORDER BY id DESC';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$events = [];
|
$events = [];
|
||||||
foreach($statement->fetchAll() as $dbEvent){
|
foreach ($statement->fetchAll() as $dbEvent) {
|
||||||
$event = new SimpleEvent(
|
$event = new SimpleEvent(
|
||||||
$dbEvent['id'],
|
$dbEvent['id'],
|
||||||
$dbEvent['name'],
|
$dbEvent['name'],
|
||||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['start']),
|
||||||
DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
\DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $dbEvent['stop']),
|
||||||
$dbEvent['organiser'],
|
$dbEvent['organiser'],
|
||||||
$dbEvent['location'],
|
$dbEvent['location'],
|
||||||
$dbEvent['description']
|
$dbEvent['description']
|
||||||
);
|
);
|
||||||
$events[] = $event;
|
$events[] = $event;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEventByID($id) {
|
public function getEventByID($id) {
|
||||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$dbEvent = $statement->fetch();
|
$dbEvent = $statement->fetch();
|
||||||
$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']
|
|
||||||
);
|
|
||||||
|
|
||||||
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) {
|
return $this->retrieve($date, $query);
|
||||||
$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) {
|
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';
|
$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($date, $query) {
|
return $this->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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \PDO;
|
class Door {
|
||||||
|
private $pdo;
|
||||||
|
|
||||||
class Door{
|
public function __construct(\PDO $pdo) {
|
||||||
private $pdo;
|
$this->pdo = $pdo;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(PDO $pdo){
|
public function getAll() {
|
||||||
$this->pdo = $pdo;
|
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
||||||
}
|
$statement = $this->pdo->prepare($query);
|
||||||
|
$statement->execute();
|
||||||
|
|
||||||
public function getAll() {
|
$doorEvents = [];
|
||||||
$query = 'SELECT time, open FROM door ORDER BY time DESC';
|
foreach ($statement->fetchAll() as $row) {
|
||||||
$statement = $this->pdo->prepare($query);
|
$doorEvents[] = [
|
||||||
$statement->execute();
|
'time' => (int) $row['time'],
|
||||||
|
'open' => (bool) $row['open'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$doorEvents = [];
|
return $doorEvents;
|
||||||
foreach($statement->fetchAll() as $row){
|
}
|
||||||
$doorEvents[] = [
|
|
||||||
'time' => (int)$row['time'],
|
|
||||||
'open' => (bool)$row['open']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
$doorEvents = [];
|
||||||
$query = 'SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC';
|
foreach ($statement->fetchAll() as $row) {
|
||||||
$statement = $this->pdo->prepare($query);
|
$doorEvents[] = [
|
||||||
$statement->bindParam(':startTime', $startTime, PDO::PARAM_STR);
|
'time' => (int) $row['time'],
|
||||||
$statement->execute();
|
'open' => (bool) $row['open'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$doorEvents = [];
|
return $doorEvents;
|
||||||
foreach($statement->fetchAll() as $row){
|
}
|
||||||
$doorEvents[] = [
|
|
||||||
'time' => (int)$row['time'],
|
|
||||||
'open' => (bool)$row['open']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
return [
|
||||||
$query = 'SELECT time, open FROM door ORDER BY time DESC LIMIT 1';
|
'time' => (int) $row['time'],
|
||||||
$statement = $this->pdo->prepare($query);
|
'open' => (bool) $row['open'],
|
||||||
$statement->execute();
|
];
|
||||||
$row = $statement->fetch();
|
}
|
||||||
return [
|
|
||||||
'time' => (int)$row['time'],
|
|
||||||
'open' => (bool)$row['open']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function removeOld() {
|
private function removeOld(): void {
|
||||||
$firstValidTime = time() - 60*60*24*7; //One week before now
|
$firstValidTime = time() - 60 * 60 * 24 * 7; // One week before now
|
||||||
$query = 'DELETE FROM door WHERE time < :firstValid';
|
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':firstValid', $firstValidTime, PDO::PARAM_STR);
|
$statement->bindParam(':firstValid', $firstValidTime, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createEvent($time, $open) {
|
public function createEvent($time, $open): void {
|
||||||
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||||
$statement = $this->pdo->prepare($query);
|
$statement = $this->pdo->prepare($query);
|
||||||
$statement->bindParam(':time', $time, PDO::PARAM_STR);
|
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
||||||
$statement->bindParam(':open', $open, PDO::PARAM_STR);
|
$statement->bindParam(':open', $open, \PDO::PARAM_STR);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
|
|
||||||
$this->removeOld();
|
$this->removeOld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,53 +1,55 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
abstract class Event {
|
abstract class Event {
|
||||||
|
private $start;
|
||||||
|
|
||||||
private $start;
|
public function __construct(\DateTimeImmutable $start) {
|
||||||
|
$this->start = $start;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(DateTimeImmutable $start) {
|
public function getStart() {
|
||||||
$this->start = $start;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart() {
|
public function getRelativeDate() {
|
||||||
return $this->start;
|
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() {
|
return $this->getStart()->format('j. F');
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \PDO;
|
class MOTD {
|
||||||
|
private $pdo;
|
||||||
|
|
||||||
class MOTD{
|
public function __construct($pdo) {
|
||||||
private $pdo;
|
$this->pdo = $pdo;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct($pdo){
|
public function setMOTD($title, $content): void {
|
||||||
$this->pdo = $pdo;
|
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) {
|
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
|
||||||
if (is_array($content)) {
|
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
|
||||||
$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->execute();
|
||||||
$statement->bindParam(':content', $content, PDO::PARAM_STR);
|
}
|
||||||
|
|
||||||
$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);
|
||||||
public function getMOTD() {
|
$statement->execute();
|
||||||
$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();
|
$data = $statement->fetch();
|
||||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
|
||||||
|
|
||||||
return $motd;
|
return ['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();
|
|
||||||
|
|
||||||
$data = $statement->fetch();
|
public function getMOTD_history($limit = 5) {
|
||||||
$motd = array("title" => $data[0], "content" => explode("\n", $data[1]));
|
$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
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
class Project{
|
class Project {
|
||||||
private $id, $name, $descr, $active;
|
private $id;
|
||||||
|
private $name;
|
||||||
|
private $descr;
|
||||||
|
private $active;
|
||||||
|
|
||||||
public function __construct($id, $name, $descr, $active){
|
public function __construct($id, $name, $descr, $active) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->descr = explode("\n", $descr);
|
$this->descr = explode("\n", $descr);
|
||||||
$this->active = $active;
|
$this->active = $active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getID(){
|
public function getID() {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName() {
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription(){
|
public function getDescription() {
|
||||||
return $this->descr;
|
return $this->descr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActive(){
|
public function getActive() {
|
||||||
return $this->active;
|
return $this->active;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,121 +1,120 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
use \PDO;
|
class ProjectManager {
|
||||||
|
private $pdo;
|
||||||
|
|
||||||
class ProjectManager{
|
public function __construct(\PDO $pdo) {
|
||||||
private $pdo;
|
$this->pdo = $pdo;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(PDO $pdo){
|
public function getAll() {
|
||||||
$this->pdo = $pdo;
|
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||||
}
|
$statement = $this->pdo->prepare($query);
|
||||||
|
$statement->execute();
|
||||||
|
|
||||||
public function getAll() {
|
$projects = [];
|
||||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
foreach ($statement->fetchAll() as $dbProj) {
|
||||||
$statement = $this->pdo->prepare($query);
|
$project = new Project(
|
||||||
$statement->execute();
|
$dbProj['id'],
|
||||||
|
$dbProj['name'],
|
||||||
|
$dbProj['description'],
|
||||||
|
$dbProj['active']
|
||||||
|
);
|
||||||
|
$projects[] = $project;
|
||||||
|
}
|
||||||
|
|
||||||
$projects = [];
|
return $projects;
|
||||||
foreach($statement->fetchAll() as $dbProj){
|
}
|
||||||
$project = new Project(
|
|
||||||
$dbProj['id'],
|
|
||||||
$dbProj['name'],
|
|
||||||
$dbProj['description'],
|
|
||||||
$dbProj['active']
|
|
||||||
);
|
|
||||||
$projects[] = $project;
|
|
||||||
}
|
|
||||||
|
|
||||||
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){
|
$dbProj = $statement->fetch();
|
||||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
if (!$dbProj) {
|
||||||
$statement = $this->pdo->prepare($query);
|
return false;
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
}
|
||||||
$statement->execute();
|
|
||||||
|
|
||||||
$dbProj = $statement->fetch();
|
return new Project(
|
||||||
if (!$dbProj) {
|
$dbProj['id'],
|
||||||
return false;
|
$dbProj['name'],
|
||||||
}
|
$dbProj['description'],
|
||||||
$project = new Project(
|
$dbProj['active']
|
||||||
$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){
|
$projectIDs = $statement->fetchAll();
|
||||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
$projects = [];
|
||||||
$statement = $this->pdo->prepare($query);
|
foreach ($projectIDs as $id) {
|
||||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
$id = $id['projectid'];
|
||||||
$statement->execute();
|
|
||||||
|
|
||||||
$projectIDs = $statement->fetchAll();
|
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||||
$projects = [];
|
$statement = $this->pdo->prepare($query);
|
||||||
foreach($projectIDs as $id){
|
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||||
$id = $id['projectid'];
|
$statement->execute();
|
||||||
|
|
||||||
$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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $projects;
|
foreach ($statement->fetchAll() as $dbProj) {
|
||||||
}
|
$project = new Project(
|
||||||
|
$dbProj['id'],
|
||||||
|
$dbProj['name'],
|
||||||
|
$dbProj['description'],
|
||||||
|
$dbProj['active']
|
||||||
|
);
|
||||||
|
$projects[] = $project;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getProjectMembers($id){
|
return $projects;
|
||||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
}
|
||||||
$statement = $this->pdo->prepare($query);
|
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
|
||||||
$statement->execute();
|
|
||||||
|
|
||||||
$members = [];
|
public function getProjectMembers($id) {
|
||||||
foreach($statement->fetchAll() as $dbUsr){
|
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||||
$members[] = [
|
$statement = $this->pdo->prepare($query);
|
||||||
'name' => $dbUsr['name'],
|
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||||
'uname' => $dbUsr['uname'],
|
$statement->execute();
|
||||||
'mail' => $dbUsr['mail'],
|
|
||||||
'role' => $dbUsr['role'],
|
|
||||||
'lead' => $dbUsr['lead'],
|
|
||||||
'owner' => $dbUsr['owner']
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
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){
|
return $members;
|
||||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
}
|
||||||
$statement = $this->pdo->prepare($query);
|
|
||||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
|
||||||
$statement->execute();
|
|
||||||
|
|
||||||
$dbOwner = $statement->fetch();
|
public function getProjectOwner($id) {
|
||||||
$owner = [
|
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||||
'name' => $dbOwner['name'],
|
$statement = $this->pdo->prepare($query);
|
||||||
'uname' => $dbOwner['uname'],
|
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||||
'mail' => $dbOwner['mail'],
|
$statement->execute();
|
||||||
'role' => $dbOwner['role'],
|
|
||||||
'lead' => $dbOwner['lead'],
|
|
||||||
'owner' => $dbOwner['owner']
|
|
||||||
];
|
|
||||||
|
|
||||||
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
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side;
|
namespace pvv\side;
|
||||||
|
|
||||||
class SimpleEvent extends Event {
|
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){
|
public function getID() {
|
||||||
$this->id = $id;
|
return $this->id;
|
||||||
$this->name = $name;
|
}
|
||||||
$this->start = $start;
|
|
||||||
$this->end = $end;
|
|
||||||
$this->org = $org;
|
|
||||||
$this->loc = $loc;
|
|
||||||
$this->descr = explode("\n", $descr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getID(){
|
public function getStart() {
|
||||||
return $this->id;
|
return $this->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart(){
|
public function getStop() {
|
||||||
return $this->start;
|
return $this->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStop(){
|
public function getOrganiser() {
|
||||||
return $this->end;
|
return $this->org;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser(){
|
public function getLocation() {
|
||||||
return $this->org;
|
return $this->loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation(){
|
public function getName() {
|
||||||
return $this->loc;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getURL() {
|
||||||
return $this->name;
|
return '/hendelser/info.php?id=' . $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() {
|
public function getImageURL(): void {}
|
||||||
return ('/hendelser/info.php?id=' . $this->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return null;
|
return $this->descr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
|
||||||
return $this->descr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getColor() {
|
|
||||||
return "#3b7";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return '#3b7';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,41 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class AnimekveldActivity implements 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) {
|
return $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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prevDate(DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 19 || $date->format('H') == 20 && $date->format('i') < 30)
|
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));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 30, 0));
|
||||||
$date = $date->setTime(19, 30, 0);
|
}
|
||||||
if ($date->format('N') != 5)
|
$date = $date->setTime(19, 30, 0);
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
if ($date->format('N') != 5) {
|
||||||
return $date;
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
return $date;
|
||||||
return new AnimekveldEvent($this->nextDate($date));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||||
return new AnimekveldEvent($this->prevDate($date));
|
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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class AnimekveldEvent extends Event {
|
class AnimekveldEvent extends Event {
|
||||||
|
public function getStop() {
|
||||||
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getStop() {
|
public function getName() { /* : string */
|
||||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
return 'Animekveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() /* : string */ {
|
public function getLocation() { /* : Location */
|
||||||
return "Animekveld";
|
return 'Koserommet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation() /* : Location */ {
|
public function getOrganiser() { /* : User */
|
||||||
return "Koserommet";
|
return 'Christoffer Viken';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser() /* : User */ {
|
public function getURL() { /* : string */
|
||||||
return "Christoffer Viken";
|
return '/anime/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() /* : string */ {
|
public function getImageURL() {
|
||||||
return '/anime/';
|
return '/sosiale/animekveld.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return '/sosiale/animekveld.jpg';
|
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!',
|
||||||
public function getDescription() {
|
'',
|
||||||
return [
|
'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() {
|
|
||||||
return "#35a";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return '#35a';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,47 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class BrettspillActivity implements 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) {
|
return $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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prevDate(DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 16 || $date->format('H') == 17 && $date->format('i') < 15)
|
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));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(16, 15, 0));
|
||||||
$date = $date->setTime(16, 15, 0);
|
}
|
||||||
if ($date->format('N') != 7)
|
$date = $date->setTime(16, 15, 0);
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
if ($date->format('N') != 7) {
|
||||||
if ($date->format('W') % 2 - 1)
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
}
|
||||||
|
if ($date->format('W') % 2 - 1) {
|
||||||
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
|
}
|
||||||
|
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||||
return new BrettspillEvent($this->nextDate($date));
|
return new BrettspillEvent($this->nextDate($date));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
|
||||||
return new BrettspillEvent($this->prevDate($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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class BrettspillEvent extends Event {
|
class BrettspillEvent extends Event {
|
||||||
|
public function getStop() {
|
||||||
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getStop() {
|
public function getName() { /* : string */
|
||||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
return 'Brettspillkveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() /* : string */ {
|
public function getLocation() { /* : Location */
|
||||||
return "Brettspillkveld";
|
return 'Programvareverkstedet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation() /* : Location */ {
|
public function getOrganiser() { /* : User */
|
||||||
return "Programvareverkstedet";
|
return 'Programvareverkstedet';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser() /* : User */ {
|
public function getURL() { /* : string */
|
||||||
return "Programvareverkstedet";
|
return '/brettspill/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() /* : string */ {
|
public function getImageURL() {
|
||||||
return '/brettspill/';
|
return '/sosiale/brettspill.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return '/sosiale/brettspill.jpg';
|
return [
|
||||||
}
|
'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? ' .
|
||||||
|
'Da er vår brettspillkveld noe for deg! ' .
|
||||||
public function getDescription() {
|
'Vi tar ut et par spill fra vårt samling of spiller så mye vi orker. Kom innom!',
|
||||||
return [
|
'',
|
||||||
'Er du en hardcore brettspillentusiast eller en nybegynner som har så vidt spilt ludo? '.
|
'## Vår samling',
|
||||||
'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!',
|
'* Dominion\*',
|
||||||
'',
|
'* Three cheers for master',
|
||||||
'## Vår samling',
|
'* Avalon',
|
||||||
'',
|
'* Hanabi',
|
||||||
'* Dominion\*',
|
'* Cards aginst humanity\*',
|
||||||
'* Three cheers for master',
|
'* Citadels',
|
||||||
'* Avalon',
|
'* Munchkin\*\*',
|
||||||
'* Hanabi',
|
'* Exploding kittens\*\*',
|
||||||
'* Cards aginst humanity\*',
|
'* Aye dark overlord',
|
||||||
'* Citadels',
|
'* Settlers of catan\*',
|
||||||
'* Munchkin\*\*',
|
'* Risk\*\*',
|
||||||
'* Exploding kittens\*\*',
|
'* og mange flere...',
|
||||||
'* Aye dark overlord',
|
'',
|
||||||
'* Settlers of catan\*',
|
'\* Vi har flere ekspansjoner til spillet',
|
||||||
'* Risk\*\*',
|
'',
|
||||||
'* og mange flere...',
|
'\*\* Vi har flere varianter av spillet',
|
||||||
'',
|
];
|
||||||
'\* Vi har flere ekspansjoner til spillet',
|
}
|
||||||
'',
|
|
||||||
'\*\* Vi har flere varianter av spillet',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getColor() {
|
|
||||||
return "#000";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
return '#000';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class DriftkveldActivity implements 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) {
|
return $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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prevDate(DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
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));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
$date = $date->setTime(18, 15, 0);
|
}
|
||||||
if ($date->format('N') != 6)
|
$date = $date->setTime(18, 15, 0);
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
if ($date->format('N') != 6) {
|
||||||
if ($date->format('W') % 2 - 1)
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
}
|
||||||
return $date;
|
if ($date->format('W') % 2 - 1) {
|
||||||
}
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
return $date;
|
||||||
return new DriftkveldEvent($this->nextDate($date));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||||
return new DriftkveldEvent($this->prevDate($date));
|
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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class DriftkveldEvent extends Event {
|
class DriftkveldEvent extends Event {
|
||||||
|
public function getStop() {
|
||||||
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getStop() {
|
public function getName() { /* : string */
|
||||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
return 'Driftkveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() /* : string */ {
|
public function getLocation() { /* : Location */
|
||||||
return "Driftkveld";
|
return 'Terminalrommet / Discord / IRC';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation() /* : Location */ {
|
public function getOrganiser() { /* : User */
|
||||||
return "Terminalrommet / Discord / IRC";
|
return 'Torstein Nordgård-Hansen';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser() /* : User */ {
|
public function getURL() { /* : string */
|
||||||
return "Torstein Nordgård-Hansen";
|
return '/driftkveld/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() /* : string */ {
|
public function getImageURL() {
|
||||||
return '/driftkveld/';
|
return '/sosiale/drift.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return '/sosiale/drift.jpg';
|
return [
|
||||||
}
|
'Vil du drifte?',
|
||||||
|
'Vil du være kul kis TM?',
|
||||||
public function getDescription() {
|
'Kom på driftkveld!',
|
||||||
return [
|
'',
|
||||||
'Vil du drifte?',
|
'Vi møtes annenhver uke for å ta unna driftarbeid og drikke kaffe.',
|
||||||
'Vil du være kul kis TM?',
|
'Alle PVVere er velkommene, enten de er erfarne driftere eller helt utenforstående!',
|
||||||
'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 getColor() {
|
||||||
|
return '#35a';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class HackekveldActivity implements 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) {
|
return $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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prevDate(DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 17 || $date->format('H') == 18 && $date->format('i') < 30)
|
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));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(18, 15, 0));
|
||||||
$date = $date->setTime(18, 15, 0);
|
}
|
||||||
if ($date->format('N') != 6)
|
$date = $date->setTime(18, 15, 0);
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
if ($date->format('N') != 6) {
|
||||||
if ($date->format('W') % 2)
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
}
|
||||||
return $date;
|
if ($date->format('W') % 2) {
|
||||||
}
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
return $date;
|
||||||
return new HackekveldEvent($this->nextDate($date));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||||
return new HackekveldEvent($this->prevDate($date));
|
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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class HackekveldEvent extends Event {
|
class HackekveldEvent extends Event {
|
||||||
|
public function getStop() {
|
||||||
|
return $this->getStart()->add(new \DateInterval('PT4H1800S'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getStop() {
|
public function getName() { /* : string */
|
||||||
return $this->getStart()->add(new DateInterval('PT4H1800S'));
|
return 'Hackekveld';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() /* : string */ {
|
public function getLocation() { /* : Location */
|
||||||
return "Hackekveld";
|
return 'Terminalrommet / Discord / IRC';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation() /* : Location */ {
|
public function getOrganiser() { /* : User */
|
||||||
return "Terminalrommet / Discord / IRC";
|
return 'PVV';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser() /* : User */ {
|
public function getURL() { /* : string */
|
||||||
return "PVV";
|
return '#';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() /* : string */ {
|
public function getImageURL() {
|
||||||
return '#';
|
return '/pvv-logo.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return '/pvv-logo.png';
|
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 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 getColor() {
|
||||||
|
return '#35a';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,47 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Activity;
|
use pvv\side\Activity;
|
||||||
use \DateTimeImmutable;
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class NerdepitsaActivity implements 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) {
|
return $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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prevDate(DateTimeImmutable $date) {
|
public function prevDate(\DateTimeImmutable $date) {
|
||||||
if ($date->format('H') < 19)
|
if ($date->format('H') < 19) {
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D'))->setTime(19, 0, 0));
|
return $this->prevDate($date->sub(new \DateInterval('P1D'))->setTime(19, 0, 0));
|
||||||
$date = $date->setTime(19, 0, 0);
|
}
|
||||||
if ($date->format('N') != 5)
|
$date = $date->setTime(19, 0, 0);
|
||||||
return $this->prevDate($date->sub(new DateInterval('P1D')));
|
if ($date->format('N') != 5) {
|
||||||
if ($date->format('W') % 2)
|
return $this->prevDate($date->sub(new \DateInterval('P1D')));
|
||||||
return $this->prevDate($date->sub(new DateInterval('P7D')));
|
}
|
||||||
return $date;
|
if ($date->format('W') % 2) {
|
||||||
}
|
return $this->prevDate($date->sub(new \DateInterval('P7D')));
|
||||||
|
}
|
||||||
|
|
||||||
public function getNextEventFrom(DateTimeImmutable $date) /* : Event */ {
|
return $date;
|
||||||
return new NerdepitsaEvent($this->nextDate($date));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function getPreviousEventFrom(DateTimeImmutable $date) /* : Event */ {
|
public function getNextEventFrom(\DateTimeImmutable $date) { /* : Event */
|
||||||
return new NerdepitsaEvent($this->prevDate($date));
|
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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
use \pvv\side\Event;
|
use pvv\side\Event;
|
||||||
|
|
||||||
use \DateInterval;
|
|
||||||
|
|
||||||
class NerdepitsaEvent extends Event {
|
class NerdepitsaEvent extends Event {
|
||||||
|
public function getStop() {
|
||||||
|
return $this->getStart()->add(new \DateInterval('PT2H1800S'));
|
||||||
|
}
|
||||||
|
|
||||||
public function getStop() {
|
public function getName() {
|
||||||
return $this->getStart()->add(new DateInterval('PT2H1800S'));
|
return 'Nerdepitsa';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getLocation() { /* : Location */
|
||||||
return "Nerdepitsa";
|
return 'Peppes Kjøpmansgata';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocation() /* : Location */ {
|
public function getOrganiser() { /* : User */
|
||||||
return "Peppes Kjøpmansgata";
|
return 'Anders Christensen';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrganiser() /* : User */ {
|
public function getURL() { /* : string */
|
||||||
return "Anders Christensen";
|
return '/nerdepitsa/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURL() /* : string */ {
|
public function getImageURL() {
|
||||||
return '/nerdepitsa/';
|
return '/sosiale/nerdepitsa.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImageURL() {
|
public function getDescription() {
|
||||||
return '/sosiale/nerdepitsa.jpg';
|
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!',
|
||||||
|
'',
|
||||||
public function getDescription() {
|
'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.',
|
||||||
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!',
|
'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 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.',
|
'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!',
|
||||||
'',
|
];
|
||||||
'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 getColor() {
|
||||||
|
return '#c35';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php //declare(strict_types=1);
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace pvv\side\social;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
ini_set('date.timezone', 'Europe/Oslo');
|
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;
|
$c = new AnimekveldActivity();
|
||||||
die($c->nextDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
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;
|
namespace pvv\side\social;
|
||||||
|
|
||||||
ini_set('date.timezone', 'Europe/Oslo');
|
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;
|
$c = new NerdepitsaActivity();
|
||||||
die($c->prevDate(new \DateTimeImmutable)->format(DATE_RFC2822));
|
exit($c->prevDate(new \DateTimeImmutable())->format(\DATE_RFC2822));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user