First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$CurrentTable = "photo_galleries";
|
||||
$DeleteField = "gallery_title";
|
||||
$dSeparator = "";
|
||||
$FormFile = "photo_galleries.form.php";
|
||||
$TitleText = "Photo Galleries";
|
||||
$OrderBy = "gallery_title";
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$templatePageTitle = "$TitleText " . getLanguageText('TEXT-ADMINISTRATION');
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Communications Administrator');
|
||||
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 (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
|
||||
|
||||
switch (strtolower($naction)) {
|
||||
case "add":
|
||||
$next_naction = "insert";
|
||||
$active = 'Y';
|
||||
|
||||
include $FormFile;
|
||||
break;
|
||||
|
||||
case "insert":
|
||||
extract($_POST);
|
||||
|
||||
// Validate the data entered
|
||||
if (strlen($gallery_title) == 0) {
|
||||
$error_message = getLanguageText('MSG-MISSING-GALLERY-TITLE');
|
||||
$new_naction = 'add';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Save the record
|
||||
$added_date = date("Y-m-d",time());
|
||||
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildInsert();
|
||||
db_query($query);
|
||||
|
||||
$form_message = getLanguageText('RECORD-INSERTED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message));
|
||||
exit();
|
||||
|
||||
case "edit":
|
||||
$next_naction = "update";
|
||||
|
||||
// Get current record
|
||||
$record_num = intval($_GET['record_num']);
|
||||
$query = "select * from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$results = db_query($query);
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
|
||||
include $FormFile;
|
||||
break;
|
||||
|
||||
case "update":
|
||||
extract($_POST);
|
||||
|
||||
// Validate the data entered
|
||||
if (strlen($gallery_title) == 0) {
|
||||
$error_message = getLanguageText('MSG-MISSING-GALLERY-TITLE');
|
||||
$new_naction = 'edit';
|
||||
return;
|
||||
}
|
||||
|
||||
$table = new Table("$CurrentTable");
|
||||
$query = $table->BuildUpdate();
|
||||
db_query($query);
|
||||
|
||||
$form_message = getLanguageText('RECORD-UPDATED-MSG');
|
||||
$naction = "list";
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message));
|
||||
exit();
|
||||
|
||||
case "delete":
|
||||
$record_num = intval($_GET['record_num']);
|
||||
|
||||
// Check if this gallery has any images
|
||||
$num = db_getVal("select count(*) from photo_gallery_images where school_num = $school_num and gallery_num = $record_num");
|
||||
if ($num > 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-UNABLE-TO-DELETE-GALLERY');
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$query = "select * from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $record_num";
|
||||
$results = db_query($query);
|
||||
if (db_num_rows($results) == 1) {
|
||||
$row = db_fetch_array($results);
|
||||
extract($row);
|
||||
|
||||
$dFields = explode(",",$DeleteField);
|
||||
$dTitle = "$TitleText ";
|
||||
for ($i = 0; $i < count($dFields); $i++) {
|
||||
$dTitle .= $row[$dFields[$i]] . $dSeparator;
|
||||
}
|
||||
|
||||
include "delete.form.php";
|
||||
}
|
||||
else {
|
||||
$error_message = getLanguageText('ERRORMSG-NOT-FOUND');
|
||||
$naction = 'list';
|
||||
header("Location: /?action=$action&naction=$naction&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
break;
|
||||
|
||||
case "delete-confirmed":
|
||||
$record_num = intval($_GET['record_num']);
|
||||
|
||||
// Delete the current record
|
||||
$query = "delete from $CurrentTable " .
|
||||
"where school_num = $school_num " .
|
||||
"and 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));
|
||||
exit();
|
||||
|
||||
default:
|
||||
$naction = "list";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// List all records if naction is "list"
|
||||
//
|
||||
if ($naction == "list") {
|
||||
|
||||
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
|
||||
include "help.docs.php";
|
||||
|
||||
// Get records to display
|
||||
$columnHeaders = array(getLanguageText('TEXT-PHOTO-GALLERY'),
|
||||
getLanguageText('TEXT-CATEGORY'),
|
||||
getLanguageText('TEXT-DATE-ADDED'),
|
||||
getLanguageText('TEXT-ACTIVE'),
|
||||
getLanguageText('TEXT-COUNT')
|
||||
);
|
||||
$columnAlign = array("left","left","left","center","center");
|
||||
$query = "select gallery_title,category_title,added_date,active,count(gi.record_num),gc.sequence,g.record_num " .
|
||||
"from photo_galleries as g left join photo_gallery_images as gi on gi.gallery_num = g.record_num, " .
|
||||
"photo_gallery_categories as gc " .
|
||||
"where g.school_num = $school_num " .
|
||||
"and g.category_num = gc.record_num " .
|
||||
"group by 1,2,3,4,6,7 " .
|
||||
"order by gc.sequence,gallery_title";
|
||||
$results = db_query($query);
|
||||
|
||||
$message_width = $default_data_width;
|
||||
include "form.messages.php";
|
||||
|
||||
echo("<center>\n");
|
||||
echo("<p><b>$TitleText List</b></p>\n");
|
||||
echo("</center>\n");
|
||||
|
||||
$folder_icon = "<img src='images/icons/folder24.png' alt='Gallery Photos' border='0'>";
|
||||
$image_icon = "<img src='images/icons/pictures24.png' alt='View Gallery' title='View Gallery' hspace='5' border='0'>";
|
||||
|
||||
$commands = array(
|
||||
"<a href='?action=photo-gallery-images&naction=list&gallery_num=%d' title='Gallery Photos'>$folder_icon</a>",
|
||||
"<a href='?action=photo-gallery&gallery_num=%d' title='View Gallery'>$image_icon</a>"
|
||||
);
|
||||
|
||||
listData($results,$columnHeaders,$action,$commands,'Y',$columnAlign);
|
||||
echo("\n\n<!-- $query -->\n\n");
|
||||
echo("</center>\n");
|
||||
}
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user