From 710225518e698000c30eba5f33d7659b16ab3d1c Mon Sep 17 00:00:00 2001 From: githubjeka Date: Wed, 11 Nov 2020 13:07:24 +0300 Subject: [PATCH] feat: launch on Humhub 1.7 Rewritten `\tracker\controllers\actions\StreamAction` for new requirements Closes #40 --- Module.php | 5 ----- controllers/actions/StreamAction.php | 33 +++++++++++++--------------- views/document/view.php | 3 ++- views/issue/__item_index.php | 3 +-- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/Module.php b/Module.php index b39a81b..4b2b93b 100644 --- a/Module.php +++ b/Module.php @@ -23,11 +23,6 @@ class Module extends ContentContainerModule public $id = 'tracker-issues'; public $documentRootPath; - - /** - * @inheritdoc - */ - public $resourcesPath = 'resources'; public function init() { diff --git a/controllers/actions/StreamAction.php b/controllers/actions/StreamAction.php index d7115cb..555487c 100644 --- a/controllers/actions/StreamAction.php +++ b/controllers/actions/StreamAction.php @@ -19,24 +19,7 @@ */ class StreamAction extends ContentContainerStream { - public $streamQueryClass = IssueWallStreamQuery::class; - - public function setupFilters() - { - if (!empty($this->streamQuery->contentId) && \Yii::$app->user->permissionmanager->can(new ViewAllDocuments())) { - $tableIssue = Issue::tableName(); - $documentsIssuesTable = DocumentIssue::tableName(); - $this->streamQuery - ->query() - ->leftJoin($documentsIssuesTable, "$documentsIssuesTable.issue_id = $tableIssue.id") - ->orWhere( - "$documentsIssuesTable.issue_id IS NOT NULL AND content.id = :id", - [':id' => $this->streamQuery->contentId] - ); - } - } - - public function setupCriteria() + public function afterApplyFilters() { if (empty($this->streamQuery->contentId)) { $this->streamQuery @@ -71,6 +54,20 @@ public function setupCriteria() " OR $tableAssignee.id IS NOT NULL)) ", [':user' => \Yii::$app->user->id] ); + + if (\Yii::$app->user->permissionmanager->can(new ViewAllDocuments())) { + $tableIssue = Issue::tableName(); + $documentsIssuesTable = DocumentIssue::tableName(); + $this->streamQuery + ->query() + ->leftJoin($documentsIssuesTable, "$documentsIssuesTable.issue_id = $tableIssue.id") + ->orWhere( + "$documentsIssuesTable.issue_id IS NOT NULL AND content.id = :id", + [':id' => $this->streamQuery->contentId] + ); + } } + + parent::afterApplyFilters(); } } diff --git a/views/document/view.php b/views/document/view.php index de62ff5..7f26d00 100644 --- a/views/document/view.php +++ b/views/document/view.php @@ -3,6 +3,7 @@ * @author Evgeniy Tkachenko */ +use humhub\modules\content\widgets\richtext\RichText; use tracker\models\Document; use tracker\models\Link; use tracker\Module; @@ -67,7 +68,7 @@ title) ?> description) : ?>
- $model->description, ]) ?>
diff --git a/views/issue/__item_index.php b/views/issue/__item_index.php index 863a367..dc56925 100644 --- a/views/issue/__item_index.php +++ b/views/issue/__item_index.php @@ -4,7 +4,6 @@ */ use humhub\libs\Html; -use humhub\widgets\RichText; use tracker\widgets\DeadlineIssueWidget; use tracker\widgets\PriorityIssueWidget; use tracker\widgets\StatusIssueWidget; @@ -46,7 +45,7 @@ ['class' => 'mark'] ) ?> - 150, 'minimal' => true, 'text' => $issue->description,]) ?> + 150, 'minimal' => true, 'text' => $issue->description,]) ?>