Преглед на файлове

Update Models\PM\PPost for block

Visman преди 3 години
родител
ревизия
ab69161e5c
променени са 1 файла, в които са добавени 29 реда и са изтрити 3 реда
  1. 29 3
      app/Models/PM/PPost.php

+ 29 - 3
app/Models/PM/PPost.php

@@ -25,11 +25,11 @@ class PPost extends DataModel
         parent::__construct($container);
 
         $this->zDepend = [
-            'id'            => ['link', 'user', 'canDelete', 'linkDelete', 'linkEdit', 'linkQuote', 'previousId', 'linkPrevious'],
+            'id'            => ['link', 'user', 'canDelete', 'linkDelete', 'linkEdit', 'linkQuote', 'previousId', 'linkPrevious', 'linkBlock'],
             'edited'        => ['editor'],
-            'posted'        => ['canDelete', 'canEdit'],
+            'posted'        => ['canDelete', 'canEdit', 'canBlock'],
             'poster'        => ['editor'],
-            'poster_id'     => ['canDelete', 'canEdit'],
+            'poster_id'     => ['canDelete', 'canEdit', 'canBlock', 'linkBlock'],
             'topic_id'      => ['parent', 'linkQuote', 'previousId', 'linkPrevious'],
         ];
     }
@@ -191,6 +191,32 @@ class PPost extends DataModel
         );
     }
 
+    /**
+     * Статус возможности (раз)блокировки
+     */
+    protected function getcanBlock(): bool
+    {
+        return $this->poster_id !== $this->c->user->id
+            && ! $this->user->isAdmin
+            && ! $this->user->isGuest;
+    }
+
+    /**
+     * Ссылка на (раз)блокировку пользователя
+     */
+    protected function getlinkBlock(): string
+    {
+        return $this->c->Router->link(
+            'PMAction',
+            [
+                'second' => $this->c->pms->second,
+                'action' => Cnst::ACTION_BLOCK,
+                'more1'  => $this->poster_id,
+                'more2'  => $this->id,
+            ]
+        );
+    }
+
     /**
      * HTML код сообщения
      */