SF.net SVN: postfixadmin:[1357] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2012-04-09 01:06:59
|
Revision: 1357 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1357&view=rev Author: christian_boltz Date: 2012-04-09 01:06:52 +0000 (Mon, 09 Apr 2012) Log Message: ----------- 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! Modified Paths: -------------- trunk/model/AliasHandler.php trunk/scripts/shells/alias.php trunk/users/edit-alias.php trunk/xmlrpc.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2012-04-09 00:34:26 UTC (rev 1356) +++ trunk/model/AliasHandler.php 2012-04-09 01:06:52 UTC (rev 1357) @@ -296,45 +296,6 @@ 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 $username @@ -461,19 +422,6 @@ 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. */ Modified: trunk/scripts/shells/alias.php =================================================================== --- trunk/scripts/shells/alias.php 2012-04-09 00:34:26 UTC (rev 1356) +++ trunk/scripts/shells/alias.php 2012-04-09 01:06:52 UTC (rev 1357) @@ -300,30 +300,25 @@ $handler = new AliasHandler(); $handler->init($address); - $status = $handler->get(); # TODO: set the "all" flag? - if ( ! $status) { + if ( ! $handler->view() ) { $this->error("Error: Not Found", "The requested alias was not found!"); } else { $result = $handler->return; $this->out(sprintf("Entries for: %s\n", $address)); $this->out("Goto: \t"); - foreach($result AS $goto) { + foreach($result['goto'] AS $goto) { $this->out("\t -> ".$goto); } - # TODO: display "deliver to mailbox" - ##NEED fix in is_mailbox_alias because user is not set correctly in this scenario! - /** - if( $handler->is_mailbox_alias($address) ) + if( $result['is_mailbox'] ) { $this->out("A mailbox was set for this alias!\n"); - } - */ - # TODO: display if vacation is on? - /** - if( $handler->is_vacation_address($address) ) { + } + if( $result['goto_mailbox'] ) { + $this->out("The alias delivers to the mailbox!\n"); + } + if( $result['on_vacation'] ) { $this->out("This alias is a vacation address!"); - } - */ + } } return; Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2012-04-09 00:34:26 UTC (rev 1356) +++ trunk/users/edit-alias.php 2012-04-09 01:06:52 UTC (rev 1357) @@ -17,15 +17,6 @@ * * Template File: users_edit-alias.tpl * - * Template Variables: - * - * tGotoArray - * tStoreAndForward - * - * Form POST \ GET Variables: - * - * fAddress - * fGoto */ require_once('../common.php'); @@ -40,9 +31,10 @@ $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 -$tGotoArray = $ah->result(); -$tStoreAndForward = $ah->hasStoreAndForward(); +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 +$result = $ah->result(); +$tGotoArray = $result['goto']; +$tStoreAndForward = $result['goto_mailbox']; if ($_SERVER['REQUEST_METHOD'] == "GET") { Modified: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php 2012-04-09 00:34:26 UTC (rev 1356) +++ trunk/xmlrpc.php 2012-04-09 01:06:52 UTC (rev 1357) @@ -142,8 +142,9 @@ $ah = new AliasHandler(); $ah->init($_SESSION['username']); /* I see no point in returning special addresses to the user. */ - $ah->get(false); - return $ah->result; + $ah->view(); + $result = $ah->result; + return $result['goto']; } /** @@ -168,7 +169,9 @@ public function hasStoreAndForward() { $ah = new AliasHandler(); $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: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |