Ver código fonte

Update Models\PM\PTopic

Visman 4 anos atrás
pai
commit
96a2433d61
1 arquivos alterados com 18 adições e 3 exclusões
  1. 18 3
      app/Models/PM/PTopic.php

+ 18 - 3
app/Models/PM/PTopic.php

@@ -30,12 +30,12 @@ class PTopic extends DataModel
             'num_replies'   => ['numPages', 'pagination'],
             'poster'        => ['last_poster', 'byOrFor', 'zpUser', 'ztUser'],
             'poster_id'     => ['closed', 'firstNew', 'zp', 'zt', 'zpUser', 'ztUser', 'actionsAllowed', 'canReply'],
-            'poster_status' => ['closed', 'actionsAllowed', 'canReply'],
+            'poster_status' => ['closed', 'actionsAllowed', 'canReply', 'isFullDeleted'],
             'poster_visit'  => ['firstNew'],
             'subject'       => ['name'],
             'target'        => ['last_poster', 'byOrFor', 'zpUser', 'ztUser'],
             'target_id'     => ['closed', 'firstNew', 'zp', 'zt', 'zpUser', 'ztUser', 'actionsAllowed', 'canReply'],
-            'target_status' => ['closed', 'actionsAllowed', 'canReply'],
+            'target_status' => ['closed', 'actionsAllowed', 'canReply', 'isFullDeleted'],
             'target_visit'  => ['firstNew'],
         ];
     }
@@ -387,7 +387,7 @@ class PTopic extends DataModel
         $this->{"{$this->zp}_visit"} = $this->last_post;
 
         $this->c->pms->update(Cnst::PTOPIC, $this);
-        $this->c->pms->updateFromPTopics(false, $this);
+        $this->c->pms->recalculate($this->zpUser);
     }
 
     /**
@@ -489,4 +489,19 @@ class PTopic extends DataModel
                 || $this->ztUser->isAdmin
             );
     }
+
+    /**
+     * Статус удаления диалога у обоих собеседников
+     */
+    protected function getisFullDeleted(): bool
+    {
+        return (
+                Cnst::PT_DELETED === $this->poster_status
+                || Cnst::PT_NOTSENT === $this->poster_status
+            )
+            && (
+                Cnst::PT_DELETED === $this->target_status
+                || Cnst::PT_NOTSENT === $this->target_status
+            );
+    }
 }