static function registerEmail($email)
 {
     $old = User::getKV('email', $email);
     if (!empty($old)) {
         // TRANS: Error text when trying to register with an already registered e-mail address.
         // TRANS: %s is the URL to recover password at.
         throw new ClientException(sprintf(_m('A user with that email address already exists. You can use the ' . '<a href="%s">password recovery</a> tool to recover a missing password.'), common_local_url('recoverpassword')));
     }
     $valid = false;
     if (Event::handle('StartValidateUserEmail', array(null, $email, &$valid))) {
         $valid = Validate::email($email, common_config('email', 'check_domain'));
         Event::handle('EndValidateUserEmail', array(null, $email, &$valid));
     }
     if (!$valid) {
         // TRANS: Error text when trying to register with an invalid e-mail address.
         throw new ClientException(_m('Not a valid email address.'));
     }
     $confirm = Confirm_address::getAddress($email, self::CONFIRMTYPE);
     if (empty($confirm)) {
         $confirm = Confirm_address::saveNew(null, $email, 'register');
     }
     return $confirm;
 }
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
$shortoptions = 'd';
$longoptions = array('dryrun');
$helptext = <<<END_OF_REGISTEREMAILUSER_HELP
cancelemailregistration.php [options] <email address>

Options:
-d --dryrun   Do not actually delete the email registration and confirmation code

Cancel an email registration code

END_OF_REGISTEREMAILUSER_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
if (count($args) == 0) {
    show_help();
}
$email = $args[0];
$confirm = Confirm_address::getAddress($email, EmailRegistrationPlugin::CONFIRMTYPE);
if (!empty($confirm)) {
    if (have_option('d', 'dryrun')) {
        print "[Dry run mode] Deleted confirmation code {$confirm->code} for {$confirm->address}.\n";
    } else {
        $confirm->delete();
        print "Deleted confirmation code {$confirm->code} for {$confirm->address}.\n";
    }
} else {
    print "Couldn't find an email registration code for {$email}.\n";
}