[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/legalpad/controller/ -> LegalpadDocumentSignatureVerificationController.php (source)

   1  <?php
   2  
   3  final class LegalpadDocumentSignatureVerificationController
   4    extends LegalpadController {
   5  
   6    private $code;
   7  
   8    public function shouldAllowPublic() {
   9      return true;
  10    }
  11  
  12    public function willProcessRequest(array $data) {
  13      $this->code = $data['code'];
  14    }
  15  
  16    public function processRequest() {
  17      $request = $this->getRequest();
  18      $viewer = $request->getUser();
  19  
  20      // NOTE: We're using the omnipotent user to handle logged-out signatures
  21      // and corporate signatures.
  22      $signature = id(new LegalpadDocumentSignatureQuery())
  23        ->setViewer(PhabricatorUser::getOmnipotentUser())
  24        ->withSecretKeys(array($this->code))
  25        ->executeOne();
  26  
  27      if (!$signature) {
  28        return $this->newDialog()
  29          ->setTitle(pht('Unable to Verify Signature'))
  30          ->appendParagraph(
  31            pht(
  32              'The signature verification code is incorrect, or the signature '.
  33              'has been invalidated. Make sure you followed the link in the '.
  34              'email correctly.'))
  35          ->addCancelButton('/', pht('Rats!'));
  36      }
  37  
  38      if ($signature->isVerified()) {
  39        return $this->newDialog()
  40          ->setTitle(pht('Signature Already Verified'))
  41          ->appendParagraph(
  42            pht(
  43              'This signature has already been verified.'))
  44          ->addCancelButton('/', pht('Okay'));
  45      }
  46  
  47      if ($request->isFormPost()) {
  48        $signature
  49          ->setVerified(LegalpadDocumentSignature::VERIFIED)
  50          ->save();
  51  
  52        return $this->newDialog()
  53          ->setTitle(pht('Signature Verified'))
  54          ->appendParagraph(pht('The signature is now verified.'))
  55          ->addCancelButton('/', pht('Okay'));
  56      }
  57  
  58      $document_link = phutil_tag(
  59        'a',
  60        array(
  61          'href' => '/'.$signature->getDocument()->getMonogram(),
  62          'target' => '_blank',
  63        ),
  64        $signature->getDocument()->getTitle());
  65  
  66      $signed_at = phabricator_datetime($signature->getDateCreated(), $viewer);
  67  
  68      $name = $signature->getSignerName();
  69      $email = $signature->getSignerEmail();
  70  
  71      $form = id(new AphrontFormView())
  72        ->setUser($viewer)
  73        ->appendRemarkupInstructions(
  74          pht('Please verify this document signature.'))
  75        ->appendChild(
  76          id(new AphrontFormMarkupControl())
  77            ->setLabel(pht('Document'))
  78            ->setValue($document_link))
  79        ->appendChild(
  80          id(new AphrontFormMarkupControl())
  81            ->setLabel(pht('Signed At'))
  82            ->setValue($signed_at))
  83        ->appendChild(
  84          id(new AphrontFormMarkupControl())
  85            ->setLabel(pht('Name'))
  86            ->setValue($name))
  87        ->appendChild(
  88          id(new AphrontFormMarkupControl())
  89            ->setLabel(pht('Email'))
  90            ->setValue($email));
  91  
  92      return $this->newDialog()
  93        ->setTitle(pht('Verify Signature?'))
  94        ->appendChild($form->buildLayoutView())
  95        ->addCancelButton('/')
  96        ->addSubmitButton(pht('Verify Signature'));
  97    }
  98  
  99  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1