71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
$ValidAccess = 2010;
|
|
require_once("include/globals.php");
|
|
|
|
|
|
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
|
logExit("Session is not active",$moduleName);
|
|
exit();
|
|
}
|
|
|
|
// Set userType
|
|
$userType = "Parent";
|
|
if (array_key_exists('type', $_SESSION['UserInfo']) && in_array($_SESSION['UserInfo']['type'],$AllAdminUserTypes)) $userType = "Admin";
|
|
if ($userType != 'Admin') return;
|
|
|
|
|
|
// Ensure that only valid user types have access to this module
|
|
if ($userType != 'Admin') {
|
|
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
|
logExit($error_message);
|
|
exit;
|
|
}
|
|
|
|
|
|
// CSRF token validation
|
|
include "include/ajax.csrfToken.php";
|
|
|
|
|
|
// Set default timezone
|
|
date_default_timezone_set("Canada/Pacific");
|
|
$now = date("Y-m-d H:i:s",time());
|
|
|
|
$return_data = array();
|
|
|
|
$moduleName = "ajax.ToggleReporting.php";
|
|
// startLog($moduleName);
|
|
|
|
|
|
// Get parameters
|
|
$school_num = intval($_GET['school_num']);
|
|
|
|
// Ensure parameters are valid
|
|
|
|
if (!is_numeric($school_num)) logExit("School num is not numeric\n");
|
|
if ($school_num == 0) logExit("school_num is zero\n");
|
|
|
|
writeLog("school_num: $school_num\n");
|
|
|
|
|
|
// Get current setting
|
|
$query = "SELECT rep FROM schools WHERE record_num = $school_num";
|
|
writeLog("query: $query\n");
|
|
$rep = db_getVal($query);
|
|
|
|
switch ($rep) {
|
|
case 'R':
|
|
default:
|
|
$query = "UPDATE schools SET rep = 'N' WHERE record_num = $school_num";
|
|
break;
|
|
|
|
case 'N':
|
|
$query = "UPDATE schools SET rep = 'R' WHERE record_num = $school_num";
|
|
break;
|
|
}
|
|
|
|
writeLog("query: $query\n");
|
|
db_query($query);
|
|
|
|
writeLog("completed\n");
|
|
?>
|