diff --git a/app/Models/Pages/Post.php b/app/Models/Pages/Post.php index 9b10504b..73be9080 100644 --- a/app/Models/Pages/Post.php +++ b/app/Models/Pages/Post.php @@ -278,6 +278,14 @@ class Post extends Page $this->user->last_post = $now; $this->c->users->update($this->user); + if ('1' == $this->c->config->o_topic_subscriptions) { // ???? + if ($v->subscribe && ! $topic->is_subscribed) { + $this->c->subscriptions->subscribe($this->user, $topic); + } elseif (! $v->subscribe && $topic->is_subscribed) { + $this->c->subscriptions->unsubscribe($this->user, $topic); + } + } + if ($merge) { $this->c->search->index($lastPost, 'merge'); } else { @@ -285,15 +293,6 @@ class Post extends Page if ($createTopic) { if ('1' == $this->c->config->o_forum_subscriptions) { // ???? - // автоподписка на свою тему - if ( - '1' == $this->c->config->o_topic_subscriptions - && $this->user->auto_notify - && $this->user->email_confirmed - ) { - $this->c->subscriptions->subscribe($this->user, $topic); - } - $this->c->subscriptions->send($post, $topic); } } else { diff --git a/app/Models/Pages/PostFormTrait.php b/app/Models/Pages/PostFormTrait.php index 76d6feb5..813540fb 100644 --- a/app/Models/Pages/PostFormTrait.php +++ b/app/Models/Pages/PostFormTrait.php @@ -134,6 +134,7 @@ trait PostFormTrait 'checked' => isset($vars['merge_post']) ? (bool) $vars['merge_post'] : true, ]; } + if ( $editPost && ! $model->user->isGuest @@ -147,6 +148,33 @@ trait PostFormTrait ]; } } + + if ( + ! $editPost + && '1' == $this->c->config->o_topic_subscriptions + && $this->user->email_confirmed + ) { + $subscribed = ! $editSubject && $model->is_subscribed; + + if ($quickReply) { + if ( + $subscribed + || $this->user->auto_notify + ) { + $form['hidden']['subscribe'] = '1'; + } + } else { + $fieldset['subscribe'] = [ + 'type' => 'checkbox', + 'label' => $subscribed ? __('Stay subscribed') : __('New subscribe'), + 'value' => '1', + 'checked' => isset($vars['subscribe']) + ? (bool) $vars['subscribe'] + : ($subscribed || $this->user->auto_notify), + ]; + } + } + if ( ! $quickReply && '1' == $this->c->config->o_smilies @@ -158,6 +186,7 @@ trait PostFormTrait 'checked' => isset($vars['hide_smilies']) ? (bool) $vars['hide_smilies'] : false, ]; } + if ($fieldset) { $form['sets']['sett'] = [ 'legend' => __('Options'), diff --git a/app/Models/Pages/PostValidatorTrait.php b/app/Models/Pages/PostValidatorTrait.php index d4f600b2..b590c844 100644 --- a/app/Models/Pages/PostValidatorTrait.php +++ b/app/Models/Pages/PostValidatorTrait.php @@ -156,6 +156,16 @@ trait PostValidatorTrait $ruleSubject = 'absent'; } + if ( + ! $editPost + && '1' == $this->c->config->o_topic_subscriptions + && $this->user->email_confirmed + ) { + $ruleSubscribe = 'checkbox'; + } else { + $ruleSubscribe = 'absent'; + } + if ('1' == $this->c->config->o_smilies) { $ruleHideSmilies = 'checkbox'; } else { @@ -177,6 +187,7 @@ trait PostValidatorTrait 'merge_post' => $ruleMergePost, 'hide_smilies' => $ruleHideSmilies, 'edit_post' => $ruleEditPost, + 'subscribe' => $ruleSubscribe, 'preview' => 'string', 'submit' => 'string|check_timeout', 'message' => 'required|string:trim|max:' . $this->c->MAX_POST_SIZE . '|check_message', diff --git a/app/lang/en/post.po b/app/lang/en/post.po index d3d4dab3..ba260be8 100644 --- a/app/lang/en/post.po +++ b/app/lang/en/post.po @@ -66,7 +66,7 @@ msgstr "Post new topic" msgid "Hide smilies" msgstr "Never show smilies as icons for this post" -msgid "Subscribe" +msgid "New subscribe" msgstr "Subscribe to this topic" msgid "Stay subscribed" diff --git a/app/lang/ru/post.po b/app/lang/ru/post.po index ed4883ee..f919d5a8 100644 --- a/app/lang/ru/post.po +++ b/app/lang/ru/post.po @@ -66,7 +66,7 @@ msgstr "Публикация новой темы" msgid "Hide smilies" msgstr "Никогда не показывать смайлы в виде картинок в этом сообщении" -msgid "Subscribe" +msgid "New subscribe" msgstr "Подписаться на эту тему" msgid "Stay subscribed"