From 41899c8dc0bda7d7edd155aae11a3931faed203c Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 11 Apr 2023 23:07:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=81=AE=E3=81=BF=E6=89=BF=E8=AA=8D=E3=81=82=E3=82=8A=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AB=E3=80=81?= =?UTF-8?q?=E6=9C=AC=E4=BA=BA=E3=81=8C=E6=8A=95=E7=A8=BF=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88=E3=81=AB=E3=80=8C=E6=89=BF?= =?UTF-8?q?=E8=AA=8D=E3=80=8D=E3=83=9C=E3=82=BF=E3=83=B3=E3=81=8C=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=20https://github.com/researchmap/RmNetCommons3/issues?= =?UTF-8?q?/2806#issuecomment-1501429547?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/Elements/BbsArticles/comment_approving_link.ctp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/View/Elements/BbsArticles/comment_approving_link.ctp b/View/Elements/BbsArticles/comment_approving_link.ctp index d0c5572..1862099 100644 --- a/View/Elements/BbsArticles/comment_approving_link.ctp +++ b/View/Elements/BbsArticles/comment_approving_link.ctp @@ -10,7 +10,8 @@ */ ?> - + request->data = $bbsArticle; ?> NetCommonsForm->create('BbsArticle', array( 'div' => false, From daa3b8d8bb1fbde45a72caab141512953772a480 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 11 Apr 2023 23:09:08 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=B8=80=E5=BA=A6=E6=89=BF=E8=AA=8D?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=9F=E8=A8=98=E4=BA=8B=E3=82=92=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E3=81=97=E3=81=A6=E6=9C=AA=E6=89=BF=E8=AA=8D=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E3=81=A8=E3=80=81=E6=9C=AA=E6=89=BF=E8=AA=8D?= =?UTF-8?q?=E3=81=AE=E6=95=B0=E3=81=8C=E3=81=9A=E3=82=8C=E3=82=8B=E3=81=9F?= =?UTF-8?q?=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.com/researchmap/Rm?= =?UTF-8?q?NetCommons3/issues/2806#issuecomment-1501429547?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/BbsArticleBehavior.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Model/Behavior/BbsArticleBehavior.php b/Model/Behavior/BbsArticleBehavior.php index cbd53e2..2844c39 100644 --- a/Model/Behavior/BbsArticleBehavior.php +++ b/Model/Behavior/BbsArticleBehavior.php @@ -152,7 +152,7 @@ public function getChildrenArticleCounts(Model $model, $bbsKey, $bbsArticles, $a $query = array( 'recursive' => -1, - 'fields' => ['BbsArticleTree.root_id', 'COUNT(*) AS bbs_article_child_count'], + 'fields' => ['BbsArticleTree.root_id', 'BbsArticle.is_active'], 'conditions' => $model->getWorkflowConditions(array( 'BbsArticleTree.root_id' => $articleTreeIds, 'BbsArticleTree.bbs_key' => $bbsKey, @@ -165,22 +165,30 @@ public function getChildrenArticleCounts(Model $model, $bbsKey, $bbsArticles, $a 'conditions' => $model->belongsTo['BbsArticleTree']['conditions'], ] ], - 'group' => array('BbsArticleTree.root_id'), + //'group' => array('BbsArticleTree.root_id', 'BbsArticle.is_active'), ); $results = $model->find('all', $query); $counts = []; foreach ($results as $result) { - $counts[$result['BbsArticleTree']['root_id']] = $result[0]['bbs_article_child_count']; + $rootId = $result['BbsArticleTree']['root_id']; + $isActive = (int)$result['BbsArticle']['is_active']; + if (! isset($counts[$rootId])) { + $counts[$rootId] = [0 => 0, 1 => 0]; + } + $counts[$rootId][$isActive]++; } foreach ($bbsArticles as $i => $article) { if (isset($counts[$article['BbsArticleTree']['id']])) { - $count = $counts[$article['BbsArticleTree']['id']]; + $id = $article['BbsArticleTree']['id']; + $activeCount = $counts[$id][1]; + $latestCount = $counts[$id][0]; + $count = $activeCount + $latestCount; - $beforeCount = $count - $bbsArticles[$i]['BbsArticleTree']['bbs_article_child_count']; - $bbsArticles[$i]['BbsArticleTree']['approval_bbs_article_child_count'] = (string)$beforeCount; + $approveCount = $count - $activeCount; + $bbsArticles[$i]['BbsArticleTree']['approval_bbs_article_child_count'] = (string)$approveCount; - $bbsArticles[$i]['BbsArticleTree']['bbs_article_child_count'] = $count; + $bbsArticles[$i]['BbsArticleTree']['bbs_article_child_count'] = (string)$count; } }