commit 63ed78577b100fd58e3636f63d1c29a122700a29
parent 4de368d8ad8a3480d600e84293ec9d8182991280
Author: MoiBaguette <[email protected]>
Date: Sun, 25 Jun 2023 21:11:20 +0200
links in table
Diffstat:
19 files changed, 269 insertions(+), 161 deletions(-)
diff --git a/Controller/Templates.php b/Controller/Templates.php
@@ -93,11 +93,11 @@ namespace Controller{
</form>';
}
- public function crud_table(string $action, string $search = "", string $search_key, \Model\PermissionUser $permissionUser = null):string{
+ public function crud_table(string $action, string $search = "", string $search_key = "", \Model\PermissionUser $permissionUser = null):string{
if($search == ""){
$search = "%";
}else{
- $search = '%' . $search . '%';
+ $search = "%$search%";
}
$table = "<table> <thead> <tr>";
foreach($this->table->get_column_names() as $column){
@@ -116,10 +116,10 @@ namespace Controller{
$col_names = $obj->get_column_names();
foreach($col_names as $col){
$table .= '<td>';
- if($col == "email" || $col == "exam" || $col == "course"){
- $table .= "<a>$col</a></td>";
+ if($col == "email" || $col == "name" || $col == "course" || $col == "exam"){
+ $table .= '<a href="/'.$this->table->get_table().'/' .$obj->{$col}.'">'. $obj->{$col} . '</a></td>';
}else{
- $table .= $obj->{$col} . '</td>';
+ $table .= $obj->{$col} . '</td>';
}
}
$table .= '
@@ -148,7 +148,7 @@ namespace Controller{
$links = '<div class ="links">';
if(isset($_SESSION['user_permissions'])){
if(in_array(1, $_SESSION['user_permissions']) || in_array(2, $_SESSION['user_permissions'])|| in_array(3, $_SESSION['user_permissions'])){
- $links .= '<a href="/userpage/'.$_SESSION["email"].'/page">My info</a>';
+ $links .= '<a href="/user/'.$_SESSION["email"].'">My info</a>';
}
if(in_array(2, $_SESSION['user_permissions']) || in_array(3, $_SESSION['user_permissions'])){
$links .= '<a href="/course">Courses</a>';
@@ -166,11 +166,18 @@ namespace Controller{
function header():string{
$header = "";
$header .= "<div class='header'>
- <h1>Lollipop</h1>";
- if(isset($_SESSION['user_permissions']))
- $header .= '<a href="/logout">logout</a>';
+ <div class='box_title'>
+ <a href='/dashboard'>Lollipop</a>
+ </div>
+ <div class='header_middle'></div>";
+ if(isset($_SESSION['user_permissions'])){
+ $header .= "<div class='box_logout'>
+ <a href='/logout'>logout</a>
+ </div>";
+ }
$header .= "</div>";
return $header;
}
+
}
}
\ No newline at end of file
diff --git a/Lollipop/Router.php b/Lollipop/Router.php
@@ -103,3 +103,4 @@ namespace Lollipop {
return null;
}
}
+}
+\ No newline at end of file
diff --git a/Model/Permission.php b/Model/Permission.php
@@ -16,7 +16,7 @@ namespace Model {
{
return "lollipop";
}
- function get_checkboxes(): string{
+ function get_checkboxes(): array{
$all_permissions = $this->db->all($this::class);
$html = "<div class='check_this_box'>";
foreach($all_permissions as $permission){
@@ -28,7 +28,7 @@ namespace Model {
$html .= '<label for="'. $permission->name .'">'. $permission->name .'</label>';
}
$html .= "</div>";
- return $html;
+ return [0 => $html];
}
}
}
\ No newline at end of file
diff --git a/index.php b/index.php
@@ -18,6 +18,7 @@ session_start();
echo $tmp;
}
}*/
+//css
$router->addRoute(["GET"], "/views/css/add_user.css", "views/css/add_user.css");
$router->addRoute(["GET"], "/views/css/course.css", "views/css/course.css");
$router->addRoute(["GET"], "/views/css/exam.css", "views/css/exam.css");
@@ -29,58 +30,73 @@ $router->addRoute(["GET"], "/", $index_get);
$router->addRoute(["POST"], "/", $index_post);
-$router->addRoute(["GET"], "/dashboard", $dashboard);
+$router->addRoute(["GET"], "/logout", $logout);
-$router->addRoute(["GET"], "/user", $user_get);
+if(isset($_SESSION['user_permissions'])){
+ if(in_array(1, $_SESSION['user_permissions']) || in_array(2, $_SESSION['user_permissions']) || in_array(3, $_SESSION['user_permissions'])){
+ $router->addRoute(["GET"], "/user/:primary_key", $user_page);
-$router->addRoute(["POST"], "/user", $user_post);
+ $router->addRoute(["GET"], "/dashboard", $dashboard);
+ }
-$router->addRoute(["GET"], "/user/search/:search_query", $user_query);
+ if(in_array(2, $_SESSION['user_permissions']) || in_array(3, $_SESSION['user_permissions']) ){
+ $router->addRoute(["GET"], "/course", $course_get);
-$router->addRoute(["POST"], "/user/search", $user_search);
+ $router->addRoute(["GET"], "/course/:course", $course_data);
-$router->addRoute(["GET"], "/user/:primary_key/edit", $user_edit);
+ $router->addRoute(["POST"], "/course", $course_post);
-$router->addRoute(["GET"], "/user/:primary_key/delete", $user_delete);
+ $router->addRoute(["GET"], "/course/search/:search_query", $course_query);
-$router->addRoute(["GET"], "/user/:primary_key/page", $user_page);
+ $router->addRoute(["POST"], "/course/search", $course_search);
-$router->addRoute(["GET"], "/logout", $logout);
+ $router->addRoute(["GET"], "/course/:primary_key/edit", $course_edit);
-$router->addRoute(["GET"], "/course", $course_get);
+ $router->addRoute(["GET"], "/course/:primary_key/delete", $course_delete);
-$router->addRoute(["POST"], "/course", $course_post);
+ $router->addRoute(["GET"], "/exam", $exam_get);
-$router->addRoute(["GET"], "/course/search/:search_query", $course_query);
+ $router->addRoute(["GET"], "/exam/:exam", $exam_data);
-$router->addRoute(["POST"], "/course/search", $course_search);
+ $router->addRoute(["POST"], "/exam", $exam_post);
-$router->addRoute(["GET"], "/course/:primary_key/edit", $course_edit);
+ $router->addRoute(["GET"], "/exam/search/:search_query", $exam_query);
-$router->addRoute(["GET"], "/course/:primary_key/delete", $course_delete);
+ $router->addRoute(["POST"], "/exam/search", $exam_search);
-$router->addRoute(["GET"], "/exam", $exam_get);
+ $router->addRoute(["GET"], "/exam/:primary_key/edit", $exam_edit);
-$router->addRoute(["POST"], "/exam", $exam_post);
+ $router->addRoute(["GET"], "/exam/:primary_key/delete", $exam_delete);
-$router->addRoute(["GET"], "/exam/search/:search_query", $exam_query);
+ $router->addRoute(["GET"], "/grade", $grade_get);
-$router->addRoute(["POST"], "/exam/search", $exam_search);
+ $router->addRoute(["POST"], "/grade", $grade_post);
-$router->addRoute(["GET"], "/exam/:primary_key/edit", $exam_edit);
+ $router->addRoute(["GET"], "/grade/search/:search_query", $grade_query);
-$router->addRoute(["GET"], "/exam/:primary_key/delete", $exam_delete);
+ $router->addRoute(["POST"], "/grade/search", $grade_search);
-$router->addRoute(["GET"], "/grade", $grade_get);
+ $router->addRoute(["GET"], "/grade/:primary_key/edit", $grade_edit);
+
+ $router->addRoute(["GET"], "/grade/:primary_key/delete", $grade_delete);
+ }
-$router->addRoute(["POST"], "/grade", $grade_post);
+ if(in_array(3, $_SESSION['user_permissions'])){
-$router->addRoute(["GET"], "/grade/search/:search_query", $grade_query);
+ $router->addRoute(["GET"], "/user", $user_get);
-$router->addRoute(["POST"], "/grade/search", $grade_search);
+ $router->addRoute(["POST"], "/user", $user_post);
-$router->addRoute(["GET"], "/grade/:primary_key/edit", $grade_edit);
+ $router->addRoute(["GET"], "/user/search/:search_query", $user_query);
-$router->addRoute(["GET"], "/grade/:primary_key/delete", $grade_delete);
+ $router->addRoute(["POST"], "/user/search", $user_search);
+
+ $router->addRoute(["GET"], "/user/:primary_key/edit", $user_edit);
+
+ $router->addRoute(["GET"], "/user/:primary_key/delete", $user_delete);
+
+ $router->addRoute(["GET"], "/test", $test);
+ }
+}
$router->route();
diff --git a/routing/course.php b/routing/course.php
@@ -2,15 +2,12 @@
$course_get = function(&$vars){
global $db;
$course = $db->get(Model\Course::class);
- $templates = new Controller\Templates($db, $course);
if(isset($_POST["search"])){
$course->load($_POST["search"]);
$data = $course->getData();
}
- $vars["form"] = $templates->form_v2("/course");
- $vars["search"] = $templates->search_form("/course/search");
- $vars["table"] = $templates->crud_table("/course", "" ,"name");
+ $vars += get_vars($course, "/course", "/course/search", "", "name");
return "views/course.html";
};
@@ -18,9 +15,6 @@ $course_post = function(&$vars){
global $db;
$course = $db->get(Model\Course::class);
$user = $db->get(Model\User::class);
- $templates = new Controller\Templates($db, $course);
- $data = [];
-
if(isset($_POST["form_type"])){
if($user->load($_POST['lecturer'])){
if($_POST["form_type"] == 'Add'){
@@ -38,19 +32,14 @@ $course_post = function(&$vars){
}
- $vars["form"] = $templates->form_v2("/course", $data);
- $vars["search"] = $templates->search_form("/course");
- $vars["table"] = $templates->crud_table("/course", "", "name");
+ $vars += get_vars($course, "/course", "/course/search", "", "name");
return "views/course.html";
};
$course_query = function(&$vars){
global $db;
$course = $db->get(Model\Course::class);
- $templates = new controller\templates($db, $course);
- $vars["form"] = $templates->form_v2("/course");
- $vars["search"] = $templates->search_form("/course/search");
- $vars["table"] = $templates->crud_table("/course", $vars["search_query"], "name");
+ $vars += get_vars($course, "/course", "/course/search", "", "name");
return "views/course.html";
};
@@ -72,26 +61,48 @@ $course_search = function(&$vars){
$course_edit = function(&$vars){
global $db;
$course = $db->get(Model\Course::class);
- $templates = new Controller\Templates($db, $course);
$data = [];
$course->load($vars["primary_key"]);
foreach($course->getData() as $key => $col){
$data[$key] = $col;
}
- $vars["form"] = $templates->form_v2("/course", $data);
- $vars["search"] = $templates->search_form("/course/search");
- $vars["table"] = $templates->crud_table("/course", "", "name");
+ $vars += get_vars($course, "/course", "/course/search", "", "name", $data);
return "views/course.html";
};
$course_delete = function(&$vars){
global $db;
$course = $db->get(Model\Course::class);
- $templates = new Controller\Templates($db, $course);
$course->load($vars["primary_key"]);
$course->delete();
- $vars["form"] = $templates->form_v2("/course");
- $vars["search"] = $templates->search_form("/course");
- $vars["table"] = $templates->crud_table("/course" ,"", "name");
+ $vars += get_vars($course, "/course", "/course/search", "", "name");
return "views/course.html";
};
+
+$course_data = function(&$vars){
+ global $db;
+ $course = $db->get(Model\Course::class);
+ $exam = $db->get(Model\Exam::class);
+ $course->where("name", $vars["course"]);
+ $tmp = $vars["course"];
+ $table = "<h1>all exams for $tmp </h1><table> <thead> <tr>";
+ foreach($exam->get_column_names() as $column){
+ $table .= "<th>$column</th>";
+ }
+ $table .= "</tr> </thead>";
+ $table .= "<tbody>";
+
+ foreach($db->all_where(Model\Exam::class, ["course_id" => $course->id]) as $data){
+ $table .= "<tr>";
+ $col_names = $exam->get_column_names();
+ foreach($col_names as $col){
+ $table .= '<td>' . $data->{$col} . '</td>';
+ }
+ $table .= "</tr>";
+ };
+
+ $table .= "
+ </tbody></table>";
+ $vars['table'] = $table;
+ return "views/parent_child.html";
+};
diff --git a/routing/exam.php b/routing/exam.php
@@ -2,26 +2,21 @@
$exam_get = function(&$vars){
global $db;
$exam = $db->get(Model\Exam::class);
- $templates = new Controller\Templates($db, $exam);
-
+
if(isset($_POST["search"])){
$exam->load($_POST["search"]);
$data = $exam->getData();
}
- $vars["form"] = $templates->form_v2("/exam");
- $vars["search"] = $templates->search_form("/exam/search");
- $vars["table"] = $templates->crud_table("/exam", "" ,"name");
+ $vars += get_vars($exam, "/exam", "/exam/search", "", "name");
return "views/exam.html";
};
$exam_post = function(&$vars){
global $db;
$exam = $db->get(Model\Exam::class);
- $templates = new Controller\Templates($db, $exam);
$course = $db->get(Model\Course::class);
- $data = [];
if(isset($_POST["form_type"])){
- if($course->load($_POST['course'])){
+ if($course->load($_POST['course_id'])){
if($_POST["form_type"] == 'Add'){
if($exam->add_exam()){
$vars["response"] = 'succesfully added: ' . $_POST["name"];
@@ -37,19 +32,14 @@ $exam_post = function(&$vars){
}
- $vars["form"] = $templates->form_v2("/exam", $data);
- $vars["search"] = $templates->search_form("/exam");
- $vars["table"] = $templates->crud_table("/exam", "", "name");
+ $vars += get_vars($exam, "/exam", "/exam/search", "", "name");
return "views/exam.html";
};
$exam_query = function(&$vars){
global $db;
$exam = $db->get(Model\Exam::class);
- $templates = new controller\templates($db, $exam);
- $vars["form"] = $templates->form_v2("/exam");
- $vars["search"] = $templates->search_form("/exam/search");
- $vars["table"] = $templates->crud_table("/exam", $vars["search_query"], "name");
+ $vars += get_vars($exam, "/exam", "/exam/search", "", "name");
return "views/exam.html";
};
@@ -71,26 +61,48 @@ $exam_search = function(&$vars){
$exam_edit = function(&$vars){
global $db;
$exam = $db->get(Model\Exam::class);
- $templates = new Controller\Templates($db, $exam);
$data = [];
$exam->load($vars["primary_key"]);
foreach($exam->getData() as $key => $col){
$data[$key] = $col;
}
- $vars["form"] = $templates->form_v2("/exam", $data);
- $vars["search"] = $templates->search_form("/exam/search");
- $vars["table"] = $templates->crud_table("/exam", "", "name");
+ $vars += get_vars($exam, "/exam", "/exam/search", "", "name", $data);
return "views/exam.html";
};
$exam_delete = function(&$vars){
global $db;
$exam = $db->get(Model\Exam::class);
- $templates = new Controller\Templates($db, $exam);
$exam->load($vars["primary_key"]);
$exam->delete();
- $vars["form"] = $templates->form_v2("/exam");
- $vars["search"] = $templates->search_form("/exam");
- $vars["table"] = $templates->crud_table("/exam" ,"", "name");
+ $vars += get_vars($exam, "/exam", "/exam/search", "", "name");
return "views/exam.html";
};
+
+$exam_data = function(&$vars){
+ global $db;
+ $exam = $db->get(Model\Exam::class);
+ $grade = $db->get(Model\Grade::class);
+ $exam->where("name", $vars["exam"]);
+ $tmp = $vars["exam"];
+ $table = "<h1>all grades for $tmp </h1><table> <thead> <tr>";
+ foreach($grade->get_column_names() as $column){
+ $table .= "<th>$column</th>";
+ }
+ $table .= "</tr> </thead>";
+ $table .= "<tbody>";
+
+ foreach($db->all_where(Model\Grade::class, ["exam" => $exam->id]) as $data){
+ $table .= "<tr>";
+ $col_names = $grade->get_column_names();
+ foreach($col_names as $col){
+ $table .= '<td>' . $data->{$col} . '</td>';
+ }
+ $table .= "</tr>";
+ };
+
+ $table .= "
+ </tbody></table>";
+ $vars['table'] = $table;
+ return "views/parent_child.html";
+};
+\ No newline at end of file
diff --git a/routing/grade.php b/routing/grade.php
@@ -8,9 +8,7 @@ $grade_get = function(&$vars){
$grade->load($_POST["search"]);
$data = $grade->getData();
}
- $vars["form"] = $templates->form_v2("/grade");
- $vars["search"] = $templates->search_form("/grade/search");
- $vars["table"] = $templates->crud_table("/grade", "" ,"email");
+ $vars += get_vars($grade, "/grade", "/grade/search", "", "email");
return "views/grade.html";
};
@@ -19,10 +17,7 @@ $grade_post = function(&$vars){
$grade = $db->get(Model\Grade::class);
$user = $db->get(Model\User::class);
$exam = $db->get(Model\Exam::class);
- $templates = new Controller\Templates($db, $grade);
- $data = [];
-
- if($exam->load($_POST['exam'])){
+ if($exam->load($_POST['exam'])){
if($user->load($_POST['email'])){
if(isset($_POST["form_type"])){
if($_POST["form_type"] == 'Add'){
@@ -41,20 +36,14 @@ $grade_post = function(&$vars){
}else{
$vars["response"] = 'foreign_key constraint on exam';
}
-
- $vars["form"] = $templates->form_v2("/grade", $data);
- $vars["search"] = $templates->search_form("/grade");
- $vars["table"] = $templates->crud_table("/grade", "", "email");
+ $vars += get_vars($grade, "/grade", "/grade/search", "", "email");
return "views/grade.html";
};
$grade_query = function(&$vars){
global $db;
$grade = $db->get(Model\Grade::class);
- $templates = new controller\templates($db, $grade);
- $vars["form"] = $templates->form_v2("/grade");
- $vars["search"] = $templates->search_form("/grade/search");
- $vars["table"] = $templates->crud_table("/grade", $vars["search_query"], "email");
+ $vars += get_vars($grade, "/grade", "/grade/search", "", "email");
return "views/grade.html";
};
@@ -76,26 +65,25 @@ $grade_search = function(&$vars){
$grade_edit = function(&$vars){
global $db;
$grade = $db->get(Model\Grade::class);
- $templates = new Controller\Templates($db, $grade);
+
$data = [];
$grade->load($vars["primary_key"]);
foreach($grade->getData() as $key => $col){
$data[$key] = $col;
}
- $vars["form"] = $templates->form_v2("/grade", $data);
- $vars["search"] = $templates->search_form("/grade/search");
- $vars["table"] = $templates->crud_table("/grade", "", "email");
+
+ $vars += get_vars($grade, "/grade", "/grade/search", "", "email", $data);
return "views/grade.html";
};
$grade_delete = function(&$vars){
global $db;
$grade = $db->get(Model\Grade::class);
- $templates = new Controller\Templates($db, $grade);
+
$grade->load($vars["primary_key"]);
$grade->delete();
- $vars["form"] = $templates->form_v2("/grade");
- $vars["search"] = $templates->search_form("/grade");
- $vars["table"] = $templates->crud_table("/grade" ,"", "email");
+
+ $vars += get_vars($grade, "/grade", "/grade/search", "", "email");
return "views/grade.html";
};
+
diff --git a/routing/index.php b/routing/index.php
@@ -1,6 +1,9 @@
<?php
$index_get = function(&$vars){
+ if(isset($_SESSION['user_permissions'])){
+ header('Location: /dashboard');
+ }
global $db;
$templates = new Controller\Templates($db, $db->get(\Model\User::class));
$vars["header"] = $templates->header();
@@ -11,6 +14,8 @@ $index_get = function(&$vars){
$index_post = function(&$vars){
global $db;
$res = $db->get(Model\User::class)->login();
+ $templates = new Controller\Templates($db, $db->get(\Model\Course::class));
+ $vars["header"] = $templates->header();
if($res == []){
header("Location: dashboard");
exit();
@@ -39,7 +44,7 @@ $dashboard = function(&$vars){
foreach($course->get_column_names() as $column){
$table .= "<th>$column</th>";
}
- $table .= "<th>registered</tr> </thead>";
+ $table .= "<th>registered</th></tr> </thead>";
$objs = $db->all(Model\Course::class);
$table .= "<tbody>";
@@ -77,4 +82,27 @@ $logout = function(&$vars){
session_unset();
session_destroy();
header("Location: /");
-};
-\ No newline at end of file
+};
+$test = function(&$vars){
+ global $db;
+ $user = $db->get(Model\User::class);
+ $permissions = $db->get(Model\Permission::class);
+
+ $permission_user = $db->get(Model\PermissionUser::class);
+ var_dump($db->all_where(Model\User::class, ["email" => ""]));
+ var_dump(get_vars($user, "/user", "/user/search", "", "email", [], $permissions->get_checkboxes(), $permission_user));
+};
+
+function get_vars(Lollipop\DatabaseObject $table, string $action, string $search_action, string $search_string, string $search_key, array $form_data = [], array $extra = [], Model\PermissionUser $permissionUser = null): array{
+ global $db;
+ $templates = new Controller\Templates($db, $table);
+
+ $array = [];
+ $array["header"] = $templates->header();
+ $array["form"] = $templates->form_v2($action, $form_data, $extra);
+ $array["search"] = $templates->search_form($search_action);
+ $array["table"] = $templates->crud_table($action, $search_string, $search_key, $permissionUser);
+ $array['links'] = $templates->links();
+ $array['first_name'] = $_SESSION['first_name'];
+ return $array;
+}
diff --git a/routing/user.php b/routing/user.php
@@ -1,18 +1,14 @@
<?php
+/* if(isset($_POST["search"])){
+ $user->load($_POST["search"]);
+ $data = $user->getData();
+ }*/
$user_get = function(&$vars){
global $db;
$user = $db->get(Model\User::class);
$permissions = $db->get(Model\Permission::class);
$permission_user = $db->get(Model\PermissionUser::class);
- $templates = new controller\templates($db, $user);
-
- if(isset($_POST["search"])){
- $user->load($_POST["search"]);
- $data = $user->getData();
- }
- $vars["form"] = $templates->form_v2("/user", [], ["checkboxes" => $permissions->get_checkboxes()]);
- $vars["search"] = $templates->search_form("/user/search");
- $vars["table"] = $templates->crud_table("/user", "" ,"email", $permission_user);
+ $vars += get_vars($user, "/user", "/user/search", "", "email", [], $permissions->get_checkboxes(), $permission_user);
return "views/user.html";
};
@@ -21,8 +17,6 @@ $user_post = function(&$vars){
$user = $db->get(Model\User::class);
$permissions = $db->get(Model\Permission::class);
$permission_user = $db->get(Model\PermissionUser::class);
- $templates = new controller\templates($db, $user);
- $data = [];
if(isset($_POST["form_type"])){
if($_POST["form_type"] == 'Add'){
@@ -34,14 +28,10 @@ $user_post = function(&$vars){
$vars["response"] = 'succesfully updated: ' . $_POST["email"];
}else{
echo"something went wrong";
- var_dump(\Lollipop\Utils::missing_fields($user->notNullable()));
}
}
}
-
- $vars["form"] = $templates->form_v2("/user", $data, ["checkboxes" => $permissions->get_checkboxes()]);
- $vars["search"] = $templates->search_form("/user");
- $vars["table"] = $templates->crud_table("/user", "", "email", $permission_user);
+ $vars += get_vars($user, "/user", "/user/search", "", "email", [], $permissions->get_checkboxes(), $permission_user);
return "views/user.html";
};
@@ -50,10 +40,8 @@ $user_query = function(&$vars){
$user = $db->get(Model\User::class);
$permissions = $db->get(Model\Permission::class);
$permission_user = $db->get(Model\PermissionUser::class);
- $templates = new controller\templates($db, $user);
- $vars["form"] = $templates->form_v2("/user", [], ["checkboxes" => $permissions->get_checkboxes()]);
- $vars["search"] = $templates->search_form("/user/search");
- $vars["table"] = $templates->crud_table("/user", $vars["search_query"], "email", $permission_user);
+ $query = '%' . $vars['search_query'] . '%';
+ $vars += get_vars($user, "/user", "/user/search", $query, "email", [], $permissions->get_checkboxes(), $permission_user);
return "views/user.html";
};
@@ -83,9 +71,7 @@ $user_edit = function(&$vars){
foreach($user->getData() as $key => $col){
$data[$key] = $col;
}
- $vars["form"] = $templates->form_v2("/user", $data, ["checkboxes" => $permissions->get_checkboxes()]);
- $vars["search"] = $templates->search_form("/user/search");
- $vars["table"] = $templates->crud_table("/user", "", "email", $permission_user);
+ $vars += get_vars($user, "/user", "/user/search", "", "email", $data, $permissions->get_checkboxes(), $permission_user);
return "views/user.html";
};
@@ -93,21 +79,27 @@ $user_delete = function(&$vars){
global $db;
$user = $db->get(Model\User::class);
$permissions = $db->get(Model\Permission::class);
- $templates = new controller\templates($db, $user);
+
$permission_user = $db->get(Model\PermissionUser::class);
$user->load($vars["primary_key"]);
$user->delete();
- $vars["form"] = $templates->form_v2("/user", [], ["checkboxes" => $permissions->get_checkboxes()]);
- $vars["search"] = $templates->search_form("/user");
- $vars["table"] = $templates->crud_table("/user" ,"", "email", $permission_user);
+ $vars += get_vars($user, "/user", "/user/search", "", "email", $permissions->get_checkboxes(), [], $permission_user);
return "views/user.html";
};
$user_page = function(&$vars){
global $db;
$user = $db->get(Model\User::class);
- $permissions = $db->get(Model\Permission::class);
- $templates = new controller\templates($db, $user);
-
+ $user->load($vars['primary_key']);
+ $data = $user->getData();
+ if(in_array(3, $_SESSION['user_permissions'])){
+ foreach($data as $key => $d){
+ $vars['user_data'] .= "<p>your $key = $d<p><br>";
+ }
+ }elseif($vars['primary'] == $_SESSION['email']){
+ foreach($data as $key => $d){
+ $vars['user_data'] .= "<p>your $key = $d<p><br>";
+ }
+ }
return "views/user_page.html";
};
\ No newline at end of file
diff --git a/views/course.html b/views/course.html
@@ -7,9 +7,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
+ {{ $header }}
<div class="flex_container">
<div class ="side_bar">
<div class ="form_card">
+ <h1>menu</h1>
+ {{ $first_name }} links:
+ {{ $links }}
+ </div>
+ <div class ="form_card">
{{$form}}
{{$response}}
</div>
diff --git a/views/css/add_user.css b/views/css/add_user.css
@@ -1,8 +1,3 @@
-.header{
- padding: 40px;
- text-align: center;
-}
-
.flex-row{
display: flex;
align-items: stretch;
diff --git a/views/css/form_template.css b/views/css/form_template.css
@@ -19,12 +19,14 @@ form{
align-items: center;
}
a{
- width: 75%;
+ display: block;
padding-left: 10px;
padding-right: 10px;
- background-color: #66ffff;
+ margin-top: 5px;
+ margin-bottom: 5px;
+ background-color:white;
border-radius: 8px;
- text-decoration:none
+ text-decoration:none;
}
input[type=text], input[type=password], input[type=date], input[type=number]{
@@ -65,9 +67,6 @@ table {
width: 100%;
}
-tr{
-
-}
th, td {
border-bottom: 1px solid #ddd;
}
diff --git a/views/css/theme.css b/views/css/theme.css
@@ -16,18 +16,15 @@ body{
padding: 40px;
background: #33b3b6;
color: white;
- text-align: center;
}
-.header h1{
- font-size: 40px;
+.box_title a{
+ font-size: 50px;
+ margin-left: 10px;
}
-
-.header a{
- align-items: center;
- align-self: center;
- margin-left: auto;
- height: 40px;
- padding-top: 9px;
- width: 140px;
+.header_middle{
+ flex-grow:1000;
+}
+.box_logout a{
+ font-size: 25px;
}
\ No newline at end of file
diff --git a/views/exam.html b/views/exam.html
@@ -8,9 +8,15 @@
</head>
</head>
<body>
+ {{ $header }}
<div class="flex_container">
<div class ="side_bar">
<div class ="form_card">
+ <h1>menu</h1>
+ {{ $first_name }} links:
+ {{ $links }}
+ </div>
+ <div class ="form_card">
{{$form}}
{{$response}}
</div>
diff --git a/views/grade.html b/views/grade.html
@@ -8,9 +8,15 @@
</head>
</head>
<body>
+ {{ $header }}
<div class="flex_container">
<div class ="side_bar">
<div class ="form_card">
+ <h1>menu</h1>
+ {{ $first_name }} links:
+ {{ $links }}
+ </div>
+ <div class ="form_card">
{{$form}}
{{$response}}
</div>
diff --git a/views/parent_child.html b/views/parent_child.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html lang="eng">
+ <title>Add User</title>
+ <link rel="stylesheet" href="/views/css/theme.css">
+ <link rel="stylesheet" href="/views/css/form_template.css">
+ <link rel="stylesheet" href="/views/css/course.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+</head>
+</head>
+<body>
+ {{ $header }}
+ <div class ="form_card">
+ <div class ="table">
+ {{ $table}}
+ </div>
+ </div>
+
+</body>
+</html>
+\ No newline at end of file
diff --git a/views/post_user.html b/views/post_user.html
diff --git a/views/user.html b/views/user.html
@@ -7,9 +7,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
+ {{ $header }}
<div class="flex_container">
<div class ="side_bar">
<div class ="form_card">
+ <h1>menu</h1>
+ {{ $first_name }} links:
+ {{ $links }}
+ </div>
+ <div class ="form_card">
{{$form}}
{{$response}}
</div>
diff --git a/views/user_page.html b/views/user_page.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html lang="eng">
+ <title>Add User</title>
+ <link rel="stylesheet" href="/views/css/theme.css">
+ <link rel="stylesheet" href="/views/css/form_template.css">
+ <link rel="stylesheet" href="/views/css/course.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+</head>
+</head>
+<body>
+ {{ $header }}
+ <div class="user_data">
+ {{ $user_data }}
+ </div>
+</body>
+</html>
+\ No newline at end of file