public function delete() { if (!$this->view()) { $this->errormsg[] = Config::Lang('pFetchmail_invalid_mailbox'); # TODO: can users hit this message at all? init() should already fail... return false; } # the correct way would be to delete the alias and fetchmail entries with *Handler before # deleting the mailbox, but it's easier and a bit faster to do it on the database level. # cleaning up all tables doesn't hurt, even if vacation or displaying the quota is disabled db_delete('fetchmail', 'mailbox', $this->id); db_delete('vacation', 'email', $this->id); db_delete('vacation_notification', 'on_vacation', $this->id); # should be caught by cascade, if PgSQL db_delete('quota', 'username', $this->id); db_delete('quota2', 'username', $this->id); db_delete('alias', 'address', $this->id); db_delete($this->db_table, $this->id_field, $this->id); # finally delete the mailbox if (!$this->mailbox_postdeletion()) { $this->error_msg[] = Config::Lang('mailbox_postdel_failed'); } list(, $domain) = explode('@', $this->id); db_log($domain, 'delete_mailbox', $this->id); $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id); return true; }
/** * @return true on success false on failure */ public function delete() { if (!$this->view()) { $this->errormsg[] = Config::Lang($this->msg['error_does_not_exist']); return false; } db_delete('domain_admins', $this->id_field, $this->id); 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 $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id); return true; }
/** * check if value of an enum field is in the list of allowed values */ protected function _inp_enma($field, $val) { if (array_key_exists($val, $this->struct[$field]['options'])) { return true; } $this->errormsg[$field] = Config::Lang_f('invalid_value_given', $field); return false; }
protected function _validate_poll_time($field, $val) { # must be > 0 if ($val < 1) { $this->errormsg[$field] = Config::Lang_f('must_be_numeric_bigger_than_null', $field); return false; } return true; }
/** * @return true on success false on failure */ public function delete() { if (!$this->view()) { $this->errormsg[] = Config::Lang('alias_does_not_exist'); return false; } if ($this->result['is_mailbox']) { $this->errormsg[] = Config::Lang('mailbox_alias_cant_be_deleted'); return false; } db_delete('alias', 'address', $this->id); list(, $domain) = explode('@', $this->id); db_log($domain, 'delete_alias', $this->id); $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id); return true; }
flash_error($validpass[0]); # TODO: honor all error messages, not only the first one $error += 1; } $mh = new MailboxHandler(); if (!$mh->login($username, $fPassword_current)) { $error += 1; $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; } if (empty($fPassword) or $fPassword != $fPassword2) { $error += 1; $pPassword_password_text = $PALANG['pPassword_password_text_error']; } if ($error == 0) { $mh->init($username); # TODO: error handling if ($mh->change_pw($fPassword, $fPassword_current)) { flash_info(Config::Lang_f('pPassword_result_success', $username)); header("Location: main.php"); exit(0); } else { flash_error(Config::Lang_f('pPassword_result_error', $username)); } } } $smarty->assign('SESSID_USERNAME', $username); $smarty->assign('pPassword_password_current_text', $pPassword_password_current_text, false); $smarty->assign('pPassword_password_text', $pPassword_password_text, false); $smarty->assign('smarty_template', 'password'); $smarty->display('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
/** * @return true on success false on failure */ public function delete() { if (!$this->view()) { $this->errormsg[] = 'An alias domain with that name does not exist!'; # TODO: make translatable? (will a user ever see this?) return false; } db_delete($this->db_table, $this->id_field, $this->id); db_log($this->id, 'delete_alias_domain', $this->result['target_domain']); $this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->result['alias_domain'] . ' -> ' . $this->result['target_domain']); return true; }
/** * @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; }