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 @@ +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 @@ 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,