4 Commits

42 changed files with 2324 additions and 736 deletions

1
.gitignore vendored
View File

@@ -5,4 +5,5 @@
/test.sql
/vendor/
/www/simplesaml
/www/simplesaml-idp
composer.phar

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "lib/OAuth2-Client"]
path = lib/OAuth2-Client
url = https://github.com/UNINETT/OAuth2-Client.git

21
dist/identity-provider/authsources.php vendored Normal file
View File

@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
$config = [
'admin' => [
'core:AdminPassword',
],
'example-userpass' => [
'exampleauth:UserPass',
'users' => [
'user:user' => [
'uid' => ['user'],
'eduPersonAffiliation' => ['member', 'student'],
],
'admin:admin' => [
'uid' => ['admin'],
'eduPersonAffiliation' => ['member', 'employee'],
],
],
],
];

1411
dist/identity-provider/config.php vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
$metadata['http://localhost:1080/simplesaml-idp/'] = [
'host' => '__DEFAULT__',
'privatekey' => 'localhost.pem',
'certificate' => 'localhost.crt',
'auth' => 'example-userpass',
];

View File

@@ -0,0 +1,16 @@
<?php
$metadata['http://localhost:1080/simplesaml/module.php/saml/sp/metadata.php/default-sp'] = [
'AssertionConsumerService' => [
[
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-acs.php/default-sp',
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',
],
],
'SingleLogoutService' => [
[
'Location' => 'http://localhost:1080/simplesaml/module.php/saml/sp/saml2-logout.php/default-sp',
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
],
],
];

63
dist/pvv_mysql.sql vendored
View File

@@ -1,63 +0,0 @@
CREATE TABLE events (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`name` TEXT,
`start` TEXT,
`stop` TEXT,
`organiser` TEXT,
`location` TEXT,
`description` TEXT
);
CREATE TABLE project_group (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`title` TEXT NOT NULL,
`description_en` TEXT NOT NULL,
`description_no` TEXT NOT NULL,
`gitea_link` TEXT NOT NULL,
`wiki_link` TEXT
);
CREATE TABLE project (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`group_id` INTEGER NOT NULL REFERENCES project_group (id),
`title` TEXT NOT NULL,
`description_en` TEXT NOT NULL,
`description_no` TEXT NOT NULL,
`gitea_link` TEXT NOT NULL,
`issue_board_link` TEXT NOT NULL,
`wiki_link` TEXT,
`languages` TEXT,
`technologies` TEXT,
`keywords` TEXT,
`license` TEXT,
`logo_url` TEXT,
FOREIGN KEY (group_id) REFERENCES project_group (id)
);
CREATE TABLE project_maintainer (
`uname` TEXT PRIMARY KEY,
`name` TEXT NOT NULL,
`link` TEXT NOT NULL,
`mail` TEXT NOT NULL,
FOREIGN KEY (project_id) REFERENCES project (id),
FOREIGN KEY (uname) REFERENCES maintainer (uname),
);
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
CREATE TABLE motd (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`title` TEXT,
`content` TEXT
);
/*
INSERT INTO motd (title, content)
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
*/
CREATE TABLE door (`time` INTEGER PRIMARY KEY, `open` BOOLEAN);
INSERT INTO
door (time, open)
VALUES
(0, FALSE);

75
dist/pvv_sqlite.sql vendored
View File

@@ -1,75 +0,0 @@
CREATE TABLE "events" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" TEXT,
"start" TEXT,
"stop" TEXT,
"organiser" TEXT,
"location" TEXT,
"description" TEXT
);
CREATE TABLE "project_group" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"title" TEXT NOT NULL,
"description_en" TEXT NOT NULL,
"description_no" TEXT NOT NULL,
"gitea_link" TEXT NOT NULL,
"wiki_link" TEXT
);
CREATE TABLE "project" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"group_id" INTEGER NOT NULL REFERENCES project_group (id),
"title" TEXT NOT NULL,
"description_en" TEXT NOT NULL,
"description_no" TEXT NOT NULL,
"gitea_link" TEXT NOT NULL,
"issue_board_link" TEXT NOT NULL,
"wiki_link" TEXT,
"languages" TEXT,
"technologies" TEXT,
"keywords" TEXT,
"license" TEXT,
"logo_url" TEXT
);
CREATE TABLE "project_maintainer" (
"uname" TEXT PRIMARY KEY,
"name" TEXT NOT NULL,
"link" TEXT NOT NULL,
"mail" TEXT NOT NULL
);
CREATE TABLE "project__project_maintainer" (
"project_id" INTEGER REFERENCES project (id),
"uname" TEXT REFERENCES maintainer (uname),
PRIMARY KEY (project_id, uname)
);
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
CREATE TABLE "motd" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"title" TEXT,
"content" TEXT
);
INSERT INTO
motd (title, content)
VALUES
(
'MOTD ./dev.sh',
'du kan endre motd i admin panelet'
);
CREATE TABLE "door" ("time" INTEGER PRIMARY KEY, "open" BOOLEAN);
INSERT INTO
door (time, open)
VALUES
(0, FALSE);
INSERT INTO
users (uname, groups)
VALUES
('min_test_bruker', 1);

17
dist/service-provider/authsources.php vendored Normal file
View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
$config = [
/* This is the name of this authentication source, and will be used to access it later. */
'default-sp' => [
'saml:SP',
'entityID' => 'https://www.pvv.ntnu.no/simplesaml/',
'idp' => 'https://idp.pvv.ntnu.no/',
],
'dev-sp' => [
'saml:SP',
'entityID' => 'http://localhost:1080/simplesaml/',
'idp' => 'http://localhost:1080/simplesaml-idp/',
],
];

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
$metadata['https://idp.pvv.ntnu.no/'] = [
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'https://idp.pvv.ntnu.no/',
'SingleSignOnService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
],
],
'SingleLogoutService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
],
],
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
];
$metadata['http://localhost:1080/simplesaml-idp/'] = [
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'https://localhost:1080/',
'SingleSignOnService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://localhost:1080/simplesaml-idp/simplesaml/saml2/idp/SSOService.php',
],
],
'SingleLogoutService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'http://localhost:1080/simplesaml-idp/simplesaml/saml2/idp/SingleLogoutService.php',
],
],
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
];

View File

@@ -1,12 +0,0 @@
<?php
declare(strict_types=1);
$config = [
/* This is the name of this authentication source, and will be used to access it later. */
'default-sp' => [
'saml:SP',
'entityID' => 'https://www.pvv.ntnu.no/simplesaml/',
'idp' => 'https://idp.pvv.ntnu.no/',
],
];

View File

@@ -1,21 +0,0 @@
<?php
declare(strict_types=1);
$metadata['https://idp.pvv.ntnu.no/'] = [
'metadata-set' => 'saml20-idp-remote',
'entityid' => 'https://idp.pvv.ntnu.no/',
'SingleSignOnService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SSOService.php',
],
],
'SingleLogoutService' => [
0 => [
'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
'Location' => 'https://idp.pvv.ntnu.no/simplesaml/saml2/idp/SingleLogoutService.php',
],
],
'certData' => 'MIIDpTCCAo2gAwIBAgIJAJIgibrB7NvsMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAk5PMR4wHAYDVQQKDBVQcm9ncmFtdmFyZXZlcmtzdGVkZXQxGDAWBgNVBAMMD2lkcC5wdnYubnRudS5ubzEgMB4GCSqGSIb3DQEJARYRZHJpZnRAcHZ2Lm50bnUubm8wHhcNMTcxMTEzMjI0NTQyWhcNMjcxMTEzMjI0NTQyWjBpMQswCQYDVQQGEwJOTzEeMBwGA1UECgwVUHJvZ3JhbXZhcmV2ZXJrc3RlZGV0MRgwFgYDVQQDDA9pZHAucHZ2Lm50bnUubm8xIDAeBgkqhkiG9w0BCQEWEWRyaWZ0QHB2di5udG51Lm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAveLujCsgVCRA360y5yezy8FcSPhaqodggDqY12UTkYOMQLBFaph6uUL4oCUlXZqxScrAYVRt9yw+7BYpcm0p51VZzVCsfMxRVkn+O1eUvsaXq3f13f87QHKYP2f0uqkGf5PvnKIdSaI/ix8WJhD8XT+h0OkHEcaBvUtSG7zbEhvG21WPHwgw2rvZSneArQ8tOitZC0u8VXSfdhtf6ynRseo0xC95634UwQAZivhQ2v4A6Tp57QG5DCXIJ9/z3PkINx3KB/hOeh0EP6Dpbp+7V0/t9778E3whpm4llrH144kzROhA7EgUgkZOjAVjxGCYlcj3xQPnnItihVOZ5B5qLwIDAQABo1AwTjAdBgNVHQ4EFgQUPLhrB+Qb/Kzz7Car9GJkKmEkz6swHwYDVR0jBBgwFoAUPLhrB+Qb/Kzz7Car9GJkKmEkz6swDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAd+4E6t0j8/p8rbZE8y/gZ9GsiRhxkR4l6JbMRUfEpqHKi415qstChRcP2Lo3Yd5qdmj9tLDWoPsqet1QgyTTmQTgUmPhhMOQDqSh90LuqEJseKWafXGS/SfWLH6MWVmzDV5YofJEw2ThPiU58GiS06OLS2poq1eAesa2LQ22J8yYisXM4sxImIFte+LYQ1+1evfBWcvU1vrGsQ0VLJHdef9WoXp1swUFhq4Zk0c7gjHiB1CFVlExAAlk9L6W3CVXmKIYlf4eUnEBGkC061Ir42+uhAMWO9Y/L1NEuboTyd2KAI/6JdKdzpmfk7zPVxWlNxNCZ7OPNuvOKp6VlpB2EA==',
'NameIDFormat' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
];

45
dist/sql/pvv_mysql.sql vendored Normal file
View File

@@ -0,0 +1,45 @@
CREATE TABLE events (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`name` TEXT,
`start` TEXT,
`stop` TEXT,
`organiser` TEXT,
`location` TEXT,
`description` TEXT
);
CREATE TABLE projects (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`name` TEXT,
`description` TEXT,
`active` BOOLEAN
);
CREATE TABLE projectmembers (
`projectid` INTEGER,
`name` TEXT,
`uname` TEXT,
`mail` TEXT,
`role` TEXT,
`lead` BOOLEAN DEFAULT 0,
`owner` BOOLEAN DEFAULT 0
);
CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0);
CREATE TABLE motd (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`title` TEXT,
`content` TEXT
);
/*
INSERT INTO motd (title, content)
VALUES ("MOTD ./dev.sh", "du kan endre motd i admin panelet");
*/
CREATE TABLE door (`time` INTEGER PRIMARY KEY, `open` BOOLEAN);
INSERT INTO
door (time, open)
VALUES
(0, FALSE);

54
dist/sql/pvv_sqlite.sql vendored Normal file
View File

@@ -0,0 +1,54 @@
CREATE TABLE "events" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" TEXT,
"start" TEXT,
"stop" TEXT,
"organiser" TEXT,
"location" TEXT,
"description" TEXT
);
CREATE TABLE "projects" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" TEXT,
"description" TEXT,
"active" BOOLEAN
);
CREATE TABLE "projectmembers" (
"projectid" INTEGER,
"name" TEXT,
"uname" TEXT,
"mail" TEXT,
"role" TEXT,
"lead" BOOLEAN DEFAULT 0,
"owner" BOOLEAN DEFAULT 0
);
CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0);
CREATE TABLE "motd" (
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
"title" TEXT,
"content" TEXT
);
INSERT INTO
motd (title, content)
VALUES
(
'MOTD ./dev.sh',
'du kan endre motd i admin panelet'
);
CREATE TABLE "door" ("time" INTEGER PRIMARY KEY, "open" BOOLEAN);
INSERT INTO
door (time, open)
VALUES
(0, FALSE);
INSERT INTO
users (uname, groups)
VALUES
('min_test_bruker', 1);

View File

@@ -19,7 +19,7 @@ $pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
$sp = 'default-sp';
$sp = 'dev-sp';
$as = new SimpleSAML\Auth\Simple($sp);
use pvv\side\Agenda;

View File

@@ -35,7 +35,8 @@ function navbar($depth, $active = null) {
function loginBar($sp = null, $pdo = null) {
if (null === $sp) {
$sp = 'default-sp';
// $sp = 'dev-sp';
$sp = 'dev-sp';
}
$result = "\n";
require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';

View File

@@ -4,7 +4,22 @@
}:
php.buildComposerProject rec {
src = ./..;
src = lib.fileset.toSource {
root = ./..;
fileset = lib.fileset.difference
(lib.fileset.unions [
../dist
../inc
../src
../www
../composer.json
../composer.lock
])
(lib.fileset.unions [
(lib.fileset.maybeMissing ../www/simplesaml)
(lib.fileset.maybeMissing ../www/simplesaml-idp)
]);
};
pname = "pvv-nettsiden";
version = "0.0.1";
vendorHash = "sha256-7I7Fdp5DvCwCdYY66Mv0hZ+a8xRzQt+WMUKG544k7Fc=";
@@ -12,15 +27,15 @@ php.buildComposerProject rec {
passthru.simplesamlphpPath = "share/php/pvv-nettsiden/vendor/simplesamlphp/simplesamlphp";
postInstall = ''
install -Dm644 dist/simplesamlphp-config.php $out/${passthru.simplesamlphpPath}/config/config.php
install -Dm644 dist/simplesamlphp-authsources.php $out/${passthru.simplesamlphpPath}/config/authsources.php
install -Dm644 dist/simplesamlphp-idp.php $out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
install -Dm644 dist/config.source-env.php $out/share/php/pvv-nettsiden/config.php
install -Dm644 dist/service-provider/config.php $out/${passthru.simplesamlphpPath}/config/config.php
install -Dm644 dist/service-provider/authsources.php $out/${passthru.simplesamlphpPath}/config/authsources.php
install -Dm644 dist/service-provider/saml20-idp-remote.php $out/${passthru.simplesamlphpPath}/metadata/saml20-idp-remote.php
install -Dm644 dist/config.source-env.php $out/share/php/pvv-nettsiden/config.php
${lib.pipe extra_files [
(lib.mapAttrsToList (target_path: source_path: ''
mkdir -p $(dirname "$out/${target_path}")
cp -r "${source_path}" "$out/${target_path}"
cp -r "${source_path}" "$out/${target_path}"
''))
(lib.concatStringsSep "\n")
]}

View File

@@ -12,6 +12,7 @@ pkgs.mkShellNoCC {
php84Packages.php-cs-fixer
sqlite-interactive
sql-formatter
openssl
];
# Prepare dev environment with sqlite and config files
@@ -21,20 +22,40 @@ pkgs.mkShellNoCC {
declare -a PROJECT_ROOT="$("${lib.getExe pkgs.git}" rev-parse --show-toplevel)"
mkdir -p "$PROJECT_ROOT/www/galleri/bilder/slideshow"
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/pvv_sqlite.sql"
test -e "$PROJECT_ROOT/pvv.sqlite" || sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/pvv_sqlite.sql"
test -e "$PROJECT_ROOT/config.php" || cp -v "$PROJECT_ROOT/dist/config.local.php" "$PROJECT_ROOT/config.php"
if [ ! -d "$PROJECT_ROOT/vendor" ] ; then
pushd "$PROJECT_ROOT"
composer install || exit $?
cp dist/simplesamlphp-authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
cp dist/simplesamlphp-idp.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
cp dist/simplesamlphp-config.php vendor/simplesamlphp/simplesamlphp/config/config.php
cp -r vendor/simplesamlphp vendor/simplesamlphp-idp
# Set up SimpleSAMLphp service provider
install dist/service-provider/authsources.php vendor/simplesamlphp/simplesamlphp/config/authsources.php
install dist/service-provider/config.php vendor/simplesamlphp/simplesamlphp/config/config.php
install dist/service-provider/saml20-idp-remote.php vendor/simplesamlphp/simplesamlphp/metadata/saml20-idp-remote.php
# Set up SimpleSAMLphp identity provider (for local testing)
install dist/identity-provider/authsources.php vendor/simplesamlphp-idp/simplesamlphp/config/authsources.php
install dist/identity-provider/config.php vendor/simplesamlphp-idp/simplesamlphp/config/config.php
install dist/identity-provider/saml20-idp-hosted.php vendor/simplesamlphp-idp/simplesamlphp/metadata/saml20-idp-hosted.php
install dist/identity-provider/saml20-sp-remote.php vendor/simplesamlphp-idp/simplesamlphp/metadata/saml20-sp-remote.php
openssl req \
-newkey rsa:4096 \
-new \
-x509 \
-days 3652 \
-nodes \
-out vendor/simplesamlphp-idp/simplesamlphp/cert/localhost.crt \
-keyout vendor/simplesamlphp-idp/simplesamlphp/cert/localhost.pem \
-subj "/C=NO/ST=Trondheim/L=Trondheim/O=Programvareverkstedet/CN=localhost"
cp dist/config.local.php config.php
ln -s ../vendor/simplesamlphp/simplesamlphp/public/ www/simplesaml
ln -s ../vendor/simplesamlphp-idp/simplesamlphp/public/ www/simplesaml-idp
popd
fi
'';

View File

@@ -21,7 +21,7 @@ class Agenda {
$this->activities = $activities;
}
public static function getFormattedDate(\DateTime $date): string {
public static function getFormattedDate(\DateTimeImmutable $date): string {
return $date->format('l j. M H.i');
}

View File

@@ -6,105 +6,35 @@ namespace pvv\side;
class Project {
private int $id;
private string $title;
private array $description_en;
private array $description_no;
private ?string $gitea_link;
private ?string $issue_board_link;
private ?string $wiki_link;
private array $programming_languages;
private array $technologies;
private array $keywords;
// NOTE: spdx identifier
private ?string $license;
private ?string $logo_url;
private string $name;
private array $descr;
private bool $active;
public function __construct(
int $id,
string $title,
?string $description_en,
?string $description_no,
?string $gitea_link,
?string $issue_board_link,
?string $wiki_link,
?string $programming_languages,
?string $technologies,
?string $keywords,
?string $license,
?string $logo_url,
string $name,
string $descr,
bool $active,
) {
$this->id = $id;
$this->title = $title;
$this->description_en
= $description_en === null || $description_en === ''
? []
: explode("\n", $description_en);
$this->description_no
= $description_no === null || $description_no === ''
? []
: explode("\n", $description_no);
$this->gitea_link = $gitea_link;
$this->issue_board_link = $issue_board_link;
$this->wiki_link = $wiki_link;
$this->programming_languages
= $programming_languages === null || $programming_languages === ''
? []
: explode(',', $programming_languages);
$this->technologies
= $technologies === null || $technologies === ''
? []
: explode(',', $technologies);
$this->keywords
= $keywords === null || $keywords === '' ? [] : explode(',', $keywords);
$this->license = $license;
$this->logo_url = $logo_url;
$this->name = $name;
$this->descr = explode("\n", $descr);
$this->active = $active;
}
public function getID(): int {
return $this->id;
}
public function getTitle(): string {
return $this->title;
public function getName(): string {
return $this->name;
}
public function getDescriptionEn(): array {
return $this->description_en;
public function getDescription(): array {
return $this->descr;
}
public function getDescriptionNo(): array {
return $this->description_no;
}
public function getGiteaLink(): ?string {
return $this->gitea_link;
}
public function getIssueBoardLink(): ?string {
return $this->issue_board_link;
}
public function getWikiLink(): ?string {
return $this->wiki_link;
}
public function getProgrammingLanguages(): array {
return $this->programming_languages;
}
public function getTechnologies(): array {
return $this->technologies;
}
public function getKeywords(): array {
return $this->keywords;
}
public function getLicense(): ?string {
return $this->license;
}
public function getLogoURL(): ?string {
return $this->logo_url;
public function getActive(): bool {
return $this->active;
}
}

View File

@@ -15,7 +15,7 @@ class ProjectManager {
* @return Project[]
*/
public function getAll(): array {
$query = 'SELECT * FROM project ORDER BY id ASC';
$query = 'SELECT * FROM projects ORDER BY id ASC';
$statement = $this->pdo->prepare($query);
$statement->execute();
@@ -23,17 +23,9 @@ class ProjectManager {
foreach ($statement->fetchAll() as $dbProj) {
$project = new Project(
$dbProj['id'],
$dbProj['title'],
$dbProj['description_en'],
$dbProj['description_no'],
$dbProj['gitea_link'],
$dbProj['issue_board_link'],
$dbProj['wiki_link'],
$dbProj['languages'],
$dbProj['technologies'],
$dbProj['keywords'],
$dbProj['license'],
$dbProj['logo_url']
$dbProj['name'],
$dbProj['description'],
$dbProj['active'],
);
$projects[] = $project;
}
@@ -42,7 +34,7 @@ class ProjectManager {
}
public function getByID(int $id): ?Project {
$query = 'SELECT * FROM project WHERE id=:id LIMIT 1';
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
$statement = $this->pdo->prepare($query);
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
$statement->execute();
@@ -54,17 +46,9 @@ class ProjectManager {
return new Project(
$dbProj['id'],
$dbProj['title'],
$dbProj['description_en'],
$dbProj['description_no'],
$dbProj['gitea_link'],
$dbProj['issue_board_link'],
$dbProj['wiki_link'],
$dbProj['languages'],
$dbProj['technologies'],
$dbProj['keywords'],
$dbProj['license'],
$dbProj['logo_url']
$dbProj['name'],
$dbProj['description'],
$dbProj['active'],
);
}
@@ -72,13 +56,7 @@ class ProjectManager {
* @return Project[]
*/
public function getByOwner(string $uname): array {
$query = '
SELECT projectid FROM project
JOIN project__project_maintainer ON project.id = project__project_maintainer.project_id
JOIN project_maintainer ON project__project_maintainer.uname = project_maintainer.uname
WHERE project_maintainer.uname = :uname
';
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
$statement = $this->pdo->prepare($query);
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
$statement->execute();
@@ -96,17 +74,9 @@ class ProjectManager {
foreach ($statement->fetchAll() as $dbProj) {
$project = new Project(
$dbProj['id'],
$dbProj['title'],
$dbProj['description_en'],
$dbProj['description_no'],
$dbProj['gitea_link'],
$dbProj['issue_board_link'],
$dbProj['wiki_link'],
$dbProj['languages'],
$dbProj['technologies'],
$dbProj['keywords'],
$dbProj['license'],
$dbProj['logo_url']
$dbProj['name'],
$dbProj['description'],
$dbProj['active'],
);
$projects[] = $project;
}
@@ -119,27 +89,44 @@ class ProjectManager {
* @return array<int,array>
*/
public function getProjectMembers(int $id): array {
$query = '
SELECT id FROM project
JOIN project__project_maintainer ON project.id = project__project_maintainer.project_id
JOIN project_maintainer ON project__project_maintainer.uname = project_maintainer.uname
WHERE project.id = :id
';
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
$statement = $this->pdo->prepare($query);
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
$statement->execute();
$maintainers = [];
$members = [];
foreach ($statement->fetchAll() as $dbUsr) {
$maintainers[] = [
$members[] = [
'name' => $dbUsr['name'],
'uname' => $dbUsr['uname'],
'link' => $dbUsr['link'],
'mail' => $dbUsr['mail'],
'role' => $dbUsr['role'],
'lead' => $dbUsr['lead'],
'owner' => $dbUsr['owner'],
];
}
return $maintainers;
return $members;
}
/**
* @return array<string,mixed>
*/
public function getProjectOwner(int $id): array {
$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();
return [
'name' => $dbOwner['name'],
'uname' => $dbOwner['uname'],
'mail' => $dbOwner['mail'],
'role' => $dbOwner['role'],
'lead' => $dbOwner['lead'],
'owner' => $dbOwner['owner'],
];
}
}

View File

@@ -39,22 +39,22 @@ class BrettspillEvent extends Event {
'',
'## Vår samling',
'',
'* Dominion\*',
'* Dominion\\*',
'* Three cheers for master',
'* Avalon',
'* Hanabi',
'* Cards aginst humanity\*',
'* Cards aginst humanity\\*',
'* Citadels',
'* Munchkin\*\*',
'* Exploding kittens\*\*',
'* Munchkin\\*\\*',
'* Exploding kittens\\*\\*',
'* Aye dark overlord',
'* Settlers of catan\*',
'* Risk\*\*',
'* Settlers of catan\\*',
'* Risk\\*\\*',
'* og mange flere...',
'',
'\* Vi har flere ekspansjoner til spillet',
'\\* Vi har flere ekspansjoner til spillet',
'',
'\*\* Vi har flere varianter av spillet',
'\\*\\* Vi har flere varianter av spillet',
];
}

View File

@@ -6,7 +6,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -8,7 +8,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -7,7 +7,7 @@ require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../config.php';
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$attrs = $as->getAttributes();
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
@@ -15,7 +15,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -5,7 +5,7 @@ $pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -7,7 +7,7 @@ require __DIR__ . '/../../../inc/navbar.php';
require __DIR__ . '/../../../src/_autoload.php';
require __DIR__ . '/../../../config.php';
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$attrs = $as->getAttributes();
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
@@ -15,7 +15,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -6,7 +6,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -10,7 +10,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -8,7 +8,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
require_once __DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];

View File

@@ -7,7 +7,7 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new pvv\admin\UserManager($pdo);
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$loginname = $attrs['uid'][0];

View File

@@ -6,7 +6,7 @@ require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../config.php';
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
@@ -36,16 +36,16 @@ $project = new pvv\side\Project(
$attrs['mail'][0],
1
);
// if ($new == 0) {
// $project = $projectManager->getByID($projectID);
// $maintainers = $projectManager->getProjectMaintainers($projectID);
if ($new == 0) {
$project = $projectManager->getByID($projectID);
$owner = $projectManager->getProjectOwner($projectID);
// if ($owner['uname'] != $attrs['uid'][0]) {
// header('HTTP/1.0 403 Forbidden');
// echo 'wrong user';
// exit;
// }
// }
if ($owner['uname'] != $attrs['uid'][0]) {
header('HTTP/1.0 403 Forbidden');
echo 'wrong user';
exit;
}
}
?>
<!DOCTYPE html>
<html lang="no">
@@ -74,48 +74,12 @@ $project = new pvv\side\Project(
<form action="update.php", method="post">
<p class="subtitle no-chin">Prosjektnavn</p>
<p class="subnote">Gi prosjektet ditt et passende navn</p>
<input class="wide" type="text" name="title" value="<?php echo $project->getTitle(); ?>" class="boxinput" required><br>
<input class="wide" type="text" name="title" value="<?php echo $project->getName(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Beskrivelse (<i style="opacity:0.5;">markdown</i>)</p>
<p class="subnote no-chin">Hva går prosjektet ditt ut på?</p>
<p class="subnote">De første to linjene blir vist på prosjektkortet, prøv å gjøre de til et fint sammendrag eller intro!</p>
<textarea class="tall" name="desc" style="width:100%" rows="8" class="boxinput" required><?php echo implode("\n", $project->getDescriptionNo()); ?></textarea>
<p class="subtitle no-chin">Beskrivelse på engelsk (<i style="opacity:0.5;">markdown</i>)</p>
<p class="subnote no-chin">Gjenta på engelsk</p>
<textarea class="tall" name="desc_en" style="width:100%" rows="8" class="boxinput" required><?php echo implode("\n", $project->getDescriptionEn()); ?></textarea>
<p class="subtitle no-chin">Gitea-link</p>
<p class="subnote">Link til prosjektet på Gitea</p>
<input class="wide" type="text" name="gitea" value="<?php echo $project->getGiteaLink(); ?>" class="boxinput" required><br>
<p class="subtitle no-chin">Issue board-link</p>
<p class="subnote">Link til issue board på Gitea</p>
<input class="wide" type="text" name="issue" value="<?php echo $project->getIssueBoardLink(); ?>" class="boxinput" required><br>
<p class="subtitle no-chin">Wiki-link</p>
<p class="subnote">Link til wiki-side</p>
<input class="wide" type="text" name="wiki" value="<?php echo $project->getWikiLink(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Programmeringsspråk</p>
<p class="subnote">Hvilke programmeringsspråk brukes i prosjektet?</p>
<input class="wide" type="text" name="langs" value="<?php echo $project->getProgrammingLanguages(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Teknologier</p>
<p class="subnote">Hvilke teknologier brukes i prosjektet?</p>
<input class="wide" type="text" name="techs" value="<?php echo $project->getTechnologies(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Nøkkelord</p>
<p class="subnote">Nøkkelord som beskriver prosjektet</p>
<input class="wide" type="text" name="keywords" value="<?php echo $project->getKeywords(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Lisens</p>
<p class="subnote">Hvilken lisens bruker prosjektet?</p>
<input class="wide" type="text" name="license" value="<?php echo $project->getLicense(); ?>" class="boxinput"><br>
<p class="subtitle no-chin">Logo-URL</p>
<p class="subnote">Link til logo for prosjektet</p>
<input class="wide" type="text" name="logo" value="<?php echo $project->getLogoURL(); ?>" class="boxinput"><br>
<textarea class="tall" name="desc" style="width:100%" rows="8" class="boxinput"><?php echo implode("\n", $project->getDescription()); ?></textarea>
<?php echo '<input type="hidden" name="id" value="' . $project->getID() . '" />'; ?>
<input type="hidden" name="active" value="1"/>

View File

@@ -71,6 +71,7 @@ $projects = $projectManager->getAll();
<br>
<center>
<a class="btn" href="edit.php?new=1">Lag prosjekt</a>
<a class="btn" href="mine.php">Mine prosjekter</a>
</center>
<br>
<?php
@@ -83,7 +84,7 @@ $projects = $projectManager->getAll();
<div class="projects-container">
<?php
$randProjects = array_rand($projects, min(8, count($projects)));
$randProjects = array_rand($projects, min(6, count($projects)));
if (!is_array($randProjects)) {
$randProjects = [$randProjects];
}

View File

@@ -10,7 +10,7 @@ if (isset($_GET['id'])) {
}
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$attrs = $as->getAttributes();
$projectManager = new pvv\side\ProjectManager($pdo);

120
www/prosjekt/mine.php Normal file
View File

@@ -0,0 +1,120 @@
<?php
date_default_timezone_set('Europe/Oslo');
setlocale(\LC_ALL, 'nb_NO');
require __DIR__ . '/../../inc/navbar.php';
require __DIR__ . '/../../src/_autoload.php';
require __DIR__ . '/../../config.php';
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();
$pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$projectManager = new pvv\side\ProjectManager($pdo);
$projects = $projectManager->getByOwner($attrs['uid'][0]);
$page = 1;
if (isset($_GET['page'])) {
$page = $_GET['page'];
}
$filter = '';
if (isset($_GET['filter'])) {
$filter = $_GET['filter'];
}
// filter
$projects = array_values(array_filter(
$projects,
static fn($project) => (preg_match('/.*' . $filter . '.*/i', $project->getName()) || preg_match('/.*' . $filter . '.*/i', implode(' ', $project->getDescription())))
));
?>
<!DOCTYPE html>
<html lang="no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="../css/normalize.css">
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="../css/events.css">
<link rel="stylesheet" href="../css/admin.css">
<meta name="theme-color" content="#024" />
<title>Prosjektverkstedet</title>
<header>Prosjekt&shy;verk&shy;stedet</header>
<body>
<nav>
<?php echo navbar(1, 'prosjekt'); ?>
<?php echo loginbar(); ?>
</nav>
<main class="gridsplit">
<div class="gridl">
<h2 class="no-chin">Mine Prosjekter</h2>
<ul class="event-list">
<?php
$counter = 0;
$pageLimit = 8;
for ($i = ($pageLimit * ($page - 1)); $i < count($projects); ++$i) {
if ($counter == $pageLimit) {
break;
}
$project = $projects[$i];
$projectID = $project->getID();
$owner = $projectManager->getProjectOwner($projectID);
if ($owner['uname'] != $attrs['uid'][0]) {
continue;
}
?>
<li>
<div class="event">
<div class="event-info">
<a href="edit.php?id=<?php echo $project->getID(); ?>">
<h3 class="no-chin"><?php echo $project->getName(); ?></h3>
</a>
<p style="text-decoration: none;"><?php echo implode('<br>', array_slice($project->getDescription(), 0, 4)); ?></p>
</div>
</div>
</li>
<?php
++$counter;
}
?>
</ul>
<?php
if ($page != 1) {
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '&filter=' . urlencode($filter) . '">Forrige side</a>';
}
if (($counter == $pageLimit) && (($pageLimit * $page) < count($projects))) {
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '&filter=' . urlencode($filter) . '">Neste side</a>';
}
?>
</div>
<div class="gridr">
<h2>Verktøy</h2>
<a class="btn" href="edit.php?new=1">Lag prosjekt</a>
<h2>Filter</h2>
<form action="mine.php" method="get">
<p class="no-chin">Navn</p>
<?php echo '<input type="text" name="filter" class="boxinput" value="' . $filter . '">'; ?><br>
<div style="margin-top: 2em;">
<input type="submit" class="btn" value="Filtrer"></input>
</div>
</form>
</div>
</main>
</body>

View File

@@ -12,7 +12,7 @@ if (!isset($_POST['title']) || !isset($_POST['desc']) || !isset($_POST['active']
}
require_once __DIR__ . '/../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
$as = new SimpleSAML\Auth\Simple('default-sp');
$as = new SimpleSAML\Auth\Simple('dev-sp');
$as->requireAuth();
$attrs = $as->getAttributes();