Implementing Spaces in Countdown
Summary: Implements T8734 Test Plan: Verify that countdowns can have spaces associated with them. Verify that non-default spaces are displayed in the header of the countdowns in the result of the query. Reviewers: lpriestley, epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13634
This commit is contained in:
		 Paul Kassianik
					Paul Kassianik
				
			
				
					committed by
					
						 epriestley
						epriestley
					
				
			
			
				
	
			
			
			 epriestley
						epriestley
					
				
			
						parent
						
							184623a7c6
						
					
				
				
					commit
					ae281301ca
				
			| @@ -0,0 +1,2 @@ | |||||||
|  | ALTER TABLE {$NAMESPACE}_countdown.countdown | ||||||
|  | ADD spacePHID VARBINARY(64); | ||||||
| @@ -5496,6 +5496,7 @@ phutil_register_library_map(array( | |||||||
|     'PhabricatorCountdown' => array( |     'PhabricatorCountdown' => array( | ||||||
|       'PhabricatorCountdownDAO', |       'PhabricatorCountdownDAO', | ||||||
|       'PhabricatorPolicyInterface', |       'PhabricatorPolicyInterface', | ||||||
|  |       'PhabricatorSpacesInterface', | ||||||
|     ), |     ), | ||||||
|     'PhabricatorCountdownApplication' => 'PhabricatorApplication', |     'PhabricatorCountdownApplication' => 'PhabricatorApplication', | ||||||
|     'PhabricatorCountdownController' => 'PhabricatorController', |     'PhabricatorCountdownController' => 'PhabricatorController', | ||||||
|   | |||||||
| @@ -41,9 +41,11 @@ final class PhabricatorCountdownEditController | |||||||
|     $e_epoch = null; |     $e_epoch = null; | ||||||
|  |  | ||||||
|     $v_text = $countdown->getTitle(); |     $v_text = $countdown->getTitle(); | ||||||
|  |     $v_space = $countdown->getSpacePHID(); | ||||||
|  |  | ||||||
|     if ($request->isFormPost()) { |     if ($request->isFormPost()) { | ||||||
|       $v_text = $request->getStr('title'); |       $v_text = $request->getStr('title'); | ||||||
|  |       $v_space = $request->getStr('spacePHID'); | ||||||
|       $date_value = AphrontFormDateControlValue::newFromRequest( |       $date_value = AphrontFormDateControlValue::newFromRequest( | ||||||
|         $request, |         $request, | ||||||
|         'epoch'); |         'epoch'); | ||||||
| @@ -63,6 +65,7 @@ final class PhabricatorCountdownEditController | |||||||
|         $countdown->setTitle($v_text); |         $countdown->setTitle($v_text); | ||||||
|         $countdown->setEpoch($date_value->getEpoch()); |         $countdown->setEpoch($date_value->getEpoch()); | ||||||
|         $countdown->setViewPolicy($view_policy); |         $countdown->setViewPolicy($view_policy); | ||||||
|  |         $countdown->setSpacePHID($v_space); | ||||||
|         $countdown->save(); |         $countdown->save(); | ||||||
|         return id(new AphrontRedirectResponse()) |         return id(new AphrontRedirectResponse()) | ||||||
|           ->setURI('/countdown/'.$countdown->getID().'/'); |           ->setURI('/countdown/'.$countdown->getID().'/'); | ||||||
| @@ -109,6 +112,7 @@ final class PhabricatorCountdownEditController | |||||||
|           ->setName('viewPolicy') |           ->setName('viewPolicy') | ||||||
|           ->setPolicyObject($countdown) |           ->setPolicyObject($countdown) | ||||||
|           ->setPolicies($policies) |           ->setPolicies($policies) | ||||||
|  |           ->setSpacePHID($v_space) | ||||||
|           ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) |           ->setCapability(PhabricatorPolicyCapability::CAN_VIEW)) | ||||||
|       ->appendChild( |       ->appendChild( | ||||||
|         id(new AphrontFormSubmitControl()) |         id(new AphrontFormSubmitControl()) | ||||||
|   | |||||||
| @@ -117,6 +117,8 @@ final class PhabricatorCountdownSearchEngine | |||||||
|       $id = $countdown->getID(); |       $id = $countdown->getID(); | ||||||
|  |  | ||||||
|       $item = id(new PHUIObjectItemView()) |       $item = id(new PHUIObjectItemView()) | ||||||
|  |         ->setUser($viewer) | ||||||
|  |         ->setObject($countdown) | ||||||
|         ->setObjectName("C{$id}") |         ->setObjectName("C{$id}") | ||||||
|         ->setHeader($countdown->getTitle()) |         ->setHeader($countdown->getTitle()) | ||||||
|         ->setHref($this->getApplicationURI("{$id}/")) |         ->setHref($this->getApplicationURI("{$id}/")) | ||||||
|   | |||||||
| @@ -2,13 +2,16 @@ | |||||||
|  |  | ||||||
| final class PhabricatorCountdown | final class PhabricatorCountdown | ||||||
|   extends PhabricatorCountdownDAO |   extends PhabricatorCountdownDAO | ||||||
|   implements PhabricatorPolicyInterface { |   implements PhabricatorPolicyInterface, | ||||||
|  |   PhabricatorSpacesInterface { | ||||||
|  |  | ||||||
|   protected $title; |   protected $title; | ||||||
|   protected $authorPHID; |   protected $authorPHID; | ||||||
|   protected $epoch; |   protected $epoch; | ||||||
|   protected $viewPolicy; |   protected $viewPolicy; | ||||||
|  |  | ||||||
|  |   protected $spacePHID; | ||||||
|  |  | ||||||
|   public static function initializeNewCountdown(PhabricatorUser $actor) { |   public static function initializeNewCountdown(PhabricatorUser $actor) { | ||||||
|     $app = id(new PhabricatorApplicationQuery()) |     $app = id(new PhabricatorApplicationQuery()) | ||||||
|       ->setViewer($actor) |       ->setViewer($actor) | ||||||
| @@ -21,7 +24,8 @@ final class PhabricatorCountdown | |||||||
|     return id(new PhabricatorCountdown()) |     return id(new PhabricatorCountdown()) | ||||||
|       ->setAuthorPHID($actor->getPHID()) |       ->setAuthorPHID($actor->getPHID()) | ||||||
|       ->setViewPolicy($view_policy) |       ->setViewPolicy($view_policy) | ||||||
|       ->setEpoch(PhabricatorTime::getNow()); |       ->setEpoch(PhabricatorTime::getNow()) | ||||||
|  |       ->setSpacePHID($actor->getDefaultSpacePHID()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   protected function getConfiguration() { |   protected function getConfiguration() { | ||||||
| @@ -66,4 +70,10 @@ final class PhabricatorCountdown | |||||||
|     return pht('The author of a countdown can always view and edit it.'); |     return pht('The author of a countdown can always view and edit it.'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | /* -( PhabricatorSpacesInterface )------------------------------------------- */ | ||||||
|  |  | ||||||
|  |   public function getSpacePHID() { | ||||||
|  |     return $this->spacePHID; | ||||||
|  |   } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user