X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=windowsphonepush%2Fwindowsphonepush.php;h=53bf83b87d1863b93780733b67be68d529cbc53f;hp=21f986e0ff8d1e7839b7d15a6baa73996566e365;hb=48dcbc6f3fc3edae74e3ea2c823011bfb7c26081;hpb=6d6e73096afb22e95678c651e055337f1bf5405d diff --git a/windowsphonepush/windowsphonepush.php b/windowsphonepush/windowsphonepush.php index 21f986e0..53bf83b8 100644 --- a/windowsphonepush/windowsphonepush.php +++ b/windowsphonepush/windowsphonepush.php @@ -25,6 +25,7 @@ * count only unseen elements which are not type=activity (likes and dislikes not seen as new elements) */ +use Friendica\Core\PConfig; function windowsphonepush_install() { @@ -87,13 +88,13 @@ function windowsphonepush_settings_post($a,$post) { if(! local_user() || (! x($_POST,'windowsphonepush-submit'))) return; $enable = intval($_POST['windowsphonepush']); - set_pconfig(local_user(),'windowsphonepush','enable',$enable); + PConfig::set(local_user(),'windowsphonepush','enable',$enable); if($enable) { - set_pconfig(local_user(),'windowsphonepush','counterunseen', 0); + PConfig::set(local_user(),'windowsphonepush','counterunseen', 0); } - set_pconfig(local_user(),'windowsphonepush','senditemtext',intval($_POST['windowsphonepush-senditemtext'])); + PConfig::set(local_user(),'windowsphonepush','senditemtext',intval($_POST['windowsphonepush-senditemtext'])); info( t('WindowsPhonePush settings updated.') . EOL); } @@ -114,13 +115,13 @@ function windowsphonepush_settings(&$a,&$s) { $a->page['htmlhead'] .= '' . "\r\n"; /* Get the current state of our config variables */ - $enabled = get_pconfig(local_user(),'windowsphonepush','enable'); + $enabled = PConfig::get(local_user(),'windowsphonepush','enable'); $checked_enabled = (($enabled) ? ' checked="checked" ' : ''); - $senditemtext = get_pconfig(local_user(), 'windowsphonepush', 'senditemtext'); + $senditemtext = PConfig::get(local_user(), 'windowsphonepush', 'senditemtext'); $checked_senditemtext = (($senditemtext) ? ' checked="checked" ' : ''); - $device_url = get_pconfig(local_user(), 'windowsphonepush', 'device_url'); + $device_url = PConfig::get(local_user(), 'windowsphonepush', 'device_url'); /* Add some HTML to the existing form */ $s .= '
'; @@ -163,8 +164,8 @@ function windowsphonepush_cron() { if(count($r)) { foreach($r as $rr) { // load stored information for the user-id of the current loop - $device_url = get_pconfig($rr['uid'], 'windowsphonepush', 'device_url'); - $lastpushid = get_pconfig($rr['uid'], 'windowsphonepush', 'lastpushid'); + $device_url = PConfig::get($rr['uid'], 'windowsphonepush', 'device_url'); + $lastpushid = PConfig::get($rr['uid'], 'windowsphonepush', 'lastpushid'); // pushing only possible if device_url (the URI on Microsoft server) is available or not "NA" (which will be sent // by app if user has switched the server setting in app - sending blank not possible as this would return an update error) @@ -185,7 +186,7 @@ function windowsphonepush_cron() { switch (trim($res_tile)) { case "Received": // ok, count has been pushed, let's save it in personal settings - set_pconfig($rr['uid'], 'windowsphonepush', 'counterunseen', $count[0]['count']); + PConfig::set($rr['uid'], 'windowsphonepush', 'counterunseen', $count[0]['count']); break; case "QueueFull": // maximum of 30 messages reached, server rejects any further push notification until device reconnects @@ -208,7 +209,7 @@ function windowsphonepush_cron() { if (intval($count[0]['max']) > intval($lastpushid)) { // user can define if he wants to see the text of the item in the push notification // this has been implemented as the device_url is not a https uri (not so secure) - $senditemtext = get_pconfig($rr['uid'], 'windowsphonepush', 'senditemtext'); + $senditemtext = PConfig::get($rr['uid'], 'windowsphonepush', 'senditemtext'); if ($senditemtext == 1) { // load item with the max id $item = q("SELECT `author-name` as author, `body` as body FROM `item` where `id` = %d", @@ -247,7 +248,7 @@ function windowsphonepush_cron() { // further log information done on count pushing with send_tile (see above) $res_toast = send_toast($device_url, $author, $body); if (trim($res_toast) === 'Received') { - set_pconfig($rr['uid'], 'windowsphonepush', 'lastpushid', $count[0]['max']); + PConfig::set($rr['uid'], 'windowsphonepush', 'lastpushid', $count[0]['max']); } } } @@ -330,7 +331,7 @@ function send_push($device_url, $headers, $msg) { // and log this fact $subscriptionStatus = get_header_value($output, 'X-SubscriptionStatus'); if ($subscriptionStatus == "Expired") { - set_pconfig(local_user(),'windowsphonepush','device_url', ""); + PConfig::set(local_user(),'windowsphonepush','device_url', ""); logger("ERROR: the stored Device-URL " . $device_url . "returned an 'Expired' error, it has been deleted now."); } @@ -393,11 +394,11 @@ function windowsphonepush_showsettings(&$a) { if(! local_user()) return; - $enable = get_pconfig(local_user(), 'windowsphonepush', 'enable'); - $device_url = get_pconfig(local_user(), 'windowsphonepush', 'device_url'); - $senditemtext = get_pconfig(local_user(), 'windowsphonepush', 'senditemtext'); - $lastpushid = get_pconfig(local_user(), 'windowsphonepush', 'lastpushid'); - $counterunseen = get_pconfig(local_user(), 'windowsphonepush', 'counterunseen'); + $enable = PConfig::get(local_user(), 'windowsphonepush', 'enable'); + $device_url = PConfig::get(local_user(), 'windowsphonepush', 'device_url'); + $senditemtext = PConfig::get(local_user(), 'windowsphonepush', 'senditemtext'); + $lastpushid = PConfig::get(local_user(), 'windowsphonepush', 'lastpushid'); + $counterunseen = PConfig::get(local_user(), 'windowsphonepush', 'counterunseen'); $addonversion = "2.0"; if (!$device_url) @@ -426,7 +427,7 @@ function windowsphonepush_updatesettings(&$a) { } // no updating if user hasn't enabled the plugin - $enable = get_pconfig(local_user(), 'windowsphonepush', 'enable'); + $enable = PConfig::get(local_user(), 'windowsphonepush', 'enable'); if(! $enable) { return "Plug-in not enabled"; } @@ -448,12 +449,12 @@ function windowsphonepush_updatesettings(&$a) { `v` = '" . $device_url . "'"); if(count($r)) { foreach($r as $rr) { - set_pconfig($rr['uid'], 'windowsphonepush', 'device_url', ''); + PConfig::set($rr['uid'], 'windowsphonepush', 'device_url', ''); logger("WARN: the sent URL was already registered with user '" . $rr['uid'] . "'. Deleted for this user as we expect to be correct now for user '" . local_user() . "'."); } } - set_pconfig(local_user(),'windowsphonepush','device_url', $device_url); + PConfig::set(local_user(),'windowsphonepush','device_url', $device_url); // output the successfull update of the device URL to the logger for error analysis if necessary logger("INFO: Device-URL for user '" . local_user() . "' has been updated with '" . $device_url . "'"); return "Device-URL updated successfully!"; @@ -468,12 +469,12 @@ function windowsphonepush_updatecounterunseen() { } // no updating if user hasn't enabled the plugin - $enable = get_pconfig(local_user(), 'windowsphonepush', 'enable'); + $enable = PConfig::get(local_user(), 'windowsphonepush', 'enable'); if(! $enable) { return "Plug-in not enabled"; } - set_pconfig(local_user(),'windowsphonepush','counterunseen', 0); + PConfig::set(local_user(),'windowsphonepush','counterunseen', 0); return "Counter set to zero"; }