mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 13:52:40 +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',
|
||||
'PhluxViewController' => 'applications/phlux/controller/PhluxViewController.php',
|
||||
'PholioActionMenuEventListener' => 'applications/pholio/event/PholioActionMenuEventListener.php',
|
||||
'PholioCapabilityDefaultView' => 'applications/pholio/capability/PholioCapabilityDefaultView.php',
|
||||
'PholioConstants' => 'applications/pholio/constants/PholioConstants.php',
|
||||
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
||||
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
||||
|
@ -4938,6 +4939,7 @@ phutil_register_library_map(array(
|
|||
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhluxViewController' => 'PhluxController',
|
||||
'PholioActionMenuEventListener' => 'PhabricatorEventListener',
|
||||
'PholioCapabilityDefaultView' => 'PhabricatorPolicyCapability',
|
||||
'PholioController' => 'PhabricatorController',
|
||||
'PholioDAO' => 'PhabricatorLiskDAO',
|
||||
'PholioImage' =>
|
||||
|
|
|
@ -82,4 +82,11 @@ final class PhabricatorApplicationPholio extends PhabricatorApplication {
|
|||
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');
|
||||
$mock_images = mpull($mock_images, null, 'getFilePHID');
|
||||
} else {
|
||||
$mock = id(new PholioMock())
|
||||
->setAuthorPHID($user->getPHID())
|
||||
->attachImages(array())
|
||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER);
|
||||
$mock = PholioMock::initializeNewMock($user);
|
||||
|
||||
$title = pht('Create Mock');
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMock extends PholioDAO
|
||||
implements
|
||||
PhabricatorMarkupInterface,
|
||||
|
@ -28,6 +25,20 @@ final class PholioMock extends PholioDAO
|
|||
private $coverFile = 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() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
|
|
Loading…
Reference in a new issue