1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

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 2015-07-15 10:17:51 -07:00 committed by epriestley
parent 184623a7c6
commit ae281301ca
5 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_countdown.countdown
ADD spacePHID VARBINARY(64);

View file

@ -5496,6 +5496,7 @@ phutil_register_library_map(array(
'PhabricatorCountdown' => array(
'PhabricatorCountdownDAO',
'PhabricatorPolicyInterface',
'PhabricatorSpacesInterface',
),
'PhabricatorCountdownApplication' => 'PhabricatorApplication',
'PhabricatorCountdownController' => 'PhabricatorController',

View file

@ -41,9 +41,11 @@ final class PhabricatorCountdownEditController
$e_epoch = null;
$v_text = $countdown->getTitle();
$v_space = $countdown->getSpacePHID();
if ($request->isFormPost()) {
$v_text = $request->getStr('title');
$v_space = $request->getStr('spacePHID');
$date_value = AphrontFormDateControlValue::newFromRequest(
$request,
'epoch');
@ -63,6 +65,7 @@ final class PhabricatorCountdownEditController
$countdown->setTitle($v_text);
$countdown->setEpoch($date_value->getEpoch());
$countdown->setViewPolicy($view_policy);
$countdown->setSpacePHID($v_space);
$countdown->save();
return id(new AphrontRedirectResponse())
->setURI('/countdown/'.$countdown->getID().'/');
@ -109,6 +112,7 @@ final class PhabricatorCountdownEditController
->setName('viewPolicy')
->setPolicyObject($countdown)
->setPolicies($policies)
->setSpacePHID($v_space)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW))
->appendChild(
id(new AphrontFormSubmitControl())

View file

@ -117,6 +117,8 @@ final class PhabricatorCountdownSearchEngine
$id = $countdown->getID();
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setObject($countdown)
->setObjectName("C{$id}")
->setHeader($countdown->getTitle())
->setHref($this->getApplicationURI("{$id}/"))

View file

@ -2,13 +2,16 @@
final class PhabricatorCountdown
extends PhabricatorCountdownDAO
implements PhabricatorPolicyInterface {
implements PhabricatorPolicyInterface,
PhabricatorSpacesInterface {
protected $title;
protected $authorPHID;
protected $epoch;
protected $viewPolicy;
protected $spacePHID;
public static function initializeNewCountdown(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
->setViewer($actor)
@ -21,7 +24,8 @@ final class PhabricatorCountdown
return id(new PhabricatorCountdown())
->setAuthorPHID($actor->getPHID())
->setViewPolicy($view_policy)
->setEpoch(PhabricatorTime::getNow());
->setEpoch(PhabricatorTime::getNow())
->setSpacePHID($actor->getDefaultSpacePHID());
}
protected function getConfiguration() {
@ -66,4 +70,10 @@ final class PhabricatorCountdown
return pht('The author of a countdown can always view and edit it.');
}
/* -( PhabricatorSpacesInterface )------------------------------------------- */
public function getSpacePHID() {
return $this->spacePHID;
}
}