From 177185656236f79b24c5588c9f17dccff3e62b5f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Thu, 6 Apr 2023 18:24:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=B2=E7=A4=BA=E6=9D=BF=E3=81=A7?= =?UTF-8?q?=E3=80=81=E5=85=AC=E9=96=8B=E6=A8=A9=E9=99=90=E3=81=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=83=A6=E3=83=BC=E3=82=B6=E8=BF=94=E4=BF=A1=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=A8=E3=80=81=E8=A1=A8=E7=A4=BA=E3=83=BB=E7=B7=A8?= =?UTF-8?q?=E9=9B=86=E3=83=BB=E5=89=8A=E9=99=A4=E3=81=8C=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=81=AA=E3=81=8F=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.com/resea?= =?UTF-8?q?rchmap/RmNetCommons3/issues/2806?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/WorkflowBehavior.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Model/Behavior/WorkflowBehavior.php b/Model/Behavior/WorkflowBehavior.php index 94d1640..ac32061 100644 --- a/Model/Behavior/WorkflowBehavior.php +++ b/Model/Behavior/WorkflowBehavior.php @@ -227,16 +227,23 @@ private function __hasSaveField(Model $model, $needle) { * * @param Model $model Model using this behavior * @param array $conditions Model::find conditions default value + * @param bool $useCommentCreatable コメントの作成権限でもチェックするかどうか * @return array Conditions data * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function getWorkflowConditions(Model $model, $conditions = array()) { + public function getWorkflowConditions( + Model $model, + $conditions = array(), + $useCommentCreatable = false + ) { if (Current::permission('content_editable')) { $activeConditions = array(); $latestConditons = array( $model->alias . '.is_latest' => true, ); - } elseif (Current::permission('content_creatable')) { + } elseif (Current::permission('content_creatable') || + $useCommentCreatable && Current::permission('content_comment_creatable')) { $activeConditions = array( $model->alias . '.is_active' => true, $model->alias . '.created_user !=' => Current::read('User.id'), @@ -318,12 +325,19 @@ public function getWorkflowConditions(Model $model, $conditions = array()) { * @param Model $model Model using this behavior * @param string $type Type of find operation (all / first / count / neighbors / list / threaded) * @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks) + * @param bool $useCommentCreatable コメントの作成権限でもチェックするかどうか * @return array Conditions data + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) */ - public function getWorkflowContents(Model $model, $type, $query = array()) { + public function getWorkflowContents( + Model $model, + $type, + $query = array(), + $useCommentCreatable = false + ) { $query = Hash::merge(array( 'recursive' => -1, - 'conditions' => $this->getWorkflowConditions($model) + 'conditions' => $this->getWorkflowConditions($model, [], $useCommentCreatable) ), $query); return $model->find($type, $query); @@ -384,7 +398,8 @@ public function canEditWorkflowContent(Model $model, $data) { * @return bool true:削除可、false:削除不可 */ public function canDeleteWorkflowContent(Model $model, $data) { - if (! $this->canEditWorkflowContent($model, $data)) { + //Model側で継承している場合、そのcanEditWorkflowContentが実行されるように、$thisではなく、$modelで呼び出す。 + if (! $model->canEditWorkflowContent($data)) { return false; } if (Current::permission('content_publishable')) {