399 lines
12 KiB
PHP
399 lines
12 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
//
|
|
// Process all actions to list and edit records
|
|
//
|
|
$action = "videos";
|
|
$CurrentTable = "videos";
|
|
$DeleteField = "title,uploaded_date";
|
|
$dSeparator = "<br>\n";
|
|
$FormFile = "videos.form.php";
|
|
$TitleText = getLanguageText('TEXT-VIDEO-TUTORIALS');
|
|
$OrderBy = "sequence,title";
|
|
$Sequence = 'Y';
|
|
|
|
|
|
// Start the template and output buffering
|
|
startTemplate();
|
|
$templatePageTitle = $TitleText;
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Administration Team');
|
|
if (checkPermission($AllowedUserTypes) != 1) {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
$action = '';
|
|
$naction = '';
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
}
|
|
|
|
|
|
|
|
if (!isset($naction)) $naction = 'list';
|
|
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
|
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
|
|
|
if ($naction == 'edit') {
|
|
if (array_key_exists('record_num',$_GET)) {
|
|
$record_num = intval($_GET['record_num']);
|
|
$entry_type = db_getVal("SELECT entry_type FROM videos WHERE record_num = $record_num");
|
|
if ($entry_type == 'Heading') $naction = 'edit-header';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Perform the requested action
|
|
switch (strtolower($naction)) {
|
|
case 'add':
|
|
$next_naction = "insert";
|
|
include $FormFile;
|
|
break;
|
|
|
|
case 'insert':
|
|
extract($_POST);
|
|
|
|
$data = array();
|
|
$data['title'] = trim($_POST['title']);
|
|
$data['description'] = trim($_POST['description']);
|
|
$data['display'] = trim($_POST['display']);
|
|
$data['file_name'] = trim($_POST['selected_filename']);
|
|
$data['uploaded_date'] = trim($_POST['uploaded_date']);
|
|
$data['entry_type'] = trim($_POST['entry_type']);
|
|
|
|
$error_message = '';
|
|
|
|
// Check that a title has been entered
|
|
if (strlen($data['title']) == 0) {
|
|
$data['title'] = str_replace("_"," ",str_replace(".mp4","",$data['file_name']));
|
|
}
|
|
|
|
// Get new sequence number
|
|
if ($Sequence == 'Y') {
|
|
$query = "select max(sequence) sequence from $CurrentTable";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
$sequence = intval($row['sequence']) + 1;
|
|
$data['sequence'] = $sequence;
|
|
}
|
|
|
|
// Update database
|
|
$table = new Table($CurrentTable);
|
|
$query = $table->BuildInsert($data);
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
|
$naction = 'list';
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case 'edit':
|
|
$next_naction = "update";
|
|
|
|
$record_num = intval($_GET['record_num']);
|
|
$query = "select * from videos where record_num = $record_num";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
|
|
include $FormFile;
|
|
break;
|
|
|
|
case 'update':
|
|
$data = array();
|
|
$data['title'] = trim($_POST['title']);
|
|
$data['description'] = trim($_POST['description']);
|
|
$data['display'] = trim($_POST['display']);
|
|
$data['file_name'] = trim($_POST['selected_filename']);
|
|
$data['uploaded_date'] = trim($_POST['uploaded_date']);
|
|
$data['entry_type'] = trim($_POST['entry_type']);
|
|
$data['record_num'] = intval($_POST['record_num']);
|
|
|
|
// Check that a title has been entered
|
|
if (strlen($data['title']) == 0) {
|
|
$data['title'] = str_replace(".mp4","",$data['file_name']);
|
|
}
|
|
|
|
// Update database
|
|
$table = new Table("videos");
|
|
$query = $table->BuildUpdate($data);
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
|
$naction = "list";
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case 'add-header':
|
|
$next_naction = "insert-header";
|
|
include "videos.header.form.php";
|
|
break;
|
|
|
|
case 'insert-header':
|
|
extract($_POST);
|
|
|
|
$data = array();
|
|
$data['title'] = trim($_POST['title']);
|
|
$data['description'] = trim($_POST['description']);
|
|
$data['display'] = trim($_POST['display']);
|
|
$data['file_name'] = '';
|
|
$data['uploaded_date'] = trim($_POST['uploaded_date']);
|
|
$data['entry_type'] = trim($_POST['entry_type']);
|
|
|
|
// Update database
|
|
$table = new Table($CurrentTable);
|
|
$query = $table->BuildInsert($data);
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
|
$naction = 'list';
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case 'edit-header':
|
|
$next_naction = "update-header";
|
|
|
|
$record_num = intval($_GET['record_num']);
|
|
$query = "select * from videos where record_num = $record_num";
|
|
$results = db_query($query);
|
|
$row = db_fetch_array($results);
|
|
extract($row);
|
|
|
|
include "videos.header.form.php";
|
|
break;
|
|
|
|
case 'update-header':
|
|
$data = array();
|
|
$data['title'] = trim($_POST['title']);
|
|
$data['description'] = trim($_POST['description']);
|
|
$data['display'] = trim($_POST['display']);
|
|
$data['file_name'] = '';
|
|
$data['uploaded_date'] = trim($_POST['uploaded_date']);
|
|
$data['entry_type'] = trim($_POST['entry_type']);
|
|
|
|
// Check that a title has been entered
|
|
if (strlen($data['title']) == 0) {
|
|
$data['title'] = str_replace(".mp4","",$data['file_name']);
|
|
}
|
|
|
|
// Update database
|
|
$table = new Table("videos");
|
|
$query = $table->BuildUpdate($data);
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
|
$naction = "list";
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "delete-confirmed":
|
|
extract($_GET);
|
|
|
|
// Get file name
|
|
$file_name = db_getVal("SELECT file_name FROM videos WHERE record_num = $record_num");
|
|
|
|
// Delete record from database
|
|
$query = "delete from videos " .
|
|
"where record_num = $record_num";
|
|
db_query($query);
|
|
|
|
$form_message = getLanguageText('RECORD-DELETED-MSG');
|
|
$naction = "list";
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
case "save-sort":
|
|
// Parse the hidden fields to update the sort sequence in the database
|
|
if (array_key_exists('row_sequence',$_POST) && strlen($_POST['row_sequence']) > 0) {
|
|
$row_sequence = preg_replace("/,$/","",$_POST['row_sequence']);
|
|
$item_sequence = explode(',',$row_sequence);
|
|
for ($i = 0; $i < count($item_sequence); $i++) {
|
|
$rnum = $item_sequence[$i];
|
|
$sequence = $i + 1;
|
|
$query = "update $CurrentTable set sequence = $sequence where record_num = $rnum";
|
|
db_query($query);
|
|
}
|
|
}
|
|
|
|
$form_message = getLanguageText('RECORDS-SORTED-MSG');
|
|
$naction = 'list';
|
|
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
|
exit();
|
|
|
|
default:
|
|
$date = date("Y-m-d",time());
|
|
$naction = "list";
|
|
break;
|
|
}
|
|
|
|
|
|
//
|
|
// List all records if naction is "list"
|
|
//
|
|
if ($naction == "list") {
|
|
?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#data-table").tableDnD({
|
|
onDrop: function(table, row) {
|
|
var rows = table.tBodies[0].rows;
|
|
var data = "&table=videos";
|
|
for (var i=0; i<rows.length; i++) {
|
|
var rowid = rows[i].id;
|
|
data += "&row_ids[]="+rowid;
|
|
|
|
// Update row classes
|
|
$("#"+rowid).removeClass("data-even");
|
|
$("#"+rowid).removeClass("data-odd");
|
|
if (i % 2) $("#"+rowid).addClass("data-even");
|
|
else $("#"+rowid).addClass("data-odd");
|
|
}
|
|
$.ajax({
|
|
url: "ajax.SequenceRecords.php",
|
|
data: data
|
|
});
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
<?php
|
|
|
|
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
|
|
include "help.docs.php";
|
|
|
|
// Get set of document records
|
|
$columnHeaders = array(
|
|
getLanguageText('TEXT-TITLE'),
|
|
getLanguageText('TEXT-DESCRIPTION')
|
|
);
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$query = "SELECT title,uploaded_date,description,entry_type,display,record_num FROM videos " .
|
|
"ORDER BY sequence,title";
|
|
}
|
|
else {
|
|
$query = "SELECT title,uploaded_date,description,entry_type,record_num FROM videos " .
|
|
"WHERE display != 'N' " .
|
|
"ORDER BY sequence,title";
|
|
}
|
|
|
|
$results = db_query($query);
|
|
$data = array();
|
|
while ($row = db_fetch_assoc($results)) {
|
|
extract($row);
|
|
|
|
$entry = array();
|
|
$entry['display_commands'] = 'Y';
|
|
|
|
$colspan = 1;
|
|
$class = '';
|
|
|
|
if ($entry_type == 'Heading') {
|
|
$title = "<b>$title</b><br><br>";
|
|
$description = '';
|
|
$entry['colspan_0'] = 3;
|
|
$entry['class_0'] = 'data-header';
|
|
$entry['display_commands'] = 'N';
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
$entry['colspan_0'] = 2;
|
|
$entry['display_commands'] = 'Y';
|
|
}
|
|
}
|
|
|
|
if (isset($display) && $display == 'N') $title = "<span class='warning'>$title</span>";
|
|
|
|
$entry[] = $title;
|
|
$entry[] = str_replace("\n","<br>",$description);
|
|
$entry['record_num'] = $record_num;
|
|
$data[] = $entry;
|
|
}
|
|
|
|
include "form.messages.php";
|
|
|
|
$play_icon = "<img src='images/icons/play24.png' alt='View Video' border='0'>";
|
|
$commands = array("<a href='#' dnum='%d' class='view-video-link' title='View Video Tutorial'>$play_icon</a>");
|
|
|
|
$customTableID = "videos-table";
|
|
$useRowIDS = true;
|
|
$displayTableHeaders = false;
|
|
$multipleTableBodies = false;
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
include "table.dnd.php";
|
|
listData($data,$columnHeaders,$action,$commands,'N');
|
|
}
|
|
else {
|
|
listDataCustom($data,$columnHeaders,$action,$commands,'N');
|
|
}
|
|
|
|
if ($_SESSION['UserInfo']['type'] == 'SuperUser') {
|
|
?>
|
|
<br>
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
<a href='?action=videos&naction=add' class='btn btn--primary>'> Upload New </a>
|
|
</td>
|
|
<td>
|
|
<a href='?action=videos&naction=add-header' class='btn btn--primary>'> New Header </a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<?php } ?>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
<?php include "include/ajax.Setup.php" ?>
|
|
|
|
$("#video-dialog").dialog({
|
|
autoOpen: false,
|
|
minWidth: 980,
|
|
modal: true,
|
|
position: { my: 'center', at: 'top' }
|
|
});
|
|
|
|
$(".view-video-link").click(function(e) {
|
|
e.preventDefault();
|
|
|
|
var dnum = $(this).attr('dnum');
|
|
|
|
$("#video-dialog").dialog('open');
|
|
$("#video-player").load('view-video.php?dnum='+dnum);
|
|
|
|
});
|
|
|
|
$(document).on('click touch','#close-video',function(e) {
|
|
e.preventDefault();
|
|
|
|
var media = $("#help-video").get(0);
|
|
media.pause();
|
|
media.currentTime = 0;
|
|
|
|
$("#video-dialog").dialog('close');
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<div id='video-dialog' title=''>
|
|
<div id='video-player'></div>
|
|
<br>
|
|
<button id='close-video' class='btn btn--outline btn--xsmall'><?php displayLanguageText('TEXT-CLOSE'); ?></button>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
endTemplate();
|
|
?>
|