[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class LegalpadDocumentSignatureViewController extends LegalpadController { 4 5 private $id; 6 7 public function willProcessRequest(array $data) { 8 $this->id = $data['id']; 9 } 10 11 public function processRequest() { 12 $request = $this->getRequest(); 13 $viewer = $request->getUser(); 14 15 $signature = id(new LegalpadDocumentSignatureQuery()) 16 ->setViewer($viewer) 17 ->withIDs(array($this->id)) 18 ->executeOne(); 19 if (!$signature) { 20 return new Aphront404Response(); 21 } 22 23 24 // NOTE: In order to see signature details (which include the relatively 25 // internal-feeling "notes" field) you must be able to edit the document. 26 // Essentially, this power is for document managers. Notably, this prevents 27 // users from seeing notes about their own exemptions by guessing their 28 // signature ID. This is purely a policy check. 29 30 $document = id(new LegalpadDocumentQuery()) 31 ->setViewer($viewer) 32 ->withIDs(array($signature->getDocument()->getID())) 33 ->requireCapabilities( 34 array( 35 PhabricatorPolicyCapability::CAN_VIEW, 36 PhabricatorPolicyCapability::CAN_EDIT, 37 )) 38 ->executeOne(); 39 if (!$document) { 40 return new Aphront404Response(); 41 } 42 43 44 $document_id = $signature->getDocument()->getID(); 45 $next_uri = $this->getApplicationURI('signatures/'.$document_id.'/'); 46 47 $data = $signature->getSignatureData(); 48 49 $exemption_phid = $signature->getExemptionPHID(); 50 $actor_phid = idx($data, 'actorPHID'); 51 $handles = $this->loadViewerHandles( 52 array( 53 $exemption_phid, 54 $actor_phid, 55 )); 56 $exemptor_handle = $handles[$exemption_phid]; 57 $actor_handle = $handles[$actor_phid]; 58 59 $form = id(new AphrontFormView()) 60 ->setUser($viewer); 61 62 if ($signature->getExemptionPHID()) { 63 $form 64 ->appendChild( 65 id(new AphrontFormMarkupControl()) 66 ->setLabel(pht('Exemption By')) 67 ->setValue($exemptor_handle->renderLink())) 68 ->appendChild( 69 id(new AphrontFormMarkupControl()) 70 ->setLabel(pht('Notes')) 71 ->setValue(idx($data, 'notes'))); 72 } 73 74 $type_corporation = LegalpadDocument::SIGNATURE_TYPE_CORPORATION; 75 if ($signature->getSignatureType() == $type_corporation) { 76 $form 77 ->appendChild( 78 id(new AphrontFormMarkupControl()) 79 ->setLabel(pht('Signing User')) 80 ->setValue($actor_handle->renderLink())) 81 ->appendChild( 82 id(new AphrontFormMarkupControl()) 83 ->setLabel(pht('Company Name')) 84 ->setValue(idx($data, 'name'))) 85 ->appendChild( 86 id(new AphrontFormMarkupControl()) 87 ->setLabel(pht('Address')) 88 ->setValue(phutil_escape_html_newlines(idx($data, 'address')))) 89 ->appendChild( 90 id(new AphrontFormMarkupControl()) 91 ->setLabel(pht('Contact Name')) 92 ->setValue(idx($data, 'contact.name'))) 93 ->appendChild( 94 id(new AphrontFormMarkupControl()) 95 ->setLabel(pht('Contact Email')) 96 ->setValue( 97 phutil_tag( 98 'a', 99 array( 100 'href' => 'mailto:'.idx($data, 'email'), 101 ), 102 idx($data, 'email')))); 103 } 104 105 return $this->newDialog() 106 ->setTitle(pht('Signature Details')) 107 ->setWidth(AphrontDialogView::WIDTH_FORM) 108 ->appendChild($form->buildLayoutView()) 109 ->addCancelButton($next_uri, pht('Close')); 110 } 111 112 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |