From b801ca8e6f7fe2acb369eaf115d6b82a05e91a99 Mon Sep 17 00:00:00 2001 From: Debarghya Das Date: Fri, 18 Jan 2013 17:53:52 -0800 Subject: [PATCH] Author Can Close Audit Option Summary: Fixes T2339 Test Plan: Close Audit button does not appear if audit.can-author-close-audit option is disabled Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2339 Differential Revision: https://secure.phabricator.com/D4525 --- conf/default.conf.php | 5 +++++ .../audit/editor/PhabricatorAuditCommentEditor.php | 4 ++++ .../config/PhabricatorDiffusionConfigOptions.php | 10 ++++++++++ .../diffusion/controller/DiffusionCommitController.php | 5 +++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/conf/default.conf.php b/conf/default.conf.php index 465e402492..1ccf8c2277 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -1338,4 +1338,9 @@ return array( // the $PATH environment variable, for when these binaries are in non-standard // locations. 'environment.append-paths' => array(), + +// -- Audit ---------------------------------------------------------- // + + // Controls whether or not task creator can Close Audits + 'audit.can-author-close-audit' => false, ); diff --git a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php index 9595fc6316..d64a48c8ca 100644 --- a/src/applications/audit/editor/PhabricatorAuditCommentEditor.php +++ b/src/applications/audit/editor/PhabricatorAuditCommentEditor.php @@ -109,6 +109,10 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor { $actor_is_author = ($actor->getPHID() == $commit->getAuthorPHID()); if ($action == PhabricatorAuditActionConstants::CLOSE) { + if (!PhabricatorEnv::getEnvConfig('audit.can-author-close-audit')) { + throw new Exception('Cannot Close Audit without enabling'. + 'audit.can-author-close-audit'); + } // "Close" means wipe out all the concerns. $concerned_status = PhabricatorAuditStatusConstants::CONCERNED; foreach ($requests as $request) { diff --git a/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php index 4b3805dbb1..d002498baa 100644 --- a/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php +++ b/src/applications/diffusion/config/PhabricatorDiffusionConfigOptions.php @@ -55,6 +55,16 @@ final class PhabricatorDiffusionConfigOptions ->setDescription(pht('Hard byte limit on including patches in email.')), $this->newOption('metamta.diffusion.time-limit', 'int', 60) ->setDescription(pht('Hard time limit on generating patches.')), + $this->newOption( + 'audit.can-author-close-audit', + 'bool', + false) + ->setBoolOptions( + array( + pht("Enable Closing Audits"), + pht("Disable Closing Audits"), + )) + ->setDescription(pht('Controls whether Author can Close Audits.')), ); } diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 854d9a04c4..1f81f013d7 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -748,8 +748,9 @@ final class DiffusionCommitController extends DiffusionController { $status_concern = PhabricatorAuditCommitStatusConstants::CONCERN_RAISED; $concern_raised = ($commit->getAuditStatus() == $status_concern); - - if ($user_is_author && $concern_raised) { + $can_close_option = PhabricatorEnv::getEnvConfig( + 'audit.can-author-close-audit'); + if ($can_close_option && $user_is_author && $concern_raised) { $actions[PhabricatorAuditActionConstants::CLOSE] = true; }