forked from llcit/FVP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.php
153 lines (151 loc) · 4.71 KB
/
archive.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<?php
include_once("./inc/dump.php");
include_once("./inc/db_pdo.php");
include_once("./inc/sqlFunctions.php");
include_once("./inc/htmlFunctions.php");
include_once("./inc/htmlFunctions.php");
$SETTINGS = parse_ini_file(__DIR__."/./inc/settings.ini");
session_start();
/* Remove delete video for now//
if ($_POST['deleteVideo'] > 0) {
include_once("./inc/S3DeleteObject.php");
deleteObject($_POST['deleteVideo']);
}*/
if (!isset($_SESSION['username'])) {
header('Location: ./login.php');
}
$user = getUser($_SESSION['username']);
if ($user->role == 'admin' || $user->role == 'staff') {
/* ------------ READ IN POST VALS ------------- */
$filters = [
'programs'=>$_POST['programs'],
'years'=>$_POST['years'],
'locations'=>$_POST['locations'],
'institutions'=>$_POST['institutions'],
'types'=>$_POST['types'],
'periods'=>$_POST['periods'],
];
/* ------------ /READ IN POST VALS ------------- */
/* ---------- MAIN ---------- */
$videoData = getVideos(null,null,$filters);
$videoList =buildVideoList($videoData);
$filterPulldowns = buildPullDowns($filters);
$pageContent = "
$filterPulldowns
<div class = 'videoListWrapper'>
$videoList
</div>
";
/* ---------- /MAIN ---------- */
}
else {
$pageContent = "
<div class = 'msg error' style='margin-top:30px;'>
Permission denied! You must be staff or admin to access this page.
</div>
<p style='width:100%;text-align:center;margin-top:30px;'>
<a href='./index.php'>Retun to Home</a>
";
}
function buildPullDowns($filters){
$fullList = [
'programs' => getUniqueVals('programs','name'),
'years' => getUniqueVals('programs','progYrs'),
'locations'=>getUniqueVals('events','city'),
'institutions'=>getUniqueVals('institutions','name'),
'types'=>getUniqueVals('presentations','type'),
'periods'=>getUniqueVals('events','phase')
];
$pullDowns = "
<form id='userControls' method='post'>
<div class='fv_selects_wrapper'>
<h4 style='display:inline'>Filter Results: </h4>
<span class='actionButtons clearfix'>
<span id='updateFilters' name='updateFilters' class='float-right'>
<button type='button' class='btn btn-primary fv_filterButton' id='clear' name='clear' onclick='clearFilters()'>Clear Filters</button>
<button type='button' class='btn btn-primary fv_filterButton' id='update' name='update' onclick='updateUI()'>Update</button>
</span>
</span>
";
$i=0;
foreach($fullList as $k=>$values) {
if ($i%3==0) {
if ($i > 1) {
$pullDowns .= "</div>";
}
$pullDowns .= "<div class='row fv_select_row'>";
}
$i++;
$input = "<select id='".$k."[]' name='".$k."[]' class='selectpicker' multiple data-width='100%'>";
foreach($values as $k2=>$val) {
foreach($val as $key=>$value) {
if ($filters[$k]) {
$selected = (in_array($value,$filters[$k])) ? "selected='selected'" : "";
}
$input .= "<option value='$value' $selected>".ucfirst($value)."</option>";
}
}
$input .= "</select>";
$pullDowns .= "
<div class='fv_select col-sm-4'>
<p class='fv_select_label'>".ucfirst($k).":</p>
$input
</div>
";
}
$pullDowns .= "
</div>
</form>
</div>
";
return $pullDowns;
}
?>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Flagship Video Archive</title>
<link rel="stylesheet" href="./css/main.css" type="text/css"/>
<script>
var base_url = '<?php echo($SETTINGS['base_url']); ?>';
</script>
<script src='./js/S3FileGen.js'></script>
<script src='./js/main.js'></script>
</head>
<body>
<div class="panel panel-default">
<?php
$header = writePageHeader($SETTINGS['base_url'],$user,$pageTitle);
echo($header);
?>
<div class="panel-body">
<?php echo($pageContent); ?>
</div>
<div class="footer">
<p> </p>
</div>
</div>
<script language='javascript'>
function updateUI() {
$("#userControls").submit();
};
function clearFilters() {
window.location.href='./archive.php';
}
$( document ).ready(function() {
$('.videoPanel').each(function() {
$(this).click(function(){
playVideo($(this).attr('id'),false);
});
});
});
</script>
<!--
<form id='deleteForm' name='deleteForm' method='post'>
<input type='hidden' id='deleteVideo' name='deleteVideo' value='0'>
</form>
-->
</body>
</html>