]> git.mxchange.org Git - friendica.git/blobdiff - mod/settings.php
Merge pull request #10620 from annando/new-notifications
[friendica.git] / mod / settings.php
index 87c56e0df4a524decb5776f1990e501d24223ea2..3ff27e98404362101a2d21176290682a03592f0d 100644 (file)
@@ -53,7 +53,8 @@ function settings_init(App $a)
 
 function settings_post(App $a)
 {
-       if (!local_user()) {
+       if (!$a->isLoggedIn()) {
+               notice(DI::l10n()->t('Permission denied.'));
                return;
        }
 
@@ -61,11 +62,6 @@ function settings_post(App $a)
                return;
        }
 
-       if (empty($a->getUserId()) || $a->getUserId() != local_user()) {
-               notice(DI::l10n()->t('Permission denied.'));
-               return;
-       }
-
        if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'addon')) {
                BaseModule::checkFormSecurityTokenRedirectOnError('/settings/addon', 'settings_addon');
 
@@ -73,7 +69,7 @@ function settings_post(App $a)
                return;
        }
 
-       $user = User::getById($a->getUserId());
+       $user = User::getById($a->getLoggedInUserId());
 
        if ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] == 'connectors')) {
                BaseModule::checkFormSecurityTokenRedirectOnError('/settings/connectors', 'settings_connectors');
@@ -266,6 +262,9 @@ function settings_post(App $a)
        $unlisted         = (($_POST['unlisted'] == 1) ? 1: 0);
        $accessiblephotos = (($_POST['accessible-photos'] == 1) ? 1: 0);
 
+       $notify_like      = (($_POST['notify_like'] == 1) ? 1 : 0);
+       $notify_announce  = (($_POST['notify_announce'] == 1) ? 1 : 0);
+
        $email_textonly   = (($_POST['email_textonly'] == 1) ? 1 : 0);
        $detailed_notif   = (($_POST['detailed_notif'] == 1) ? 1 : 0);
 
@@ -362,6 +361,9 @@ function settings_post(App $a)
        DI::pConfig()->set(local_user(), 'expire', 'photos', $expire_photos);
        DI::pConfig()->set(local_user(), 'expire', 'network_only', $expire_network_only);
 
+       DI::pConfig()->set(local_user(), 'system', 'notify_like', $notify_like);
+       DI::pConfig()->set(local_user(), 'system', 'notify_announce', $notify_announce);
+
        DI::pConfig()->set(local_user(), 'system', 'email_textonly', $email_textonly);
        DI::pConfig()->set(local_user(), 'system', 'detailed_notif', $detailed_notif);
        DI::pConfig()->set(local_user(), 'system', 'notify_ignored', $notify_ignored);
@@ -594,11 +596,11 @@ function settings_content(App $a)
                return;
        }
 
-       $user = User::getById($a->getUserId());
+       $user = User::getById($a->getLoggedInUserId());
 
        $username   = $user['username'];
        $email      = $user['email'];
-       $nickname   = $a->getNickname();
+       $nickname   = $a->getLoggedInUserNickname();
        $timezone   = $user['timezone'];
        $language   = $user['language'];
        $notify     = $user['notify-flags'];
@@ -752,7 +754,7 @@ function settings_content(App $a)
                '$cntunkmail'         => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail , DI::l10n()->t("\x28to prevent spam abuse\x29")],
                '$group_select'       => Group::displayGroupSelection(local_user(), $user['def_gid']),
                '$permissions'        => DI::l10n()->t('Default Post Permissions'),
-               '$aclselect'          => ACL::getFullSelectorHTML(DI::page(), $a->user),
+               '$aclselect'          => ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()),
 
                '$expire' => [
                        'label'        => DI::l10n()->t('Expiration settings'),
@@ -775,6 +777,10 @@ function settings_content(App $a)
                '$notify7'  => ['notify7', DI::l10n()->t('You are tagged in a post'), ($notify & Notification\Type::TAG_SELF), Notification\Type::TAG_SELF, ''],
                '$notify8'  => ['notify8', DI::l10n()->t('You are poked/prodded/etc. in a post'), ($notify & Notification\Type::POKE), Notification\Type::POKE, ''],
 
+               '$lbl_notify'      => DI::l10n()->t('Create a desktop notification when:'),
+               '$notify_like'     => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(local_user(), 'system', 'notify_like'), ''],
+               '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(local_user(), 'system', 'notify_announce'), ''],
+
                '$desktop_notifications' => ['desktop_notifications', DI::l10n()->t('Activate desktop notifications') , false, DI::l10n()->t('Show desktop popup on new notifications')],
 
                '$email_textonly' => ['email_textonly', DI::l10n()->t('Text-only notification emails'),