Browse Source

Update Poll model and temlate

Visman 3 years ago
parent
commit
15d81858ff
4 changed files with 13 additions and 8 deletions
  1. 6 5
      app/Models/Poll/Poll.php
  2. 3 0
      app/lang/en/poll.po
  3. 3 0
      app/lang/ru/poll.po
  4. 1 3
      app/templates/layouts/poll.forkbb.php

+ 6 - 5
app/Models/Poll/Poll.php

@@ -93,11 +93,10 @@ class Poll extends DataModel
      */
     protected function getuserVoted(): bool
     {
-        if ($this->c->user->isGuest) {
-            return true;
-        }
-
-        if ($this->tid < 1) {
+        if (
+            $this->c->user->isGuest
+            || $this->tid < 1
+        ) {
             return false;
         }
 
@@ -253,6 +252,8 @@ class Poll extends DataModel
             return ['Poll results are hidden up to %s voters', $this->parent->poll_term];
         } elseif ($this->userVoted) {
             return 'You voted';
+        } elseif ($this->c->user->isGuest) {
+            return 'Guest cannot vote';
         } else {
             return 'Poll status is undefined';
         }

+ 3 - 0
app/lang/en/poll.po

@@ -84,6 +84,9 @@ msgstr "Poll results are hidden up to %s voters."
 msgid "You voted"
 msgstr "You voted."
 
+msgid "Guest cannot vote"
+msgstr "Guest can't vote."
+
 msgid "Poll status is undefined"
 msgstr "Poll status is undefined."
 

+ 3 - 0
app/lang/ru/poll.po

@@ -84,6 +84,9 @@ msgstr "Результаты опроса скрыты до %s проголос
 msgid "You voted"
 msgstr "Вы проголосовали."
 
+msgid "Guest cannot vote"
+msgstr "Гость не может голосовать."
+
 msgid "Poll status is undefined"
 msgstr "Статус опроса неопределен."
 

+ 1 - 3
app/templates/layouts/poll.forkbb.php

@@ -42,9 +42,7 @@
               <button class="f-btn" name="vote" value="{{ __('Vote') }}" title="{{ __('Vote') }}"><span>{!! __('Vote') !!}</span></button>
             </p>
           </form>
-@else
-    @if (null !== $poll->status)
+@elseif (null !== $poll->status)
           <p class="f-poll-status"><span>{!! __($poll->status) !!}</span></p>
-    @endif
 @endif
         </div>