Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15413573
D8110.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8110.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -828,6 +828,8 @@
'JavelinViewExample' => 'applications/uiexample/examples/JavelinViewExample.php',
'JavelinViewExampleServerView' => 'applications/uiexample/examples/JavelinViewExampleServerView.php',
'LeaseHostBuildStepImplementation' => 'applications/harbormaster/step/LeaseHostBuildStepImplementation.php',
+ 'LegalpadCapabilityDefaultEdit' => 'applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php',
+ 'LegalpadCapabilityDefaultView' => 'applications/legalpad/capability/LegalpadCapabilityDefaultView.php',
'LegalpadConstants' => 'applications/legalpad/constants/LegalpadConstants.php',
'LegalpadController' => 'applications/legalpad/controller/LegalpadController.php',
'LegalpadDAO' => 'applications/legalpad/storage/LegalpadDAO.php',
@@ -3382,6 +3384,8 @@
'JavelinViewExample' => 'PhabricatorUIExample',
'JavelinViewExampleServerView' => 'AphrontView',
'LeaseHostBuildStepImplementation' => 'BuildStepImplementation',
+ 'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability',
+ 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability',
'LegalpadController' => 'PhabricatorController',
'LegalpadDAO' => 'PhabricatorLiskDAO',
'LegalpadDocument' =>
Index: src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
===================================================================
--- src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
+++ src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
@@ -51,4 +51,13 @@
));
}
+ protected function getCustomCapabilities() {
+ return array(
+ LegalpadCapabilityDefaultView::CAPABILITY => array(
+ ),
+ LegalpadCapabilityDefaultEdit::CAPABILITY => array(
+ ),
+ );
+ }
+
}
Index: src/applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php
===================================================================
--- /dev/null
+++ src/applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php
@@ -0,0 +1,16 @@
+<?php
+
+final class LegalpadCapabilityDefaultEdit
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'legalpad.default.edit';
+
+ public function getCapabilityKey() {
+ return self::CAPABILITY;
+ }
+
+ public function getCapabilityName() {
+ return pht('Default Edit Policy');
+ }
+
+}
Index: src/applications/legalpad/capability/LegalpadCapabilityDefaultView.php
===================================================================
--- /dev/null
+++ src/applications/legalpad/capability/LegalpadCapabilityDefaultView.php
@@ -0,0 +1,20 @@
+<?php
+
+final class LegalpadCapabilityDefaultView
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'legalpad.default.view';
+
+ public function getCapabilityKey() {
+ return self::CAPABILITY;
+ }
+
+ public function getCapabilityName() {
+ return pht('Default View Policy');
+ }
+
+ public function shouldAllowPublicPolicySetting() {
+ return true;
+ }
+
+}
Index: src/applications/legalpad/controller/LegalpadDocumentEditController.php
===================================================================
--- src/applications/legalpad/controller/LegalpadDocumentEditController.php
+++ src/applications/legalpad/controller/LegalpadDocumentEditController.php
@@ -18,14 +18,7 @@
if (!$this->id) {
$is_create = true;
- $document = id(new LegalpadDocument())
- ->setVersions(0)
- ->setCreatorPHID($user->getPHID())
- ->setContributorCount(0)
- ->setRecentContributorPHIDs(array())
- ->attachSignatures(array())
- ->setViewPolicy(PhabricatorPolicies::POLICY_USER)
- ->setEditPolicy(PhabricatorPolicies::POLICY_USER);
+ $document = LegalpadDocument::initializeNewDocument($user);
$body = id(new LegalpadDocumentBody())
->setCreatorPHID($user->getPHID());
$document->attachDocumentBody($body);
Index: src/applications/legalpad/storage/LegalpadDocument.php
===================================================================
--- src/applications/legalpad/storage/LegalpadDocument.php
+++ src/applications/legalpad/storage/LegalpadDocument.php
@@ -1,8 +1,5 @@
<?php
-/**
- * @group legalpad
- */
final class LegalpadDocument extends LegalpadDAO
implements
PhabricatorPolicyInterface,
@@ -23,6 +20,25 @@
private $contributors = self::ATTACHABLE;
private $signatures = self::ATTACHABLE;
+ public static function initializeNewDocument(PhabricatorUser $actor) {
+ $app = id(new PhabricatorApplicationQuery())
+ ->setViewer($actor)
+ ->withClasses(array('PhabricatorApplicationLegalpad'))
+ ->executeOne();
+
+ $view_policy = $app->getPolicy(LegalpadCapabilityDefaultView::CAPABILITY);
+ $edit_policy = $app->getPolicy(LegalpadCapabilityDefaultEdit::CAPABILITY);
+
+ return id(new LegalpadDocument())
+ ->setVersions(0)
+ ->setCreatorPHID($actor->getPHID())
+ ->setContributorCount(0)
+ ->setRecentContributorPHIDs(array())
+ ->attachSignatures(array())
+ ->setViewPolicy($view_policy)
+ ->setEditPolicy($edit_policy);
+ }
+
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 7:44 PM (7 h, 46 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704434
Default Alt Text
D8110.diff (5 KB)
Attached To
Mode
D8110: Allow configuration of default document policies for Legalpad
Attached
Detach File
Event Timeline
Log In to Comment