Path: blob/master/src/applications/metamta/management/PhabricatorMailManagementUnverifyWorkflow.php
12256 views
<?php12final class PhabricatorMailManagementUnverifyWorkflow3extends PhabricatorMailManagementWorkflow {45protected function didConstruct() {6$this7->setName('unverify')8->setSynopsis(9pht('Unverify an email address so it no longer receives mail.'))10->setExamples('**unverify** __address__ ...')11->setArguments(12array(13array(14'name' => 'addresses',15'wildcard' => true,16'help' => pht('Address (or addresses) to unverify.'),17),18));19}2021public function execute(PhutilArgumentParser $args) {22$console = PhutilConsole::getConsole();23$viewer = $this->getViewer();2425$addresses = $args->getArg('addresses');26if (!$addresses) {27throw new PhutilArgumentUsageException(28pht('Specify one or more email addresses to unverify.'));29}3031foreach ($addresses as $address) {32$email = id(new PhabricatorUserEmail())->loadOneWhere(33'address = %s',34$address);35if (!$email) {36echo tsprintf(37"%s\n",38pht(39'Address "%s" is unknown.',40$address));41continue;42}4344$user_phid = $email->getUserPHID();4546$user = id(new PhabricatorPeopleQuery())47->setViewer($viewer)48->withPHIDs(array($user_phid))49->executeOne();5051if (!$user) {52echo tsprintf(53"%s\n",54pht(55'Address "%s" belongs to invalid user "%s".',56$address,57$user_phid));58continue;59}6061if (!$email->getIsVerified()) {62echo tsprintf(63"%s\n",64pht(65'Address "%s" (owned by "%s") is already unverified.',66$address,67$user->getUsername()));68continue;69}7071$email->openTransaction();727374->setIsVerified(0)75->save();7677if ($email->getIsPrimary()) {78$user79->setIsEmailVerified(0)80->save();81}8283$email->saveTransaction();8485if ($email->getIsPrimary()) {86echo tsprintf(87"%s\n",88pht(89'Unverified "%s", the primary address for "%s".',90$address,91$user->getUsername()));92} else {93echo tsprintf(94"%s\n",95pht(96'Unverified "%s", an address for "%s".',97$address,98$user->getUsername()));99}100}101102echo tsprintf(103"%s\n",104pht('Done.'));105106return 0;107}108109}110111112