Page MenuHomePhabricator
Paste P2026

email2user.php
ActivePublic

Authored by jimh on Dec 13 2016, 3:28 AM.
Tags
None
Referenced Files
F2114362: email2user.php
Dec 13 2016, 3:28 AM
Subscribers
None
Had to do a little freehand scribbling to remove some company stuff and extra distracting functionality, but I'm pretty sure this will still work. Execute the code thus:
$ php email2uer.php jdoe
It should just come back with something like:
johndoe@yourcompany.com
(or warn you that this user id isn't in the Phabricator SQL database...)
Then use it however you'd like. Thanks Chad and staff for your patience.
========================================
<?php
$root = "/Users/yourinstalldir/phabricator";
require_once $root.'/scripts/__init_script__.php';
if ($argc !== 2) {
print "Usage mail2user.php <username>";
exit(1);
}
$username = $argv[1];
$existing_user = id(new PhabricatorUser())->loadOneWhere(
'username = %s',
$username);
if (!$existing_user) {
print "*** ERROR - username $username is not a valid Phabricator user.";
return 1;
}
$PHID = $existing_user->getPHID();
$existing_email = id(new PhabricatorUserEmail())->loadOneWhere(
'userPHID = %s',
$PHID);
$address = $existing_email->getAddress();
print "$address";
return 0;
?>

Event Timeline