浏览代码

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);
         parent::__construct($container);
 
 
         $this->zDepend = [
         $this->zDepend = [
-            'id'            => ['link', 'user', 'canDelete', 'linkDelete', 'linkEdit', 'linkQuote', 'previousId', 'linkPrevious'],
+            'id'            => ['link', 'user', 'canDelete', 'linkDelete', 'linkEdit', 'linkQuote', 'previousId', 'linkPrevious', 'linkBlock'],
             'edited'        => ['editor'],
             'edited'        => ['editor'],
-            'posted'        => ['canDelete', 'canEdit'],
+            'posted'        => ['canDelete', 'canEdit', 'canBlock'],
             'poster'        => ['editor'],
             'poster'        => ['editor'],
-            'poster_id'     => ['canDelete', 'canEdit'],
+            'poster_id'     => ['canDelete', 'canEdit', 'canBlock', 'linkBlock'],
             'topic_id'      => ['parent', 'linkQuote', 'previousId', 'linkPrevious'],
             '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 код сообщения
      * HTML код сообщения
      */
      */