Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99426202
PhabricatorMailManagementUnverifyWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jan 24, 11:21
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Jan 26, 11:21 (2 d)
Engine
blob
Format
Raw Data
Handle
23797993
Attached To
rPH Phabricator
PhabricatorMailManagementUnverifyWorkflow.php
View Options
<?php
final
class
PhabricatorMailManagementUnverifyWorkflow
extends
PhabricatorMailManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'unverify'
)
->
setSynopsis
(
pht
(
'Unverify an email address so it no longer receives mail.'
))
->
setExamples
(
'**unverify** __address__ ...'
)
->
setArguments
(
array
(
array
(
'name'
=>
'addresses'
,
'wildcard'
=>
true
,
'help'
=>
pht
(
'Address (or addresses) to unverify.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$viewer
=
$this
->
getViewer
();
$addresses
=
$args
->
getArg
(
'addresses'
);
if
(!
$addresses
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify one or more email addresses to unverify.'
));
}
foreach
(
$addresses
as
$address
)
{
$email
=
id
(
new
PhabricatorUserEmail
())->
loadOneWhere
(
'address = %s'
,
$address
);
if
(!
$email
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Address "%s" is unknown.'
,
$address
));
continue
;
}
$user_phid
=
$email
->
getUserPHID
();
$user
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$user_phid
))
->
executeOne
();
if
(!
$user
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Address "%s" belongs to invalid user "%s".'
,
$address
,
$user_phid
));
continue
;
}
if
(!
$email
->
getIsVerified
())
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Address "%s" (owned by "%s") is already unveriifed.'
,
$address
,
$user
->
getUsername
()));
continue
;
}
$email
->
openTransaction
();
$email
->
setIsVerified
(
0
)
->
save
();
if
(
$email
->
getIsPrimary
())
{
$user
->
setIsEmailVerified
(
0
)
->
save
();
}
$email
->
saveTransaction
();
if
(
$email
->
getIsPrimary
())
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Unverified "%s", the primary address for "%s".'
,
$address
,
$user
->
getUsername
()));
}
else
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Unverified "%s", an address for "%s".'
,
$address
,
$user
->
getUsername
()));
}
}
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Done.'
));
return
0
;
}
}
Event Timeline
Log In to Comment