This repository was archived by the owner on Sep 17, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcontroller.php
More file actions
88 lines (81 loc) · 2.66 KB
/
Copy pathcontroller.php
File metadata and controls
88 lines (81 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require_once "model.php";
#function login_filter() {
# if ( !isset($_SESSION["account"])) {
# #
# # session is set during login to indicate we are logged in lol
# #
# header('Location: login.php');
# }
#}
function controller() {
#
# READ a reading
#
if (isset($_GET['id'])) {
#
# typical view object path (GET)
#
$id = $_GET['id'];
reading_read_model($id);
#model code
#...drop through to HTML
} else if (isset($_SESSION['reading_index'])) {
#
# specail cases to dispaly while performing some other action
# then the id is stored in session, but we are still going to display it
#
$id = $_SESSION['reading_index'];
reading_read_model($id);
#model code
#...drop through to HTML
}
#
# vector: create button isset via POST
# controler: create object
# model: object: reading, action: create
# view: redirect GET[id] to 'manage object' page.
#
if (isset($_POST['reading_create'])) {
# model
$new_id = reading_create_model();
# view
header("Location: manage_reading.php?id=$new_id");
}
#
# vector: update button isset via POST
# data: object values by $k in POST
# controller: update object
# model: object is 'reading', action is 'update'
# view: redirect GET[id] to 'manage object' page
#
if (isset($_POST['reading_update'])) {
# model code
reading_update_model();
# view code
$id = $_POST['reading_index'];
header("Location: manage_reading.php?id=$id");
}
if (isset($_POST['reading_delete'])) {
# model code - session indicator to show confirm behavior
$_SESSION['reading_delete'] = $_POST['reading_delete'];
$_SESSION['reading_index'] = $_POST['reading_index'];
# view code
session_write_close();
header("Location: manage_reading.php");
}
#
# vector: affirm delete button via POST
# data: reading_index from POST
# controller: delete object
# model: object is 'reading", action is 'delete'
# view: redirect/GET to index
#
if (isset($_POST['confirm_delete'])) {
# model code
reading_delete_model();
# view code
header("Location: index.php");
}
}
?>