Compare commits
8 Commits
local-dev-
...
revamp-pro
| Author | SHA1 | Date | |
|---|---|---|---|
|
bdc0f22182
|
|||
|
f47ce08760
|
|||
|
961f021d27
|
|||
|
158e816ed0
|
|||
|
42cb584ef4
|
|||
|
1eabf809f0
|
|||
|
bb5b013d31
|
|||
|
a366769fb9
|
@@ -1,7 +0,0 @@
|
||||
# this is a development container, not hardened for hosting
|
||||
FROM php:7.4-cli
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
sqlite3 \
|
||||
unzip \
|
||||
git
|
||||
32
README.md
32
README.md
@@ -4,36 +4,8 @@
|
||||
A website created with the latest and greatest web technologies.
|
||||
May contain blackjack and other things one tends to include in awesome projects.
|
||||
|
||||
## Installation
|
||||
|
||||
git clone --recursive https://github.com/Programvareverkstedet/nettsiden.git
|
||||
|
||||
Put it in a folder your webserver can find.
|
||||
|
||||
## Development setup
|
||||
|
||||
The development environment can be setup with:
|
||||
|
||||
nix develop
|
||||
|
||||
For this you will need to install the nix package manager and possibly set the experimental features in your nix config, likely located at /etc/nix/nix.conf or $HOME/.config/nix/nix.conf.
|
||||
|
||||
Installing nix with your package manager might not work without some tweaking, but the upstream script should just work which you can find [here](https://nixos.org/download/).
|
||||
|
||||
experimental-features = flakes nix-command
|
||||
|
||||
You can then run the server with:
|
||||
|
||||
runDev
|
||||
|
||||
### Admin account
|
||||
|
||||
Login goes through `idp.pvv.ntnu.no` via SAML, so you have to use your PVV account.
|
||||
(This only works if you use access the local development site via the the hostname `localhost`)
|
||||
To make your account into an admin account, run:
|
||||
|
||||
sqlite3 pvv.sqlite "INSERT INTO users (uname, groups) VALUES ('YOUR_USERNAME', 1);"
|
||||
See [Getting Started](./docs/getting-started.md) for help to hack on the project.
|
||||
|
||||
## Hosting
|
||||
|
||||

|
||||

|
||||
|
||||
6
dist/simplesaml-dev/authsources.php
vendored
6
dist/simplesaml-dev/authsources.php
vendored
@@ -16,13 +16,13 @@ $config = [
|
||||
'user:user' => [
|
||||
'uid' => ['user'],
|
||||
'group' => ['users'],
|
||||
'cn' => '/home/pvv/d/user',
|
||||
'cn' => 'Ole Petter',
|
||||
'mail' => 'user+test@pvv.ntnu.no',
|
||||
],
|
||||
'admin:admin' => [
|
||||
'uid' => ['admin'],
|
||||
'group' => ['admins'],
|
||||
'cn' => '/home/pvv/d/admin',
|
||||
'group' => ['admin'],
|
||||
'cn' => 'Admin Adminsson',
|
||||
'mail' => 'admin+test@pvv.ntnu.no',
|
||||
],
|
||||
],
|
||||
|
||||
42
dist/sql/pvv_mysql.sql
vendored
42
dist/sql/pvv_mysql.sql
vendored
@@ -8,21 +8,39 @@ CREATE TABLE events (
|
||||
`description` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE projects (
|
||||
CREATE TABLE project_group (
|
||||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`description` TEXT,
|
||||
`active` BOOLEAN
|
||||
`title` TEXT NOT NULL,
|
||||
`description_en` TEXT NOT NULL,
|
||||
`description_no` TEXT NOT NULL,
|
||||
`gitea_link` TEXT NOT NULL,
|
||||
`wiki_link` TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE projectmembers (
|
||||
`projectid` INTEGER,
|
||||
`name` TEXT,
|
||||
`uname` TEXT,
|
||||
`mail` TEXT,
|
||||
`role` TEXT,
|
||||
`lead` BOOLEAN DEFAULT 0,
|
||||
`owner` BOOLEAN DEFAULT 0
|
||||
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);
|
||||
|
||||
45
dist/sql/pvv_sqlite.sql
vendored
45
dist/sql/pvv_sqlite.sql
vendored
@@ -8,21 +8,42 @@ CREATE TABLE "events" (
|
||||
"description" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "projects" (
|
||||
CREATE TABLE "project_group" (
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT,
|
||||
"description" TEXT,
|
||||
"active" BOOLEAN
|
||||
"title" TEXT NOT NULL,
|
||||
"description_en" TEXT NOT NULL,
|
||||
"description_no" TEXT NOT NULL,
|
||||
"gitea_link" TEXT NOT NULL,
|
||||
"wiki_link" TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE "projectmembers" (
|
||||
"projectid" INTEGER,
|
||||
"name" TEXT,
|
||||
"uname" TEXT,
|
||||
"mail" TEXT,
|
||||
"role" TEXT,
|
||||
"lead" BOOLEAN DEFAULT 0,
|
||||
"owner" BOOLEAN DEFAULT 0
|
||||
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);
|
||||
|
||||
7
dist/sql/test_data_sqlite.sql
vendored
Normal file
7
dist/sql/test_data_sqlite.sql
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
-- See users in ../authsources.php
|
||||
INSERT INTO
|
||||
users (uname, groups)
|
||||
VALUES
|
||||
('admin', 1 | 2 | 4),
|
||||
('user', 0);
|
||||
@@ -1,21 +0,0 @@
|
||||
version: "3.9"
|
||||
|
||||
# cleanup:
|
||||
|
||||
# docker container prune -f && docker volume prune -f
|
||||
# docker system prune -a
|
||||
|
||||
services:
|
||||
nettside: # https://hub.docker.com/_/php
|
||||
#image: php:7.4-cli
|
||||
build: .
|
||||
volumes:
|
||||
- .:/usr/src/nettside
|
||||
working_dir: /usr/src/nettside
|
||||
command: ./dev.sh
|
||||
environment:
|
||||
- DOCKER_HOST=0.0.0.0
|
||||
- DOCKER_PORT=1080
|
||||
ports:
|
||||
- 1080:1080
|
||||
user: "${DOCKER_USER}"
|
||||
|
Before Width: | Height: | Size: 477 KiB After Width: | Height: | Size: 477 KiB |
|
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 1.0 MiB |
72
docs/getting-started.md
Normal file
72
docs/getting-started.md
Normal file
@@ -0,0 +1,72 @@
|
||||
# Getting started
|
||||
|
||||
Let's get you up and running.
|
||||
|
||||
## List of dependencies
|
||||
|
||||
You will need to install the following pieces of software:
|
||||
|
||||
- Git
|
||||
- SQLite3
|
||||
- PHP
|
||||
- Composer
|
||||
- OpenSSL
|
||||
|
||||
If you are running Ubuntu or Debian, you can install these dependencies with:
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install git sqlite3 php composer openssl
|
||||
```
|
||||
|
||||
## Automatic setup
|
||||
|
||||
You can use the scripts in the `scripts/` directory to quickly set up a development environment.
|
||||
|
||||
By running the `./scripts/setup.sh`, all dependencies will be installed, in addition to other miscellaneous setup tasks. You can then run `./scripts/run.sh` to start the webserver.
|
||||
|
||||
You should now be able to access the site at [http://localhost:1080](http://localhost:1080).
|
||||
|
||||
Sometimes it is useful to completely reset the state of the project, deleting the data, redownloading dependencies, etc. You can do this by running `./scripts/reset.sh`. Be careful, as this will delete all data in the database!
|
||||
|
||||
> [!WARN]
|
||||
> Even when resetting the project with the reset script, there are some situation where you need to clear your cookies or your browser cache to get a clean state.
|
||||
> How to do this varies between browsers, so please refer to your browser's documentation for instructions.
|
||||
|
||||
## Setup with nix
|
||||
|
||||
We provide a devshell with all dependencies included. We do recommend still using the scripts for setup tasks.
|
||||
|
||||
```bash
|
||||
nix develop
|
||||
./scripts/setup.sh
|
||||
./scripts/run.sh
|
||||
```
|
||||
|
||||
## Logging in
|
||||
|
||||
We have a development configuration for SimpleSAMLphp (which we use as our authentication system), that lets you log in with dummy users while developing.
|
||||
|
||||
The available users are:
|
||||
|
||||
- `admin` (password: `admin`) - An admin user
|
||||
- `user` (password: `user`) - A normal user
|
||||
|
||||
In addition, if you need to look into the SAML setup, you can log into the SimpleSAMLphp admin interface at [http://localhost:1080/simplesaml/admin](http://localhost:1080/simplesaml/admin) with username `admin` and password `123`.
|
||||
|
||||
## The codebase
|
||||
|
||||
In the codebase, you will find the following directories:
|
||||
|
||||
- `dist`: Contains files related to deployment, hosting and packaging.
|
||||
- `docs`: Documentation for the project.
|
||||
- `inc`: PHP include files, containing a base set of useful classes, functions and constants.
|
||||
- `nix`: Nix config for packaging, devshells, NixOS modules, etc.
|
||||
- `scripts`: Helper scripts for setting up development environments, running the server, etc.
|
||||
- `src`: The main library code for the project. This contains raw PHP code with business logic and database access.
|
||||
- `vendor`: Third-party dependencies installed with composer.
|
||||
- `www`: The webroot for the project. This contains public assets, styling, javascript and PHP code concerned with routing and rendering webpages.
|
||||
|
||||
## How SimpleSAMLphp is set up in the development environment
|
||||
|
||||
It used to be the case that we would connect to our production instance of SimpleSAMLphp for authentication even in development environments. This is no longer the case, as we now use our local SimpleSAMLphp instance both as a service provider and as an identity provider in development. The `config.php` and `authsources.php` files are written in a way where one single instance of SimpleSAMLphp acts as both parts. It will send authentication requests to itself. See `dist/simplesaml-dev` for implementation details.
|
||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
@@ -1,4 +1,4 @@
|
||||
{ pkgs, lib }:
|
||||
{ pkgs }:
|
||||
let
|
||||
phpEnv = pkgs.php84.buildEnv {
|
||||
extensions = { enabled, all }: enabled ++ (with all; [ iconv mbstring pdo_mysql pdo_sqlite ]);
|
||||
@@ -14,45 +14,4 @@ pkgs.mkShellNoCC {
|
||||
sql-formatter
|
||||
openssl
|
||||
];
|
||||
|
||||
# Prepare dev environment with sqlite and config files
|
||||
shellHook = ''
|
||||
alias runDev='php -S localhost:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/'
|
||||
|
||||
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/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 $?
|
||||
|
||||
# Set up SimpleSAMLphp identity provider (for local testing)
|
||||
install -m644 dist/simplesaml-dev/authsources.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/config.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-hosted.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-sp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
|
||||
# See session.phpsession.savepath in config.php
|
||||
mkdir -p vendor/simplesamlphp/simplesamlphp/sessions/
|
||||
|
||||
openssl req \
|
||||
-newkey rsa:4096 \
|
||||
-new \
|
||||
-x509 \
|
||||
-days 3652 \
|
||||
-nodes \
|
||||
-out vendor/simplesamlphp/simplesamlphp/cert/localhost.crt \
|
||||
-keyout vendor/simplesamlphp/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
|
||||
popd
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
||||
36
scripts/clean.sh
Executable file
36
scripts/clean.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(git grep)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r GIT_TREE_IS_DIRTY="$(
|
||||
if ! git diff --quiet --ignore-submodules \
|
||||
|| git ls-files --others --exclude-standard | grep -q .; then
|
||||
echo 1
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
)"
|
||||
|
||||
if [ "$GIT_TREE_IS_DIRTY" == "1" ]; then
|
||||
echo "Git working tree is dirty, refusing to reset" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
(
|
||||
cd "$PROJECT_ROOT"
|
||||
git clean -fdx
|
||||
)
|
||||
21
scripts/reset.sh
Executable file
21
scripts/reset.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(git)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
"$PROJECT_ROOT/scripts/clean.sh"
|
||||
"$PROJECT_ROOT/scripts/setup.sh"
|
||||
"$PROJECT_ROOT/scripts/seed-test-data.sh"
|
||||
37
scripts/run.sh
Executable file
37
scripts/run.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
php
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
# Check for hints that our project might not be correctly set up
|
||||
if [ ! -d "$PROJECT_ROOT/vendor" ] \
|
||||
|| [ ! -f "$PROJECT_ROOT/config.php" ] \
|
||||
|| [ ! -d "$PROJECT_ROOT/www/simplesaml" ] \
|
||||
|| [ ! -d "$PROJECT_ROOT/www/galleri/bilder" ]; then
|
||||
echo "It looks like the project is not correctly set up." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -a PHP_ARGS=(
|
||||
-S localhost:1080
|
||||
-d error_reporting=E_ALL
|
||||
-d display_errors=1
|
||||
-t www/
|
||||
)
|
||||
|
||||
(cd "$PROJECT_ROOT" && php "${PHP_ARGS[@]}")
|
||||
26
scripts/seed-test-data.sh
Executable file
26
scripts/seed-test-data.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
sqlite3
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
|
||||
if [ ! -f "$PROJECT_ROOT/pvv.sqlite" ] ; then
|
||||
echo "Database file $PROJECT_ROOT/pvv.sqlite does not exist. Please run setup.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sqlite3 "$PROJECT_ROOT/pvv.sqlite" < "$PROJECT_ROOT/dist/sql/test_data_sqlite.sql"
|
||||
57
scripts/setup.sh
Executable file
57
scripts/setup.sh
Executable file
@@ -0,0 +1,57 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REQUIRED_COMMANDS=(
|
||||
git
|
||||
composer
|
||||
sqlite3
|
||||
openssl
|
||||
install
|
||||
)
|
||||
MISSING_COMMANDS=false
|
||||
for cmd in "${REQUIRED_COMMANDS[@]}"; do
|
||||
if ! command -v "$cmd" &> /dev/null; then
|
||||
echo "$cmd could not be found" >&2
|
||||
MISSING_COMMANDS=true
|
||||
fi
|
||||
done
|
||||
if [ "$MISSING_COMMANDS" = true ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r PROJECT_ROOT="$(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/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 $?
|
||||
|
||||
# Set up SimpleSAMLphp identity provider (for local testing)
|
||||
install -m644 dist/simplesaml-dev/authsources.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/config.php -t vendor/simplesamlphp/simplesamlphp/config/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-idp-hosted.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
install -m644 dist/simplesaml-dev/saml20-sp-remote.php -t vendor/simplesamlphp/simplesamlphp/metadata/
|
||||
|
||||
# See session.phpsession.savepath in config.php
|
||||
mkdir -p vendor/simplesamlphp/simplesamlphp/sessions/
|
||||
|
||||
openssl req \
|
||||
-newkey rsa:4096 \
|
||||
-new \
|
||||
-x509 \
|
||||
-days 3652 \
|
||||
-nodes \
|
||||
-out vendor/simplesamlphp/simplesamlphp/cert/localhost.crt \
|
||||
-keyout vendor/simplesamlphp/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
|
||||
popd
|
||||
fi
|
||||
@@ -78,7 +78,7 @@ class Door {
|
||||
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':time', $time, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':open', $open, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':open', $open, \PDO::PARAM_BOOL);
|
||||
$statement->execute();
|
||||
|
||||
$this->removeOld();
|
||||
|
||||
@@ -6,35 +6,105 @@ namespace pvv\side;
|
||||
|
||||
class Project {
|
||||
private int $id;
|
||||
private string $name;
|
||||
private array $descr;
|
||||
private bool $active;
|
||||
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;
|
||||
|
||||
public function __construct(
|
||||
int $id,
|
||||
string $name,
|
||||
string $descr,
|
||||
bool $active,
|
||||
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,
|
||||
) {
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->active = $active;
|
||||
$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;
|
||||
}
|
||||
|
||||
public function getID(): int {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->name;
|
||||
public function getTitle(): string {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function getDescription(): array {
|
||||
return $this->descr;
|
||||
public function getDescriptionEn(): array {
|
||||
return $this->description_en;
|
||||
}
|
||||
|
||||
public function getActive(): bool {
|
||||
return $this->active;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class ProjectManager {
|
||||
* @return Project[]
|
||||
*/
|
||||
public function getAll(): array {
|
||||
$query = 'SELECT * FROM projects ORDER BY id ASC';
|
||||
$query = 'SELECT * FROM project ORDER BY id ASC';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
@@ -23,9 +23,17 @@ class ProjectManager {
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active'],
|
||||
$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']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
@@ -34,7 +42,7 @@ class ProjectManager {
|
||||
}
|
||||
|
||||
public function getByID(int $id): ?Project {
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$query = 'SELECT * FROM project WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
@@ -46,9 +54,17 @@ class ProjectManager {
|
||||
|
||||
return new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active'],
|
||||
$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']
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,7 +72,13 @@ class ProjectManager {
|
||||
* @return Project[]
|
||||
*/
|
||||
public function getByOwner(string $uname): array {
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$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
|
||||
';
|
||||
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
@@ -74,9 +96,17 @@ class ProjectManager {
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['active'],
|
||||
$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']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
@@ -89,44 +119,27 @@ class ProjectManager {
|
||||
* @return array<int,array>
|
||||
*/
|
||||
public function getProjectMembers(int $id): array {
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$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
|
||||
';
|
||||
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$members = [];
|
||||
$maintainers = [];
|
||||
foreach ($statement->fetchAll() as $dbUsr) {
|
||||
$members[] = [
|
||||
$maintainers[] = [
|
||||
'name' => $dbUsr['name'],
|
||||
'uname' => $dbUsr['uname'],
|
||||
'link' => $dbUsr['link'],
|
||||
'mail' => $dbUsr['mail'],
|
||||
'role' => $dbUsr['role'],
|
||||
'lead' => $dbUsr['lead'],
|
||||
'owner' => $dbUsr['owner'],
|
||||
];
|
||||
}
|
||||
|
||||
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'],
|
||||
];
|
||||
return $maintainers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ $desc = $_POST['desc'];
|
||||
$name = $_POST['organisername'];
|
||||
$uname = $_POST['organiser'];
|
||||
$mail = $_POST['organiseremail'];
|
||||
$active = ($_POST['active'] ?? 0);
|
||||
$active = ($_POST['active'] ?? false);
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
@@ -42,7 +42,7 @@ if ($id == 0) {
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_BOOL);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
@@ -59,7 +59,7 @@ if ($id == 0) {
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_BOOL);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
@@ -36,16 +36,16 @@ $project = new pvv\side\Project(
|
||||
$attrs['mail'][0],
|
||||
1
|
||||
);
|
||||
if ($new == 0) {
|
||||
$project = $projectManager->getByID($projectID);
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
// if ($new == 0) {
|
||||
// $project = $projectManager->getByID($projectID);
|
||||
// $maintainers = $projectManager->getProjectMaintainers($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,12 +74,48 @@ if ($new == 0) {
|
||||
<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->getName(); ?>" class="boxinput"><br>
|
||||
<input class="wide" type="text" name="title" value="<?php echo $project->getTitle(); ?>" class="boxinput" required><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"><?php echo implode("\n", $project->getDescription()); ?></textarea>
|
||||
<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>
|
||||
|
||||
<?php echo '<input type="hidden" name="id" value="' . $project->getID() . '" />'; ?>
|
||||
<input type="hidden" name="active" value="1"/>
|
||||
|
||||
@@ -71,7 +71,6 @@ $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
|
||||
@@ -84,7 +83,7 @@ $projects = $projectManager->getAll();
|
||||
<div class="projects-container">
|
||||
|
||||
<?php
|
||||
$randProjects = array_rand($projects, min(6, count($projects)));
|
||||
$randProjects = array_rand($projects, min(8, count($projects)));
|
||||
if (!is_array($randProjects)) {
|
||||
$randProjects = [$randProjects];
|
||||
}
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
<?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('default-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­verk­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>
|
||||
@@ -30,7 +30,7 @@ $mail = $attrs['mail'][0];
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)';
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, TRUE)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
@@ -39,7 +39,7 @@ if ($id == 0) {
|
||||
$statement->execute();
|
||||
$new_id = $pdo->lastInsertId();
|
||||
|
||||
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', 1, 1)";
|
||||
$ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', TRUE, TRUE)";
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':id', $new_id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
@@ -62,7 +62,7 @@ if ($id == 0) {
|
||||
}
|
||||
}
|
||||
if ($is_member) {// leave
|
||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=0 and owner=0;';
|
||||
$query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=FALSE and owner=FALSE;';
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
@@ -70,7 +70,7 @@ if ($id == 0) {
|
||||
$statement->execute();
|
||||
echo 'leave';
|
||||
} else {// join
|
||||
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', 0, 0)";
|
||||
$query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', FALSE, FALSE)";
|
||||
$statement = $pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
|
||||
Reference in New Issue
Block a user