From d278474358b021ced58448425d516ee6745cd154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=EF=BF=BD=EF=BF=BD?= Date: Wed, 24 Sep 2014 22:05:47 +0000 Subject: [PATCH] rewrite the account deactivation code to make sure it works with mailboxes and restores properly --- bureau/admin/adm_deactivate.php | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/bureau/admin/adm_deactivate.php b/bureau/admin/adm_deactivate.php index ab71ed3e..7ebfbbf8 100644 --- a/bureau/admin/adm_deactivate.php +++ b/bureau/admin/adm_deactivate.php @@ -126,11 +126,11 @@ foreach ($domains as $key => $domain) { } else { # 2.1 keep a copy of where it was, in an SQL request - $backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE `domaine`='$domain' AND sub='$sub';\n"; + $backup .= "UPDATE `sub_domaines` SET `type`='$type', valeur='$dest',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n"; # 2.2 change the subdomain to redirect to http://spam.koumbit.org/ $dom->lock(); - if (!$dom->set_sub_domain($domain, $sub, $dom->type_url, $redirect)) { + if (! $db->query("UPDATE `sub_domaines` SET `type`='" . $dom->type_url . "', valeur='$redirect',web_action='UPDATE' WHERE id=" . $r['sub'][$k]['id'] . ";\n") ) { print "-- error in $sub.$domain: " . $err->errstr() . "\n"; } $dom->unlock(); @@ -141,6 +141,35 @@ foreach ($domains as $key => $domain) { if (!$confirmed) print ''; } +$mail_dom = $mail->enum_domains(); + +if ($confirmed) { + print "
";
+  printf(_("-- disabling all the mail passwords\n"));
+}
+if (!$confirmed) print "\n
  • mailboxes
      \n"; +reset($mail_dom); +# 1.3 foreach mail domain, we list the email hashes +foreach ($mail_dom as $key => $domain) { + if (!$confirmed) print '' . $domain['domaine'] . '
        '; + $mails = $mail->enum_domain_mails($domain['id']); + foreach ($mails as $key => $mail) { + if ($mail['islocal']) { + if (!$confirmed) print '
      • ' . $mail['address'] . '@' . $domain['domaine']; + $pass = $mail['password']; + $id = $mail['id']; + $backup .= $b = "update address set password='$pass' where id=$id"; + if (!$confirmed) print "
      • \n"; + if ($confirmed) { + $db->query("update `address` set password='!$pass' where id=$id"); + } + } + } +} + + +if (!$confirmed) print "
    \n"; + # 3. wrap up (?) if ($confirmed) { print "-- The following is a serie of SQL request you can run, as root, to revert the user's domains to their previous state.\n";