2017-10-28 16:44:56 +02:00
|
|
|
<?php
|
|
|
|
date_default_timezone_set('Europe/Oslo');
|
2018-02-10 18:08:53 +01:00
|
|
|
setlocale(LC_ALL, 'nb_NO');
|
2017-10-28 16:44:56 +02:00
|
|
|
require __DIR__ . '/../../../src/_autoload.php';
|
2024-02-15 22:57:03 +01:00
|
|
|
require __DIR__ . '/../../../config.php';
|
2024-03-12 19:33:09 +01:00
|
|
|
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
2017-10-28 16:44:56 +02:00
|
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
2017-11-11 17:06:56 +01:00
|
|
|
$userManager = new \pvv\admin\UserManager($pdo);
|
|
|
|
|
|
|
|
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
|
|
|
$as = new SimpleSAML_Auth_Simple('default-sp');
|
|
|
|
$as->requireAuth();
|
|
|
|
$attrs = $as->getAttributes();
|
|
|
|
$uname = $attrs['uid'][0];
|
|
|
|
|
|
|
|
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
2017-11-11 20:37:04 +01:00
|
|
|
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
2017-11-11 17:06:56 +01:00
|
|
|
exit();
|
|
|
|
}
|
2017-10-28 16:44:56 +02:00
|
|
|
|
|
|
|
if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['organisername']) or !isset($_POST['organiser'])){
|
|
|
|
header('Location: ' . $_SERVER['HTTP_REFERER']);
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = 0;
|
|
|
|
if(isset($_POST['id'])){
|
|
|
|
$id = $_POST['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $_POST['title'];
|
|
|
|
$desc = $_POST['desc'];
|
2018-02-26 16:24:50 +01:00
|
|
|
$name = $_POST['organisername'];
|
2017-10-28 16:44:56 +02:00
|
|
|
$uname = $_POST['organiser'];
|
2018-02-26 16:24:50 +01:00
|
|
|
$mail = $_POST['organiseremail'];
|
2017-10-28 16:44:56 +02:00
|
|
|
$active = (isset($_POST['active']) ? $_POST['active'] : 0);
|
|
|
|
|
|
|
|
$statement;
|
|
|
|
if($id == 0){
|
2018-02-26 16:24:50 +01:00
|
|
|
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, :active)';
|
2017-10-28 16:44:56 +02:00
|
|
|
$statement = $pdo->prepare($query);
|
|
|
|
|
|
|
|
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
2018-02-26 16:24:50 +01:00
|
|
|
|
|
|
|
$statement->execute();
|
|
|
|
|
|
|
|
$ownerQuery = 'INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (last_insert_rowid(), :owner, :owneruname, :owneremail, \'Prosjektleder\', 1, 1)';
|
|
|
|
$statement = $pdo->prepare($ownerQuery);
|
|
|
|
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
|
|
|
|
|
|
|
$statement->execute();
|
2017-10-28 16:44:56 +02:00
|
|
|
}else{
|
2018-02-26 16:24:50 +01:00
|
|
|
$query = 'UPDATE projects SET name=:title, description=:desc, active=:active WHERE id=:id';
|
2017-10-28 16:44:56 +02:00
|
|
|
$statement = $pdo->prepare($query);
|
|
|
|
|
|
|
|
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
|
|
|
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
|
|
|
|
2018-02-26 16:24:50 +01:00
|
|
|
$statement->execute();
|
|
|
|
|
|
|
|
$query = 'UPDATE projectmembers SET name=:name, uname=:uname, mail=:mail';
|
|
|
|
$statement = $pdo->prepare($query);
|
|
|
|
|
|
|
|
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
|
|
|
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
|
|
|
|
|
|
|
$statement->execute();
|
|
|
|
}
|
2017-10-28 16:44:56 +02:00
|
|
|
|
|
|
|
header('Location: .');
|
|
|
|
?>
|
|
|
|
|
|
|
|
<a href=".?page=1">Om du ikke ble automatisk omdirigert tilbake klikk her</a>
|