示例#1
0
    header("Location: list.php?table=domain");
    # domain not owned by this admin
    exit(0);
}
// store domain and page browser offset in $_SESSION so after adding/editing aliases/mailboxes we can
// take the user back to the appropriate domain listing.
$_SESSION['list-virtual:domain'] = $fDomain;
$_SESSION['prefill:alias:domain'] = $fDomain;
$_SESSION['prefill:mailbox:domain'] = $fDomain;
$_SESSION['prefill:aliasdomain:target_domain'] = $fDomain;
$_SESSION['list-virtual:limit'] = $fDisplay;
#
# alias domain
#
if (Config::bool('alias_domain')) {
    $handler = new AliasdomainHandler(0, $admin_username);
    $formconf = $handler->webformConfig();
    # might change struct
    $aliasdomain_data = array('struct' => $handler->getStruct(), 'msg' => $handler->getMsg(), 'formconf' => $formconf);
    $aliasdomain_data['msg']['show_simple_search'] = False;
    # hide search box
    $aliasdomain_data['msg']['can_create'] = 1;
    # hide create button if all domains (of this admin) are already used as alias domains
    $handler->getList("");
    if (count($handler->result()) + 1 >= count($list_domains)) {
        $aliasdomain_data['msg']['can_create'] = 0;
    }
    # all domains (of this admin) are already alias domains
    # get the really requested list
    if (count($search) == 0) {
        $list_param = "alias_domain='{$fDomain}' OR target_domain='{$fDomain}'";
 /**
  *  @return true on success false on failure
  */
 public function delete()
 {
     # TODO: check for _can_delete instead
     if (!$this->is_superadmin) {
         $this->errormsg[] = Config::Lang_f('no_delete_permissions', $this->id);
         return false;
     }
     if (!$this->view()) {
         $this->errormsg[] = Config::Lang('domain_does_not_exist');
         # TODO: can users hit this message at all? init() should already fail...
         return false;
     }
     if (Config::bool('alias_domain')) {
         # check if this domain is an alias domain target - if yes, do not allow to delete it
         $handler = new AliasdomainHandler(0, $this->admin_username);
         $handler->getList("target_domain = '" . escape_string($this->id) . "'");
         $aliasdomains = $handler->result();
         if (count($aliasdomains) > 0) {
             $this->errormsg[] = Config::Lang_f('delete_domain_aliasdomain_target', $this->id);
             return false;
         }
     }
     # the correct way would be to recursively delete mailboxes, aliases, alias_domains, fetchmail entries
     # with *Handler before deleting the domain, but this would be terribly slow on domains with many aliases etc.,
     # so we do it the fast way on the database level
     # cleaning up all tables doesn't hurt, even if vacation or displaying the quota is disabled
     # 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 (!$this->domain_postdeletion()) {
         $this->error_msg[] = $PALANG['domain_postdel_failed'];
     }
     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;
 }