]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/resend_confirm_address.php
Added type-hint for StartShowEntryForms hook
[quix0rs-gnu-social.git] / scripts / resend_confirm_address.php
index 1d7cb55ca5529f7330fcda554df453e5a8c7e966..8a456a812cd1508cef4fe031c2c7f6bc2768bda0 100755 (executable)
@@ -1,7 +1,8 @@
 #!/usr/bin/env php
 <?php
 
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', dirname(__DIR__));
+define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
 
 $shortoptions = 'e::ay';
 $longoptions = array('email=', 'all', 'yes');
@@ -33,9 +34,10 @@ $ca = null;
 
 if (have_option('e', 'email')) {
     $email = get_option_value('e', 'email');
-    $ca = Confirm_address::getAddress($email, 'email');
-    if (!$ca instanceof Confirm_address) {
-        print "Can't find email $email in confirm_address table.\n";
+    try {
+        $ca = Confirm_address::getByAddress($email, 'email');
+    } catch (NoResultException $e) {
+        print sprintf("Can't find %s address %s in %s table.\n", $e->obj->address_type, $e->obj->address, $e->obj->tableName());
         exit(1);
     }
 } elseif (have_option('a', 'all')) {
@@ -64,6 +66,11 @@ function mailConfirmAddress(Confirm_address $ca)
 {
     try {
         $user = User::getByID($ca->user_id);
+        $profile = $user->getProfile();
+        if ($profile->isSilenced()) {
+            $ca->delete();
+            return;
+        }
         if ($user->email === $ca->address) {
             throw new AlreadyFulfilledException('User already has identical confirmed email address.');
         }