Page MenuHomePhabricator

D8111.id18343.diff
No OneTemporary

D8111.id18343.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2182,6 +2182,7 @@
'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',
@@ -4896,6 +4897,7 @@
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhluxViewController' => 'PhluxController',
'PholioActionMenuEventListener' => 'PhabricatorEventListener',
+ 'PholioCapabilityDefaultView' => 'PhabricatorPolicyCapability',
'PholioController' => 'PhabricatorController',
'PholioDAO' => 'PhabricatorLiskDAO',
'PholioImage' =>
diff --git a/src/applications/pholio/application/PhabricatorApplicationPholio.php b/src/applications/pholio/application/PhabricatorApplicationPholio.php
--- a/src/applications/pholio/application/PhabricatorApplicationPholio.php
+++ b/src/applications/pholio/application/PhabricatorApplicationPholio.php
@@ -82,4 +82,11 @@
return $items;
}
+ protected function getCustomCapabilities() {
+ return array(
+ PholioCapabilityDefaultView::CAPABILITY => array(
+ ),
+ );
+ }
+
}
diff --git a/src/applications/pholio/capability/PholioCapabilityDefaultView.php b/src/applications/pholio/capability/PholioCapabilityDefaultView.php
new file mode 100644
--- /dev/null
+++ b/src/applications/pholio/capability/PholioCapabilityDefaultView.php
@@ -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;
+ }
+
+}
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -38,10 +38,7 @@
$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');
diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php
--- a/src/applications/pholio/storage/PholioMock.php
+++ b/src/applications/pholio/storage/PholioMock.php
@@ -1,8 +1,5 @@
<?php
-/**
- * @group pholio
- */
final class PholioMock extends PholioDAO
implements
PhabricatorMarkupInterface,
@@ -28,6 +25,20 @@
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,

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 6:23 AM (3 w, 11 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706369
Default Alt Text
D8111.id18343.diff (3 KB)

Event Timeline