Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15532430
D8110.id18342.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.id18342.diff
View Options
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
@@ -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',
@@ -3369,6 +3371,8 @@
'JavelinViewExample' => 'PhabricatorUIExample',
'JavelinViewExampleServerView' => 'AphrontView',
'LeaseHostBuildStepImplementation' => 'BuildStepImplementation',
+ 'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability',
+ 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability',
'LegalpadController' => 'PhabricatorController',
'LegalpadDAO' => 'PhabricatorLiskDAO',
'LegalpadDocument' =>
diff --git a/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php b/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
--- a/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
+++ b/src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
@@ -51,4 +51,13 @@
));
}
+ protected function getCustomCapabilities() {
+ return array(
+ LegalpadCapabilityDefaultView::CAPABILITY => array(
+ ),
+ LegalpadCapabilityDefaultEdit::CAPABILITY => array(
+ ),
+ );
+ }
+
}
diff --git a/src/applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php b/src/applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php
new file mode 100644
--- /dev/null
+++ b/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');
+ }
+
+}
diff --git a/src/applications/legalpad/capability/LegalpadCapabilityDefaultView.php b/src/applications/legalpad/capability/LegalpadCapabilityDefaultView.php
new file mode 100644
--- /dev/null
+++ b/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;
+ }
+
+}
diff --git a/src/applications/legalpad/controller/LegalpadDocumentEditController.php b/src/applications/legalpad/controller/LegalpadDocumentEditController.php
--- a/src/applications/legalpad/controller/LegalpadDocumentEditController.php
+++ b/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);
diff --git a/src/applications/legalpad/storage/LegalpadDocument.php b/src/applications/legalpad/storage/LegalpadDocument.php
--- a/src/applications/legalpad/storage/LegalpadDocument.php
+++ b/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, Apr 24, 3:52 PM (2 d, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7741281
Default Alt Text
D8110.id18342.diff (5 KB)
Attached To
Mode
D8110: Allow configuration of default document policies for Legalpad
Attached
Detach File
Event Timeline
Log In to Comment