mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Add a defualt view policy for Pholio
Summary: Similar to D8110, but for Pholio. Also an IRC user request. Test Plan: Set setting to something unusual, created a new mock. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D8111
This commit is contained in:
parent
088e98a30e
commit
99ab11e97c
5 changed files with 44 additions and 7 deletions
|
@ -2197,6 +2197,7 @@ phutil_register_library_map(array(
|
||||||
'PhluxVariableQuery' => 'applications/phlux/query/PhluxVariableQuery.php',
|
'PhluxVariableQuery' => 'applications/phlux/query/PhluxVariableQuery.php',
|
||||||
'PhluxViewController' => 'applications/phlux/controller/PhluxViewController.php',
|
'PhluxViewController' => 'applications/phlux/controller/PhluxViewController.php',
|
||||||
'PholioActionMenuEventListener' => 'applications/pholio/event/PholioActionMenuEventListener.php',
|
'PholioActionMenuEventListener' => 'applications/pholio/event/PholioActionMenuEventListener.php',
|
||||||
|
'PholioCapabilityDefaultView' => 'applications/pholio/capability/PholioCapabilityDefaultView.php',
|
||||||
'PholioConstants' => 'applications/pholio/constants/PholioConstants.php',
|
'PholioConstants' => 'applications/pholio/constants/PholioConstants.php',
|
||||||
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
||||||
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
||||||
|
@ -4938,6 +4939,7 @@ phutil_register_library_map(array(
|
||||||
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhluxViewController' => 'PhluxController',
|
'PhluxViewController' => 'PhluxController',
|
||||||
'PholioActionMenuEventListener' => 'PhabricatorEventListener',
|
'PholioActionMenuEventListener' => 'PhabricatorEventListener',
|
||||||
|
'PholioCapabilityDefaultView' => 'PhabricatorPolicyCapability',
|
||||||
'PholioController' => 'PhabricatorController',
|
'PholioController' => 'PhabricatorController',
|
||||||
'PholioDAO' => 'PhabricatorLiskDAO',
|
'PholioDAO' => 'PhabricatorLiskDAO',
|
||||||
'PholioImage' =>
|
'PholioImage' =>
|
||||||
|
|
|
@ -82,4 +82,11 @@ final class PhabricatorApplicationPholio extends PhabricatorApplication {
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getCustomCapabilities() {
|
||||||
|
return array(
|
||||||
|
PholioCapabilityDefaultView::CAPABILITY => array(
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PholioCapabilityDefaultView
|
||||||
|
extends PhabricatorPolicyCapability {
|
||||||
|
|
||||||
|
const CAPABILITY = 'pholio.default.view';
|
||||||
|
|
||||||
|
public function getCapabilityKey() {
|
||||||
|
return self::CAPABILITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCapabilityName() {
|
||||||
|
return pht('Default View Policy');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldAllowPublicPolicySetting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -38,10 +38,7 @@ final class PholioMockEditController extends PholioController {
|
||||||
$files = mpull($mock_images, 'getFile');
|
$files = mpull($mock_images, 'getFile');
|
||||||
$mock_images = mpull($mock_images, null, 'getFilePHID');
|
$mock_images = mpull($mock_images, null, 'getFilePHID');
|
||||||
} else {
|
} else {
|
||||||
$mock = id(new PholioMock())
|
$mock = PholioMock::initializeNewMock($user);
|
||||||
->setAuthorPHID($user->getPHID())
|
|
||||||
->attachImages(array())
|
|
||||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER);
|
|
||||||
|
|
||||||
$title = pht('Create Mock');
|
$title = pht('Create Mock');
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
|
||||||
* @group pholio
|
|
||||||
*/
|
|
||||||
final class PholioMock extends PholioDAO
|
final class PholioMock extends PholioDAO
|
||||||
implements
|
implements
|
||||||
PhabricatorMarkupInterface,
|
PhabricatorMarkupInterface,
|
||||||
|
@ -28,6 +25,20 @@ final class PholioMock extends PholioDAO
|
||||||
private $coverFile = self::ATTACHABLE;
|
private $coverFile = self::ATTACHABLE;
|
||||||
private $tokenCount = self::ATTACHABLE;
|
private $tokenCount = self::ATTACHABLE;
|
||||||
|
|
||||||
|
public static function initializeNewMock(PhabricatorUser $actor) {
|
||||||
|
$app = id(new PhabricatorApplicationQuery())
|
||||||
|
->setViewer($actor)
|
||||||
|
->withClasses(array('PhabricatorApplicationPholio'))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
$view_policy = $app->getPolicy(PholioCapabilityDefaultView::CAPABILITY);
|
||||||
|
|
||||||
|
return id(new PholioMock())
|
||||||
|
->setAuthorPHID($actor->getPHID())
|
||||||
|
->attachImages(array())
|
||||||
|
->setViewPolicy($view_policy);
|
||||||
|
}
|
||||||
|
|
||||||
public function getConfiguration() {
|
public function getConfiguration() {
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_AUX_PHID => true,
|
self::CONFIG_AUX_PHID => true,
|
||||||
|
|
Loading…
Reference in a new issue