First Commit

This commit is contained in:
mark committed 2026-10-19 15:22:52 -07:00
1 parent 5eb9dd037d
commit 2e62c0e60b
11877 files changed
+2035312

No files matched your search

+248
View File
@@ -0,0 +1,248 @@
<?php
require_once("include/globals.php");
if (SessionActive() != 1 || ! UserLoggedIn()) {
header("Location: /");
exit();
}
// Start the template and output buffering
startTemplate();
$templatePageTitle = getLanguageText('TEXT-CLASSIFIED-ADS') . " " . getLanguageText('TEXT-ADMINISTRATION');
$headerArgs = "";
// Ensure that only valid user types have access to this module
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator','Communications Administrator','Administration Team','Staff');
if (checkPermission($AllowedUserTypes) != 1) {
echo("<br>\n");
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
include "form.messages.php";
return;
}
//
// Process all actions to list and edit records
//
$CurrentTable = "classified_ads";
$DeleteField = "title,status";
$dSeparator = "<br>";
$FormFile = "classified.form.php";
$TitleText = getLanguageText('TEXT-CLASSIFIED-ADS');
$OrderBy = "posted_time,post_until_date,title";
?>
<table cellpadding='2' cellspacing='2'>
<tr>
<td align='center'><a href='?action=classified-admin&show=all' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-VIEW-ALL'); ?></a></td>
<td align='center'><a href='?action=classified-admin&show_status=new' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-VIEW-NEW'); ?></a></td>
<td align='center'><a href='?action=classified-admin&show_status=approved' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-VIEW-APPROVED'); ?></a></td>
<td align='center'><a href='?action=classified-admin&show_status=rejected' class='btn btn--primary btn--xsmall'><?php displayLanguageText('TEXT-VIEW-REJECTED'); ?></a></td>
</tr>
</table>
<br>
<?php
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
switch (strtolower($naction)) {
case "add":
$next_naction = "insert";
$active = 'Y';
include $FormFile;
break;
case "insert":
extract($_POST);
if (strlen($title) == 0) {
$error_message = "Please provide an ad title and contact information";
$next_naction = "insert";
include $FormFile;
break;
}
if ($subcategory_num == 0) {
$error_message = "Please select a classified ad category";
$next_naction = "insert";
include $FormFile;
break;
}
if (strlen($contact_email) == 0) {
$error_message = "Please provide contact information";
$next_naction = "insert";
include $FormFile;
break;
}
// Insert primary record
$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) . "&error_message=" . urlencode($error_message));
exit();
case "edit":
$next_naction = "update";
// Get current record
$record_num = intval($_GET['record_num']);
$query = "select * from $CurrentTable where record_num = $record_num";
$results = db_query($query);
if (db_num_rows($results) == 1) {
$row = db_fetch_array($results);
extract($row);
$schedule_num = $record_num;
include $FormFile;
}
else {
$error_message = "Error: Record Not Found";
}
break;
case "update":
extract($_POST);
if (strlen($title) == 0) {
$error_message = "Please provide an ad title and contact information";
include $FormFile;
break;
}
if ($subcategory_num == 0) {
$error_message = "Please select a classified ad category";
$next_naction = "insert";
include $FormFile;
break;
}
if (strlen($contact_email) == 0) {
$error_message = "Please provide contact information";
$next_naction = "insert";
include $FormFile;
break;
}
$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) . "&error_message=" . urlencode($error_message));
exit();
case "delete":
$record_num = intval($_GET['record_num']);
$query = "select * from $CurrentTable where 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 = "Error: Record Not Found";
}
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) . "&error_message=" . urlencode($error_message));
exit();
default:
$naction = "list";
break;
}
//
// List all records if naction is "list"
//
if ($naction == "list" || $naction == 'list-all') {
// Define specific where clauses
$today = date("Y-m-d",time());
$cust_where = "and post_until_date > '$today' ";
if (array_key_exists('show',$_GET)) {
$show = db_escape_string($_GET['show']);
if ($show == 'all') $cust_where = "";
$TitleText = "All Classified Ads";
}
if (array_key_exists('show_status',$_GET)) {
$show_status = db_escape_string($_GET['show_status']);
if ($show_status == 'new') $cust_where .= "and c.status = 'Entered' ";
if ($show_status == 'approved') $cust_where .= "and c.status = 'Approved' ";
if ($show_status == 'rejected') $cust_where .= "and c.status = 'Rejected' ";
$TitleText = ucwords($show_status) . " Classified Ads";
}
$scriptName = str_replace("/m/data1/app.hotlunches.net/","",__FILE__);
include "help.docs.php";
// Get records to display
$columnHeaders = array(getLanguageText('TEXT-TITLE'),
getLanguageText('TEXT-CATEGORY'),
getLanguageText('TEXT-SUBCATEGORY'),
getLanguageText('TEXT-POSTED-BY'),
getLanguageText('TEXT-DISPLAY-UNTIL'),
getLanguageText('TEXT-STATUS')
);
$query = "select title,category,subcategory,userid,post_until_date,c.status,c.record_num " .
"from classified_ads as c, classified_categories as cc, classified_subcategories as cs, users as u " .
"where c.school_num = $school_num " .
"and (u.school_num = $school_num or u.school_num = 0) " .
"and subcategory_num = cs.record_num " .
"and category_num = cc.record_num " .
"and posted_by = u.record_num " .
$cust_where .
"order by posted_time,post_until_date,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");
listData($results,$columnHeaders,$action);
}
endTemplate();
?>