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