@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.

Allow configuration of default document policies for Legalpad

Summary: Ref T3116. User request / generally modern feature.

Test Plan: Set defaults to whacky projects and created a new document; it defaulted appropriately.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran, allan.laal

Maniphest Tasks: T3116

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

+69 -11
+4
src/__phutil_library_map__.php
··· 828 828 'JavelinViewExample' => 'applications/uiexample/examples/JavelinViewExample.php', 829 829 'JavelinViewExampleServerView' => 'applications/uiexample/examples/JavelinViewExampleServerView.php', 830 830 'LeaseHostBuildStepImplementation' => 'applications/harbormaster/step/LeaseHostBuildStepImplementation.php', 831 + 'LegalpadCapabilityDefaultEdit' => 'applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php', 832 + 'LegalpadCapabilityDefaultView' => 'applications/legalpad/capability/LegalpadCapabilityDefaultView.php', 831 833 'LegalpadConstants' => 'applications/legalpad/constants/LegalpadConstants.php', 832 834 'LegalpadController' => 'applications/legalpad/controller/LegalpadController.php', 833 835 'LegalpadDAO' => 'applications/legalpad/storage/LegalpadDAO.php', ··· 3382 3384 'JavelinViewExample' => 'PhabricatorUIExample', 3383 3385 'JavelinViewExampleServerView' => 'AphrontView', 3384 3386 'LeaseHostBuildStepImplementation' => 'BuildStepImplementation', 3387 + 'LegalpadCapabilityDefaultEdit' => 'PhabricatorPolicyCapability', 3388 + 'LegalpadCapabilityDefaultView' => 'PhabricatorPolicyCapability', 3385 3389 'LegalpadController' => 'PhabricatorController', 3386 3390 'LegalpadDAO' => 'PhabricatorLiskDAO', 3387 3391 'LegalpadDocument' =>
+9
src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
··· 51 51 )); 52 52 } 53 53 54 + protected function getCustomCapabilities() { 55 + return array( 56 + LegalpadCapabilityDefaultView::CAPABILITY => array( 57 + ), 58 + LegalpadCapabilityDefaultEdit::CAPABILITY => array( 59 + ), 60 + ); 61 + } 62 + 54 63 }
+16
src/applications/legalpad/capability/LegalpadCapabilityDefaultEdit.php
··· 1 + <?php 2 + 3 + final class LegalpadCapabilityDefaultEdit 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'legalpad.default.edit'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Default Edit Policy'); 14 + } 15 + 16 + }
+20
src/applications/legalpad/capability/LegalpadCapabilityDefaultView.php
··· 1 + <?php 2 + 3 + final class LegalpadCapabilityDefaultView 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'legalpad.default.view'; 7 + 8 + public function getCapabilityKey() { 9 + return self::CAPABILITY; 10 + } 11 + 12 + public function getCapabilityName() { 13 + return pht('Default View Policy'); 14 + } 15 + 16 + public function shouldAllowPublicPolicySetting() { 17 + return true; 18 + } 19 + 20 + }
+1 -8
src/applications/legalpad/controller/LegalpadDocumentEditController.php
··· 18 18 if (!$this->id) { 19 19 $is_create = true; 20 20 21 - $document = id(new LegalpadDocument()) 22 - ->setVersions(0) 23 - ->setCreatorPHID($user->getPHID()) 24 - ->setContributorCount(0) 25 - ->setRecentContributorPHIDs(array()) 26 - ->attachSignatures(array()) 27 - ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 28 - ->setEditPolicy(PhabricatorPolicies::POLICY_USER); 21 + $document = LegalpadDocument::initializeNewDocument($user); 29 22 $body = id(new LegalpadDocumentBody()) 30 23 ->setCreatorPHID($user->getPHID()); 31 24 $document->attachDocumentBody($body);
+19 -3
src/applications/legalpad/storage/LegalpadDocument.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group legalpad 5 - */ 6 3 final class LegalpadDocument extends LegalpadDAO 7 4 implements 8 5 PhabricatorPolicyInterface, ··· 22 19 private $documentBody = self::ATTACHABLE; 23 20 private $contributors = self::ATTACHABLE; 24 21 private $signatures = self::ATTACHABLE; 22 + 23 + public static function initializeNewDocument(PhabricatorUser $actor) { 24 + $app = id(new PhabricatorApplicationQuery()) 25 + ->setViewer($actor) 26 + ->withClasses(array('PhabricatorApplicationLegalpad')) 27 + ->executeOne(); 28 + 29 + $view_policy = $app->getPolicy(LegalpadCapabilityDefaultView::CAPABILITY); 30 + $edit_policy = $app->getPolicy(LegalpadCapabilityDefaultEdit::CAPABILITY); 31 + 32 + return id(new LegalpadDocument()) 33 + ->setVersions(0) 34 + ->setCreatorPHID($actor->getPHID()) 35 + ->setContributorCount(0) 36 + ->setRecentContributorPHIDs(array()) 37 + ->attachSignatures(array()) 38 + ->setViewPolicy($view_policy) 39 + ->setEditPolicy($edit_policy); 40 + } 25 41 26 42 public function getConfiguration() { 27 43 return array(