]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Settings/Account.php
Issue 11870: Weeks can now start at every day
[friendica.git] / src / Module / Settings / Account.php
index d991fd89ec6be9fc7537c855495d20305c23bc2d..dcbb1861f209db45b7fe3679413f063c739f867f 100644 (file)
@@ -25,11 +25,13 @@ use Exception;
 use Friendica\Core\ACL;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\Core\Worker;
 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;
@@ -252,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)]);
@@ -348,7 +374,7 @@ class Account extends BaseSettings
                                                // "http" or "@" to be present in the string.
                                                // All other fields from the row will be ignored
                                                if ((strpos($csvRow[0], '@') !== false) || in_array(parse_url($csvRow[0], PHP_URL_SCHEME), ['http', 'https'])) {
-                                                       Worker::add(PRIORITY_LOW, 'AddContact', $_SESSION['uid'], $csvRow[0]);
+                                                       Worker::add(PRIORITY_MEDIUM, 'AddContact', local_user(), $csvRow[0]);
                                                } else {
                                                        Logger::notice('Invalid account', ['url' => $csvRow[0]]);
                                                }
@@ -516,13 +542,18 @@ class Account extends BaseSettings
                }
 
                $net_pub_desc = '';
-               if (strlen(DI::config()->get('system', 'directory'))) {
-                       $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', DI::config()->get('system', 'directory'), DI::config()->get('system', 'directory'));
+               if (Search::getGlobalDirectory()) {
+                       $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', Search::getGlobalDirectory(), Search::getGlobalDirectory());
                }
 
                /* Installed langs */
                $lang_choices = DI::l10n()->getAvailableLanguages();
 
+               $notify_type = DI::pConfig()->get(local_user(), 'system', 'notify_type');
+
+               $passwordRules = DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')
+                       . (PASSWORD_DEFAULT === PASSWORD_BCRYPT ? ' ' . DI::l10n()->t('Password length is limited to 72 characters.') : '');
+
                $tpl = Renderer::getMarkupTemplate('settings/account.tpl');
                $o   = Renderer::replaceMacros($tpl, [
                        '$ptitle' => DI::l10n()->t('Account Settings'),
@@ -535,7 +566,7 @@ class Account extends BaseSettings
                        '$open'                => $this->parameters['open'] ?? 'password',
 
                        '$h_pass'        => DI::l10n()->t('Password Settings'),
-                       '$password1'     => ['password', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).'), false, 'autocomplete="off"'],
+                       '$password1'     => ['password', DI::l10n()->t('New Password:'), '', $passwordRules, false, 'autocomplete="off"', User::getPasswordRegExp()],
                        '$password2'     => ['confirm', DI::l10n()->t('Confirm:'), '', DI::l10n()->t('Leave password fields blank unless changing'), false, 'autocomplete="off"'],
                        '$password3'     => ['opassword', DI::l10n()->t('Current Password:'), '', DI::l10n()->t('Your current password to confirm the changes'), false, 'autocomplete="off"'],
                        '$password4'     => ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes of the email address'), false, 'autocomplete="off"'],
@@ -586,11 +617,15 @@ class Account extends BaseSettings
                        '$notify5' => ['notify5', DI::l10n()->t('You receive a private message'), ($notify & Notification\Type::MAIL), Notification\Type::MAIL, ''],
                        '$notify6' => ['notify6', DI::l10n()->t('You receive a friend suggestion'), ($notify & Notification\Type::SUGGEST), Notification\Type::SUGGEST, ''],
                        '$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')],