From cb6349b88cc2a289b4523d955dc3c32eb4f051be Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Apr 2015 09:40:12 -0700 Subject: [PATCH] Implement a "!projects" mail command Summary: Ref T7199. Implements `!projects` for all objects which implement `PhabricatorProjectInterface`. Test Plan: Added projects to a task via email. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7199 Differential Revision: https://secure.phabricator.com/D12246 --- src/__phutil_library_map__.php | 2 + .../ProjectAddProjectsEmailCommand.php | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/applications/project/command/ProjectAddProjectsEmailCommand.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 116886402e..f924623cb0 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3025,6 +3025,7 @@ phutil_register_library_map(array( 'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php', 'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php', 'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php', + 'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php', 'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php', 'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php', 'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php', @@ -6517,6 +6518,7 @@ phutil_register_library_map(array( 'PonderVoteSaveController' => 'PonderController', 'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType', 'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType', + 'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand', 'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability', 'ProjectConduitAPIMethod' => 'ConduitAPIMethod', 'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod', diff --git a/src/applications/project/command/ProjectAddProjectsEmailCommand.php b/src/applications/project/command/ProjectAddProjectsEmailCommand.php new file mode 100644 index 0000000000..dc69b2d208 --- /dev/null +++ b/src/applications/project/command/ProjectAddProjectsEmailCommand.php @@ -0,0 +1,70 @@ +setViewer($viewer) + ->setAllowedTypes( + array( + PhabricatorProjectProjectPHIDType::TYPECONST, + )) + ->setObjectList(implode(' ', $argv)) + ->setAllowPartialResults(true) + ->execute(); + + $xactions = array(); + + $type_project = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; + $xactions[] = $object->getApplicationTransactionTemplate() + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue('edge:type', $type_project) + ->setNewValue( + array( + '+' => array_fuse($project_phids), + )); + + return $xactions; + } + +}