AliasHandler:

- remove deprecated functions get() and hasStoreAndForward()

scripts/shells/alias.php:
- ViewTask: switch to *Handler syntax
- ViewTask: display is_mailbox, goto_mailbox and on_vacation status

users/edit-alias.php:
- replace $ah->get() and $ah->hasStoreAndForward() with *Handler syntax
- remove outdated comment in header

xmlrpc.php:
- switch get() and hasStoreAndForward() to *Handler syntax

Note: the changes in xmlrpc.php are untested!


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1357 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 14 years ago
parent e4d5d4574e
commit fff6654634

@ -296,45 +296,6 @@ class AliasHandler extends PFAHandler {
They still work, but are deprecated and will be removed. They still work, but are deprecated and will be removed.
**********************************************************************************************************************************************************/ **********************************************************************************************************************************************************/
/**
* @return bool true if succeed
* (may be an empty list, especially if $CONF['alias_control'] is turned off...)
* @param boolean - by default we don't return special addresses (e.g. vacation and mailbox alias); pass in true here if you wish to.
*/
public function get($all=false) {
$E_username = escape_string($this->id);
$table_alias = table_by_key('alias');
$sql = "SELECT * FROM $table_alias WHERE address='$E_username'";
$result = db_query($sql);
if($result['rows'] != 1) {
return false;
}
$row = db_array ($result['result']);
// At the moment Postfixadmin stores aliases in it's database in a comma seperated list; this may change one day.
$list = explode(',', $row['goto']);
if($all) {
$this->return = $list;
return true;
}
$filtered_list = array();
/* if !$all, remove vacation & mailbox aliases */
foreach($list as $address) {
if($address != '' ) {
if($this->is_vacation_address($address) || $this->is_mailbox_alias($address)) {
# TODO: store "vacation_active" and "mailbox" status - should be readable public
}
else {
$filtered_list[] = $address;
}
}
}
$this->return = $filtered_list;
return true;
}
/** /**
* @param string $address * @param string $address
* @param string $username * @param string $username
@ -461,19 +422,6 @@ class AliasHandler extends PFAHandler {
return true; return true;
} }
/**
* Determine whether a local delivery address is present. This is
* stores as an alias with the same name as the mailbox name (username)
* @return boolean true if local delivery is enabled
*/
public function hasStoreAndForward() {
$result = $this->get(true); # TODO: error checking?
if(in_array($this->id, $this->return)) {
return true;
}
return false;
}
/** /**
* @return boolean true if the user has an alias record (i.e row in alias table); else false. * @return boolean true if the user has an alias record (i.e row in alias table); else false.
*/ */

@ -300,30 +300,25 @@ class ViewTask extends Shell {
$handler = new AliasHandler(); $handler = new AliasHandler();
$handler->init($address); $handler->init($address);
$status = $handler->get(); # TODO: set the "all" flag? if ( ! $handler->view() ) {
if ( ! $status) {
$this->error("Error: Not Found", "The requested alias was not found!"); $this->error("Error: Not Found", "The requested alias was not found!");
} else { } else {
$result = $handler->return; $result = $handler->return;
$this->out(sprintf("Entries for: %s\n", $address)); $this->out(sprintf("Entries for: %s\n", $address));
$this->out("Goto: \t"); $this->out("Goto: \t");
foreach($result AS $goto) { foreach($result['goto'] AS $goto) {
$this->out("\t -> ".$goto); $this->out("\t -> ".$goto);
} }
# TODO: display "deliver to mailbox" if( $result['is_mailbox'] ) {
##NEED fix in is_mailbox_alias because user is not set correctly in this scenario!
/**
if( $handler->is_mailbox_alias($address) )
$this->out("A mailbox was set for this alias!\n"); $this->out("A mailbox was set for this alias!\n");
} }
*/ if( $result['goto_mailbox'] ) {
# TODO: display if vacation is on? $this->out("The alias delivers to the mailbox!\n");
/** }
if( $handler->is_vacation_address($address) ) { if( $result['on_vacation'] ) {
$this->out("This alias is a vacation address!"); $this->out("This alias is a vacation address!");
} }
*/
} }
return; return;

@ -17,15 +17,6 @@
* *
* Template File: users_edit-alias.tpl * Template File: users_edit-alias.tpl
* *
* Template Variables:
*
* tGotoArray
* tStoreAndForward
*
* Form POST \ GET Variables:
*
* fAddress
* fGoto
*/ */
require_once('../common.php'); require_once('../common.php');
@ -40,9 +31,10 @@ $ah->init($USERID_USERNAME);
$smarty->assign ('USERID_USERNAME', $USERID_USERNAME); $smarty->assign ('USERID_USERNAME', $USERID_USERNAME);
if ( ! $ah->get() ) die("Can't get alias details. Invalid alias?"); # this can only happen if a admin deleted the user since the user logged in if ( ! $ah->view() ) die("Can't get alias details. Invalid alias?"); # this can only happen if a admin deleted the user since the user logged in
$tGotoArray = $ah->result(); $result = $ah->result();
$tStoreAndForward = $ah->hasStoreAndForward(); $tGotoArray = $result['goto'];
$tStoreAndForward = $result['goto_mailbox'];
if ($_SERVER['REQUEST_METHOD'] == "GET") if ($_SERVER['REQUEST_METHOD'] == "GET")
{ {

@ -142,8 +142,9 @@ class AliasProxy {
$ah = new AliasHandler(); $ah = new AliasHandler();
$ah->init($_SESSION['username']); $ah->init($_SESSION['username']);
/* I see no point in returning special addresses to the user. */ /* I see no point in returning special addresses to the user. */
$ah->get(false); $ah->view();
return $ah->result; $result = $ah->result;
return $result['goto'];
} }
/** /**
@ -168,7 +169,9 @@ class AliasProxy {
public function hasStoreAndForward() { public function hasStoreAndForward() {
$ah = new AliasHandler(); $ah = new AliasHandler();
$ah->init($_SESSION['username']); $ah->init($_SESSION['username']);
return $ah->hasStoreAndForward(); $ah->view();
$result = $ah->result;
return $result['goto_mailbox'] == 1;
} }
} }
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */

Loading…
Cancel
Save