(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
pull/2/head
Christian Boltz 15 years ago
parent 20e14ad664
commit 9aa96dabd0

@ -207,21 +207,22 @@ class AliasHandler {
* @param alias address * @param alias address
* @return true on success false on failure * @return true on success false on failure
*/ */
public function delete($address){ public function delete(){
# TODO: use $this->username instead of $address function parameter? if( ! $this->get($this->username) ) {
if( ! $this->get($address) ) { $this->errormsg[] = 'An alias with that address does not exist.'; # TODO: make translatable
# TODO: error message "no such alias"
return false; return false;
} }
if (is_mailbox_alias($address) ) { if ($this->is_mailbox_alias($this->username) ) { ### FIXME use different check, this one always returns true :-(
# TODO: error message "alias belongs to a mailbox and can't be deleted" ### 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; return false;
} }
$result = db_delete('alias', 'address', $address); $result = db_delete('alias', 'address', $this->username);
if( $result == 1 ) { 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; return true;
} }
} }

@ -189,10 +189,7 @@ class DeleteTask extends Shell {
} }
if (!empty($this->args[0])) { if (!empty($this->args[0])) {
$this->help(); $this->__handle($this->args[0]);
// $output = $this->__handle($this->args[0]);
// $this->out($output);
} }
} }
/** /**
@ -259,7 +256,6 @@ class DeleteTask extends Shell {
} }
} }
### PasswordTask was a rest of Copy Paste :D Deleted. Check it!
class ViewTask extends Shell { class ViewTask extends Shell {
/** /**
* Execution method always used for tasks * Execution method always used for tasks

Loading…
Cancel
Save