forked from Graphite-Tattle/Tattle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lines.php
81 lines (69 loc) · 2.82 KB
/
lines.php
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
<?php
include 'inc/init.php';
fAuthorization::requireLoggedIn();
fRequest::overrideAction();
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete', 'view'));
$line_id = fRequest::get('line_id', 'integer');
$graph_id = fRequest::get('graph_id', 'integer');
if ('delete' == $action) {
$class_name = 'Line';
try {
$obj = new Line($line_id);
$graph = new Graph($obj->getGraphId());
$delete_text = 'Are you sure you want to delete the line : <strong>' . $obj->getAlias() . '</strong>?';
if (fRequest::isPost()) {
fRequest::validateCSRFToken(fRequest::get('token'));
$obj->delete();
fMessaging::create('success', Graph::makeUrl('edit',$graph),
'The line for ' . $graph->getName() . ' was successfully deleted');
fURL::redirect(Graph::makeUrl('edit',$graph));
}
} catch (fNotFoundException $e) {
fMessaging::create('error', Graph::makeUrl('edit',$graph),
'The line requested could not be found');
fURL::redirect(Graph::makeUrl('edit',$graph));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
include VIEW_PATH . '/delete.php';
// --------------------------------- //
} elseif ('edit' == $action) {
try {
$line = new Line($line_id);
$graph = new Graph($line->getGraphId());
if (fRequest::isPost()) {
$line->populate();
fRequest::validateCSRFToken(fRequest::get('token'));
$line->store();
fMessaging::create('affected', fURL::get(), $graph->getName());
fMessaging::create('success', fURL::getWithQueryString(),
'The Line ' . $line->getAlias(). ' was successfully updated');
}
} catch (fNotFoundException $e) {
fMessaging::create('error', Graph::makeUrl('edit',$graph),
'The Line requested, ' . fHTML::encode($line_id) . ', could not be found');
fURL::redirect(Graph::makeUrl('edit',$graph));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
include VIEW_PATH . '/add_edit_line.php';
// --------------------------------- //
} elseif ('add' == $action) {
$line = new Line();
$graph = new Graph($graph_id);
if (fRequest::isPost()) {
try {
$line->populate();
fRequest::validateCSRFToken(fRequest::get('token'));
$line->store();
$graph_url = Graph::makeUrl('edit',$graph);
fMessaging::create('affected', $graph_url, $line->getAlias());
fMessaging::create('success', $graph_url,
'The Line ' . $line->getAlias() . ' was successfully created');
fURL::redirect($graph_url);
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
}
include VIEW_PATH . '/add_edit_line.php';
}