Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13967724
D9778.id23480.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
D9778.id23480.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
@@ -854,6 +854,7 @@
'JavelinUIExample' => 'applications/uiexample/examples/JavelinUIExample.php',
'JavelinViewExample' => 'applications/uiexample/examples/JavelinViewExample.php',
'JavelinViewExampleServerView' => 'applications/uiexample/examples/JavelinViewExampleServerView.php',
+ 'LegalpadCapabilityCreateDocuments' => 'applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php',
'LegalpadCapabilityDefaultEdit' => 'applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php',
'LegalpadCapabilityDefaultView' => 'applications/legalpad/capability/LegalpadCapabilityDefaultView.php',
'LegalpadConstants' => 'applications/legalpad/constants/LegalpadConstants.php',
@@ -3603,6 +3604,7 @@
'JavelinUIExample' => 'PhabricatorUIExample',
'JavelinViewExample' => 'PhabricatorUIExample',
'JavelinViewExampleServerView' => 'AphrontView',
+ 'LegalpadCapabilityCreateDocuments' => 'PhabricatorPolicyCapability',
'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability',
'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability',
'LegalpadController' => 'PhabricatorController',
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
@@ -69,6 +69,8 @@
protected function getCustomCapabilities() {
return array(
+ LegalpadCapabilityCreateDocuments::CAPABILITY => array(
+ ),
LegalpadCapabilityDefaultView::CAPABILITY => array(
),
LegalpadCapabilityDefaultEdit::CAPABILITY => array(
diff --git a/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php b/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php
new file mode 100644
--- /dev/null
+++ b/src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php
@@ -0,0 +1,20 @@
+<?php
+
+final class LegalpadCapabilityCreateDocuments
+ extends PhabricatorPolicyCapability {
+
+ const CAPABILITY = 'legalpad.create';
+
+ public function getCapabilityKey() {
+ return self::CAPABILITY;
+ }
+
+ public function getCapabilityName() {
+ return pht('Can Create Documents');
+ }
+
+ public function describeCapabilityRejection() {
+ return pht('You do not have permission to create new documents.');
+ }
+
+}
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,6 +18,9 @@
if (!$this->id) {
$is_create = true;
+ $this->requireApplicationCapability(
+ LegalpadCapabilityCreateDocuments::CAPABILITY);
+
$document = LegalpadDocument::initializeNewDocument($user);
$body = id(new LegalpadDocumentBody())
->setCreatorPHID($user->getPHID());
@@ -145,14 +148,15 @@
$submit = new AphrontFormSubmitControl();
if ($is_create) {
$submit->setValue(pht('Create Document'));
+ $submit->addCancelButton($this->getApplicationURI());
$title = pht('Create Document');
$short = pht('Create');
} else {
- $submit->setValue(pht('Update Document'));
+ $submit->setValue(pht('Edit Document'));
$submit->addCancelButton(
$this->getApplicationURI('view/'.$document->getID()));
- $title = pht('Update Document');
- $short = pht('Update');
+ $title = pht('Edit Document');
+ $short = pht('Edit');
$crumbs->addTextCrumb(
$document->getMonogram(),
diff --git a/src/applications/legalpad/controller/LegalpadDocumentListController.php b/src/applications/legalpad/controller/LegalpadDocumentListController.php
--- a/src/applications/legalpad/controller/LegalpadDocumentListController.php
+++ b/src/applications/legalpad/controller/LegalpadDocumentListController.php
@@ -25,11 +25,17 @@
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
+ $can_create = $this->hasApplicationCapability(
+ LegalpadCapabilityCreateDocuments::CAPABILITY);
+
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Document'))
->setHref($this->getApplicationURI('create/'))
- ->setIcon('fa-plus-square'));
+ ->setIcon('fa-plus-square')
+ ->setDisabled(!$can_create)
+ ->setWorkflow(!$can_create));
+
return $crumbs;
}
diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php b/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php
--- a/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php
+++ b/src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php
@@ -71,6 +71,9 @@
$crumbs->addTextCrumb(
$this->document->getMonogram(),
'/'.$this->document->getMonogram());
+ $crumbs->addTextCrumb(
+ pht('Manage'),
+ $this->getApplicationURI('view/'.$this->document->getID().'/'));
} else {
$crumbs->addTextCrumb(
pht('Signatures'),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 17, 3:32 PM (3 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6722561
Default Alt Text
D9778.id23480.diff (5 KB)
Attached To
Mode
D9778: Add a "Can Create Documents" permission for Legalpad
Attached
Detach File
Event Timeline
Log In to Comment