70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
require_once("include/globals.php");
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
header("Location: /");
|
|
exit();
|
|
}
|
|
|
|
|
|
if (array_key_exists('naction',$_REQUEST)) {
|
|
$naction = $_REQUEST['naction'];
|
|
if ($naction == 'insert' || $naction == 'update' || $naction == 'delete') {
|
|
extract($_POST);
|
|
|
|
$classified_ads = new Table("classified_ads");
|
|
|
|
switch($naction) {
|
|
case 'insert':
|
|
if (strlen($title) > 0 && strlen($contact_email) > 0) {
|
|
$posted_by = $_SESSION['UserInfo']['record_num'];
|
|
$posted_time = time();
|
|
$post_until_date = date("Y-m-d",time() + 60 * 60 * 24 * $school_record['classified_duration']);
|
|
$status = $school_record['default_classified_status'];
|
|
|
|
$query = $classified_ads->BuildInsert();
|
|
db_query($query);
|
|
|
|
header("Location: /?action=classified&selected_category=$subcategory_num");
|
|
exit();
|
|
}
|
|
else {
|
|
$error_message = "Please select a category and provide an ad title and contact information";
|
|
}
|
|
break;
|
|
|
|
case 'update':
|
|
if (strlen($title) > 0 && strlen($contact_email) > 0) {
|
|
$query = $classified_ads->BuildUpdate();
|
|
db_query($query);
|
|
|
|
header("Location: /?action=classified&selected_category=$subcategory_num");
|
|
exit();
|
|
}
|
|
else {
|
|
$error_message = "Please select a category and provide an ad title and contact information";
|
|
}
|
|
break;
|
|
|
|
case 'delete':
|
|
$num = intval($_GET['num']);
|
|
$uid = $_SESSION['UserInfo']['record_num'];
|
|
$subcategory_num = intval($_GET['subcategory_num']);
|
|
|
|
$query = "delete from classified_ads " .
|
|
"where school_num = $school_num " .
|
|
"and record_num = $num " .
|
|
"and posted_by = $uid";
|
|
db_query($query);
|
|
|
|
header("Location: /?action=classified&selected_category=$subcategory_num");
|
|
exit();
|
|
break;
|
|
}
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
?>
|