From e5b57d8c27504f7239795fa6d35b40b3396c10cf Mon Sep 17 00:00:00 2001 From: Git Date: Mon, 31 Mar 2014 08:01:19 +0000 Subject: [PATCH] Empty commit --- classes/notificationsmanager.class.php | 21 ++++++- classes/notificationsmanagerview.class.php | 8 +++ classes/pushserver.class.php | 48 ++++++++++++++++ sections/ajax/index.php | 3 + sections/ajax/pushbullet_devices.php | 21 +++++++ static/functions/user_settings.js | 64 ++++++++++++++++++++++ 6 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 sections/ajax/pushbullet_devices.php diff --git a/classes/notificationsmanager.class.php b/classes/notificationsmanager.class.php index 06507e8f..2639ce28 100644 --- a/classes/notificationsmanager.class.php +++ b/classes/notificationsmanager.class.php @@ -675,7 +675,12 @@ public static function save_settings($UserID, $Settings) { WHERE UserID = '$UserID'"); $PushService = (int) $_POST['pushservice']; - $PushOptions = db_string(serialize(array("PushKey" => $_POST['pushkey']))); + $PushOptionsArray = array("PushKey" => $_POST['pushkey']); + if ($PushService === 6) { //pushbullet + $PushOptionsArray['PushDevice'] = $_POST['pushdevice']; + + } + $PushOptions = db_string(serialize($PushOptionsArray)); if ($PushService != 0) { G::$DB->query(" @@ -752,13 +757,23 @@ public static function send_push($UserIDs, $Title, $Body, $URL = '', $Type = 'Gl case '5': $Service = "Pushover"; break; + case '6': + $Service = "PushBullet"; + break; default: break; } if (!empty($Service) && !empty($PushOptions['PushKey'])) { - $JSON = json_encode(array("service" => strtolower($Service), + $Options = array("service" => strtolower($Service), "user" => array("key" => $PushOptions['PushKey']), - "message" => array("title" => $Title, "body" => $Body, "url" => $URL))); + "message" => array("title" => $Title, "body" => $Body, "url" => $URL)); + + if ($Service === 'PushBullet') { + $Options["user"]["device"] = $PushOptions['PushDevice']; + + } + + $JSON = json_encode($Options); G::$DB->query(" INSERT INTO push_notifications_usage (PushService, TimesUsed) diff --git a/classes/notificationsmanagerview.class.php b/classes/notificationsmanagerview.class.php index d44db8f3..5215dbb3 100644 --- a/classes/notificationsmanagerview.class.php +++ b/classes/notificationsmanagerview.class.php @@ -20,6 +20,9 @@ public static function load_js() { private static function render_push_settings() { $PushService = self::$Settings['PushService']; $PushOptions = unserialize(self::$Settings['PushOptions']); + if (empty($PushOptions['PushDevice'])) { + $PushOptions['PushDevice'] = ''; + } ?> Push notifications @@ -31,10 +34,15 @@ private static function render_push_settings() { +