]> git.mxchange.org Git - friendica-addons.git/blobdiff - windowsphonepush/windowsphonepush.php
Merge 2019.12 master into develop
[friendica-addons.git] / windowsphonepush / windowsphonepush.php
index a6c9aa9b271ef848e7c75c2f45d910f2a38d6375..242fe96db217cd7a563924d328269b1ff7174330 100644 (file)
  */
 
 use Friendica\App;
+use Friendica\BaseObject;
 use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
-use Friendica\Core\Addon;
-use Friendica\Core\Authentication;
+use Friendica\App\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 +46,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 +64,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");
 }
@@ -338,19 +340,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";
@@ -473,7 +475,9 @@ function windowsphonepush_login(App $a)
                die('This api requires login');
        }
 
-       Authentication::setAuthenticatedSessionForUser($record);
+       /** @var Authentication $authentication */
+       $authentication = BaseObject::getClass(Authentication::class);
+       $authentication->setForUser($a, $record);
        $_SESSION["allow_api"] = true;
-       Addon::callHooks('logged_in', $a->user);
+       Hook::callAll('logged_in', $a->user);
 }