Renamed flightHotifications to notifications.

pull/263/head
Joe Prochazka 2016-09-20 16:17:50 -04:00
rodzic c78b78f637
commit d10d81f003
9 zmienionych plików z 81 dodań i 71 usunięć

Wyświetl plik

@ -50,22 +50,22 @@
if ($common->postBack()) {
// Flight notifications
$notificationArray = explode(',', $_POST['flightNotifications']);
$notificationArray = explode(',', $_POST['notifications']);
if ($settings::db_driver == "xml") {
// XML
$notifications = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml");
$notifications = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
unset($notifications->flight);
foreach ($notificationArray as $notification) {
$newNotification = $notifications->addChild('flight', $notification);
$dom = dom_import_simplexml($notifications)->ownerDocument;
$dom->formatOutput = TRUE;
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $dom->saveXML());
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml", $dom->saveXML());
}
} else {
// PDO
$dbh = $common->pdoOpen();
$sql = "SELECT * FROM ".$settings::db_prefix."flightNotifications";
$sql = "SELECT * FROM ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$savedFlights = $sth->fetchAll();
@ -75,7 +75,7 @@
// Remove flight if not in list.
if (!in_array($flight, $notificationArray)) {
$dbh = $common->pdoOpen();
$sql = "DELETE FROM ".$settings::db_prefix."flightNotifications WHERE flight = :flight";
$sql = "DELETE FROM ".$settings::db_prefix."notifications WHERE flight = :flight";
$sth = $dbh->prepare($sql);
$sth->bindParam(':flight', $flight['flight'], PDO::PARAM_STR, 10);
$sth->execute();
@ -87,7 +87,7 @@
// Add flight if not saved already.
if (!in_array($flight, $savedFlights)) {
$dbh = $common->pdoOpen();
$sql = "INSERT INTO ".$settings::db_prefix."flightNotifications (flight) VALUES (:flight)";
$sql = "INSERT INTO ".$settings::db_prefix."notifications (flight) VALUES (:flight)";
$sth = $dbh->prepare($sql);
$sth->bindParam(':flight', $flight, PDO::PARAM_STR, 10);
$sth->execute();
@ -98,9 +98,9 @@
}
// Set TRUE or FALSE for checkbox items.
$enableFlightNotifications = FALSE;
if (isset($_POST['enableFlightNotifications']) && $_POST['enableFlightNotifications'] == "TRUE")
$enableFlightNotifications = TRUE;
$enableNotifications = FALSE;
if (isset($_POST['enableNotifications']) && $_POST['enableNotifications'] == "TRUE")
$enableNotifications = TRUE;
$enableFlights = FALSE;
if (isset($_POST['enableFlights']) && $_POST['enableFlights'] == "TRUE")
@ -150,16 +150,16 @@
if (isset($_POST['useDump1090FaMap']) && $_POST['useDump1090FaMap'] == "TRUE")
$useDump1090FaMap = TRUE;
$enableFlightNotificationsTwitter = FALSE;
if (isset($_POST['enableFlightNotificationsTwitter']) && $_POST['enableFlightNotificationsTwitter'] == "TRUE")
$enableFlightNotificationsTwitter = TRUE;
$enableNotificationsTwitter = FALSE;
if (isset($_POST['enableTwitterNotifications']) && $_POST['enableTwitterNotifications'] == "TRUE")
$enableTwitterNotifications = TRUE;
// Update settings using those supplied by the form.
$common->updateSetting("siteName", $_POST['siteName']);
$common->updateSetting("template", $_POST['template']);
$common->updateSetting("defaultPage", $_POST['defaultPage']);
$common->updateSetting("dateFormat", $_POST['dateFormat']);
$common->updateSetting("enableFlightNotifications", $enableFlightNotifications);
$common->updateSetting("enableNotifications", $enableNotifications);
$common->updateSetting("enableFlights", $enableFlights);
$common->updateSetting("enableBlog", $enableBlog);
$common->updateSetting("enableInfo", $enableInfo);
@ -181,7 +181,7 @@
$common->updateSetting("networkInterface", $_POST['networkInterface']);
$common->updateSetting("timeZone", $_POST['timeZone']);
$common->updateSetting("useDump1090FaMap", $useDump1090FaMap);
$common->updateSetting("enableFlightNotificationsTwitter", $enableFlightNotificationsTwitter);
$common->updateSetting("enableTwitterNotifications", $enableTwitterNotifications);
$common->updateSetting("twitterUserName", $_POST['twitterUserName']);
$common->updateSetting("twitterConsumerKey", $_POST['twitterConsumerKey']);
$common->updateSetting("twitterConsumerSecret", $_POST['twitterConsumerSecret']);
@ -204,29 +204,29 @@
}
// Get notification settings.
$flightNotifications = NULL;
$notifications = NULL;
$savedFlights = array();
if ($settings::db_driver == "xml") {
// XML
$savedFlights = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml");
$savedFlights = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
foreach ($savedFlights as $savedFlight) {
$flightNotifications = ltrim($flightNotifications.",".$savedFlight, ',');
$notifications = ltrim($notifications.",".$savedFlight, ',');
}
} else {
//PDO
$dbh = $common->pdoOpen();
$sql = "SELECT * FROM ".$settings::db_prefix."flightNotifications";
$sql = "SELECT * FROM ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$savedFlights = $sth->fetchAll();
$sth = NULL;
$dbh = NULL;
foreach ($savedFlights as $savedFlight) {
$flightNotifications = ltrim($flightNotifications.",".$savedFlight['flight'], ',');
$notifications = ltrim($notifications.",".$savedFlight['flight'], ',');
}
}
$enableFlightNotifications = $common->getSetting("enableFlightNotifications");
$enableFlightNotificationsTwitter = $common->getSetting("enableFlightNotificationsTwitter");
$enablenotifications = $common->getSetting("enableNotifications");
$enableTwitterNotifications = $common->getSetting("enableTwitterNotifications");
$twitterUserName = $common->getSetting("twitterUserName");
$twitterConsumerKey = $common->getSetting("twitterConsumerKey");
$twitterConsumerSecret = $common->getSetting("twitterConsumerSecret ");
@ -385,16 +385,16 @@
<div class="panel-body">
<div class="checkbox">
<label>
<input type="checkbox" name="enableFlightNotifications" value="TRUE"<?php ($enableFlightNotifications == 1 ? print ' checked' : ''); ?>> Enable flight notifications.
<input type="checkbox" name="enableNotifications" value="TRUE"<?php ($enableNotifications == 1 ? print ' checked' : ''); ?>> Enable flight notifications.
</label>
</div>
<div class="form-group">
<label for="flightNotifications"">Flight Notifications (coma delimited)</label>
<input type="text" class="form-control" id="flightNotifications" name="flightNotifications" value="<?php echo $flightNotifications; ?>">
<label for="notifications"">Flight Notifications (coma delimited)</label>
<input type="text" class="form-control" id="notifications" name="notifications" value="<?php echo $notifications; ?>">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="enableFlightNotificationsTwitter" value="TRUE"<?php ($enableFlightNotificationsTwitter == 1 ? print ' checked' : ''); ?>> Enable Twitter flight notifications.
<input type="checkbox" name="enableTwitterNotifications" value="TRUE"<?php ($enableTwitterNotifications == 1 ? print ' checked' : ''); ?>> Enable Twitter flight notifications.
</label>
</div>
<div class="form-group">

Wyświetl plik

@ -48,19 +48,19 @@
$settings = new settings();
$common = new common();
// Get all flights to be notified about from the flightNotifications.xml file.
// Get all flights to be notified about from the notifications.xml file.
$lookingFor = array();
if ($settings::db_driver == "xml") {
// XML
$savedFlights = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml");
$savedFlights = simplexml_load_file($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
foreach ($savedFlights as $savedFlight) {
$lookingFor[] = array($savedFlight);
}
} else {
// PDO
$dbh = $common->pdoOpen();
$sql = "SELECT flight FROM ".$settings::db_prefix."flightNotifications";
$sql = "SELECT flight FROM ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$lookingFor = $sth->fetchAll();

Wyświetl plik

@ -228,7 +228,6 @@
foreach ($item as $key => $value) {
$pattern = '/\{'.$itemName.'->(.*?)\}/';
preg_match_all($pattern, $thisIteration, $placeholders, PREG_PATTERN_ORDER);
foreach ($placeholders as $placeholder) {

Wyświetl plik

@ -1 +0,0 @@
Placeholder file to make sure the import folder is created.

Wyświetl plik

@ -167,7 +167,7 @@ EOF;
$xml->startDocument('1.0','UTF-8');
$xml->startElement("flights");
$xml->endElement();
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $xml->flush(true));
file_put_contents($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml", $xml->flush(true));
// Create XML files used to store settings data.
$xml = new XMLWriter();
@ -206,10 +206,10 @@ EOF;
date datetime NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
flight VARCHAR(10) NOT NULL,
lastSeen datetime NOT NULL);';
lastMessageCount INT(11) NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights(
id INT(11) AUTO_INCREMENT PRIMARY KEY,
aircraft INT(11) NOT NULL,
@ -254,10 +254,10 @@ EOF;
date VARCHAR(20) NOT NULL,
author VARCHAR(100) NOT NULL,
contents VARCHAR(20000) NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id SERIAL PRIMARY KEY,
flight VARCHAR(10) NOT NULL,
lastSeen VARCHAR(100) NOT NULL);';
lastMessageCount INT(11) NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights (
id SERIAL PRIMARY KEY,
aircraft INT(11) NOT NULL,
@ -301,10 +301,10 @@ EOF;
date DATETIME NOT NULL,
author TEXT NOT NULL,
contents TEXT NOT NULL);';
$flightNotificationsSql = 'CREATE TABLE '.$dbPrefix.'flightNotifications (
$notificationsSql = 'CREATE TABLE '.$dbPrefix.'notifications (
id INTEGER PRIMARY KEY AUTOINCREMENT,
flight TEXT NOT NULL,
lastSeen DATETIME NOT NULL);';
lastMessageCount INTEGER NOT NULL);';
$flightsSql = 'CREATE TABLE '.$dbPrefix.'flights (
id INTEGER PRIMARY KEY AUTOINCREMENT,
aircraft INTEGER NOT NULL,
@ -345,7 +345,7 @@ EOF;
$sth->execute();
$sth = NULL;
$sth = $dbh->prepare($flightNotificationsSql);
$sth = $dbh->prepare($notificationsSql);
$sth->execute();
$sth = NULL;
@ -394,12 +394,12 @@ EOF;
$common->addSetting('measurementTemperature', 'imperial');
$common->addSetting('measurementBandwidth', 'kbps');
$common->addSetting('networkInterface', 'eth0');
$common->addSetting('enableFlightNotifications', FALSE);
$common->addSetting('enableNotifications', FALSE);
$common->addSetting('emailFrom', 'noreply@adsbreceiver.net');
$common->addSetting('emailReplyTo', 'noreply@adsbreceiver.net');
$common->addSetting('timeZone', $_POST['timeZone']);
$common->addSetting('useDump1090FaMap', FALSE);
$common->addSetting('enableFlightNotificationsTwitter', FALSE);
$common->addSetting('enableTwitterNotifications', FALSE);
$common->addSetting('twitterUserName', '');
$common->addSetting('twitterConsumerKey', '');
$common->addSetting('twitterConsumerSecret', '');

Wyświetl plik

@ -235,42 +235,54 @@
if ($common->getSetting("version") == "2.3.0") {
try {
// Rename the file flightNotifications.xml to notifications.xml
rename($_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."flightNotifications.xml", $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."notifications.xml");
// Add lastSeen as a column to the flightNotifications table.
if ($settings::db_driver == "mysql") {
// Check to see if the column already exists.
$dbh = $common->pdoOpen();
if (count($dbh->query("SHOW COLUMNS FROM `".$settings::db_prefix."flightNotifications` LIKE 'lastSeen'")->fetchAll()) == 0) {
// Add the column if it does not exist.
// Rename the flightNotifications table to notifications.
$sql = "RENAME TABLE ".$settings::db_prefix."flightNotifications TO ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the lastMessageCount column to the notifications table..
$sql = "ALTER TABLE ".$settings::db_prefix."flightNotifications ADD COLUMN lastSeen DATETIME";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
}
$dbh = NULL;
}
if ($settings::db_driver == "sqlite") {
// Check to see if the column already exists.
$dbh = $common->pdoOpen();
$columns = $dbh->query("pragma table_info(flightNotifications)")->fetchArray(SQLITE3_ASSOC);
$columnExists = FALSE;
foreach($columns as $column ){
if ($column['name'] == 'lastSeen') {
$columnExists = TRUE;
}
}
// Rename the flightNotifications table to notifications.
$sql = "ALTER TABLE ".$settings::db_prefix."flightNotifications RENAME TO ".$settings::db_prefix."notifications";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
// Add the column if it does not exist.
if (!$columnExists) {
$sql = "ALTER TABLE ".$settings::db_prefix."flightNotifications ADD COLUMN lastSeen DATETIME";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth = NULL;
}
$dbh = NULL;
}
// Add new flight notification Twitter settings.
$common->addSetting('enableFlightNotificationsTwitter', FALSE);
// Rename the enableFlightNotifications to enableNotifications.
$enableNotifications = $common->getSetting('enableFlightNotifications')
$common->addSetting('enableNotifications', $enableNotifications);
$common->deleteSetting('enableFlightNotifications');
// Add new flight notification Twitter settings
$common->addSetting('enableTwitterNotifications', FALSE);
$common->addSetting('twitterUserName', '');
$common->addSetting('twitterConsumerKey', '');
$common->addSetting('twitterConsumerSecret', '');

Wyświetl plik

@ -29,7 +29,7 @@
<link rel="stylesheet" href="/templates/{setting:template}/assets/css/bootstrap.min.css">
<link rel="stylesheet" href="/templates/{setting:template}/assets/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="/templates/{setting:template}/assets/css/portal.css">
{if setting:enableFlightNotifications eq TRUE}<link rel="stylesheet" href="/templates/{setting:template}/assets/css/notifications.css">{/if}
{if setting:enableNotifications eq TRUE}<link rel="stylesheet" href="/templates/{setting:template}/assets/css/notifications.css">{/if}
{area:head}
</head>
<body>
@ -66,7 +66,7 @@
</div>
</div>
</nav>
{if setting:enableFlightNotifications eq TRUE}
{if setting:enableNotifications eq TRUE}
<div id="flight-notifications" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
@ -97,7 +97,7 @@
</footer>
<script src="/templates/{setting:template}/assets/js/jquery-2.2.1.min.js"></script>
<script src="/templates/{setting:template}/assets/js/bootstrap.min.js"></script>
{if setting:enableFlightNotifications eq TRUE}
{if setting:enableNotifications eq TRUE}
<script src="/templates/{setting:template}/assets/js/notifications.js"></script>
{/if}
<script type="text/javascript">

Wyświetl plik

@ -58,8 +58,8 @@ class NotificationsProcessor(object):
return
mapping = { "s": formatSymbol }
self.STMTS = {
'select_flight_count': "SELECT COUNT(*) FROM adsb_flightNotifications WHERE flight = %(s)s AND lastSeen < %(s)s" % mapping,
'update_flight_seen': "UPDATE adsb_flightNotifications SET lastSeen = %(s)s WHERE flight = %(s)s" % mapping
'select_notifications_count': "SELECT COUNT(*) FROM adsb_flightNotifications WHERE flight = %(s)s AND lastSeen < %(s)s" % mapping,
'update_notifications_message': "UPDATE adsb_flightNotifications SET lastSeen = %(s)s WHERE flight = %(s)s" % mapping
}
def connectDB(self):