Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php
12262 views
1
<?php
2
3
final class PhabricatorAuthContactNumberTestController
4
extends PhabricatorAuthContactNumberController {
5
6
public function handleRequest(AphrontRequest $request) {
7
$viewer = $request->getViewer();
8
$id = $request->getURIData('id');
9
10
$number = id(new PhabricatorAuthContactNumberQuery())
11
->setViewer($viewer)
12
->withIDs(array($id))
13
->requireCapabilities(
14
array(
15
PhabricatorPolicyCapability::CAN_VIEW,
16
PhabricatorPolicyCapability::CAN_EDIT,
17
))
18
->executeOne();
19
if (!$number) {
20
return new Aphront404Response();
21
}
22
23
$id = $number->getID();
24
$cancel_uri = $number->getURI();
25
26
// NOTE: This is a global limit shared by all users.
27
PhabricatorSystemActionEngine::willTakeAction(
28
array(id(new PhabricatorAuthApplication())->getPHID()),
29
new PhabricatorAuthTestSMSAction(),
30
1);
31
32
if ($request->isFormPost()) {
33
$uri = PhabricatorEnv::getURI('/');
34
$uri = new PhutilURI($uri);
35
36
$mail = id(new PhabricatorMetaMTAMail())
37
->setMessageType(PhabricatorMailSMSMessage::MESSAGETYPE)
38
->addTos(array($viewer->getPHID()))
39
->setSensitiveContent(false)
40
->setBody(
41
pht(
42
'This is a terse test text message (from "%s").',
43
$uri->getDomain()))
44
->save();
45
46
return id(new AphrontRedirectResponse())->setURI($mail->getURI());
47
}
48
49
$number_display = phutil_tag(
50
'strong',
51
array(),
52
$number->getDisplayName());
53
54
return $this->newDialog()
55
->setTitle(pht('Set Test Message'))
56
->appendParagraph(
57
pht(
58
'Send a test message to %s?',
59
$number_display))
60
->addSubmitButton(pht('Send SMS'))
61
->addCancelButton($cancel_uri);
62
}
63
64
}
65
66