\n";
print "Reason (this is not displayed to any users and is just for your records): \n";
print " \n";
print "User Message (this will be displayed on the site during the maintenance window): \n";
print "\n";
print "\n";
print "
\n";
print "\n";
print "\n";
print "
\n";
print "
\n"; # edit dialog
print "
\n";
print "
Delete Site Maintenance
\n";
print "Click Delete Entry to delete this site maintenance entry
\n";
print "
\n";
print "
\n";
print "
Start:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
End:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
Owner:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
Created:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
Inform Hours Ahead:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
Allow Reservations:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
Reason:
\n";
print "
\n";
print "
\n";
print "
\n";
print "
User Message:
\n";
print "
\n";
print "
\n";
print "
\n";
print "\n";
print "
\n";
print "\n";
print "\n";
print "
\n";
print "
\n"; # confirm dialog
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn AJcreateSiteMaintenance()
///
/// \brief creates an file in the maintenance directory, creates an entry in
/// the sitemaintenance table and does a javascript page reload
///
////////////////////////////////////////////////////////////////////////////////
function AJcreateSiteMaintenance() {
global $user;
$data = processSiteMaintenanceInput();
if($data['err'])
return;
if(! writeMaintenanceFile($data['startts'], $data['endts'], $data['usermessage'])) {
print "alert('Failed to create maintenance file on web server.\\n";
print "Please have sysadmin check permissions on maintenance directory.');\n";
return;
}
$reason = mysql_real_escape_string($data['reason']);
$usermessage = mysql_real_escape_string($data['usermessage']);
$query = "INSERT INTO sitemaintenance "
. "(start, "
. "end, "
. "ownerid, "
. "created, "
. "reason, "
. "usermessage, "
. "informhoursahead, "
. "allowreservations) "
. "VALUES "
. "('{$data['startdt']}', "
. "'{$data['enddt']}', "
. "{$user['id']}, "
. "NOW(), "
. "'$reason', "
. "'$usermessage', "
. "{$data['hoursahead']}, "
. "{$data['allowreservations']})";
doQuery($query, 101);
$_SESSION['usersessiondata'] = array();
print "window.location.href = '" . BASEURL . SCRIPT . "?mode=siteMaintenance';";
#print "clearEdit();";
#siteMaintenance();
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn AJgetSiteMaintenanceData()
///
/// \brief gets info about a sitemaintenance entry and returns it in JSON format
///
////////////////////////////////////////////////////////////////////////////////
function AJgetSiteMaintenanceData() {
$id = getContinuationVar('id');
$tmp = getMaintItems($id);
$data = $tmp[$id];
$start = datetimeToUnix($data['start']) * 1000;
$end = datetimeToUnix($data['end']) * 1000;
$cdata = array('id' => $id,
'update' => 1);
$cont = addContinuationsEntry('AJeditSiteMaintenance', $cdata,
SECINDAY, 1, 0);
$arr = array('start' => $start,
'end' => $end,
'hoursahead' => $data['informhoursahead'],
'allowreservations' => $data['allowreservations'],
'reason' => $data['reason'],
'usermessage' => $data['usermessage'],
'cont' => $cont);
sendJSON($arr);
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn AJgetDelSiteMaintenanceData()
///
/// \brief gets info about a sitemaintenance entry to be displayed on the
/// confirm delete dialog and returns it in JSON format
///
////////////////////////////////////////////////////////////////////////////////
function AJgetDelSiteMaintenanceData() {
$id = getContinuationVar('id');
$tmp = getMaintItems($id);
$data = $tmp[$id];
$cdata = array('id' => $id,
'update' => 1,
'start' => datetimeToUnix($data['start']));
$cont = addContinuationsEntry('AJdeleteSiteMaintenance', $cdata,
SECINDAY, 1, 0);
$tmp = datetimeToUnix($data['start']);
$start = date('g:i A, n/j/Y', $tmp);
$tmp = datetimeToUnix($data['end']);
$end = date('g:i A, n/j/Y', $tmp);
$tmp = datetimeToUnix($data['created']);
$created = date('g:i A, n/j/Y', $tmp);
$hours = $data['informhoursahead'] % 24;
if($hours == 1)
$hours = (int)($data['informhoursahead'] / 24) . " days, 1 hour";
else
$hours = (int)($data['informhoursahead'] / 24) . " days, $hours hours";
$hours = "{$data['informhoursahead']} ($hours)";
if($data['allowreservations'])
$allowres = 'Yes';
else
$allowres = 'No';
$reason = preg_replace('/(.{1,50}[ \n])/', '\1 ', $data['reason']);
$reason = preg_replace('/\n \n/', "