diff --git a/resources/sql/autopatches/20150702.spaces.1.slowvote.sql b/resources/sql/autopatches/20150702.spaces.1.slowvote.sql new file mode 100644 index 0000000000..54b7f90003 --- /dev/null +++ b/resources/sql/autopatches/20150702.spaces.1.slowvote.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_slowvote.slowvote_poll +ADD spacePHID varbinary(64); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6e1f73ca88..144c1e0152 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -6606,6 +6606,7 @@ phutil_register_library_map(array( 'PhabricatorTokenReceiverInterface', 'PhabricatorProjectInterface', 'PhabricatorDestructibleInterface', + 'PhabricatorSpacesInterface', ), 'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController', 'PhabricatorSlowvotePollPHIDType' => 'PhabricatorPHIDType', diff --git a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php index 7374ea6468..44d9cec792 100644 --- a/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php +++ b/src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php @@ -50,6 +50,7 @@ final class PhabricatorSlowvoteEditController $v_description = $poll->getDescription(); $v_responses = $poll->getResponseVisibility(); $v_shuffle = $poll->getShuffle(); + $v_space = $poll->getSpacePHID(); $responses = $request->getArr('response'); if ($request->isFormPost()) { @@ -60,6 +61,8 @@ final class PhabricatorSlowvoteEditController $v_view_policy = $request->getStr('viewPolicy'); $v_projects = $request->getArr('projects'); + $v_space = $request->getStr('spacePHID'); + if ($is_new) { $poll->setMethod($request->getInt('method')); } @@ -104,6 +107,10 @@ final class PhabricatorSlowvoteEditController ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) ->setNewValue($v_view_policy); + $xactions[] = id(clone $template) + ->setTransactionType(PhabricatorTransactions::TYPE_SPACE) + ->setNewValue($v_space); + if (empty($errors)) { $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $xactions[] = id(new PhabricatorSlowvoteTransaction()) @@ -250,7 +257,8 @@ final class PhabricatorSlowvoteEditController ->setName('viewPolicy') ->setPolicyObject($poll) ->setPolicies($policies) - ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) + ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) + ->setSpacePHID($v_space)) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($button) diff --git a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php index 90c9686859..dc4bff410d 100644 --- a/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php +++ b/src/applications/slowvote/query/PhabricatorSlowvoteSearchEngine.php @@ -147,6 +147,8 @@ final class PhabricatorSlowvoteSearchEngine } $item = id(new PHUIObjectItemView()) + ->setUser($viewer) + ->setObject($poll) ->setObjectName('V'.$poll->getID()) ->setHeader($poll->getQuestion()) ->setHref('/V'.$poll->getID()) diff --git a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php index bf0ecaaa96..b1cd8c6c01 100644 --- a/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php +++ b/src/applications/slowvote/storage/PhabricatorSlowvotePoll.php @@ -8,7 +8,8 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO PhabricatorFlaggableInterface, PhabricatorTokenReceiverInterface, PhabricatorProjectInterface, - PhabricatorDestructibleInterface { + PhabricatorDestructibleInterface, + PhabricatorSpacesInterface { const RESPONSES_VISIBLE = 0; const RESPONSES_VOTERS = 1; @@ -25,6 +26,7 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO protected $method; protected $viewPolicy; protected $isClosed = 0; + protected $spacePHID; private $options = self::ATTACHABLE; private $choices = self::ATTACHABLE; @@ -41,7 +43,8 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO return id(new PhabricatorSlowvotePoll()) ->setAuthorPHID($actor->getPHID()) - ->setViewPolicy($view_policy); + ->setViewPolicy($view_policy) + ->setSpacePHID($actor->getDefaultSpacePHID()); } protected function getConfiguration() { @@ -201,4 +204,10 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO $this->saveTransaction(); } + /* -( PhabricatorSpacesInterface )--------------------------------------- */ + + public function getSpacePHID() { + return $this->spacePHID; + } + }