From 17e5f7ff3118156ce92a366ef05b4e052790012e Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 18 Feb 2015 13:19:07 -0800 Subject: [PATCH] Legalpad - make "Cancel" button "Log Out" button for required signature documents Summary: Fixes T7299. Also re-direct the user to the initial request uri if the signature was required. Test Plan: made a signature required legalpad doc. visit the instance at a specific uri, signed the document, and ended up at that specific uri Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7299 Differential Revision: https://secure.phabricator.com/D11809 --- .../LegalpadDocumentSignController.php | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignController.php b/src/applications/legalpad/controller/LegalpadDocumentSignController.php index 61ea2eb271..8663d7feba 100644 --- a/src/applications/legalpad/controller/LegalpadDocumentSignController.php +++ b/src/applications/legalpad/controller/LegalpadDocumentSignController.php @@ -180,11 +180,19 @@ final class LegalpadDocumentSignController extends LegalpadController { if (!$errors) { $signature->save(); - // If the viewer is logged in, send them to the document page, which - // will show that they have signed the document. Otherwise, send them - // to a completion page. + // If the viewer is logged in, signing for themselves, send them to + // the document page, which will show that they have signed the + // document. Unless of course they were required to sign the + // document to use Phabricator; in that case try really hard to + // re-direct them to where they wanted to go. + // + // Otherwise, send them to a completion page. if ($viewer->isLoggedIn() && $is_individual) { $next_uri = '/'.$document->getMonogram(); + if ($document->getRequireSignature()) { + $request_uri = $request->getRequestURI(); + $next_uri = (string) $request_uri; + } } else { $this->sendVerifySignatureEmail( $document, @@ -401,11 +409,19 @@ final class LegalpadDocumentSignController extends LegalpadController { 'agree', 'agree', pht('I agree to the terms laid forth above.'), - false)) + false)); + if ($document->getRequireSignature()) { + $cancel_uri = '/logout/'; + $cancel_text = pht('Log Out'); + } else { + $cancel_uri = $this->getApplicationURI(); + $cancel_text = pht('Cancel'); + } + $form ->appendChild( id(new AphrontFormSubmitControl()) ->setValue(pht('Sign Document')) - ->addCancelButton($this->getApplicationURI())); + ->addCancelButton($cancel_uri, $cancel_text)); return $form; }