]> git.mxchange.org Git - friendica-addons.git/blobdiff - windowsphonepush/windowsphonepush.php
Merge branch '2019.06-rc'
[friendica-addons.git] / windowsphonepush / windowsphonepush.php
index b6e455fba0bc43237193a771d87827937f81302d..30c6cf60f399642b1e705d5d017a1b6a3400965f 100644 (file)
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Addon;
-use Friendica\Core\Authentication;
+use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
+use Friendica\Core\Session;
 use Friendica\Database\DBA;
 use Friendica\Model\Item;
 use Friendica\Model\User;
@@ -44,15 +44,15 @@ function windowsphonepush_install()
         * The first is within cron - so the push notifications will be
         * sent every 10 minutes (or whatever is set in crontab).
         */
-       Addon::registerHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
+       Hook::register('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
 
        /* Then we'll attach into the addon settings page, and also the
         * settings post hook so that we can create and update
         * user preferences. User shall be able to activate the addon and
         * define whether he allows pushing first characters of item text
         */
-       Addon::registerHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
-       Addon::registerHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
+       Hook::register('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
+       Hook::register('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
 
        Logger::log("installed windowsphonepush");
 }
@@ -62,9 +62,9 @@ function windowsphonepush_uninstall()
        /* uninstall unregisters any hooks created with register_hook
         * during install. Don't delete data in table `pconfig`.
         */
-       Addon::unregisterHook('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
-       Addon::unregisterHook('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
-       Addon::unregisterHook('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
+       Hook::unregister('cron', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_cron');
+       Hook::unregister('addon_settings', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings');
+       Hook::unregister('addon_settings_post', 'addon/windowsphonepush/windowsphonepush.php', 'windowsphonepush_settings_post');
 
        Logger::log("removed windowsphonepush");
 }
@@ -82,7 +82,7 @@ function windowsphonepush_module()
  */
 function windowsphonepush_settings_post($a, $post)
 {
-       if (!local_user() || (!x($_POST, 'windowsphonepush-submit'))) {
+       if (!local_user() || empty($_POST['windowsphonepush-submit'])) {
                return;
        }
        $enable = intval($_POST['windowsphonepush']);
@@ -338,19 +338,19 @@ function windowsphonepush_content(App $a)
                switch ($path2) {
                        case "show_settings":
                                windowsphonepush_showsettings($a);
-                               killme();
+                               exit();
                                break;
                        case "update_settings":
                                $ret = windowsphonepush_updatesettings($a);
                                header("Content-Type: application/json; charset=utf-8");
                                echo json_encode(['status' => $ret]);
-                               killme();
+                               exit();
                                break;
                        case "update_counterunseen":
                                $ret = windowsphonepush_updatecounterunseen();
                                header("Content-Type: application/json; charset=utf-8");
                                echo json_encode(['status' => $ret]);
-                               killme();
+                               exit();
                                break;
                        default:
                                echo "Fehler";
@@ -456,7 +456,7 @@ function windowsphonepush_updatecounterunseen()
 function windowsphonepush_login(App $a)
 {
        if (!isset($_SERVER['PHP_AUTH_USER'])) {
-               Logger::log('API_login: ' . print_r($_SERVER, true), LOGGER_DEBUG);
+               Logger::log('API_login: ' . print_r($_SERVER, true), Logger::DEBUG);
                header('WWW-Authenticate: Basic realm="Friendica"');
                header('HTTP/1.0 401 Unauthorized');
                die('This api requires login');
@@ -467,13 +467,13 @@ function windowsphonepush_login(App $a)
        if ($user_id) {
                $record = DBA::selectFirst('user', [], ['uid' => $user_id]);
        } else {
-               Logger::log('API_login failure: ' . print_r($_SERVER, true), LOGGER_DEBUG);
+               Logger::log('API_login failure: ' . print_r($_SERVER, true), Logger::DEBUG);
                header('WWW-Authenticate: Basic realm="Friendica"');
                header('HTTP/1.0 401 Unauthorized');
                die('This api requires login');
        }
 
-       Authentication::setAuthenticatedSessionForUser($record);
+       Session::setAuthenticatedForUser($a, $record);
        $_SESSION["allow_api"] = true;
-       Addon::callHooks('logged_in', $a->user);
+       Hook::callAll('logged_in', $a->user);
 }