DomainHandler.php, AdminHandler.php:

- implement delete()



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1560 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 11 years ago
parent 5871516b47
commit 2f26624ceb

@ -179,15 +179,13 @@ class AdminHandler extends PFAHandler {
return false; return false;
} }
$result = db_delete('domain_admins', $this->id_field, $this->id); # TODO: check for errors? db_delete('domain_admins', $this->id_field, $this->id);
db_delete($this->db_table, $this->id_field, $this->id);
$result = db_delete($this->db_table, $this->id_field, $this->id); db_log ('admin', 'delete_admin', $this->id); # TODO delete_admin is not a valid db_log keyword yet, and 'admin' is not displayed in viewlog.php
if ( $result == 1 ) { $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id);
list(/*NULL*/,$domain) = explode('@', $this->id);
db_log ($domain, 'delete_admin', $this->id); # TODO delete_admin is not a valid db_log keyword yet
return true; return true;
} }
}
# TODO: generate password if $new, no password specified and $CONF['generate_password'] is set # TODO: generate password if $new, no password specified and $CONF['generate_password'] is set

@ -136,21 +136,42 @@ class DomainHandler extends PFAHandler {
*/ */
public function delete() { public function delete() {
if ( ! $this->view() ) { if ( ! $this->view() ) {
$this->errormsg[] = 'A domain with that name does not exist.'; # TODO: make translatable $this->errormsg[] = Config::Lang('domain_does_not_exist'); # TODO: can users hit this message at all? init() should already fail...
return false; return false;
} }
$this->errormsg[] = '*** Domain deletion not implemented yet ***'; # TODO: check if this domain is an alias domain target - if yes, do not allow to delete it
return false; # XXX function aborts here until TODO below is implemented! XXX
# TODO: recursively delete mailboxes, aliases, alias_domains, fetchmail entries etc. before deleting the domain
# TODO: move the needed code from delete.php here # the correct way would be to recursively delete mailboxes, aliases, alias_domains, fetchmail entries
$result = db_delete($this->db_table, $this->id_field, $this->id); # with *Handler before deleting the domain, but this would be terribly slow on domains with many aliases etc.,
if ( $result == 1 ) { # so we do it the fast way on the database level
list(/*NULL*/,$domain) = explode('@', $this->id); # cleaning up all tables doesn't hurt, even if vacation or displaying the quota is disabled
db_log ($domain, 'delete_domain', $this->id); # TODO delete_domain is not a valid db_log keyword yet because we don't yet log add/delete domain
return true; # some tables don't have a domain field, so we need a workaround
$like_domain = "LIKE '" . escape_string('%@' . $this->id) . "'";
db_delete('domain_admins', 'domain', $this->id);
db_delete('alias', 'domain', $this->id);
db_delete('mailbox', 'domain', $this->id);
db_delete('alias_domain', 'alias_domain', $this->id);
db_delete('vacation', 'domain', $this->id);
db_delete('vacation_notification', 'on_vacation', $this->id, "OR on_vacation $like_domain");
db_delete('quota', 'username', $this->id, "OR username $like_domain");
db_delete('quota2', 'username', $this->id, "OR username $like_domain");
db_delete('fetchmail', 'mailbox', $this->id, "OR mailbox $like_domain");
db_delete('log', 'domain', $this->id); # TODO: should we really delete the log?
# finally delete the domain
db_delete($this->db_table, $this->id_field, $this->id);
if ( !domain_postdeletion($this->id) ) {
$this->error_msg[] = $PALANG['pAdminDelete_domain_error']; # TODO: better error message
} }
db_log ($this->id, 'delete_domain', $this->id); # TODO delete_domain is not a valid db_log keyword yet
$this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id);
return true;
} }
} }

Loading…
Cancel
Save