tbrehm
2008-04-14 430a0fa948cf485a7d0ae40d639c37fa3070aed5
interface/web/mail/mail_domain_del.php
@@ -48,7 +48,44 @@
   exit;
}
$app->uses("tform_actions");
$app->tform_actions->onDelete();
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
   function onBeforeDelete() {
      global $app; $conf;
      $domain = $this->dataRecord['domain'];
      // Before we delete the email domain,
      // we will delete all depending records.
      // Delete all forwardings where the osurce or destination belongs to this domain
      $records = $app->db->queryAllRecords("SELECT forwarding_id as id FROM mail_forwarding WHERE source like '%@".$app->db->quote($domain)."' OR destination like '%@".$app->db->quote($domain)."'");
      foreach($records as $rec) {
         $app->db->datalogDelete('mail_forwarding','forwarding_id',$rec['id']);
      }
      // Delete all fetchmail accounts where destination belongs to this domain
      $records = $app->db->queryAllRecords("SELECT mailget_id as id FROM mail_get WHERE destination like '%@".$app->db->quote($domain)."'");
      foreach($records as $rec) {
         $app->db->datalogDelete('mail_get','mailget_id',$rec['id']);
      }
      // Delete all mailboxes where destination belongs to this domain
      $records = $app->db->queryAllRecords("SELECT mailuser_id as id FROM mail_user WHERE email like '%@".$app->db->quote($domain)."'");
      foreach($records as $rec) {
         $app->db->datalogDelete('mail_user','mailuser_id',$rec['id']);
      }
   }
}
$page = new page_action;
$page->onDelete();
?>