AliasHandler:

- setmore(): keep/(re-)add vacation and mailbox alias to goto
- hide 'goto_mailbox' if the alias does not belong to a mailbox
  (done in initStruct for $new, otherwise in init())

edit.php:
- set $form_fields and $id_field later (after $hander->init()) - needed
  for AliasHandler to decide if goto_mailbox should be displayed

With this commit, AliasHandler is feature-complete for usage with 
edit.php. We even get a "deliver to local mailbox" checkbox :-)


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1348 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent e66bb02b84
commit 9b2da37d84

@ -47,9 +47,6 @@ $formconf = $handler->webformConfig();
authentication_require_role($formconf['required_role']);
$form_fields = $handler->getStruct();
$id_field = $handler->getId_field();
if ($active != '0' && $active != '1') {
$active = ''; # ignore invalid values
}
@ -62,6 +59,9 @@ if ($edit != '' || $active != '' || $formconf['early_init']) {
}
}
$form_fields = $handler->getStruct();
$id_field = $handler->getId_field();
if ($edit != "") {
$mode = 'edit';
if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { # read values from database (except if $active is set to save some CPU cycles)

@ -20,6 +20,8 @@ class AliasHandler extends PFAHandler {
$this->db_table = 'alias';
$this->id_field = 'address';
$mbgoto = 1 - $this->new;
$this->struct=array(
# field name allow display in... type $PALANG label $PALANG description default / ...
# editing? form list
@ -42,7 +44,7 @@ class AliasHandler extends PFAHandler {
' FROM ' . table_by_key('mailbox') .
' WHERE username IS NOT NULL ' .
' ) AS __mailbox ON __mailbox_username = address' ),
'goto_mailbox' => pacol( 1, 1, 1, 'bool', 'pEdit_alias_forward_and_store' , '' , 0,
'goto_mailbox' => pacol( $mbgoto, $mbgoto,$mbgoto,'bool', 'pEdit_alias_forward_and_store' , '' , 0,
/*options*/ '',
/*not_in_db*/ 1 ),
'on_vacation' => pacol( 1, 0, 1, 'bool', 'pUsersMenu_vacation' , '' , 0 ,
@ -96,7 +98,18 @@ class AliasHandler extends PFAHandler {
$id = '@' . $domain;
}
return parent::init($id);
$retval = parent::init($id);
# hide 'goto_mailbox' for non-mailbox aliases
# parent::init called view() before, so we can rely on having $this->return filled
# (only validate_new_id() is called from parent::init and could in theory change $this->return)
if ($this->new || $this->return['is_mailbox'] == 0) {
$this->struct['goto_mailbox']['editable'] = 0;
$this->struct['goto_mailbox']['display_in_form'] = 0;
$this->struct['goto_mailbox']['display_in_list'] = 0;
}
return $retval;
}
protected function validate_new_id() {
@ -164,6 +177,32 @@ class AliasHandler extends PFAHandler {
}
}
if (! $this->new) { # edit mode - preserve vacation and mailbox alias if they were included before
$old_ah = new AliasHandler();
if (!$old_ah->init($this->id)) {
$this->errormsg[] = $old_ah->errormsg[0];
} elseif (!$old_ah->view()) {
$this->errormsg[] = $old_ah->errormsg[0];
} else {
$oldvalues = $old_ah->result();
if ($oldvalues['on_vacation']) {
$vh = new VacationHandler($this->id);
$values['goto'][] = $vh->getVacationAlias();
}
if ($oldvalues['is_mailbox']) { # alias belongs to a mailbox - add/keep mailbox to/in goto
if (!isset($values['goto_mailbox'])) { # no new value given?
$values['goto_mailbox'] = $oldvalues['goto_mailbox'];
}
if ($values['goto_mailbox']) {
$values['goto'][] = $this->id;
}
}
}
}
$this->values['goto'] = join(',', $values['goto']); # TODO: add mailbox and vacation aliases
}

Loading…
Cancel
Save