@ -42,7 +42,7 @@ class AliasHandler extends PFAHandler {
/*options*/ '',
/*options*/ '',
/*not_in_db*/ 0,
/*not_in_db*/ 0,
/*dont_write_to_db*/ 1,
/*dont_write_to_db*/ 1,
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox, __mailbox_username ',
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox',
# __mailbox_username is unused, but needed as workaround for a MariaDB bug
# __mailbox_username is unused, but needed as workaround for a MariaDB bug
/*extrafrom*/ 'LEFT JOIN ( ' .
/*extrafrom*/ 'LEFT JOIN ( ' .
' SELECT 1 as __is_mailbox, username as __mailbox_username ' .
' SELECT 1 as __is_mailbox, username as __mailbox_username ' .
@ -50,6 +50,7 @@ class AliasHandler extends PFAHandler {
' WHERE username IS NOT NULL ' .
' WHERE username IS NOT NULL ' .
' AND ' . db_in_clause($this->domain_field, $this->allowed_domains) .
' AND ' . db_in_clause($this->domain_field, $this->allowed_domains) .
' ) AS __mailbox ON __mailbox_username = address' ),
' ) AS __mailbox ON __mailbox_username = address' ),
'__mailbox_username' => pacol( 0, 0, 1, 'vtxt', '' , '' , 0), # filled via is_mailbox
'goto_mailbox' => pacol( $mbgoto, $mbgoto,$mbgoto,'bool', 'pEdit_alias_forward_and_store' , '' , 0,
'goto_mailbox' => pacol( $mbgoto, $mbgoto,$mbgoto,'bool', 'pEdit_alias_forward_and_store' , '' , 0,
/*options*/ '',
/*options*/ '',
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value
@ -304,22 +305,28 @@ class AliasHandler extends PFAHandler {
return $db_result;
return $db_result;
}
}
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1 ) {
private function condition_ignore_mailboxes($condition, $searchmode ) {
# only list aliases that do not belong to mailboxes
# only list aliases that do not belong to mailboxes
# TODO: breaks if $condition is an array
if (is_array($condition)) {
if ($condition != '') {
$condition['__mailbox_username'] = 1;
$condition = " AND ( $condition ) ";
$searchmode['__mailbox_username'] = 'NULL';
} else {
if ($condition != '') {
$condition = " ( $condition ) AND ";
}
$condition = " $condition __mailbox_username IS NULL ";
}
}
return parent::getList( "__mailbox_username IS NULL $condition", $searchmode, $limit, $offset);
return array($condition, $searchmode);
}
public function getList($condition, $searchmode = array(), $limit=-1, $offset=-1) {
list($condition, $searchmode) = $this->condition_ignore_mailboxes($condition, $searchmode);
return parent::getList($condition, $searchmode, $limit, $offset);
}
}
public function getPagebrowser($condition, $searchmode = array()) {
public function getPagebrowser($condition, $searchmode = array()) {
# only list aliases that do not belong to mailboxes
list($condition, $searchmode) = $this->condition_ignore_mailboxes($condition, $searchmode);
# TODO: breaks if $condition is an array
return parent::getPagebrowser($condition, $searchmode);
if ($condition != '') {
$condition = " AND ( $condition ) ";
}
return parent::getPagebrowser( "__mailbox_username IS NULL $condition", $searchmode);
}
}