* count only unseen elements which are not type=activity (likes and dislikes not seen as new elements)
*/
use Friendica\App;
+use Friendica\Core\Addon;
use Friendica\Core\PConfig;
use Friendica\Model\User;
* The first is within cron - so the push notifications will be
* sent every 10 minutes (or whatever is set in crontab).
*/
- register_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
+ Addon::registerHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
/* Then we'll attach into the plugin settings page, and also the
* settings post hook so that we can create and update
* user preferences. User shall be able to activate the plugin and
* define whether he allows pushing first characters of item text
*/
- register_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
- register_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
+ Addon::registerHook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
+ Addon::registerHook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
logger("installed windowsphonepush");
}
/* uninstall unregisters any hooks created with register_hook
* during install. Don't delete data in table `pconfig`.
*/
- unregister_hook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
- unregister_hook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
- unregister_hook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
+ Addon::unregisterHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
+ Addon::unregisterHook('plugin_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
+ Addon::unregisterHook('plugin_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
logger("removed windowsphonepush");
}
"</wp:Tile> " .
"</wp:Notification>";
- $result = send_push($device_url, array(
+ $result = send_push($device_url, [
'X-WindowsPhone-Target: token',
'X-NotificationClass: ' . $priority,
- ), $msg);
+ ], $msg);
return $result;
}
"</wp:Toast>" .
"</wp:Notification>";
- $result = send_push($device_url, array(
+ $result = send_push($device_url, [
'X-WindowsPhone-Target: toast',
'X-NotificationClass: ' . $priority,
- ), $msg);
+ ], $msg);
return $result;
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers + array(
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers + [
'Content-Type: text/xml',
'charset=utf-8',
'Accept: application/*',
- )
+ ]
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $msg);
case "update_settings":
$ret = windowsphonepush_updatesettings($a);
header("Content-Type: application/json; charset=utf-8");
- echo json_encode(array('status' => $ret));
+ echo json_encode(['status' => $ret]);
killme();
break;
case "update_counterunseen":
$ret = windowsphonepush_updatecounterunseen();
header("Content-Type: application/json; charset=utf-8");
- echo json_encode(array('status' => $ret));
+ echo json_encode(['status' => $ret]);
killme();
break;
default:
}
header("Content-Type: application/json");
- echo json_encode(array('uid' => local_user(),
+ echo json_encode(['uid' => local_user(),
'enable' => $enable,
'device_url' => $device_url,
'senditemtext' => $senditemtext,
'lastpushid' => $lastpushid,
'counterunseen' => $counterunseen,
- 'addonversion' => $addonversion));
+ 'addonversion' => $addonversion]);
}
/* update_settings is used to transfer the device_url from WP device to the Friendica server
die('This api requires login');
}
- $user = $_SERVER['PHP_AUTH_USER'];
- $encrypted = hash('whirlpool',trim($_SERVER['PHP_AUTH_PW']));
+ $user_id = User::authenticate($_SERVER['PHP_AUTH_USER'], trim($_SERVER['PHP_AUTH_PW']));
- // check if user specified by app is available in the user table
- $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
- dbesc(trim($user)),
- dbesc(trim($user)),
- dbesc($encrypted)
- );
-
- if(count($r)){
- $record = $r[0];
+ if ($user_id) {
+ $record = dba::selectFirst('user', [], ['uid' => $user_id]);
} else {
logger('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
header('WWW-Authenticate: Basic realm="Friendica"');