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

Make view/sign page the primary Legalpad page

Summary:
- Makes the "legal document" page the main page.
- Links to the "manage" page.
- The "manage" operation now requires CAN_EDIT.
- Modernize some crumbs and such.

Test Plan: {F170213}

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

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

+71 -43
+2 -2
src/__phutil_library_map__.php
··· 863 863 'LegalpadDocumentEditController' => 'applications/legalpad/controller/LegalpadDocumentEditController.php', 864 864 'LegalpadDocumentEditor' => 'applications/legalpad/editor/LegalpadDocumentEditor.php', 865 865 'LegalpadDocumentListController' => 'applications/legalpad/controller/LegalpadDocumentListController.php', 866 + 'LegalpadDocumentManageController' => 'applications/legalpad/controller/LegalpadDocumentManageController.php', 866 867 'LegalpadDocumentQuery' => 'applications/legalpad/query/LegalpadDocumentQuery.php', 867 868 'LegalpadDocumentRemarkupRule' => 'applications/legalpad/remarkup/LegalpadDocumentRemarkupRule.php', 868 869 'LegalpadDocumentSearchEngine' => 'applications/legalpad/query/LegalpadDocumentSearchEngine.php', ··· 871 872 'LegalpadDocumentSignatureListController' => 'applications/legalpad/controller/LegalpadDocumentSignatureListController.php', 872 873 'LegalpadDocumentSignatureQuery' => 'applications/legalpad/query/LegalpadDocumentSignatureQuery.php', 873 874 'LegalpadDocumentSignatureVerificationController' => 'applications/legalpad/controller/LegalpadDocumentSignatureVerificationController.php', 874 - 'LegalpadDocumentViewController' => 'applications/legalpad/controller/LegalpadDocumentViewController.php', 875 875 'LegalpadMockMailReceiver' => 'applications/legalpad/mail/LegalpadMockMailReceiver.php', 876 876 'LegalpadReplyHandler' => 'applications/legalpad/mail/LegalpadReplyHandler.php', 877 877 'LegalpadTransaction' => 'applications/legalpad/storage/LegalpadTransaction.php', ··· 3616 3616 'LegalpadDocumentEditController' => 'LegalpadController', 3617 3617 'LegalpadDocumentEditor' => 'PhabricatorApplicationTransactionEditor', 3618 3618 'LegalpadDocumentListController' => 'LegalpadController', 3619 + 'LegalpadDocumentManageController' => 'LegalpadController', 3619 3620 'LegalpadDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3620 3621 'LegalpadDocumentRemarkupRule' => 'PhabricatorRemarkupRuleObject', 3621 3622 'LegalpadDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', ··· 3628 3629 'LegalpadDocumentSignatureListController' => 'LegalpadController', 3629 3630 'LegalpadDocumentSignatureQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3630 3631 'LegalpadDocumentSignatureVerificationController' => 'LegalpadController', 3631 - 'LegalpadDocumentViewController' => 'LegalpadController', 3632 3632 'LegalpadMockMailReceiver' => 'PhabricatorObjectMailReceiver', 3633 3633 'LegalpadReplyHandler' => 'PhabricatorMailReplyHandler', 3634 3634 'LegalpadTransaction' => 'PhabricatorApplicationTransaction',
+1 -1
src/applications/legalpad/application/PhabricatorApplicationLegalpad.php
··· 45 45 'create/' => 'LegalpadDocumentEditController', 46 46 'edit/(?P<id>\d+)/' => 'LegalpadDocumentEditController', 47 47 'comment/(?P<id>\d+)/' => 'LegalpadDocumentCommentController', 48 - 'view/(?P<id>\d+)/' => 'LegalpadDocumentViewController', 48 + 'view/(?P<id>\d+)/' => 'LegalpadDocumentManageController', 49 49 'verify/(?P<code>[^/]+)/' => 50 50 'LegalpadDocumentSignatureVerificationController', 51 51 'signatures/(?P<id>\d+)/' => 'LegalpadDocumentSignatureListController',
-12
src/applications/legalpad/controller/LegalpadController.php
··· 22 22 return $nav; 23 23 } 24 24 25 - public function buildApplicationCrumbs() { 26 - $crumbs = parent::buildApplicationCrumbs(); 27 - 28 - $crumbs->addAction( 29 - id(new PHUIListItemView()) 30 - ->setName(pht('Create Document')) 31 - ->setHref($this->getApplicationURI('create/')) 32 - ->setIcon('fa-plus-square')); 33 - 34 - return $crumbs; 35 - } 36 - 37 25 public function buildApplicationMenu() { 38 26 return $this->buildSideNav(true)->getMenu(); 39 27 }
+12
src/applications/legalpad/controller/LegalpadDocumentListController.php
··· 18 18 return $this->delegateToController($controller); 19 19 } 20 20 21 + public function buildApplicationCrumbs() { 22 + $crumbs = parent::buildApplicationCrumbs(); 23 + 24 + $crumbs->addAction( 25 + id(new PHUIListItemView()) 26 + ->setName(pht('Create Document')) 27 + ->setHref($this->getApplicationURI('create/')) 28 + ->setIcon('fa-plus-square')); 29 + 30 + return $crumbs; 31 + } 32 + 21 33 }
+38 -14
src/applications/legalpad/controller/LegalpadDocumentSignController.php
··· 14 14 15 15 public function processRequest() { 16 16 $request = $this->getRequest(); 17 - $user = $request->getUser(); 17 + $viewer = $request->getUser(); 18 18 19 19 $document = id(new LegalpadDocumentQuery()) 20 - ->setViewer($user) 20 + ->setViewer($viewer) 21 21 ->withIDs(array($this->id)) 22 22 ->needDocumentBodies(true) 23 23 ->executeOne(); ··· 29 29 $signer_phid = null; 30 30 $signature = null; 31 31 $signature_data = array(); 32 - if ($user->isLoggedIn()) { 33 - $signer_phid = $user->getPHID(); 32 + if ($viewer->isLoggedIn()) { 33 + $signer_phid = $viewer->getPHID(); 34 34 $signature_data = array( 35 - 'email' => $user->loadPrimaryEmailAddress()); 35 + 'email' => $viewer->loadPrimaryEmailAddress()); 36 36 } else if ($request->isFormPost()) { 37 37 $email = new PhutilEmailAddress($request->getStr('email')); 38 38 $email_obj = id(new PhabricatorUserEmail()) ··· 41 41 return $this->signInResponse(); 42 42 } 43 43 $external_account = id(new PhabricatorExternalAccountQuery()) 44 - ->setViewer($user) 44 + ->setViewer($viewer) 45 45 ->withAccountTypes(array('email')) 46 46 ->withAccountDomains(array($email->getDomainName())) 47 47 ->withAccountIDs(array($email->getAddress())) ··· 54 54 55 55 if ($signer_phid) { 56 56 $signature = id(new LegalpadDocumentSignatureQuery()) 57 - ->setViewer($user) 57 + ->setViewer($viewer) 58 58 ->withDocumentPHIDs(array($document->getPHID())) 59 59 ->withSignerPHIDs(array($signer_phid)) 60 60 ->withDocumentVersions(array($document->getVersions())) ··· 132 132 } 133 133 134 134 $verified = LegalpadDocumentSignature::UNVERIFIED; 135 - if ($user->isLoggedIn() && $addr_obj) { 135 + if ($viewer->isLoggedIn() && $addr_obj) { 136 136 $email_obj = id(new PhabricatorUserEmail()) 137 137 ->loadOneWhere('address = %s', $addr_obj->getAddress()); 138 - if ($email_obj && $email_obj->getUserPHID() == $user->getPHID()) { 138 + if ($email_obj && $email_obj->getUserPHID() == $viewer->getPHID()) { 139 139 $verified = LegalpadDocumentSignature::VERIFIED; 140 140 } 141 141 } ··· 165 165 166 166 $document_body = $document->getDocumentBody(); 167 167 $engine = id(new PhabricatorMarkupEngine()) 168 - ->setViewer($user); 168 + ->setViewer($viewer); 169 169 $engine->addObject( 170 170 $document_body, 171 171 LegalpadDocumentBody::MARKUP_FIELD_TEXT); ··· 173 173 174 174 $title = $document_body->getTitle(); 175 175 176 + $manage_uri = $this->getApplicationURI('view/'.$document->getID().'/'); 177 + 178 + $can_edit = PhabricatorPolicyFilter::hasCapability( 179 + $viewer, 180 + $document, 181 + PhabricatorPolicyCapability::CAN_EDIT); 182 + 176 183 $header = id(new PHUIHeaderView()) 177 - ->setHeader($title); 184 + ->setHeader($title) 185 + ->addActionLink( 186 + id(new PHUIButtonView()) 187 + ->setTag('a') 188 + ->setIcon( 189 + id(new PHUIIconView()) 190 + ->setIconFont('fa-pencil')) 191 + ->setText(pht('Manage Document')) 192 + ->setHref($manage_uri) 193 + ->setDisabled(!$can_edit) 194 + ->setWorkflow(!$can_edit)); 178 195 179 196 $content = array( 180 197 $this->buildDocument( ··· 190 207 $e_address_1, 191 208 $error_view)); 192 209 210 + $crumbs = $this->buildApplicationCrumbs(); 211 + $crumbs->addTextCrumb($document->getMonogram()); 212 + 193 213 return $this->buildApplicationPage( 194 - $content, 214 + array( 215 + $crumbs, 216 + $content, 217 + ), 195 218 array( 196 219 'title' => $title, 197 220 'pageObjects' => array($document->getPHID()), ··· 220 243 $e_address_1 = true, 221 244 $error_view = null) { 222 245 223 - $user = $this->getRequest()->getUser(); 246 + $viewer = $this->getRequest()->getUser(); 224 247 if ($has_signed) { 225 248 $instructions = pht('Thank you for signing and agreeing.'); 226 249 } else { ··· 229 252 230 253 $data = $signature->getSignatureData(); 231 254 $form = id(new AphrontFormView()) 232 - ->setUser($user) 255 + ->setUser($viewer) 233 256 ->appendChild( 234 257 id(new AphrontFormTextControl()) 235 258 ->setLabel(pht('Name')) ··· 282 305 if ($error_view) { 283 306 $view->setErrorView($error_view); 284 307 } 308 + 285 309 return $view; 286 310 } 287 311
+16 -12
src/applications/legalpad/controller/LegalpadDocumentViewController.php src/applications/legalpad/controller/LegalpadDocumentManageController.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group legalpad 5 - */ 6 - final class LegalpadDocumentViewController extends LegalpadController { 3 + final class LegalpadDocumentManageController extends LegalpadController { 7 4 8 5 private $id; 9 6 ··· 14 11 public function processRequest() { 15 12 $request = $this->getRequest(); 16 13 $user = $request->getUser(); 14 + 15 + // NOTE: We require CAN_EDIT to view this page. 17 16 18 17 $document = id(new LegalpadDocumentQuery()) 19 18 ->setViewer($user) 20 19 ->withIDs(array($this->id)) 21 20 ->needDocumentBodies(true) 22 21 ->needContributors(true) 22 + ->requireCapabilities( 23 + array( 24 + PhabricatorPolicyCapability::CAN_VIEW, 25 + PhabricatorPolicyCapability::CAN_EDIT, 26 + )) 23 27 ->executeOne(); 24 - 25 28 if (!$document) { 26 29 return new Aphront404Response(); 27 30 } ··· 83 86 $crumbs->setActionList($actions); 84 87 $crumbs->addTextCrumb( 85 88 $document->getMonogram(), 86 - $this->getApplicationURI('view/'.$document->getID())); 89 + '/'.$document->getMonogram()); 90 + $crumbs->addTextCrumb(pht('Manage')); 87 91 88 92 $object_box = id(new PHUIObjectBoxView()) 89 93 ->setHeader($header) ··· 136 140 137 141 $actions->addAction( 138 142 id(new PhabricatorActionView()) 143 + ->setIcon('fa-pencil-square') 144 + ->setName(pht('View/Sign Document')) 145 + ->setHref('/'.$document->getMonogram())); 146 + 147 + $actions->addAction( 148 + id(new PhabricatorActionView()) 139 149 ->setIcon('fa-pencil') 140 150 ->setName(pht('Edit Document')) 141 151 ->setHref($this->getApplicationURI('/edit/'.$doc_id.'/')) 142 152 ->setDisabled(!$can_edit) 143 153 ->setWorkflow(!$can_edit)); 144 - 145 - $actions->addAction( 146 - id(new PhabricatorActionView()) 147 - ->setIcon('fa-pencil-square') 148 - ->setName(pht('Sign Document')) 149 - ->setHref('/'.$document->getMonogram())); 150 154 151 155 $actions->addAction( 152 156 id(new PhabricatorActionView())
+2 -2
src/applications/legalpad/query/LegalpadDocumentSearchEngine.php
··· 132 132 $title = $document->getTitle(); 133 133 134 134 $item = id(new PHUIObjectItemView()) 135 - ->setObjectName('L'.$document->getID()) 135 + ->setObjectName($document->getMonogram()) 136 136 ->setHeader($title) 137 - ->setHref($this->getApplicationURI('view/'.$document->getID())) 137 + ->setHref('/'.$document->getMonogram()) 138 138 ->setObject($document) 139 139 ->addIcon('none', pht('Last updated: %s', $last_updated)) 140 140 ->addByline(pht('Updated by: %s', $updater))