This repository was archived by the owner on Jul 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_acad_manages_courses_action.php
98 lines (82 loc) · 2.68 KB
/
admin_acad_manages_courses_action.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
include_once 'check_access_permissions.php';
mustHaveAnyOfTheseRoles( array( 'AWS_ADMIN', 'ADMIN' ) );
include_once 'methods.php';
include_once 'database.php';
include_once 'tohtml.php';
if( $_POST['response'] == 'DO_NOTHING' )
{
echo printInfo( "User said do nothing.");
goBack( "admin_acad_manages_courses.php", 0 );
exit;
}
// Instructor extras has to be reformatted.
$extraInstTxt = '';
if( is_array( __get__( $_POST, 'more_instructors', false) ) )
$extraInstTxt = implode(',', $_POST[ 'more_instructors' ] );
// Append to already existibg extra instructiors.
if( __get__( $_POST, 'instructor_extras', '' ) && $extraInstTxt )
if( $extraInstTxt )
$_POST[ 'instructor_extras' ] .= ',' . $extraInstTxt;
else
if ( $extraInstTxt )
$_POST[ 'instructor_extras' ] = $extraInstTxt;
if( $_POST['response'] == 'delete' )
{
// We may or may not get email here. Email will be null if autocomplete was
// used in previous page. In most cases, user is likely to use autocomplete
// feature.
if( strlen($_POST[ 'id' ]) > 0 )
{
$res = deleteFromTable( 'courses_metadata', 'id', $_POST );
if( $res )
{
echo printInfo( "Successfully deleted entry" );
goBack( 'admin_acad_manages_courses.php', 0 );
exit;
}
else
echo minionEmbarrassed( "Failed to delete speaker from database" );
}
}
else if ( $_POST[ 'response' ] == 'Add' )
{
echo printInfo( "Adding a new course in current course list" );
if( strlen( $_POST[ 'id' ] ) > 0 )
{
$res = insertIntoTable(
'courses_metadata'
, 'id,name,credits,description'
. ',instructor_1,instructor_2,instructor_3'
. ',instructor_4,instructor_5,instructor_6,instructor_extras,comment'
, $_POST
);
if( ! $res )
echo printWarning( "Could not add course to list" );
else
{
goBack( 'admin_acad_manages_courses.php', 0 );
exit;
}
}
else
echo printWarning( "Course ID can not be empty!" );
}
else if ( $_POST[ 'response' ] == 'Update' )
{
$res = updateTable( 'courses_metadata'
, 'id'
, 'name,credits,description'
. ',instructor_1,instructor_2,instructor_3'
. ',instructor_4,instructor_5,instructor_6,instructor_extras,comment'
, $_POST
);
if( $res )
{
echo printInfo( 'Updated course : ' . $_POST[ 'id' ] );
goBack( 'admin_acad_manages_courses.php', 0 );
exit;
}
}
echo goBackToPageLink( 'admin_acad_manages_courses.php', 'Go back' );
?>