forked from stunningpixels/yearbook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChoose.php
54 lines (49 loc) · 1.36 KB
/
Choose.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
<?php
require_once '../Composer/vendor/autoload.php';
require_once 'Configuration.php';
require_once 'Controllers/Authenticator.php';
if (!Authenticator::IsLoggedIn())
{
Redirect('/login');
return;
}
$TaskStates = TaskState::GetTaskStates();
if ($TaskStates[TaskIds::Choose]->Task->Status != Task::Available)
{
http_response_code(403);
return;
}
if (isset($_POST['DeleteEntryId']))
{
try
{
$GLOBALS['YearbookModel']->RemoveBiographyEntry($_SESSION['StudentId'], $_POST['DeleteEntryId']);
}
catch (MeekroDBException $DBException)
{
// Swallow :(
// If we could distinguish between an ownership check failure versus a DB error, we could return appropriate error codes...
}
}
$AddSuccess = true;
if (isset($_POST['AuthorStudentId']))
{
try
{
$GLOBALS['YearbookModel']->AddBiographyEntry($_POST['AuthorStudentId'], $_SESSION['StudentId']);
}
catch (MeekroDBException $DBException)
{
$AddSuccess = false;
}
}
$Template = new Twig_Environment(new Twig_Loader_Filesystem(array('Templates', 'Templates/Modules')), array('cache' => '../Cache', 'auto_reload' => true));
$Template->display(
'Choose.html',
array(
'Students' => $GLOBALS['YearbookModel']->FindStudents(),
'BiographyEntries' => $GLOBALS['YearbookModel']->FindBiographiesByTargetStudentId($_SESSION['StudentId']),
'OperationSuccessful' => $AddSuccess,
'TaskStates' => $TaskStates
)
);