@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add a "Can Create Documents" permission for Legalpad

Summary: Ref T3116. Installs might reasonably want to restrict creation of these documents to actual lawyers or something.

Test Plan: Adjusted policy, tried to create document, set it back, created a document.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T3116

Differential Revision: https://secure.phabricator.com/D9778

+41 -4
+2
src/__phutil_library_map__.php
··· 854 854 'JavelinUIExample' => 'applications/uiexample/examples/JavelinUIExample.php', 855 855 'JavelinViewExample' => 'applications/uiexample/examples/JavelinViewExample.php', 856 856 'JavelinViewExampleServerView' => 'applications/uiexample/examples/JavelinViewExampleServerView.php', 857 + 'LegalpadCapabilityCreateDocuments' => 'applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php', 857 858 'LegalpadCapabilityDefaultEdit' => 'applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php', 858 859 'LegalpadCapabilityDefaultView' => 'applications/legalpad/capability/LegalpadCapabilityDefaultView.php', 859 860 'LegalpadConstants' => 'applications/legalpad/constants/LegalpadConstants.php', ··· 3603 3604 'JavelinUIExample' => 'PhabricatorUIExample', 3604 3605 'JavelinViewExample' => 'PhabricatorUIExample', 3605 3606 'JavelinViewExampleServerView' => 'AphrontView', 3607 + 'LegalpadCapabilityCreateDocuments' => 'PhabricatorPolicyCapability', 3606 3608 'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 3607 3609 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability', 3608 3610 'LegalpadController' => 'PhabricatorController',
+2
src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
··· 69 69 70 70 protected function getCustomCapabilities() { 71 71 return array( 72 + LegalpadCapabilityCreateDocuments::CAPABILITY => array( 73 + ), 72 74 LegalpadCapabilityDefaultView::CAPABILITY => array( 73 75 ), 74 76 LegalpadCapabilityDefaultEdit::CAPABILITY => array(
+20
src/applications/legalpad/capability/LegalpadCapabilityCreateDocuments.php
··· 1 + <?php 2 + 3 + final class LegalpadCapabilityCreateDocuments 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'legalpad.create'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Can Create Documents'); 14 + } 15 + 16 + public function describeCapabilityRejection() { 17 + return pht('You do not have permission to create new documents.'); 18 + } 19 + 20 + }
+7 -3
src/applications/legalpad/controller/LegalpadDocumentEditController.php
··· 18 18 if (!$this->id) { 19 19 $is_create = true; 20 20 21 + $this->requireApplicationCapability( 22 + LegalpadCapabilityCreateDocuments::CAPABILITY); 23 + 21 24 $document = LegalpadDocument::initializeNewDocument($user); 22 25 $body = id(new LegalpadDocumentBody()) 23 26 ->setCreatorPHID($user->getPHID()); ··· 145 148 $submit = new AphrontFormSubmitControl(); 146 149 if ($is_create) { 147 150 $submit->setValue(pht('Create Document')); 151 + $submit->addCancelButton($this->getApplicationURI()); 148 152 $title = pht('Create Document'); 149 153 $short = pht('Create'); 150 154 } else { 151 - $submit->setValue(pht('Update Document')); 155 + $submit->setValue(pht('Edit Document')); 152 156 $submit->addCancelButton( 153 157 $this->getApplicationURI('view/'.$document->getID())); 154 - $title = pht('Update Document'); 155 - $short = pht('Update'); 158 + $title = pht('Edit Document'); 159 + $short = pht('Edit'); 156 160 157 161 $crumbs->addTextCrumb( 158 162 $document->getMonogram(),
+7 -1
src/applications/legalpad/controller/LegalpadDocumentListController.php
··· 25 25 public function buildApplicationCrumbs() { 26 26 $crumbs = parent::buildApplicationCrumbs(); 27 27 28 + $can_create = $this->hasApplicationCapability( 29 + LegalpadCapabilityCreateDocuments::CAPABILITY); 30 + 28 31 $crumbs->addAction( 29 32 id(new PHUIListItemView()) 30 33 ->setName(pht('Create Document')) 31 34 ->setHref($this->getApplicationURI('create/')) 32 - ->setIcon('fa-plus-square')); 35 + ->setIcon('fa-plus-square') 36 + ->setDisabled(!$can_create) 37 + ->setWorkflow(!$can_create)); 38 + 33 39 34 40 return $crumbs; 35 41 }
+3
src/applications/legalpad/controller/LegalpadDocumentSignatureListController.php
··· 71 71 $crumbs->addTextCrumb( 72 72 $this->document->getMonogram(), 73 73 '/'.$this->document->getMonogram()); 74 + $crumbs->addTextCrumb( 75 + pht('Manage'), 76 + $this->getApplicationURI('view/'.$this->document->getID().'/')); 74 77 } else { 75 78 $crumbs->addTextCrumb( 76 79 pht('Signatures'),