X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FSettings%2FAccount.php;h=33a5feff492d3fba72db77146aac34dd03c16cb5;hb=9bb371850ab4185b98a6372e930450794f882209;hp=43e8c8120c5322631c44ec1f55d56eca4618af98;hpb=7199a912899ac97724b9009a1d1f855f303b131a;p=friendica.git diff --git a/src/Module/Settings/Account.php b/src/Module/Settings/Account.php index 43e8c8120c..33a5feff49 100644 --- a/src/Module/Settings/Account.php +++ b/src/Module/Settings/Account.php @@ -31,6 +31,7 @@ use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Group; use Friendica\Model\Notification; +use Friendica\Model\Post\UserNotification; use Friendica\Model\Profile; use Friendica\Model\User; use Friendica\Model\Verb; @@ -253,6 +254,30 @@ class Account extends BaseSettings $notify_like = !empty($request['notify_like']); $notify_announce = !empty($request['notify_announce']); + $notify_type = 0; + + if (!empty($request['notify_tagged'])) { + $notify_type = $notify_type | UserNotification::TYPE_EXPLICIT_TAGGED; + } + if (!empty($request['notify_direct_comment'])) { + $notify_type = $notify_type | (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT); + } + if (!empty($request['notify_thread_comment'])) { + $notify_type = $notify_type | UserNotification::TYPE_THREAD_COMMENT; + } + if (!empty($request['notify_comment_participation'])) { + $notify_type = $notify_type | UserNotification::TYPE_COMMENT_PARTICIPATION; + } + if (!empty($request['notify_activity_participation'])) { + $notify_type = $notify_type | UserNotification::TYPE_ACTIVITY_PARTICIPATION; + } + DI::pConfig()->set(local_user(), 'system', 'notify_type', $notify_type); + + if (!($notify_type & (UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT))) { + $notify_like = false; + $notify_announce = false; + } + // Reset like notifications when they are going to be shown again if (!DI::pConfig()->get(local_user(), 'system', 'notify_like') && $notify_like) { DI::notification()->setAllSeenForUser(local_user(), ['vid' => Verb::getID(Activity::LIKE)]); @@ -524,6 +549,8 @@ class Account extends BaseSettings /* Installed langs */ $lang_choices = DI::l10n()->getAvailableLanguages(); + $notify_type = DI::pConfig()->get(local_user(), 'system', 'notify_type'); + $tpl = Renderer::getMarkupTemplate('settings/account.tpl'); $o = Renderer::replaceMacros($tpl, [ '$ptitle' => DI::l10n()->t('Account Settings'), @@ -589,9 +616,14 @@ class Account extends BaseSettings '$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'), ''], + '$lbl_notify' => DI::l10n()->t('Create a desktop notification when:'), + '$notify_tagged' => ['notify_tagged', DI::l10n()->t('Someone tagged you'), is_null($notify_type) || $notify_type & UserNotification::TYPE_EXPLICIT_TAGGED, ''], + '$notify_direct_comment' => ['notify_direct_comment', DI::l10n()->t('Someone directly commented on your post'), is_null($notify_type) || $notify_type & (UserNotification::TYPE_IMPLICIT_TAGGED + UserNotification::TYPE_DIRECT_COMMENT + UserNotification::TYPE_DIRECT_THREAD_COMMENT), ''], + '$notify_like' => ['notify_like', DI::l10n()->t('Someone liked your content'), DI::pConfig()->get(local_user(), 'system', 'notify_like'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')], + '$notify_announce' => ['notify_announce', DI::l10n()->t('Someone shared your content'), DI::pConfig()->get(local_user(), 'system', 'notify_announce'), DI::l10n()->t('Can only be enabled, when the direct comment notification is enabled.')], + '$notify_thread_comment' => ['notify_thread_comment', DI::l10n()->t('Someone commented in your thread'), is_null($notify_type) || $notify_type & UserNotification::TYPE_THREAD_COMMENT, ''], + '$notify_comment_participation' => ['notify_comment_participation', DI::l10n()->t('Someone commented in a thread where you commented'), is_null($notify_type) || $notify_type & UserNotification::TYPE_COMMENT_PARTICIPATION, ''], + '$notify_activity_participation' => ['notify_activity_participation', DI::l10n()->t('Someone commented in a thread where you interacted'), is_null($notify_type) || $notify_type & UserNotification::TYPE_ACTIVITY_PARTICIPATION, ''], '$desktop_notifications' => ['desktop_notifications', DI::l10n()->t('Activate desktop notifications'), false, DI::l10n()->t('Show desktop popup on new notifications')],