You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-01-03 17:02:30 +03:00
(mostly) make CLI "alias delete" working
shells/alias.php: - execute still called help() instead of __handle() model/AliasHandler.php - delete(): - remove useless $address parameter from delete() (we have $this->username) - added error messages - fixed variable names for db_log Reason for the "mostly": The $this->is_mailbox_alias() in delete() always returns true and therefore forbids deletion. git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@930 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
@@ -207,21 +207,22 @@ class AliasHandler {
|
||||
* @param alias address
|
||||
* @return true on success false on failure
|
||||
*/
|
||||
public function delete($address){
|
||||
# TODO: use $this->username instead of $address function parameter?
|
||||
if( ! $this->get($address) ) {
|
||||
# TODO: error message "no such alias"
|
||||
public function delete(){
|
||||
if( ! $this->get($this->username) ) {
|
||||
$this->errormsg[] = 'An alias with that address does not exist.'; # TODO: make translatable
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_mailbox_alias($address) ) {
|
||||
# TODO: error message "alias belongs to a mailbox and can't be deleted"
|
||||
if ($this->is_mailbox_alias($this->username) ) { ### FIXME use different check, this one always returns true :-(
|
||||
### FIXME best solution might be to lookup the mailbox table (via UserHandler)
|
||||
$this->errormsg[] = 'This alias belongs to a mailbox and can\'t be deleted.'; # TODO: make translatable
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = db_delete('alias', 'address', $address);
|
||||
$result = db_delete('alias', 'address', $this->username);
|
||||
if( $result == 1 ) {
|
||||
db_log ($SESSID_USERNAME, $fDomain, 'delete_alias', $fDelete);
|
||||
list(/*NULL*/,$domain) = explode('@', $this->username);
|
||||
db_log ('CLI', $domain, 'delete_alias', $this->username); # TODO: replace hardcoded CLI
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,10 +189,7 @@ class DeleteTask extends Shell {
|
||||
}
|
||||
|
||||
if (!empty($this->args[0])) {
|
||||
$this->help();
|
||||
// $output = $this->__handle($this->args[0]);
|
||||
// $this->out($output);
|
||||
|
||||
$this->__handle($this->args[0]);
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -259,7 +256,6 @@ class DeleteTask extends Shell {
|
||||
}
|
||||
|
||||
}
|
||||
### PasswordTask was a rest of Copy Paste :D Deleted. Check it!
|
||||
class ViewTask extends Shell {
|
||||
/**
|
||||
* Execution method always used for tasks
|
||||
|
||||
Reference in New Issue
Block a user