Path: blob/master/src/applications/legalpad/controller/LegalpadDocumentSignatureViewController.php
13464 views
<?php12final class LegalpadDocumentSignatureViewController extends LegalpadController {34public function handleRequest(AphrontRequest $request) {5$viewer = $request->getViewer();6$id = $request->getURIData('id');78$signature = id(new LegalpadDocumentSignatureQuery())9->setViewer($viewer)10->withIDs(array($id))11->executeOne();12if (!$signature) {13return new Aphront404Response();14}151617// NOTE: In order to see signature details (which include the relatively18// internal-feeling "notes" field) you must be able to edit the document.19// Essentially, this power is for document managers. Notably, this prevents20// users from seeing notes about their own exemptions by guessing their21// signature ID. This is purely a policy check.2223$document = id(new LegalpadDocumentQuery())24->setViewer($viewer)25->withIDs(array($signature->getDocument()->getID()))26->requireCapabilities(27array(28PhabricatorPolicyCapability::CAN_VIEW,29PhabricatorPolicyCapability::CAN_EDIT,30))31->executeOne();32if (!$document) {33return new Aphront404Response();34}353637$document_id = $signature->getDocument()->getID();38$next_uri = $this->getApplicationURI('signatures/'.$document_id.'/');3940$data = $signature->getSignatureData();4142$exemption_phid = $signature->getExemptionPHID();43$actor_phid = idx($data, 'actorPHID');44$handles = $this->loadViewerHandles(45array(46$exemption_phid,47$actor_phid,48));49$exemptor_handle = $handles[$exemption_phid];50$actor_handle = $handles[$actor_phid];5152$form = id(new AphrontFormView())53->setUser($viewer);5455if ($signature->getExemptionPHID()) {56$form57->appendChild(58id(new AphrontFormMarkupControl())59->setLabel(pht('Exemption By'))60->setValue($exemptor_handle->renderLink()))61->appendChild(62id(new AphrontFormMarkupControl())63->setLabel(pht('Notes'))64->setValue(idx($data, 'notes')));65}6667$type_corporation = LegalpadDocument::SIGNATURE_TYPE_CORPORATION;68if ($signature->getSignatureType() == $type_corporation) {69$form70->appendChild(71id(new AphrontFormMarkupControl())72->setLabel(pht('Signing User'))73->setValue($actor_handle->renderLink()))74->appendChild(75id(new AphrontFormMarkupControl())76->setLabel(pht('Company Name'))77->setValue(idx($data, 'name')))78->appendChild(79id(new AphrontFormMarkupControl())80->setLabel(pht('Address'))81->setValue(phutil_escape_html_newlines(idx($data, 'address'))))82->appendChild(83id(new AphrontFormMarkupControl())84->setLabel(pht('Contact Name'))85->setValue(idx($data, 'contact.name')))86->appendChild(87id(new AphrontFormMarkupControl())88->setLabel(pht('Contact Email'))89->setValue(90phutil_tag(91'a',92array(93'href' => 'mailto:'.idx($data, 'email'),94),95idx($data, 'email'))));96}9798return $this->newDialog()99->setTitle(pht('Signature Details'))100->setWidth(AphrontDialogView::WIDTH_FORM)101->appendChild($form->buildLayoutView())102->addCancelButton($next_uri, pht('Close'));103}104105}106107108