1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +01:00

Implement PhabricatorProjectInterface in Paste

Summary: Ref T2628. Implements PhabricatorProjectInterface (D9340) in Paste.

Test Plan: See screenshots.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2628

Differential Revision: https://secure.phabricator.com/D9341
This commit is contained in:
epriestley 2014-06-03 17:22:09 -07:00
parent 4cda3e5811
commit 4b9765b896
4 changed files with 36 additions and 1 deletions

View file

@ -4663,6 +4663,7 @@ phutil_register_library_map(array(
2 => 'PhabricatorTokenReceiverInterface',
3 => 'PhabricatorFlaggableInterface',
4 => 'PhabricatorPolicyInterface',
5 => 'PhabricatorProjectInterface',
),
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',

View file

@ -75,6 +75,15 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
}
$v_policy = $paste->getViewPolicy();
if ($is_create) {
$v_projects = array();
} else {
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$paste->getPHID(),
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
$v_projects = array_reverse($v_projects);
}
if ($request->isFormPost()) {
$xactions = array();
@ -89,6 +98,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
$v_title = $request->getStr('title');
$v_language = $request->getStr('language');
$v_policy = $request->getStr('can_view');
$v_projects = $request->getArr('projects');
// NOTE: The author is the only editor and can always view the paste,
// so it's impossible for them to choose an invalid policy.
@ -114,6 +124,13 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
$xactions[] = id(new PhabricatorPasteTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($v_policy);
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
$xactions[] = id(new PhabricatorPasteTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $proj_edge_type)
->setNewValue(array('=' => array_fuse($v_projects)));
$editor = id(new PhabricatorPasteEditor())
->setActor($user)
->setContentSourceFromRequest($request)
@ -161,6 +178,20 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
->setPolicies($policies)
->setName('can_view'));
if ($v_projects) {
$project_handles = $this->loadViewerHandles($v_projects);
} else {
$project_handles = array();
}
$form->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
->setName('projects')
->setValue($project_handles)
->setDatasource('/typeahead/common/projects/'));
$form
->appendChild(
id(new AphrontFormTextAreaControl())

View file

@ -77,6 +77,7 @@ final class PhabricatorPasteEditor
return;
case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
case PhabricatorTransactions::TYPE_EDGE:
return;
}
@ -94,6 +95,7 @@ final class PhabricatorPasteEditor
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_COMMENT:
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
case PhabricatorTransactions::TYPE_EDGE:
return;
}

View file

@ -5,7 +5,8 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorFlaggableInterface,
PhabricatorPolicyInterface {
PhabricatorPolicyInterface,
PhabricatorProjectInterface {
protected $title;
protected $authorPHID;