Thread: SF.net SVN: postfixadmin:[1303] trunk (Page 8)
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-12-20 23:07:40
|
Revision: 1303 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1303&view=rev Author: christian_boltz Date: 2011-12-20 23:07:34 +0000 (Tue, 20 Dec 2011) Log Message: ----------- Make $struct in the *Handler classes customizeable config.inc.php: - add $CONF['*_struct_hook'] to modify $struct in the *Handler classes PFAHandler.php: - call $CONF['*_struct_hook'] hook AdminHandler.php, AliasdomainHandler.php, DomainHandler.php: - remove now outdated TODO notes Modified Paths: -------------- trunk/config.inc.php trunk/model/AdminHandler.php trunk/model/AliasdomainHandler.php trunk/model/DomainHandler.php trunk/model/PFAHandler.php Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/config.inc.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -230,7 +230,45 @@ } */ +/* + *_struct_hook - change, add or remove fields + If you need additional fields or want to change or remove existing fields, + you can write a hook function to modify $struct in the *Handler classes. + + The edit form will automatically be updated according to the modified + $struct. The list page is not yet updated automatically. + + You can define one hook function per class, named like the primary database + table of that class. + The hook function is called with $struct as parameter and must return the + modified $struct. + + Note: Adding a field to $struct adds the handling of this field in + PostfixAdmin, but it does not create it in the database. You have to do + that yourself. + Please follow the naming policy for custom database fields and tables on + http://sourceforge.net/apps/mediawiki/postfixadmin/index.php?title=Custom_fields + to avoid clashes with future versions of PostfixAdmin. + + See initStruct() in the *Handler class for the default $struct. + See pacol() in functions.inc.php for the available flags on each column. + + Example: + + function x_struct_admin_modify($struct) { + $struct['superadmin']['editable'] = 0; # make the 'superadmin' flag read-only + $struct['superadmin']['display_in_form'] = 0; # don't display the 'superadmin' flag in edit form + $struct['x_newfield'] = pacol( [...] ); # additional field 'x_newfield' + return $struct; # important! + } + $CONF['admin_struct_hook'] = 'x_struct_admin_modify'; +*/ +$CONF['admin_struct_hook'] = ''; +$CONF['domain_struct_hook'] = ''; +$CONF['alias_domain_struct_hook'] = ''; + + // Default Domain Values // Specify your default values below. Quota in MB. $CONF['aliases'] = '10'; Modified: trunk/model/AdminHandler.php =================================================================== --- trunk/model/AdminHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/AdminHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -81,8 +81,6 @@ 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), # obsoletes pAdminList_admin_modified ); - - # TODO: hook to modify $this->struct } # messages used in various functions. Modified: trunk/model/AliasdomainHandler.php =================================================================== --- trunk/model/AliasdomainHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/AliasdomainHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -49,8 +49,6 @@ $keys = array_keys($this->struct['alias_domain']['options']); unset ($this->struct['target_domain']['options'][$keys[0]]); } - - # TODO: hook to modify $this->struct } public function init($id) { Modified: trunk/model/DomainHandler.php =================================================================== --- trunk/model/DomainHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/DomainHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -76,8 +76,6 @@ 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), ); - - # TODO: hook to modify $this->struct } # messages used in various functions. Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2011-12-20 16:46:08 UTC (rev 1302) +++ trunk/model/PFAHandler.php 2011-12-20 23:07:34 UTC (rev 1303) @@ -40,6 +40,12 @@ } $this->initStruct(); + + $struct_hook = Config::read($this->db_table . '_struct_hook'); + if ( $struct_hook != 'NO' && function_exists($struct_hook) ) { + $this->struct = $struct_hook($this->struct); + } + $this->initMsg(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-12-26 16:02:20
|
Revision: 1306 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1306&view=rev Author: christian_boltz Date: 2011-12-26 16:02:14 +0000 (Mon, 26 Dec 2011) Log Message: ----------- adminlistdomain.tpl: - use edit.php to switch active status for domains - display backupmx and active status as yes/no instead of 1/0 edit-active-domain.php - deleted, obsoleted by using edit.php configs/menu.conf - remove now superfluous url_edit_active_domain Modified Paths: -------------- trunk/configs/menu.conf trunk/templates/adminlistdomain.tpl Removed Paths: ------------- trunk/edit-active-domain.php Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2011-12-26 15:56:11 UTC (rev 1305) +++ trunk/configs/menu.conf 2011-12-26 16:02:14 UTC (rev 1306) @@ -45,6 +45,3 @@ [adminlistadmin] url_edit_active_admin = edit-active-admin.php url_edit_admin = edit.php?table=admin - -[adminlistdomain] -url_edit_active_domain = edit-active-domain.php Deleted: trunk/edit-active-domain.php =================================================================== --- trunk/edit-active-domain.php 2011-12-26 15:56:11 UTC (rev 1305) +++ trunk/edit-active-domain.php 2011-12-26 16:02:14 UTC (rev 1306) @@ -1,58 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * File: edit-active-domain.php - * Responsible for toggling the status of a domain - * Template File: message.tpl - * - * Template Variables: - * - * none - * - * Form POST \ GET Variables: - * - * fDomain - */ - -require_once('common.php'); - -authentication_require_role('global-admin'); - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - - $sqlSet='active=1-active'; - if ('pgsql'==$CONF['database_type']) $sqlSet='active=NOT active'; - - $result = db_query ("UPDATE $table_domain SET $sqlSet,modified=NOW() WHERE domain='$fDomain'"); - if ($result['rows'] != 1) - { - $error = 1; - flash_error($PALANG['pAdminEdit_domain_result_error']); - } - - if ($error != 1) - { - header ("Location: list-domain.php"); - exit; - } -} - -$smarty->assign ('smarty_template', 'message'); -$smarty->display ('index.tpl'); - - -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?> Modified: trunk/templates/adminlistdomain.tpl =================================================================== --- trunk/templates/adminlistdomain.tpl 2011-12-26 15:56:11 UTC (rev 1305) +++ trunk/templates/adminlistdomain.tpl 2011-12-26 16:02:14 UTC (rev 1306) @@ -31,9 +31,9 @@ {if $CONF.quota==YES}<td>{$domain.maxquota}</td>{/if} {if $CONF.domain_quota===YES}<td>{$domain.total_quota} / {$domain.quota}</td>{/if} {if $CONF.transport==YES}<td>{$domain.transport}</td>{/if} - <td>{$domain.backupmx}</td> + <td>{$domain._backupmx}</td> <td>{$domain.modified}</td> - <td><a href="{#url_edit_active_domain#}?domain={$domain.domain|escape:"url"}">{$domain.active}</a></td> + <td><a href="{#url_edit_domain#}&edit={$domain.domain|escape:"url"}&active={if ($domain.active==0)}1{else}0{/if}">{$domain._active}</a></td> <td><a href="{#url_edit_domain#}&edit={$domain.domain|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="{#url_delete#}?table=domain&delete={$domain.domain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm_domain}{$PALANG.pAdminList_admin_domain}: {$domain.domain}')">{$PALANG.del}</a></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-12-26 16:08:30
|
Revision: 1307 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1307&view=rev Author: christian_boltz Date: 2011-12-26 16:08:24 +0000 (Mon, 26 Dec 2011) Log Message: ----------- adminlistadmin.tpl: - use edit.php to switch active status for domains edit-active-admin.php: - deleted, obsoleted by using edit.php configs/menu.conf: - remove now superfluous url_edit_active_admin Modified Paths: -------------- trunk/configs/menu.conf trunk/templates/adminlistadmin.tpl Removed Paths: ------------- trunk/edit-active-admin.php Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2011-12-26 16:02:14 UTC (rev 1306) +++ trunk/configs/menu.conf 2011-12-26 16:08:24 UTC (rev 1307) @@ -43,5 +43,4 @@ form_search = <form name="search" method="post" action="list-virtual.php"><input name="search" size="10" /></form> [adminlistadmin] -url_edit_active_admin = edit-active-admin.php url_edit_admin = edit.php?table=admin Deleted: trunk/edit-active-admin.php =================================================================== --- trunk/edit-active-admin.php 2011-12-26 16:02:14 UTC (rev 1306) +++ trunk/edit-active-admin.php 2011-12-26 16:08:24 UTC (rev 1307) @@ -1,59 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * File: edit-active-admin.php - * Edit an active administrator. This is used as a 'toggle' page from list-admin. - * - * Template File: message.tpl - * - * Template Variables: - * - * none - * - * Form POST \ GET Variables: - * - * fUsername - */ - -require_once('common.php'); - -authentication_require_role('global-admin'); - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']); - - $sqlSet='active=1-active'; - if ('pgsql'==$CONF['database_type']) $sqlSet='active=NOT active'; - - $result = db_query ("UPDATE $table_admin SET $sqlSet,modified=NOW() WHERE username='$fUsername'"); - if ($result['rows'] != 1) - { - $error = 1; - flash_error($PALANG['pAdminEdit_admin_result_error']); - } - - if ($error != 1) - { - header ("Location: list-admin.php"); - exit; - } -} -$smarty->assign ('smarty_template', 'message'); -$smarty->display ('index.tpl'); - - -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ - -?> Modified: trunk/templates/adminlistadmin.tpl =================================================================== --- trunk/templates/adminlistadmin.tpl 2011-12-26 16:02:14 UTC (rev 1306) +++ trunk/templates/adminlistadmin.tpl 2011-12-26 16:08:24 UTC (rev 1307) @@ -18,7 +18,7 @@ {/if} </td> <td>{$admin.modified}</td> - <td><a href="{#url_edit_active_admin#}&edit={$admin.username|escape:"url"}">{$admin._active}</a></td> + <td><a href="{#url_edit_admin#}&edit={$admin.username|escape:"url"}&active={if ($admin.active==0)}1{else}0{/if}">{$admin._active}</a></td> <td><a href="{#url_edit_admin#}&edit={$admin.username|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="{#url_delete#}?table=admin&delete={$admin.username|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pAdminList_admin_username}: {$admin.username}');">{$PALANG.del}</a></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-12-26 16:26:36
|
Revision: 1308 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1308&view=rev Author: christian_boltz Date: 2011-12-26 16:26:30 +0000 (Mon, 26 Dec 2011) Log Message: ----------- list-virtual_alias_domain.tpl: - use edit.php to switch active status for alias domains edit-active.php: - remove now superfluous handling of alias domains configs/menu.conf: - remove now superfluous url_edit_active (templates for list-mailbox and list-alias use hardcoded 'edit-active.php') Modified Paths: -------------- trunk/configs/menu.conf trunk/edit-active.php trunk/templates/list-virtual_alias_domain.tpl Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2011-12-26 16:08:24 UTC (rev 1307) +++ trunk/configs/menu.conf 2011-12-26 16:26:30 UTC (rev 1308) @@ -33,8 +33,6 @@ url_user_logout = logout.php -url_edit_active = edit-active.php - tr_header = <tr class="header"> tr_hilightoff = <tr class="hilightoff" onmouseover="className='hilighton';" onmouseout="className='hilightoff';"> Modified: trunk/edit-active.php =================================================================== --- trunk/edit-active.php 2011-12-26 16:08:24 UTC (rev 1307) +++ trunk/edit-active.php 2011-12-26 16:26:30 UTC (rev 1308) @@ -32,7 +32,6 @@ authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); -$fAliasDomain = ''; $fUsername = ''; $fAlias = ''; $fDomain = ''; @@ -40,7 +39,6 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { - if (isset ($_GET['alias_domain'])) $fAliasDomain = escape_string ($_GET['alias_domain']); if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']); if (isset ($_GET['alias'])) $fAlias = escape_string ($_GET['alias']); else $fAlias = escape_string ($_GET['username']); if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); @@ -81,19 +79,6 @@ db_log ($fDomain, 'edit_alias_state', $fAlias); } } - if ($fAliasDomain != '') - { - $result = db_query ("UPDATE $table_alias_domain SET $setSql WHERE alias_domain='$fDomain'"); - if ($result['rows'] != 1) - { - $error = 1; - flash_error($PALANG['pEdit_alias_domain_result_error']); - } - else - { - db_log ($fDomain, 'edit_alias_domain_state', $fDomain); - } - } } if ($error != 1) Modified: trunk/templates/list-virtual_alias_domain.tpl =================================================================== --- trunk/templates/list-virtual_alias_domain.tpl 2011-12-26 16:08:24 UTC (rev 1307) +++ trunk/templates/list-virtual_alias_domain.tpl 2011-12-26 16:26:30 UTC (rev 1308) @@ -30,7 +30,7 @@ {/if} {if $item.target_domain != $fDomain}</a>{/if}</td> <td>{$item.modified}</td> - <td><a href="{#url_edit_active#}?alias_domain=true&domain={$item.alias_domain|escape:"url"}&return={$smarty.config.url_list_virtual|escape:"url"}?domain={$fDomain|escape:"url"}&limit={$current_limit|escape:"url"}">{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td> + <td><a href="{#url_create_alias_domain#}&edit={$item.alias_domain|escape:"url"}&active={if ($item.active==0)}1{else}0{/if}">{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td> <td><a href="{#url_create_alias_domain#}&edit={$item.alias_domain|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="{#url_delete#}?table=alias_domain&delete={$item.alias_domain|escape:"url"}&domain={$item.alias_domain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_alias_domains}: {$item.alias_domain}');">{$PALANG.del}</a></td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-12-26 20:54:47
|
Revision: 1310 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1310&view=rev Author: christian_boltz Date: 2011-12-26 20:54:40 +0000 (Mon, 26 Dec 2011) Log Message: ----------- AliasHandler.php: - add initStruct() (not the final version, but works for now) - add initMsg() - replace $this->username with $this->id everywhere - drop __construct() - default __construct will be used now users/edit-alias.php, xmlrpc.php, VacationHandler.php, scripts/shells/alias.php: - use default init sequence for AliasHandler (new, then ->init()) Modified Paths: -------------- trunk/model/AliasHandler.php trunk/model/VacationHandler.php trunk/scripts/shells/alias.php trunk/users/edit-alias.php trunk/xmlrpc.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2011-12-26 18:27:25 UTC (rev 1309) +++ trunk/model/AliasHandler.php 2011-12-26 20:54:40 UTC (rev 1310) @@ -16,20 +16,43 @@ */ public $return = null; - /** - * @param string $username - */ - public function __construct($username) { - $this->username = strtolower($username); + protected function initStruct() { + $this->db_table = 'alias'; + $this->id_field = 'address'; + + $this->struct=array( + # field name allow display in... type $PALANG label $PALANG description default / options / ... + # editing? form list + 'address' => pacol( $this->new, 1, 1, 'mail', 'pCreate_alias_domain_alias' , 'pCreate_alias_domain_alias_text' ), + 'goto' => pacol( 1, 1, 1, 'mail', 'pCreate_alias_domain_target' , 'pCreate_alias_domain_target_text' ), + 'domain' => pacol( $this->new, 0, 0, 'text', '' , '' ), + 'active' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_active' , '' , 1 ), + 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), + 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), + ); } + protected function initMsg() { + $this->msg['error_already_exists'] = 'pCreate_alias_address_text_error2'; + $this->msg['error_does_not_exist'] = 'pCreate_alias_address_text_error1'; # TODO: better error message + if ($this->new) { + $this->msg['logname'] = 'create_alias'; + $this->msg['store_error'] = 'pCreate_alias_result_error'; + } else { + $this->msg['logname'] = 'edit_alias'; + $this->msg['store_error'] = 'pEdit_alias_result_error'; + } + } + + + /** * @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->username); + $E_username = escape_string($this->id); $table_alias = table_by_key('alias'); $sql = "SELECT * FROM $table_alias WHERE address='$E_username'"; @@ -71,7 +94,7 @@ public function is_mailbox_alias($address) { global $CONF; - if($address != $this->username) { # avoid false positives if $address is a mailbox + if($address != $this->id) { # avoid false positives if $address is a mailbox return false; } @@ -120,7 +143,7 @@ } $addresses = array_unique($addresses); - list (/*NULL*/, $domain) = explode('@', $this->username); + list (/*NULL*/, $domain) = explode('@', $this->id); if ( ! $this->get(true) ) die("Alias not existing?"); # TODO: better error behaviour @@ -142,7 +165,7 @@ if($flags == 'remote_only') { foreach($addresses as $address) { # TODO: write a remove_from_array function, see http://tech.petegraham.co.uk/2007/03/22/php-remove-values-from-array/ // strip out our username... if it's in the list given. - if($address != $this->username) { + if($address != $this->id) { $new_list[] = $address; } } @@ -150,8 +173,8 @@ } if($flags == 'forward_and_store') { - if(!in_array($this->username, $addresses)) { - $addresses[] = $this->username; + if(!in_array($this->id, $addresses)) { + $addresses[] = $this->id; } } $new_list = array(); @@ -161,15 +184,15 @@ } } $addresses = array_unique($new_list); - $E_username = escape_string($this->username); + $E_username = escape_string($this->id); $goto = implode(',', $addresses); if(sizeof($addresses) == 0) { - # $result = db_delete('alias', 'address', $this->username); # '"DELETE FROM $table_alias WHERE address = '$username'"; # TODO: should never happen and causes broken behaviour - error_log("Alias set to empty / Attemp to delete: " . $this->username); # TODO: more/better error handling - maybe just return false? + # $result = db_delete('alias', 'address', $this->id); # '"DELETE FROM $table_alias WHERE address = '$username'"; # TODO: should never happen and causes broken behaviour + error_log("Alias set to empty / Attemp to delete: " . $this->id); # TODO: more/better error handling - maybe just return false? } if($this->hasAliasRecord() == false) { # TODO should never happen in update() - see also the comments on handling DELETE above $alias_data = array( - 'address' => $this->username, + 'address' => $this->id, 'goto' => $goto, 'domain' => $domain, 'active' => db_get_boolean(True), @@ -179,7 +202,7 @@ $alias_data = array( 'goto' => $goto, ); - $result = db_update('alias', 'address', $this->username, $alias_data); + $result = db_update('alias', 'address', $this->id, $alias_data); } if($result != 1) { return false; @@ -195,7 +218,7 @@ */ public function hasStoreAndForward() { $result = $this->get(true); # TODO: error checking? - if(in_array($this->username, $this->return)) { + if(in_array($this->id, $this->return)) { return true; } return false; @@ -205,7 +228,7 @@ * @return boolean true if the user has an alias record (i.e row in alias table); else false. */ public function hasAliasRecord() { - $username = escape_string($this->username); + $username = escape_string($this->id); $table_alias = table_by_key('alias'); $sql = "SELECT * FROM $table_alias WHERE address = '$username'"; $result = db_query($sql); @@ -224,15 +247,15 @@ return false; } - if ($this->is_mailbox_alias($this->username) ) { + if ($this->is_mailbox_alias($this->id) ) { $this->errormsg[] = 'This alias belongs to a mailbox and can\'t be deleted.'; # TODO: make translatable return false; } - $result = db_delete('alias', 'address', $this->username); + $result = db_delete('alias', 'address', $this->id); if( $result == 1 ) { - list(/*NULL*/,$domain) = explode('@', $this->username); - db_log ($domain, 'delete_alias', $this->username); + list(/*NULL*/,$domain) = explode('@', $this->id); + db_log ($domain, 'delete_alias', $this->id); return true; } } Modified: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php 2011-12-26 18:27:25 UTC (rev 1309) +++ trunk/model/VacationHandler.php 2011-12-26 20:54:40 UTC (rev 1310) @@ -13,7 +13,8 @@ * @return boolean true on success. */ function remove() { - $ah = new AliasHandler($this->username); + $ah = new AliasHandler(); + $ah->init($this->username); $result = $ah->get(true); if($result === true) { // fetch all # TODO check $result, error handling $aliases = $ah->return; @@ -53,7 +54,8 @@ * Why do we bother storing true/false in the vacation table if the alias dictates it anyway? */ function check_vacation() { - $ah = new AliasHandler($this->username); + $ah = new AliasHandler(); + $ah->init($this->username); $success = $ah->get(true); # fetch all. if (!$success) { return false; # TODO: error handling? @@ -127,7 +129,8 @@ } # TODO error check # TODO wrap whole function in db_begin / db_commit (or rollback)? - $ah = new AliasHandler($this->username); + $ah = new AliasHandler(); + $ah->init($this->username); $alias = $ah->get(true); $aliases = $ah->return; $vacation_address = $this->getVacationAlias(); Modified: trunk/scripts/shells/alias.php =================================================================== --- trunk/scripts/shells/alias.php 2011-12-26 18:27:25 UTC (rev 1309) +++ trunk/scripts/shells/alias.php 2011-12-26 20:54:40 UTC (rev 1310) @@ -103,7 +103,8 @@ */ function __handle($address, $goto) { - $handler = new AliasHandler($address); + $handler = new AliasHandler(1); + $handler->init($address); $return = $handler->add($goto); if($return == 1) { @@ -227,7 +228,8 @@ ### (and will probably cause some error messages that I added today ;-) ### Implemented check it please! - $handler = new AliasHandler($address); + $handler = new AliasHandler(); + $handler->init($address); $status = $handler->delete(); if ($status == true) { $this->out("Mailbox of '$address' was deleted."); @@ -296,7 +298,8 @@ function __handle($address) { - $handler = new AliasHandler($address); + $handler = new AliasHandler(); + $handler->init($address); $status = $handler->get(); # TODO: set the "all" flag? if ( ! $status) { $this->error("Error: Not Found", "The requested alias was not found!"); @@ -343,3 +346,5 @@ } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2011-12-26 18:27:25 UTC (rev 1309) +++ trunk/users/edit-alias.php 2011-12-26 20:54:40 UTC (rev 1310) @@ -37,7 +37,9 @@ $tmp = preg_split ('/@/', $USERID_USERNAME); $USERID_DOMAIN = $tmp[1]; -$ah = new AliasHandler($USERID_USERNAME); +$ah = new AliasHandler(); +$ah->init($USERID_USERNAME); + $smarty->assign ('USERID_USERNAME', $USERID_USERNAME); Modified: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php 2011-12-26 18:27:25 UTC (rev 1309) +++ trunk/xmlrpc.php 2011-12-26 20:54:40 UTC (rev 1310) @@ -139,7 +139,8 @@ * @return array - array of aliases this user has. Array may be empty. */ public function get() { - $ah = new AliasHandler($_SESSION['username']); + $ah = new AliasHandler(); + $ah->init($_SESSION['username']); /* I see no point in returning special addresses to the user. */ $ah->get(false); return $ah->result; @@ -151,7 +152,8 @@ * @return boolean true */ public function update($addresses, $flags) { - $ah = new AliasHandler($_SESSION['username']); + $ah = new AliasHandler(); + $ah->init($_SESSION['username']); /** * if the user is on vacation, they should use VacationProxy stuff to remove it * and we'll never return the vacation address from here anyway @@ -164,7 +166,8 @@ * (i.e. their email address is also in the alias table). IF it returns false, then it's 'remote_only' */ public function hasStoreAndForward() { - $ah = new AliasHandler($_SESSION['username']); + $ah = new AliasHandler(); + $ah->init($_SESSION['username']); return $ah->hasStoreAndForward(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2011-12-27 18:13:38
|
Revision: 1311 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1311&view=rev Author: christian_boltz Date: 2011-12-27 18:13:32 +0000 (Tue, 27 Dec 2011) Log Message: ----------- AliasHandler now works with edit.php in many cases (TODO: catchall handling, mailbox and vacation aliases) AliasHandler.php - drop unused $username - set $domain_field - initStruct(): - use correct labels - set 'domain' field options to allowed domains - add (virtual) 'localpart' field - add comments for more virtual fields - add webformConfig() (note: modifies $struct on $new - otherwise we couldn't use the domain dropdown in the web interface) - add mergeId to merge localpart and domain to address (called by edit.php _before_ ->init) - add validate_new_id() (doesn't work for catchall yet) - add setmore() to - fill 'domain' based on 'address' - convert $values[goto] from array to comma-separated string - add read_from_db_postprocess to split goto to an array (TODO: handling of mailbox and vacation aliases) - add _field_goto() validator - add empty, commented dummy delete() that will replace the "old" delete function one day - make hasAliasRecord() private (only used internally) - mark all "old" functions as obsolete edit.php: - add handling of txtl field (convert textarea to array) - call $handler->mergeId if $id_field is editable, but not displayed in form (usecase: merge localpart + domain to address) editform.tpl: - add handling of txtl fields (textarea, filled by array) PFAHandler.php: - add setmore() hook function - runs at the end of set() AdminHandler.php: - add a comment for 'txtl' (array of one line texts, like alias goto) Modified Paths: -------------- trunk/edit.php trunk/model/AdminHandler.php trunk/model/AliasHandler.php trunk/model/PFAHandler.php trunk/templates/editform.tpl Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2011-12-26 20:54:40 UTC (rev 1310) +++ trunk/edit.php 2011-12-27 18:13:32 UTC (rev 1311) @@ -85,6 +85,19 @@ } else { if($field['type'] == 'bool') { $values[$key] = safepost($key, 0); # isset() for unchecked checkboxes is always false + } elseif($field['type'] == 'txtl') { + $values[$key] = safepost($key); + $values[$key] = preg_replace ('/\\\r\\\n/', ',', $values[$key]); + $values[$key] = preg_replace ('/\r\n/', ',', $values[$key]); + $values[$key] = preg_replace ('/,[\s]+/i', ',', $values[$key]); + $values[$key] = preg_replace ('/[\s]+,/i', ',', $values[$key]); + $values[$key] = preg_replace ('/,,*/', ',', $values[$key]); + $values[$key] = preg_replace ('/,*$|^,*/', '', $values[$key]); + if ($values[$key] == '') { + $values[$key] = array(); + } else { + $values[$key] = explode(",", $values[$key]); + } } else { $values[$key] = safepost($key); } @@ -99,6 +112,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST" || $active != '') { if ($edit != "") $values[$id_field] = $edit; + if ($new && ($form_fields[$id_field]['display_in_form'] == 0) && ($form_fields[$id_field]['editable'] == 1) ) { # address split to localpart and domain? + $values[$id_field] = $handler->mergeId($values); + } + if (!$handler->init($values[$id_field])) { $error = 1; $errormsg = $handler->errormsg; Modified: trunk/model/AdminHandler.php =================================================================== --- trunk/model/AdminHandler.php 2011-12-26 20:54:40 UTC (rev 1310) +++ trunk/model/AdminHandler.php 2011-12-27 18:13:32 UTC (rev 1311) @@ -30,6 +30,7 @@ # text one line of text # pass password (will be encrypted with pacrypt()) # num number + # txtl text "list" - array of one line texts # vnum "virtual" number, coming from JOINs etc. # bool boolean (converted to 0/1, additional column _$field with yes/no) # ts timestamp (created/modified) Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2011-12-26 20:54:40 UTC (rev 1310) +++ trunk/model/AliasHandler.php 2011-12-27 18:13:32 UTC (rev 1311) @@ -8,7 +8,7 @@ */ class AliasHandler extends PFAHandler { - private $username = null; + protected $domain_field = 'domain'; /** * @@ -21,14 +21,22 @@ $this->id_field = 'address'; $this->struct=array( - # field name allow display in... type $PALANG label $PALANG description default / options / ... + # field name allow display in... type $PALANG label $PALANG description default / ... # editing? form list - 'address' => pacol( $this->new, 1, 1, 'mail', 'pCreate_alias_domain_alias' , 'pCreate_alias_domain_alias_text' ), - 'goto' => pacol( 1, 1, 1, 'mail', 'pCreate_alias_domain_target' , 'pCreate_alias_domain_target_text' ), - 'domain' => pacol( $this->new, 0, 0, 'text', '' , '' ), - 'active' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_active' , '' , 1 ), - 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), - 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), + 'address' => pacol( $this->new, 1, 1, 'mail', 'pEdit_alias_address' , 'pCreate_alias_catchall_text' ), + 'localpart' => pacol( $this->new, 0, 0, 'text', 'pEdit_alias_address' , 'pCreate_alias_catchall_text' , '', + /*options*/ '', + /*not_in_db*/ 1 ), + 'domain' => pacol( $this->new, 0, 0, 'enum', '' , '' , '', + /*options*/ $this->allowed_domains ), + 'goto' => pacol( 1, 1, 1, 'txtl', 'pEdit_alias_goto' , 'pEdit_alias_help' ), +# target (forwardings) +# is_mailbox (alias belongs to mailbox) +# mailbox_target (is_mailbox and mailbox is (part of the) target +# vacation (active? 0/1) + 'active' => pacol( 1, 1, 1, 'bool', 'pAdminEdit_domain_active' , '' , 1 ), + 'created' => pacol( 0, 0, 1, 'ts', 'created' , '' ), + 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), ); } @@ -45,7 +53,98 @@ } + public function webformConfig() { + if ($this->new) { # the webform will display a localpart field + domain dropdown on $new + $this->struct['address']['display_in_form'] = 0; + $this->struct['localpart']['display_in_form'] = 1; + $this->struct['domain']['display_in_form'] = 1; + } + return array( + # $PALANG labels + 'formtitle_create' => 'pCreate_alias_welcome', + 'formtitle_edit' => 'pEdit_alias_welcome', + 'create_button' => 'pCreate_alias_button', + 'successmessage' => 'pCreate_alias_result_success', # TODO: better message for edit + + # various settings + 'required_role' => 'admin', + 'listview' => 'list-virtual.php', + 'early_init' => 0, + ); + } + + protected function validate_new_id() { + $valid = check_email($this->id); # TODO: check_email should return error message instead of using flash_error itsself + # TODO: handle catchall (input: *@domain, write to db: @domain (without *) + return $valid; + } + + /** + * merge localpart and domain to address + * called by edit.php (if id_field is editable and hidden in editform) _before_ ->init + */ + public function mergeId($values) { + if ($this->struct['localpart']['display_in_form'] == 1 && $this->struct['domain']['display_in_form']) { # webform mode - combine to 'address' field + if (empty($values['localpart']) || empty($values['domain']) ) { # localpart or domain not set + return ""; + } + if ($values['localpart'] == '*') $values['localpart'] = ''; # catchall + error_log("merged to: " . $values['localpart'] . '@' . $values['domain']); + return $values['localpart'] . '@' . $values['domain']; + } else { + return $values[$this->id_field]; + } + } + + protected function setmore($values) { + if ($this->new) { + if ($this->struct['address']['display_in_form'] == 1) { # default mode - split off 'domain' field from 'address' # TODO: do this unconditional? + list(/*NULL*/,$domain) = explode('@', $values['address']); + $this->values['domain'] = $domain; + } + } + + $this->values['goto'] = join(',', $values['goto']); # TODO: add mailbox and vacation aliases + } + + protected function read_from_db_postprocess($db_result) { + foreach ($db_result as $key => $value) { + $db_result[$key]['goto'] = explode(',', $db_result[$key]['goto']); + } +#print_r($db_result); exit; + return $db_result; + } + +/* delete is already implemented in the "old functions" section + public function delete() { + $this->errormsg[] = '*** Alias domain deletion not implemented yet ***'; + return false; # XXX function aborts here until TODO below is implemented! XXX + # TODO: move the needed code from delete.php here + } +*/ + + protected function _field_goto($field, $val) { + if (count($val) == 0) { + # TODO: empty is ok for mailboxes - mailbox alias is in a separate field + $this->errormsg[$field] = 'empty goto'; # TODO: better error message + return false; + } + + foreach ($val as $singlegoto) { + if (!check_email($singlegoto)) { + $this->errormsg[$field] .= "invalid: $singlegoto "; # TODO: better error message + } + } + + return false; + } + +/********************************************************************************************************************************************************** + old function from non-PFAHandler times of AliasHandler + 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...) @@ -227,7 +326,7 @@ /** * @return boolean true if the user has an alias record (i.e row in alias table); else false. */ - public function hasAliasRecord() { + private function hasAliasRecord() { # only used by update() in this class $username = escape_string($this->id); $table_alias = table_by_key('alias'); $sql = "SELECT * FROM $table_alias WHERE address = '$username'"; Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2011-12-26 20:54:40 UTC (rev 1310) +++ trunk/model/PFAHandler.php 2011-12-27 18:13:32 UTC (rev 1311) @@ -138,6 +138,8 @@ } } + $this->setmore($values); + if (count($this->errormsg) == 0) { $this->values_valid = true; } @@ -145,6 +147,15 @@ } /** + * set more values + * can be used to update additional columns etc. + * hint: modify $this->values and $this->errormsg directly as needed + */ + protected function setmore($values) { + # do nothing + } + + /** * store $this->values in the database * calls $this->storemore() where additional things can be done * @return bool - true if all values are valid, otherwise false Modified: trunk/templates/editform.tpl =================================================================== --- trunk/templates/editform.tpl 2011-12-26 20:54:40 UTC (rev 1310) +++ trunk/templates/editform.tpl 2011-12-27 18:13:32 UTC (rev 1311) @@ -39,6 +39,9 @@ --> {elseif $field.type == 'pass'} <input class="flat" type="password" name="{$key}" /> + {elseif $field.type == 'txtl'} + <textarea class="flat" rows="10" cols="35" name="{$key}">{foreach key=key2 item=field2 from=$value_{$key}}{$field2} +{/foreach}</textarea> {else} <input class="flat" type="text" name="{$key}" value="{$value_{$key}}" /> {/if} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-01-10 00:30:07
|
Revision: 1317 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1317&view=rev Author: christian_boltz Date: 2012-01-10 00:30:01 +0000 (Tue, 10 Jan 2012) Log Message: ----------- create-alias.php: - deleted, obsoleted by edit.php?table=alias functions.inc.php: - drop function check_alias() - it was only used by create-alias.php (AliasHandler has a similar function create_allowed(), which is a copy of check_alias() with superfluous {...} removed) configs/menu.conf - replace create-alias.php with edit.php?table=alias - append "?" to url_create_mailbox to avoid temporary change in menu.tpl (create-mailbox is the only one which still needs ? instead of &) templates/list-virtual.tpl: - use {#url_create_alias#} instead of hardcoded create-alias.php templates/menu.tpl: - $url_domain: url-escape domain, use & instead of ? Modified Paths: -------------- trunk/configs/menu.conf trunk/functions.inc.php trunk/templates/list-virtual.tpl trunk/templates/menu.tpl Removed Paths: ------------- trunk/create-alias.php Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/configs/menu.conf 2012-01-10 00:30:01 UTC (rev 1317) @@ -7,8 +7,8 @@ url_edit_domain = edit.php?table=domain # list-virtual url_list_virtual = list-virtual.php -url_create_mailbox = create-mailbox.php -url_create_alias = create-alias.php +url_create_mailbox = create-mailbox.php? +url_create_alias = edit.php?table=alias url_create_alias_domain = edit.php?table=aliasdomain # fetchmail url_fetchmail = fetchmail.php Deleted: trunk/create-alias.php =================================================================== --- trunk/create-alias.php 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/create-alias.php 2012-01-10 00:30:01 UTC (rev 1317) @@ -1,203 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * File: create-alias.php - * Template File: create-alias.tpl - * Responsible for allowing for the creation of mail aliases. - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * Template Variables: - * - * tAddress - * tGoto - * tDomain - * - * Form POST \ GET Variables: - * - * fAddress - * fGoto - * fDomain - * - */ - -require_once('common.php'); - -authentication_require_role('admin'); -$username = authentication_get_username(); -$SESSID_USERNAME = $username; -if(authentication_has_role('global-admin')) { - $list_domains = list_domains (); -} -else { - $list_domains = list_domains_for_admin ($username); -} - -$pCreate_alias_address_text_error = ""; - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if (isset ($_GET['domain'])) { - $tDomain = escape_string ($_GET['domain']); - } -} - -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if (isset ($_POST['fAddress']) && isset ($_POST['fDomain'])) { - $fAddress = escape_string($_POST['fAddress']) . "@" . escape_string ($_POST['fDomain']); - $fAddress = strtolower ($fAddress); - } - - if (isset ($_POST['fGoto'])) { - $fGoto = escape_string ($_POST['fGoto']); - $fGoto = strtolower ($fGoto); - } - if(isset($_POST['fActive'])) { - $fActive = escape_string ($_POST['fActive']); - } - else { - $fActive = "1"; - } - - if(isset($_POST['fDomain'])) { - $fDomain = escape_string ($_POST['fDomain']); - } - -# TODO: Doesn't work with multiple aliases - fix or discard... -# if(!preg_match ('/@/',$fGoto)) { -# $fGoto = $fGoto . "@" . escape_string ($_POST['fDomain']); -# } - - if(!(authentication_has_role('global-admin') || - check_owner ($SESSID_USERNAME, $fDomain) )) - { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error1']; - } - - if(!check_alias($fDomain)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error3']; - } - - if(empty ($fAddress) || !check_email ($fAddress)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error1']; - } - - // Begin check alias email - $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace ('/\r\n/', ',', $goto); - $goto = preg_replace ('/,[\s]+/i', ',', $goto); - $goto = preg_replace ('/[\s]+,/i', ',', $goto); - $goto = preg_replace ('/,*$|^,*/', '', $goto); - $goto = preg_replace ('/,,*/', ',', $goto); - - if (empty ($goto) && !authentication_has_role('global-admin')) { - $error = 1; - $tGoto = $_POST['fGoto']; - flash_error($PALANG['pEdit_alias_goto_text_error1']); - } - - $new_aliases = array(); - if ($error != 1) { - $new_aliases = explode(',', $goto); - } - $new_aliases = array_unique($new_aliases); - - foreach($new_aliases as $address) { - if (in_array($address, $CONF['default_aliases'])) continue; - if (empty($address)) continue; # TODO: should never happen - remove after 2.2 release - if (!check_email($address)) { - $error = 1; - $tGoto = $goto; - flash_error($PALANG['pEdit_alias_goto_text_error2'] . "$address"); - } - } - - $goto = implode(',', $new_aliases); - $fGoto = escape_string($goto); - // End check alias mail - - if (empty($fGoto)) { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - flash_error($PALANG['pCreate_alias_address_text_error1']); - } - - if (escape_string($_POST['fAddress']) == "*") { - $fAddress = "@" . escape_string ($_POST['fDomain']); - } - - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress'"); - if ($result['rows'] == 1) - { - $error = 1; - $tAddress = escape_string ($_POST['fAddress']); - $tGoto = $fGoto; - $tDomain = $fDomain; - $pCreate_alias_address_text_error = $PALANG['pCreate_alias_address_text_error2']; - } - - if ($fActive == "on") { - $sqlActive = db_get_boolean(True); - } - else { - $sqlActive = db_get_boolean(False); - } - - if ($error != 1) { - if (preg_match('/^\*@(.*)$/', $fGoto, $match)) { - $fGoto = "@" . $match[1]; - } - - $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) { - $tDomain = $fDomain; - flash_error($PALANG['pCreate_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />\n"); - } - else { - db_log ($fDomain, 'create_alias', "$fAddress -> $fGoto"); - - $tDomain = $fDomain; - flash_info($PALANG['pCreate_alias_result_success'] . "<br />($fAddress -> $fGoto)<br />\n"); - } - } else { # on error - $tAddress = htmlentities($_POST['fAddress']); - $tGoto = htmlentities($_POST['fGoto']); - $tDomain = htmlentities($_POST['fDomain']); - } -} - -$smarty->assign ('mode', 'create'); -$smarty->assign ('tAddress', $tAddress); -$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain)), false); -$smarty->assign ('pCreate_alias_address_text_error', $pCreate_alias_address_text_error, false); -$smarty->assign ('tGoto', $tGoto, false); -$smarty->assign ('smarty_template', 'edit-alias'); -$smarty->display ('index.tpl'); - -/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ -?> Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/functions.inc.php 2012-01-10 00:30:01 UTC (rev 1317) @@ -577,29 +577,6 @@ // -// check_alias -// Action: Checks if the domain is still able to create aliases. -// Call: check_alias (string domain) -// -function check_alias ($domain) { - $limit = get_domain_properties ($domain); - if ($limit['aliases'] == 0) { - # 0 = unlimited, -1 = disabled - return true; - } - if ($limit['aliases'] < 0) { - return false; - } - if ($limit['alias_count'] >= $limit['aliases']) { - return false; - } else { - return true; - } -} - - - -// // check_mailbox // Action: Checks if the domain is still able to create mailboxes. // Call: check_mailbox (string domain) Modified: trunk/templates/list-virtual.tpl =================================================================== --- trunk/templates/list-virtual.tpl 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/templates/list-virtual.tpl 2012-01-10 00:30:01 UTC (rev 1317) @@ -45,7 +45,7 @@ </table> {$nav_bar_alias.bottom} {if $tCanAddAlias} - <br /><a href="create-alias.php?domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias}</a><br /> + <br /><a href="{#url_create_alias#}&domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias}</a><br /> {/if} {/if} {if $tab=='all'}<br />{/if} Modified: trunk/templates/menu.tpl =================================================================== --- trunk/templates/menu.tpl 2012-01-10 00:07:09 UTC (rev 1316) +++ trunk/templates/menu.tpl 2012-01-10 00:30:01 UTC (rev 1317) @@ -3,7 +3,7 @@ {if !empty($smarty.get) && !empty($smarty.get.domain)} {*** zuweisung muss eleganter gehen ***} {assign var="url_domain" value=$smarty.get.domain} - {assign var="url_domain" value="?domain=$url_domain"} + {assign var="url_domain" value="&domain={$url_domain|escape:url}"} {/if} {/strip} <div id="menu"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-08 20:16:59
|
Revision: 1348 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1348&view=rev Author: christian_boltz Date: 2012-04-08 20:16:53 +0000 (Sun, 08 Apr 2012) Log Message: ----------- 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 :-) Modified Paths: -------------- trunk/edit.php trunk/model/AliasHandler.php Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2012-04-08 17:41:02 UTC (rev 1347) +++ trunk/edit.php 2012-04-08 20:16:53 UTC (rev 1348) @@ -47,9 +47,6 @@ 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 @@ } } +$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) Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2012-04-08 17:41:02 UTC (rev 1347) +++ trunk/model/AliasHandler.php 2012-04-08 20:16:53 UTC (rev 1348) @@ -20,6 +20,8 @@ $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 @@ ' 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 @@ $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 @@ } } + 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 } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-08 21:18:33
|
Revision: 1350 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1350&view=rev Author: christian_boltz Date: 2012-04-08 21:18:27 +0000 (Sun, 08 Apr 2012) Log Message: ----------- templates/list-virtual_alias.tpl, templates/list-virtual_mailbox.tpl: - change edit-alias.php links to edit.php?table=alias edit-alias.php, templates/edit-alias.tpl: - now obsolete :-) -> deleted Modified Paths: -------------- trunk/templates/list-virtual_alias.tpl trunk/templates/list-virtual_mailbox.tpl Removed Paths: ------------- trunk/edit-alias.php trunk/templates/edit-alias.tpl Deleted: trunk/edit-alias.php =================================================================== --- trunk/edit-alias.php 2012-04-08 21:17:56 UTC (rev 1349) +++ trunk/edit-alias.php 2012-04-08 21:18:27 UTC (rev 1350) @@ -1,178 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * File: edit-alias.php - * Used to update an alias. - * - * Template File: edit-alias.tpl - * - * Template Variables: - * - * tGoto - * - * Form POST \ GET Variables: - * - * fAddress - * fDomain - * fGoto - */ - -require_once('common.php'); - -authentication_require_role('admin'); -$SESSID_USERNAME = authentication_get_username(); - -if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { - die("Check config.inc.php - domain administrators do not have the ability to edit user's aliases (alias_control_admin)"); -} - -/* retrieve existing alias record for the user first... may be via GET or POST */ - -$fAddress = safepost('address', safeget('address')); # escaped below -$fDomain = escape_string(preg_replace("/.*@/", "", $fAddress)); -$fAddress = escape_string($fAddress); # escaped now -if ($fAddress == "") { - die("Required parameters not present"); -} - -/* Check the user is able to edit the domain's aliases */ - - if(!check_owner($SESSID_USERNAME, $fDomain) && !authentication_has_role('global-admin')) - { - die("You lack permission to do this. yes."); - } - - $table_alias = table_by_key('alias'); - $alias_list = array(); - $orig_alias_list = array(); - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tGoto = $row['goto']; - $orig_alias_list = explode(',', $tGoto); - $tGoto = str_replace(',', "\n", $tGoto); - $alias_list = $orig_alias_list; - //. if we are not a global admin, and alias_control_admin is NO, hide the alias that's the mailbox name. - if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { - - /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $alias_list = array(); // empty it, repopulated again below - foreach($orig_alias_list as $alias) { - if(strtolower($alias) == strtolower($fAddress)) { - // mailbox address is dropped if they don't have special_alias_control enabled, and/or not a global-admin - } - else { - $alias_list[] = $alias; - } - } - } - } -} -else { - die("Invalid alias"); -} - -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ - $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; - - if (isset ($_POST['fGoto'])) $fGoto = escape_string ($_POST['fGoto']); - $fGoto = strtolower ($fGoto); - - if (!check_alias_owner ($SESSID_USERNAME, $fAddress)) - { - $error = 1; - $tGoto = $fGoto; - flash_error($PALANG['pEdit_alias_result_error']); - } - - $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace ('/\r\n/', ',', $goto); - $goto = preg_replace ('/,[\s]+/i', ',', $goto); - $goto = preg_replace ('/[\s]+,/i', ',', $goto); - $goto = preg_replace ('/,*$|^,*/', '', $goto); - $goto = preg_replace ('/,,*/', ',', $goto); - - if (empty ($goto) && !authentication_has_role('global-admin')) - { - $error = 1; - $tGoto = $_POST['fGoto']; - flash_error($PALANG['pEdit_alias_goto_text_error1']); - } - - $new_aliases = array(); - if ($error != 1) - { - $new_aliases = explode(',', $goto); - } - $new_aliases = array_unique($new_aliases); - - foreach($new_aliases as $address) { - if (in_array($address, $CONF['default_aliases'])) continue; - if (empty($address)) continue; # TODO: should never happen - remove after 2.2 release - if (!check_email($address)) - { - $error = 1; - $tGoto = $_POST['fGoto']; - flash_error($PALANG['pEdit_alias_goto_text_error2'] . "$address"); - } - } - - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { - // if original record had a mailbox alias, so ensure the updated one does too. - if(in_array($fAddress, $orig_alias_list)) { - $new_aliases[] = $fAddress; - } - } - - } - // duplicates suck, mmkay.. - $new_aliases = array_unique($new_aliases); - - $goto = implode(',', $new_aliases); - - if ($error != 1) - { - $goto = escape_string($goto); - $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] != 1) - { - flash_error($PALANG['pEdit_alias_result_error']); - } - else - { - db_log ($fDomain, 'edit_alias', "$fAddress -> $goto"); - - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } - } -} - -$smarty->assign ('mode', 'edit'); -$smarty->assign ('pCreate_alias_address_text_error', ''); -$smarty->assign ('fAddress', $fAddress); -$smarty->assign ('tGoto', $tGoto); -$smarty->assign ('smarty_template', 'edit-alias'); -$smarty->display ('index.tpl'); - -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?> Deleted: trunk/templates/edit-alias.tpl =================================================================== --- trunk/templates/edit-alias.tpl 2012-04-08 21:17:56 UTC (rev 1349) +++ trunk/templates/edit-alias.tpl 2012-04-08 21:18:27 UTC (rev 1350) @@ -1,47 +0,0 @@ -<div id="edit_form"> -<form name="alias" method="post" action=""> -<table> - <tr> - <th colspan="4"> -{if $mode == 'edit'} - {$PALANG.pEdit_alias_welcome} -{else} - {$PALANG.pCreate_alias_welcome}</th> -{/if} - </tr> - <tr> - <td class="label"><label>{$PALANG.pEdit_alias_address}:</label></td> - <td> -{if $mode == 'edit'} - <em>{$fAddress}</em> -{else} - <input class="flat" type="text" name="fAddress" value="{$tAddress}" /> - @ - <select class="flat" name="fDomain">{$select_options}</select> -{/if} - </td> - <td>{if $mode == 'create'}{$PALANG.pCreate_alias_catchall_text}{/if}</td> - <td><span class="error_msg">{$pCreate_alias_address_text_error}</span></td> - </tr> - <tr> - <td class="label"><label>{$PALANG.pEdit_alias_goto}:</label></td> - <td><textarea class="flat" rows="10" cols="35" name="fGoto">{$tGoto}</textarea></td> - <td>{$PALANG.pCreate_alias_goto_text}<br /><br />{$PALANG.pEdit_alias_help}</td> - <td> </td> - </tr> -{if $mode == 'create'} -<!-- TODO: 'active' should also be available in edit-alias --> - <tr> - <td class="label"><label>{$PALANG.pCreate_alias_active}:</label></td> - <td><input class="flat" type="checkbox" name="fActive" checked="checked"/></td> - <td colspan="2"> </td> - </tr> -{/if} - <tr> - <td> </td> - <td colspan="3"><input class="button" type="submit" name="submit" - value="{if $mode == 'edit'}{$PALANG.save}{else}{$PALANG.pCreate_alias_button}{/if}" /></td> - </tr> -</table> -</form> -</div> Modified: trunk/templates/list-virtual_alias.tpl =================================================================== --- trunk/templates/list-virtual_alias.tpl 2012-04-08 21:17:56 UTC (rev 1349) +++ trunk/templates/list-virtual_alias.tpl 2012-04-08 21:18:27 UTC (rev 1350) @@ -35,12 +35,12 @@ {if $authentication_has_role.global_admin==true} {assign var="address" value=$item.address|escape:"url"} <td><a href="edit-active.php?alias={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}&return={$file|escape:"url"}?domain={$fDomain|escape:"url"}&limit={$current_limit|escape:"url"}">{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td> - <td><a href="edit-alias.php?address={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}">{$PALANG.edit}</a></td> + <td><a href="edit.php?table=alias&edit={$item.address|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="delete.php?table=alias&delete={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_aliases}: {$item.address}');">{$PALANG.del}</a></td> {else} {if $CONF.special_alias_control===YES || $check_alias_owner[$i]==true} <td><a href="edit-active.php?alias={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}">{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td> - <td><a href="edit-alias.php?address={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}">{$PALANG.edit}</a></td> + <td><a href="edit.php?table=alias&edit={$item.address|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="delete.php?table=alias&delete={$item.address|escape:"url"}&domain={$fDomain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_aliases}: {$item.address}');">{$PALANG.del}</a></td> {else} <td>{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</td> Modified: trunk/templates/list-virtual_mailbox.tpl =================================================================== --- trunk/templates/list-virtual_mailbox.tpl 2012-04-08 21:17:56 UTC (rev 1349) +++ trunk/templates/list-virtual_mailbox.tpl 2012-04-08 21:18:27 UTC (rev 1350) @@ -83,7 +83,7 @@ {if $authentication_has_role.global_admin!==true && $CONF.alias_control_admin===YES}{assign var="edit_aliases" value=1}{/if} {if $authentication_has_role.global_admin==true && $CONF.alias_control===YES}{assign var="edit_aliases" value=1}{/if} {if $edit_aliases==1} - <td><a href="edit-alias.php?address={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}">{$PALANG.pOverview_alias_edit}</a></td> + <td><a href="edit.php?table=alias&edit={$item.username|escape:"url"}">{$PALANG.pOverview_alias_edit}</a></td> {/if} <td><a href="edit-mailbox.php?username={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="delete.php?table=mailbox&delete={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_mailboxes}: {$item.username}');">{$PALANG.del}</a></td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-08 22:21:02
|
Revision: 1352 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1352&view=rev Author: christian_boltz Date: 2012-04-08 22:20:55 +0000 (Sun, 08 Apr 2012) Log Message: ----------- list-virtual.php: - use AliasdomainHander instead of doing direct database queries - add search support for alias domains - display "create alias domain" button only if this is possible - always assign $tAliasDomains smarty variable (even if empty) to avoid warnings - always escape $fDomain (even if it comes from $list_domains) - rename $SESSID_USERNAME to $admin_username templates/list-virtual_alias_domain.tpl: - remove reference to non-existing variable $tTargetDomain Modified Paths: -------------- trunk/list-virtual.php trunk/templates/list-virtual_alias_domain.tpl Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2012-04-08 21:25:25 UTC (rev 1351) +++ trunk/list-virtual.php 2012-04-08 22:20:55 UTC (rev 1352) @@ -33,7 +33,7 @@ authentication_require_role('admin'); $fDomain = false; -$SESSID_USERNAME = authentication_get_username(); +$admin_username = authentication_get_username(); if (authentication_has_role('global-admin')) { $list_domains = list_domains (); @@ -69,7 +69,7 @@ if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) { if (empty ($fDomain)) { - $fDomain = $list_domains[0]; + $fDomain = escape_string($list_domains[0]); } } @@ -95,35 +95,29 @@ # alias domain # -# TODO: add search support for alias domains - if (boolconf('alias_domain')) { - $modified_field = 'modified'; - if ('pgsql'==$CONF['database_type']) { # TODO: do we really need the extract(epoch from modified) for pgsql? We ust gmstrftime anyway (see below) - $modified_field = 'extract(epoch from modified) as modified'; + if ($search == "") { + $list_param = "alias_domain='$fDomain' OR target_domain='$fDomain'"; + } else { + $list_param = "alias_domain LIKE '%$search%' OR target_domain LIKE '%$search%'"; } - $query = " - SELECT alias_domain,target_domain,$modified_field,active FROM $table_alias_domain - WHERE alias_domain='$fDomain' OR target_domain='$fDomain' - ORDER BY alias_domain - LIMIT $page_size OFFSET $fDisplay - "; + $handler = new AliasdomainHandler(0, $admin_username); + if ($handler->getList($list_param)) { + $tAliasDomains = $handler->result(); + } else { + $tAliasDomains = array(); + # TODO: check if there was an error or simply no alias domains + } - $result = db_query ($query); - $tAliasDomains = array(); $can_create_alias_domain = 1; - if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) { - if ('pgsql'==$CONF['database_type']) { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tAliasDomains[] = $row; - if ($row['target_domain'] == $fDomain) $can_create_alias_domain = 0; - } - } - # TODO: set $can_create_alias_domain = 0; if all domains (of this admin) are already used as alias domains + foreach ($tAliasDomains as $row) { + if ($row['alias_domain'] == $fDomain) $can_create_alias_domain = 0; # domain is already an alias domain + } + # set $can_create_alias_domain = 0 if all domains (of this admin) are already used as alias domains + if ($handler->getList("1=1")) { + if ( count($handler->result()) + 1 >= count($list_domains) ) $can_create_alias_domain = 0; # all domains (of this admin) are already alias domains + } } # @@ -303,7 +297,7 @@ if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) for ($i = 0; $i < sizeof ($tAlias); $i++) { $gen_show_status [$i] = gen_show_status($tAlias[$i]['address']); - $check_alias_owner [$i] = check_alias_owner($SESSID_USERNAME, $tAlias[$i]['address']); + $check_alias_owner [$i] = check_alias_owner($admin_username, $tAlias[$i]['address']); } $gen_show_status_mailbox = array (); @@ -448,9 +442,7 @@ $smarty->assign ('tDisplay_next_show', $tDisplay_next_show); $smarty->assign ('tDisplay_next', $tDisplay_next); -if(sizeof ($tAliasDomains) > 0) - $smarty->assign ('tAliasDomains', $tAliasDomains); - +$smarty->assign ('tAliasDomains', $tAliasDomains); $smarty->assign ('can_create_alias_domain', $can_create_alias_domain); $smarty->assign ('tAlias', $tAlias); $smarty->assign ('gen_show_status', $gen_show_status, false); Modified: trunk/templates/list-virtual_alias_domain.tpl =================================================================== --- trunk/templates/list-virtual_alias_domain.tpl 2012-04-08 21:25:25 UTC (rev 1351) +++ trunk/templates/list-virtual_alias_domain.tpl 2012-04-08 22:20:55 UTC (rev 1352) @@ -3,7 +3,7 @@ <tr> <th colspan="6">{$PALANG.pOverview_alias_domain_title}</th> </tr> - {if $tAliasDomains|@count>0 || $tTargetDomain|@count>1} + {if $tAliasDomains|@count>0} {if $tAliasDomains|@count>0} {* -> HAT alias-domains *} {#tr_header#} <td>{$PALANG.pOverview_alias_address}</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-08 23:11:52
|
Revision: 1354 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1354&view=rev Author: christian_boltz Date: 2012-04-08 23:11:46 +0000 (Sun, 08 Apr 2012) Log Message: ----------- list-virtual.php: - use AliasHandler instead of direct SQL queries templates/list-virtual_alias.tpl: - goto is an array now, not a comma-separated string Modified Paths: -------------- trunk/list-virtual.php trunk/templates/list-virtual_alias.tpl Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2012-04-08 23:07:22 UTC (rev 1353) +++ trunk/list-virtual.php 2012-04-08 23:11:46 UTC (rev 1354) @@ -125,9 +125,13 @@ # if ($search == "") { + $list_param = "domain='$fDomain'"; + # sql_domain / sql_where only needed for pagebrowser $sql_domain = " $table_alias.domain='$fDomain' "; $sql_where = ""; } else { + $list_param = "(address LIKE '%$search%' OR goto LIKE '%$search%')"; + # sql_domain / sql_where only needed for pagebrowser $sql_domain = db_in_clause("$table_alias.domain", $list_domains); $sql_where = " AND ( address LIKE '%$search%' OR goto LIKE '%$search%' ) "; } @@ -137,28 +141,24 @@ WHERE $sql_domain AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) $sql_where ORDER BY address "; - +/* $query = " SELECT address, goto, modified, active $alias_pagebrowser_query LIMIT $page_size OFFSET $fDisplay "; +*/ -$result = db_query ($query); -if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) { - if ('pgsql'==$CONF['database_type']) { - //. at least in my database, $row['modified'] already looks like : 2009-04-11 21:38:10.75586+01, - // while gmstrftime expects an integer value. strtotime seems happy though. - //$row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['modified'] = date('Y-m-d H:i', strtotime($row['modified'])); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tAlias[] = $row; - } +$handler = new AliasHandler(0, $admin_username); +if ($handler->getList($list_param, $page_size, $fDisplay)) { + $tAlias = $handler->result(); +} else { + $tAlias= array(); + # TODO: check if there was an error or simply no aliases } + # # mailboxes # @@ -295,7 +295,7 @@ $check_alias_owner = array (); if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) - for ($i = 0; $i < sizeof ($tAlias); $i++) { + foreach (array_keys($tAlias) as $i) { $gen_show_status [$i] = gen_show_status($tAlias[$i]['address']); $check_alias_owner [$i] = check_alias_owner($admin_username, $tAlias[$i]['address']); } Modified: trunk/templates/list-virtual_alias.tpl =================================================================== --- trunk/templates/list-virtual_alias.tpl 2012-04-08 23:07:22 UTC (rev 1353) +++ trunk/templates/list-virtual_alias.tpl 2012-04-08 23:11:46 UTC (rev 1354) @@ -24,11 +24,15 @@ <td><i>sorry, alias_goto_limit > 0 not handled</i></td> {else} <td> + {foreach key=key2 item=singlegoto from=$item.goto} + {if $search eq ""} - {$item.goto|replace:",":"<br/>"} + {$singlegoto}<br /> {else} - {$item.goto|replace:",":"<br/>"|replace:$search:"<span class='searchresult'>$search</span>"} + {$singlegoto|replace:$search:"<span class='searchresult'>$search</span>"}<br /> {/if} + + {/foreach} </td> {/if} <td>{$item.modified}</td> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-09 00:34:32
|
Revision: 1356 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1356&view=rev Author: christian_boltz Date: 2012-04-09 00:34:26 +0000 (Mon, 09 Apr 2012) Log Message: ----------- VacationHandler: - use new *Handler syntax to add/remove vacation alias (implemented as function updateAlias() to avoid code duplication) AliasHandler: - setmore(): only use $oldvalues if no new on_vacation value is given - setmore(): fix "undefined index" warning edit.php: - only set $values if a field is editable and displayed in the form - do not set default values in $values (without those changes, the vacation alias was always removed when editing an alias) Modified Paths: -------------- trunk/edit.php trunk/model/AliasHandler.php trunk/model/VacationHandler.php Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2012-04-08 23:18:29 UTC (rev 1355) +++ trunk/edit.php 2012-04-09 00:34:26 UTC (rev 1356) @@ -80,9 +80,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { foreach($form_fields as $key => $field) { - if ($field['editable'] == 0) { - $values[$key] = $field['default']; - } else { + if ($field['editable'] && $field['display_in_form']) { if($field['type'] == 'bool') { $values[$key] = safepost($key, 0); # isset() for unchecked checkboxes is always false } elseif($field['type'] == 'txtl') { Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2012-04-08 23:18:29 UTC (rev 1355) +++ trunk/model/AliasHandler.php 2012-04-09 00:34:26 UTC (rev 1356) @@ -195,8 +195,12 @@ $this->errormsg[] = $old_ah->errormsg[0]; } else { $oldvalues = $old_ah->result(); - - if ($oldvalues['on_vacation']) { + + if (!isset($values['on_vacation'])) { # no new value given? + $values['on_vacation'] = $oldvalues['on_vacation']; + } + + if ($values['on_vacation']) { $vh = new VacationHandler($this->id); $values['goto'][] = $vh->getVacationAlias(); } @@ -209,7 +213,7 @@ $values['goto'][] = $this->id; # if the alias points to the mailbox, don't display the "empty goto" error message - if ($this->errormsg['goto'] == Lang::read('pEdit_alias_goto_text_error1') ) { + if (isset($this->errormsg['goto']) && $this->errormsg['goto'] == Lang::read('pEdit_alias_goto_text_error1') ) { unset($this->errormsg['goto']); } } @@ -240,7 +244,7 @@ $db_result[$key]['goto_mailbox'] = 0; } } -#print_r($db_result); exit; + return $db_result; } Modified: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php 2012-04-08 23:18:29 UTC (rev 1355) +++ trunk/model/VacationHandler.php 2012-04-09 00:34:26 UTC (rev 1356) @@ -5,6 +5,7 @@ protected $username = null; function __construct($username) { $this->username = $username; + $this->id = $username; } /** @@ -13,19 +14,7 @@ * @return boolean true on success. */ function remove() { - $ah = new AliasHandler(); - $ah->init($this->username); - $result = $ah->get(true); - if($result === true) { // fetch all # TODO check $result, error handling - $aliases = $ah->return; - $new_aliases = array(); - /* go through the user's aliases and remove any that look like a vacation address */ - foreach($aliases as $alias) { # TODO replace with (to be written) array_remove() - if(!$ah->is_vacation_address($alias)) { - $new_aliases[] = $alias; - } - } - $ah->update($new_aliases, '', false); # TODO: supress logging in AliasHandler if called from VacationHandler (VacationHandler should log itsself) + if (!$this->updateAlias(0)) return false; // tidy up vacation table. $vacation_data = array( @@ -36,8 +25,6 @@ # TODO db_log() call (maybe except if called from set_away?) /* crap error handling; oh for exceptions... */ return true; - } - return false; } /** @@ -54,18 +41,21 @@ * Why do we bother storing true/false in the vacation table if the alias dictates it anyway? */ function check_vacation() { - $ah = new AliasHandler(); - $ah->init($this->username); - $success = $ah->get(true); # fetch all. - if (!$success) { - return false; # TODO: error handling? + $handler = new AliasHandler(); + + if (!$handler->init($this->id)) { + # print_r($handler->errormsg); # TODO: error handling + return false; } - $aliases = $ah->result(); - foreach($aliases as $alias) { - if($ah->is_vacation_address($alias)) { - return true; - } + + if (!$handler->view()) { + # print_r($handler->errormsg); # TODO: error handling + return false; } + + $result = $handler->result(); + + if ($result['on_vacation']) return true; return false; } @@ -129,15 +119,42 @@ } # TODO error check # TODO wrap whole function in db_begin / db_commit (or rollback)? - $ah = new AliasHandler(); - $ah->init($this->username); - $alias = $ah->get(true); - $aliases = $ah->return; - $vacation_address = $this->getVacationAlias(); - $aliases[] = $vacation_address; - return $ah->update($aliases, '', false); + + return $this->updateAlias(1); } + /** + * add/remove the vacation alias + * @param int $vacationActive + */ + protected function updateAlias($vacationActive) { + $handler = new AliasHandler(); + + if (!$handler->init($this->id)) { + # print_r($handler->errormsg); # TODO: error handling + return false; + } + + $values = array ( + 'on_vacation' => $vacationActive, + ); + + if (!$handler->set($values)) { + # print_r($handler->errormsg); # TODO: error handling + return false; + } + + # TODO: supress logging in AliasHandler if called from VacationHandler (VacationHandler should log itsself) + + if (!$handler->store()) { + print_r($handler->errormsg); # TODO: error handling + return false; + } + + # still here? then everything worked + return true; + } + /** * Returns the vacation alias for this user. * i.e. if this user's username was ro...@ex..., and the autoreply domain was set to This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <chr...@us...> - 2012-04-09 01:48:10
|
Revision: 1358 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1358&view=rev Author: christian_boltz Date: 2012-04-09 01:48:04 +0000 (Mon, 09 Apr 2012) Log Message: ----------- remove obsolete functions from AliasHandler (part 2/2) AliasHandler.php: - remove obsolete functions update(), is_mailbox_alias(), is_vacation_address(), hasAliasRecord() - updated delete() to use new *Handler syntax (most of it should be moved to PFAHandler, but that's another story ;-) users/edit-alias.php: - replace $ah->update with $ah->set / $ah->store - use 0/1 for $fForward_and_store instead of YES/NO - use safepost instead of isset() templates/users_edit-alias.tpl: - use 0/1 for $fForward_and_store instead of YES/NO xmlrpc.php: - replace $ah->update with new *Handler syntax Note: the changes in xmlrpc.php are untested again ;-) Modified Paths: -------------- trunk/model/AliasHandler.php trunk/templates/users_edit-alias.tpl trunk/users/edit-alias.php trunk/xmlrpc.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2012-04-09 01:06:52 UTC (rev 1357) +++ trunk/model/AliasHandler.php 2012-04-09 01:48:04 UTC (rev 1358) @@ -293,159 +293,19 @@ /********************************************************************************************************************************************************** old function from non-PFAHandler times of AliasHandler - They still work, but are deprecated and will be removed. + Will be replaced by a global delete() function in PFAHandler **********************************************************************************************************************************************************/ - /** - * @param string $address - * @param string $username - * @return boolean true if the username is an alias for the mailbox AND we have alias_control turned off. - * TODO: comment for @return: does alias_control really matter here? - */ - public function is_mailbox_alias($address) { - global $CONF; - - if($address != $this->id) { # avoid false positives if $address is a mailbox - return false; - } - - $table_mailbox = table_by_key('mailbox'); - $E_address = escape_string($address); - $sql = "SELECT * FROM $table_mailbox WHERE username='$E_address'"; - $result = db_query($sql); - if($result['rows'] != 1) { - return false; - } else { - return true; - } - } - /** - * @param string $address - * @return boolean true if the address contains the vacation domain - */ - public function is_vacation_address($address) { - global $CONF; - if($CONF['vacation'] == 'YES') { - if(stripos($address, '@' . $CONF['vacation_domain'])) { # TODO: check full vacation address user#domain.com@vacation_domain - return true; - } - } - return false; - } - /** - * @return boolean true on success - * @param string $username - * @param array $addresses - list of aliases to set for the user. - * @param string flags - forward_and_store or remote_only or '' - * @param boolean $vacation_persist - set to false to stop the vacation address persisting across updates - * Set the user's aliases to those provided. If $addresses ends up being empty the alias record is removed. # TODO: deleting that's buggy behaviour, error out instead - */ - public function update($addresses, $flags = '', $vacation_persist=true) { - // find out if the user is on vacation or not; if they are, - // then the vacation alias needs adding to the db (as we strip it out in the get method) - // likewise with the alias_control address. - - # TODO: move all validation from edit-alias/create-alias and users/edit-alias here - - $valid_flags = array('', 'forward_and_store', 'remote_only'); - if(!in_array($flags, $valid_flags)) { - die("Invalid flag passed into update()... : $flag - valid options are :" . implode(',', $valid_flags)); - } - $addresses = array_unique($addresses); - - list (/*NULL*/, $domain) = explode('@', $this->id); - - if ( ! $this->get(true) ) die("Alias not existing?"); # TODO: better error behaviour - - foreach($this->return as $address) { - if($vacation_persist) { - if($this->is_vacation_address($address)) { - $addresses[] = $address; - } - } - if($flags != 'remote_only') { - if($this->is_mailbox_alias($address)) { - $addresses[] = $address; - } - } - } - $addresses = array_unique($addresses); - - $new_list = array(); - if($flags == 'remote_only') { - foreach($addresses as $address) { # TODO: write a remove_from_array function, see http://tech.petegraham.co.uk/2007/03/22/php-remove-values-from-array/ - // strip out our username... if it's in the list given. - if($address != $this->id) { - $new_list[] = $address; - } - } - $addresses = $new_list; - } - - if($flags == 'forward_and_store') { - if(!in_array($this->id, $addresses)) { - $addresses[] = $this->id; - } - } - $new_list = array(); - foreach($addresses as $address) { - if($address != '') { - $new_list[] = $address; # TODO use remove_from_array, see above - } - } - $addresses = array_unique($new_list); - $E_username = escape_string($this->id); - $goto = implode(',', $addresses); - if(sizeof($addresses) == 0) { - # $result = db_delete('alias', 'address', $this->id); # '"DELETE FROM $table_alias WHERE address = '$username'"; # TODO: should never happen and causes broken behaviour - error_log("Alias set to empty / Attemp to delete: " . $this->id); # TODO: more/better error handling - maybe just return false? - } - if($this->hasAliasRecord() == false) { # TODO should never happen in update() - see also the comments on handling DELETE above - $alias_data = array( - 'address' => $this->id, - 'goto' => $goto, - 'domain' => $domain, - 'active' => db_get_boolean(True), - ); - $result = db_insert('alias', $alias_data); - } else { - $alias_data = array( - 'goto' => $goto, - ); - $result = db_update('alias', 'address', $this->id, $alias_data); - } - if($result != 1) { - return false; - } - db_log ($domain, 'edit_alias', "$E_username -> $goto"); - return true; - } - - /** - * @return boolean true if the user has an alias record (i.e row in alias table); else false. - */ - private function hasAliasRecord() { # only used by update() in this class - $username = escape_string($this->id); - $table_alias = table_by_key('alias'); - $sql = "SELECT * FROM $table_alias WHERE address = '$username'"; - $result = db_query($sql); - if($result['rows'] == 1) { - return true; - } - return false; - } - - /** * @return true on success false on failure */ public function delete(){ - if( ! $this->get() ) { + if( ! $this->view() ) { $this->errormsg[] = 'An alias with that address does not exist.'; # TODO: make translatable return false; } - if ($this->is_mailbox_alias($this->id) ) { + if ($this->return['is_mailbox']) { $this->errormsg[] = 'This alias belongs to a mailbox and can\'t be deleted.'; # TODO: make translatable return false; } Modified: trunk/templates/users_edit-alias.tpl =================================================================== --- trunk/templates/users_edit-alias.tpl 2012-04-09 01:06:52 UTC (rev 1357) +++ trunk/templates/users_edit-alias.tpl 2012-04-09 01:48:04 UTC (rev 1358) @@ -22,9 +22,9 @@ <tr> <td> </td> <td colspan="2"> - <input class="flat" type="radio" name="fForward_and_store" value="YES"{$forward_and_store}/> + <input class="flat" type="radio" name="fForward_and_store" value="1"{$forward_and_store}/> {$PALANG.pEdit_alias_forward_and_store}<br /> - <input class="flat" type="radio" name="fForward_and_store" value="NO" {$forward_only}/> + <input class="flat" type="radio" name="fForward_and_store" value="0" {$forward_only}/> {$PALANG.pEdit_alias_forward_only} </td> </tr> Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2012-04-09 01:06:52 UTC (rev 1357) +++ trunk/users/edit-alias.php 2012-04-09 01:48:04 UTC (rev 1358) @@ -60,9 +60,12 @@ $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; - if (isset($_POST['fGoto'])) $fGoto = trim($_POST['fGoto']); - if (isset($_POST['fForward_and_store'])) $fForward_and_store = $_POST['fForward_and_store']; + $fGoto = trim(safepost('fGoto')); + $fForward_and_store = safepost('fForward_and_store'); + # TODO: use edit.php (or create a edit_user.php) + # TODO: this will obsolete lots of the code below (parsing $goto and the error checks) + $goto = strtolower ($fGoto); $goto = preg_replace ('/\\\r\\\n/', ',', $goto); $goto = preg_replace ('/\r\n/', ',', $goto); @@ -76,7 +79,7 @@ $goto = array_merge(array_unique($goto)); $good_goto = array(); - if($fForward_and_store != 'YES' && sizeof($goto) == 1 && $goto[0] == '') { + if($fForward_and_store != 1 && sizeof($goto) == 1 && $goto[0] == '') { flash_error($PALANG['pEdit_alias_goto_text_error1']); $error += 1; } @@ -100,22 +103,31 @@ } if ($error == 0) { - $flags = 'remote_only'; - if($fForward_and_store == "YES" ) { - $flags = 'forward_and_store'; + + $values = array( + 'goto' => $good_goto, + 'goto_mailbox' => $fForward_and_store, + ); + + if (!$ah->set($values)) { + $errormsg = $ah->errormsg; + flash_error($errormsg[0]); } - $updated = $ah->update($good_goto, $flags); + + $updated = $ah->store(); + if($updated) { header ("Location: main.php"); exit; } flash_error($PALANG['pEdit_alias_result_error']); + } else { $tGotoArray = $goto; } $smarty->assign ('tGotoArray', $tGotoArray); - if ($fForward_and_store == "YES") { + if ($fForward_and_store == 1) { $smarty->assign ('forward_and_store', ' checked="checked"'); $smarty->assign ('forward_only', ''); } else { Modified: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php 2012-04-09 01:06:52 UTC (rev 1357) +++ trunk/xmlrpc.php 2012-04-09 01:48:04 UTC (rev 1358) @@ -155,11 +155,19 @@ public function update($addresses, $flags) { $ah = new AliasHandler(); $ah->init($_SESSION['username']); - /** - * if the user is on vacation, they should use VacationProxy stuff to remove it - * and we'll never return the vacation address from here anyway - */ - return $ah->update($addresses, $flags, true); + + $values['goto'] = $addresses; + + if ($flags == 'forward_and_store') { + $values['goto_mailbox'] = 1; + } elseif ($flags == 'remote_only') { + $values['goto_mailbox'] = 0; + } else { + return false; # invalid parameter + } + + if (!$ah->set($values)) return false; + return $ah->store(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-09 15:02:23
|
Revision: 1360 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1360&view=rev Author: christian_boltz Date: 2012-04-09 15:02:16 +0000 (Mon, 09 Apr 2012) Log Message: ----------- MailboxHandler: - start rewrite based on PFAHandler - add initStruct(), initMsg(), webformConfig(), validate_new_id(), create_allowed() - drop old __construct() and view() - replace $this->username with $this->id - replace check of old password in change_pw() with $this->login users/password.php: - adopt to *Handler syntax scripts/shells/mailbox.php: - adopt to *Handler view() syntax - add TODO - maildir column isn't displayed xmlrpc.php: - adopt to *Handler syntax Note: as usual, the changes in xmlrpc.php are untested ;-) Modified Paths: -------------- trunk/model/MailboxHandler.php trunk/scripts/shells/mailbox.php trunk/users/password.php trunk/xmlrpc.php Modified: trunk/model/MailboxHandler.php =================================================================== --- trunk/model/MailboxHandler.php 2012-04-09 02:00:10 UTC (rev 1359) +++ trunk/model/MailboxHandler.php 2012-04-09 15:02:16 UTC (rev 1360) @@ -4,16 +4,122 @@ /** * Simple class to represent a user. */ -class MailboxHandler { +class MailboxHandler extends PFAHandler { - protected $username = null; + protected $domain_field = 'domain'; - public $errormsg = array(); + # init $this->struct, $this->db_table and $this->id_field + protected function initStruct() { + $this->db_table = 'mailbox'; + $this->id_field = 'username'; + + $this->struct=array( + # field name allow display in... type $PALANG label $PALANG description default / options / ... + # editing? form list + 'username' => pacol( $this->new, 1, 1, 'text', '' , '' , '' ), + 'local_part' => pacol( 0, 0, 0, 'text', '' , '' , '' ), + 'domain' => pacol( 0, 0, 0, 'enum', '' , '' , '' ), + 'maildir' => pacol( 0, 0, 0, 'text', '' , '' , '' ), + 'password' => pacol( 1, 1, 0, 'pass', '' , '' , '' ), + 'password2' => pacol( 1, 1, 0, 'pass', '' , '' , '', + /*options*/ '', + /*not_in_db*/ 0, + /*dont_write_to_db*/ 1, + /*select*/ 'password as password2' + ), + 'name' => pacol( 1, 1, 1, 'text', '' , '' , '' ), + 'quota' => pacol( 1, 1, 1, 'int' , '' , '' , '' ), + 'active' => pacol( 1, 1, 1, 'bool', '' , '' , 1 ), + 'created' => pacol( 0, 0, 1, 'ts', '' , '' ), + 'modified' => pacol( 0, 0, 1, 'ts', '' , '' ), + # TODO: add virtual 'notified' column and allow to display who received a vacation response? + ); + } - public function __construct($username) { - $this->username = strtolower($username); + # messages used in various functions. + # always list the key to hand over to Lang::read + # the only exception is 'logname' which uses the key for db_log + protected function initMsg() { + $this->msg['error_already_exists'] = 'pCreate_mailbox_username_text_error2'; + $this->msg['error_does_not_exist'] = 'pCreate_mailbox_username_text_error1'; + if ($this->new) { + $this->msg['logname'] = 'create_mailbox'; + $this->msg['store_error'] = 'pCreate_mailbox_result_error'; + } else { + $this->msg['logname'] = 'edit_mailbox'; + $this->msg['store_error'] = 'pCreate_mailbox_result_error'; # TODO: better error message + } } + /* + * Configuration for the web interface + */ + public function webformConfig() { + return array( + # $PALANG labels + 'formtitle_create' => 'pCreate_mailbox_welcome', + 'formtitle_edit' => 'pEdit_mailbox_welcome', + 'create_button' => 'pCreate_mailbox_button', + 'successmessage' => 'pCreate_mailbox_result_success', + + # various settings + 'required_role' => 'admin', + 'listview' => 'list-virtual.php', + 'early_init' => 1, # 0 for create-domain + ); + } + + + protected function validate_new_id() { + if ($this->id == '') { + $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error1'); + return false; + } + + list($local_part,$domain) = explode ('@', $this->id); + + if(!$this->create_allowed($domain)) { + $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error3'); + return false; + } + + # check if an alias with this name already exists - if yes, don't allow to create the mailbox + $handler = new AliasHandler(1); + if (!$handler->init($this->id)) { + $this->errormsg[] = Lang::read('pCreate_mailbox_username_text_error2'); + return false; + } + + return check_email($this->id); # TODO: check_email should return error message instead of using flash_error itsself + } + + /** + * check number of existing mailboxes for this domain - is one more allowed? + */ + private function create_allowed($domain) { + $limit = get_domain_properties ($domain); + + if ($limit['mailboxes'] == 0) return true; # unlimited + if ($limit['mailboxes'] < 0) return false; # disabled + if ($limit['mailbox_count'] >= $limit['mailboxes']) return false; + return true; + } + + +/* function already exists (see old code below + public function delete() { + $this->errormsg[] = '*** deletion not implemented yet ***'; + return false; # XXX function aborts here! XXX + } +*/ + + + +/******************************************************************************************************************** + old functions - we'll see what happens to them + (at least they should use the *Handler functions instead of doing SQL) +/********************************************************************************************************************/ + public function change_pass($old_password, $new_password) { error_log('MailboxHandler->change_pass is deprecated. Please use MailboxHandler->change_pw!'); return $this->change_pw($new_password, $old_password); @@ -29,36 +135,29 @@ * as per the configuration in config.inc.php */ public function change_pw($new_password, $old_password, $match = true) { - list(/*NULL*/,$domain) = explode('@', $username); + list(/*NULL*/,$domain) = explode('@', $this->id); - $E_username = escape_string($this->username); - $table_mailbox = table_by_key('mailbox'); - if ($match == true) { - $active = db_get_boolean(True); - $result = db_query("SELECT password FROM $table_mailbox WHERE username='$E_username' AND active='$active'"); - $result = db_assoc($result['result']); - - if (pacrypt($old_password, $result['password']) != $result['password']) { - db_log ($domain, 'edit_password', "MATCH FAILURE: " . $this->username); + if (!$this->login($this->id, $old_password)) { + db_log ($domain, 'edit_password', "MATCH FAILURE: " . $this->id); $this->errormsg[] = 'Passwords do not match'; # TODO: make translatable return false; - } + } } $set = array( 'password' => pacrypt($new_password) , ); - $result = db_update('mailbox', 'username', $this->username, $set ); + $result = db_update('mailbox', 'username', $this->id, $set ); if ($result != 1) { - db_log ($domain, 'edit_password', "FAILURE: " . $this->username); + db_log ($domain, 'edit_password', "FAILURE: " . $this->id); $this->errormsg[] = Lang::read('pEdit_mailbox_result_error'); return false; } - db_log ($domain, 'edit_password', $this->username); + db_log ($domain, 'edit_password', $this->id); return true; } @@ -103,7 +202,7 @@ # TODO: copy/move all checks and validations from create-mailbox.php here - $username = $this->username; + $username = $this->id; list($local_part,$domain) = explode ('@', $username); @@ -191,7 +290,7 @@ # TODO: move "send the mail" to a function $fTo = $username; $fFrom = smtp_get_admin_email(); - if(empty($fFrom) || $fFrom == 'CLI') $fFrom = $this->username; + if(empty($fFrom) || $fFrom == 'CLI') $fFrom = $this->id; $fSubject = Lang::read('pSendmail_subject_text'); $fBody = Config::read('welcome_text'); @@ -207,26 +306,8 @@ } - - - public function view() { - - $username = $this->username; - $table_mailbox = table_by_key('mailbox'); - -# TODO: check if DATE_FORMAT works in MySQL and PostgreSQL -# TODO: maybe a more fine-grained date format would be better for non-CLI usage - $result = db_query("SELECT username, name, maildir, quota, local_part, domain, DATE_FORMAT(created, '%d.%m.%y') AS created, DATE_FORMAT(modified, '%d.%m.%y') AS modified, active FROM $table_mailbox WHERE username='$username'"); - if ($result['rows'] != 0) { - $this->return = db_array($result['result']); - return true; - } - $this->errormsg = $result['error']; - return false; - } - public function delete() { - $username = $this->username; + $username = $this->id; list(/*$local_part*/,$domain) = explode ('@', $username); $E_username = escape_string($username); Modified: trunk/scripts/shells/mailbox.php =================================================================== --- trunk/scripts/shells/mailbox.php 2012-04-09 02:00:10 UTC (rev 1359) +++ trunk/scripts/shells/mailbox.php 2012-04-09 15:02:16 UTC (rev 1360) @@ -466,7 +466,10 @@ function __handle($address) { - $handler = new MailboxHandler($address); + $handler = new MailboxHandler(); + if ( ! $handler->init($address)) { + $this->error("Not found!", "The mailbox you have searched could not be found."); + } if ( ! $handler->view() ) { $this->error("Not Found!", "The mailbox you have searched could not be found."); } @@ -478,6 +481,7 @@ $this->out(sprintf("+%'-25s+%'-15s+%'-10s+%'-20s+%'-8s+%'-8s+%'-6s+",'','','','','','','')); $this->out(sprintf('|%25s|%15s|%10s|%20s|%8s|%8s|%6s|', 'Address', 'Name', 'Quota', 'Dir', 'Created', 'Modified', 'Active')); $this->out(sprintf("+%'-25s+%'-15s+%'-10s+%'-20s+%'-8s+%'-8s+%'-6s+",'','','','','','','')); + $result['maildir'] = '--- skipped ---'; # TODO: include in view() result - or don't (try to) display it $this->out(sprintf('|%25s|%15s|%10s|%20s|%8s|%8s|%6s|', $result['username'], $result['name'], $result['quota'], $result['maildir'], $result['created'], $result['modified'], $result['active'])); $this->out(sprintf("+%'-25s+%'-15s+%'-10s+%'-20s+%'-8s+%'-8s+%'-6s+",'','','','','','','')); Modified: trunk/users/password.php =================================================================== --- trunk/users/password.php 2012-04-09 02:00:10 UTC (rev 1359) +++ trunk/users/password.php 2012-04-09 15:02:16 UTC (rev 1360) @@ -66,8 +66,9 @@ if ($error == 0) { - $uh = new MailboxHandler($username); - if($uh->change_pw($fPassword, $fPassword_current) ) { + $mh = new MailboxHandler(); + $mh->init($username); # TODO: error handling + if($mh->change_pw($fPassword, $fPassword_current) ) { flash_info($PALANG['pPassword_result_success']); header("Location: main.php"); exit(0); Modified: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php 2012-04-09 02:00:10 UTC (rev 1359) +++ trunk/xmlrpc.php 2012-04-09 15:02:16 UTC (rev 1360) @@ -73,7 +73,8 @@ * @return boolean true on success */ public function changePassword($old_password, $new_password) { - $uh = new MailboxHandler($_SESSION['username']); + $uh = new MailboxHandler(); + if (!$uh->init($_SESSION['username'])) return false; return $uh->change_pw($new_password, $old_password); } @@ -83,7 +84,7 @@ * @return boolean true if successful. */ public function login($username, $password) { - $uh = new MailboxHandler($_SESSION['username']); + $uh = new MailboxHandler(); # $_SESSION['username']); return $uh->login($username, $password); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-04-09 20:01:46
|
Revision: 1364 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1364&view=rev Author: christian_boltz Date: 2012-04-09 20:01:40 +0000 (Mon, 09 Apr 2012) Log Message: ----------- PFAHandler: - set(): call $this->_missing_$fieldname() if a field is not set on $new - new function set_default_value() - typically called from _missing_$fieldname to set the default from $struct AliasHandler: - set default values on $new: - on_vacation and active from $struct default - localpart and domain based on address scripts/shells/alias.php: - convert AddTask to *Handler syntax. It was broken before, see https://sourceforge.net/tracker/?func=detail&aid=3232719&group_id=191583&atid=937964 Modified Paths: -------------- trunk/model/AliasHandler.php trunk/model/PFAHandler.php trunk/scripts/shells/alias.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2012-04-09 17:56:21 UTC (rev 1363) +++ trunk/model/AliasHandler.php 2012-04-09 20:01:40 UTC (rev 1364) @@ -286,7 +286,24 @@ } } + protected function _missing_on_vacation($field) { return $this->set_default_value($field); } + protected function _missing_active ($field) { return $this->set_default_value($field); } + protected function _missing_localpart ($field) { + if (isset($this->RAWvalues['address'])) { + $parts = explode('@', $this->RAWvalues['address']); + if (count($parts) == 2) $this->RAWvalues['localpart'] = $parts[0]; + } + } + + protected function _missing_domain ($field) { + if (isset($this->RAWvalues['address'])) { + $parts = explode('@', $this->RAWvalues['address']); + if (count($parts) == 2) $this->RAWvalues['domain'] = $parts[1]; + } + } + + /** * Returns the vacation alias for this user. * i.e. if this user's username was ro...@ex..., and the autoreply domain was set to Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2012-04-09 17:56:21 UTC (rev 1363) +++ trunk/model/PFAHandler.php 2012-04-09 20:01:40 UTC (rev 1364) @@ -98,6 +98,19 @@ $this->RAWvalues = $values; # allows comparison of two fields before the second field is checked # Warning: $this->RAWvalues contains unchecked input data - use it carefully! + if ($this->new) { + foreach($this->struct as $key=>$row) { + if ($row['editable'] && !isset($values[$key]) ) { + $func="_missing_".$key; # call $this->_missing_$fieldname() + if (method_exists($this, $func) ) { + $this->{$func}($key); # function can set $this->RAWvalues[$key] (or do nothing if it can't set a useful value) + } + } + } + $values = $this->RAWvalues; + } + + # base validation $this->values = array(); $this->values_valid = false; @@ -362,6 +375,18 @@ return false; } + /** + * set field to default value + * typically called from _missing_$fieldname() + * @param string $field - fieldname + */ + protected function set_default_value($field) { + if (isset($this->struct[$field]['default'])) { + $this->RAWvalues[$field] = $this->struct[$field]['default']; + } + } + + /************************************************************************** * functions for basic input validation */ Modified: trunk/scripts/shells/alias.php =================================================================== --- trunk/scripts/shells/alias.php 2012-04-09 17:56:21 UTC (rev 1363) +++ trunk/scripts/shells/alias.php 2012-04-09 20:01:40 UTC (rev 1364) @@ -105,9 +105,13 @@ $handler = new AliasHandler(1); $handler->init($address); - $return = $handler->add($goto); - if($return == 1) { + $values = array( + 'goto' => explode(',', $goto), + ); + if (!$handler->set($values)) { + $this->error("Error:", join("\n", $handler->errormsg)); + } elseif (!$handler->store()) { $this->error("Error:", join("\n", $handler->errormsg)); } else { $this->out(""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2012-04-19 21:55:42
|
Revision: 1373 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1373&view=rev Author: GingerDog Date: 2012-04-19 21:55:36 +0000 (Thu, 19 Apr 2012) Log Message: ----------- Merge jan-kruis's vacation interval reply behaviour - see SF patch 3508083 - https://sourceforge.net/tracker/?func=detail&aid=3508083&group_id=191583&atid=937966 ; Thank you Modified Paths: -------------- trunk/VIRTUAL_VACATION/vacation.pl trunk/config.inc.php trunk/languages/en.lang trunk/languages/nl.lang trunk/model/VacationHandler.php trunk/templates/vacation.tpl trunk/upgrade.php trunk/vacation.php Modified: trunk/VIRTUAL_VACATION/vacation.pl =================================================================== --- trunk/VIRTUAL_VACATION/vacation.pl 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/VIRTUAL_VACATION/vacation.pl 2012-04-19 21:55:36 UTC (rev 1373) @@ -67,12 +67,15 @@ # 2009-08-10 Sebastian <reg9009 at yahoo dot de> # Adjust SQL query for vacation timeframe. It is now possible to set from/until date for vacation message. # -# 2012-04-19 Nikolaos Topp <info at ichier.de> +# 2012-04-1 Nikolaos Topp <info at ichier.de> # Add configuration parameter $smtp_client in order to get mails through # postfix helo-checks, using check_helo_access whitelist without permitting 'localhost' default style stuff -# 2012-03-16 Jan Kruis <jan at crossreferenc dot nl> +# +# 2012-04-19 Jan Kruis <jan at crossreferenc dot nl> # change SQL query for vacation into function. -# +# Add sub get_interval() +# Gives the user the option to set the interval time ( 0 = one reply, 1 = autoreply, > 1 = Delay reply ) +# See https://sourceforge.net/tracker/?func=detail&aid=3508083&group_id=191583&atid=937966 # Requirements - the following perl modules are required: # DBD::Pg or DBD::mysql @@ -269,6 +272,25 @@ # used to detect infinite address lookup loops my $loopcount=0; +# +# Get interval_time for email user from the vacation table +# +sub get_interval { + my ($to) = @_; + my $query = qq{SELECT interval_time FROM vacation WHERE email=? }; + my $stm = $dbh->prepare($query) or panic_prepare($query); + $stm->execute($to) or panic_execute($query," 'email='$to'"); + my $rv = $stm->rows; + if ($rv == 1) { + my @row = $stm->fetchrow_array; + my $interval = $row[0] ; + return $interval ; + } else { + return 0 ; + } +} + + sub already_notified { my ($to, $from) = @_; my $logger = get_logger(); @@ -300,6 +322,9 @@ # Let's play safe and notify anyway return 1; } + + $interval = get_interval($to); + if ($interval) { $query = qq{SELECT NOW()-notified_at FROM vacation_notification WHERE on_vacation=? AND notified=?}; $stm = $dbh->prepare($query) or panic_prepare($query); Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/config.inc.php 2012-04-19 21:55:36 UTC (rev 1373) @@ -299,6 +299,8 @@ // You should define default transport. It must be in array above. $CONF['transport_default'] = 'virtual'; +$CONF['usercontol'] = 'YES'; + // Virtual Vacation // If you want to use virtual vacation for you mailbox users set this to 'YES'. // NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/) @@ -316,6 +318,23 @@ // Set to 'YES' if your domain admins should be able to edit user vacation. $CONF['vacation_control_admin'] = 'YES'; +// Get the user ofr Admin a chioce of reply +$CONF['choice_of_reply'] = array ( + 'One Reply', // Only Reply ones on a email + 'Auto Reply', // Only Reply to this Sender if last email from this sender + 'Interval Reply' // same as above but delay time is +); + +$CONF['replytype_default'] = 'One Reply'; +$CONF['autoreplydelay_default'] = '10'; // Send no email if last email was send within 10 sec. +$CONF['intervaldelay_default'] = '3600'; // Send only a reply to a email if the last 1 hour ago. + +// Users Control for Domain Admin +// Set to "Yes" if your doamain admins schould be able to edit field userscontrole in table domain +// Userscontrol is edited in admin_create-domain.tpl and admin_edit-domain.tpl +// Userscontrol is default set to on when creating a domain +$CONF['users_domain_controle'] = 'YES'; + // Alias Control // Postfix Admin inserts an alias in the alias table for every mailbox it creates. // The reason for this is that when you want catch-all and normal mailboxes Modified: trunk/languages/en.lang =================================================================== --- trunk/languages/en.lang 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/languages/en.lang 2012-04-19 21:55:36 UTC (rev 1373) @@ -194,6 +194,9 @@ $PALANG['pVacation_result_error'] = 'Unable to update auto response settings!'; $PALANG['pVacation_result_removed'] = 'Auto response for %s has been disabled!'; $PALANG['pVacation_result_added'] = 'Auto response for %s has been enabled!'; +$PALANG['pVacation_reply_type'] = 'Choice of reply'; +$PALANG['pVacation_reply_delay_time'] = 'Interval time'; +$PALANG['pVacation_reply_delay_time_text'] = 'Time in seconds'; $PALANG['pViewlog_welcome'] = 'View the last 10 actions for '; $PALANG['pViewlog_timestamp'] = 'Timestamp'; @@ -261,6 +264,7 @@ $PALANG['pAdminList_domain_quota'] = 'Domain quota (MB)'; $PALANG['pAdminList_domain_transport'] = 'Transport'; $PALANG['pAdminList_domain_backupmx'] = 'Backup MX'; +$PALANG['pAdminList_domain_usercontrol'] = 'User Control'; $PALANG['pAdminList_domain_modified'] = 'Last Modified'; $PALANG['pAdminList_domain_active'] = 'Active'; @@ -294,6 +298,7 @@ $PALANG['pAdminCreate_domain_defaultaliases'] = 'Add default mail aliases'; $PALANG['pAdminCreate_domain_defaultaliases_text'] = ''; $PALANG['pAdminCreate_domain_backupmx'] = 'Mail server is backup MX'; # obsolete +$PALANG['pAdminCreate_domain_usercontrol'] = 'Allow user control'; $PALANG['pAdminCreate_domain_button'] = 'Add Domain'; $PALANG['pAdminCreate_domain_result_error'] = 'Unable to add domain!'; $PALANG['pAdminCreate_domain_result_success'] = 'Domain has been added!'; @@ -315,6 +320,7 @@ $PALANG['pAdminEdit_domain_transport'] = 'Transport'; $PALANG['pAdminEdit_domain_transport_text'] = 'Define transport'; $PALANG['pAdminEdit_domain_backupmx'] = 'Mail server is backup MX'; +$PALANG['pAdminEdit_domain_usercontrol'] = 'Allow user control'; $PALANG['pAdminEdit_domain_active'] = 'Active'; $PALANG['pAdminEdit_domain_button'] = 'Edit Domain'; # text no longer used $PALANG['pAdminEdit_domain_result_error'] = 'Unable to modify domain!'; Modified: trunk/languages/nl.lang =================================================================== --- trunk/languages/nl.lang 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/languages/nl.lang 2012-04-19 21:55:36 UTC (rev 1373) @@ -191,6 +191,10 @@ $PALANG['pVacation_result_error'] = 'Niet in staat automatisch beantwoorden te wijzigen!'; $PALANG['pVacation_result_removed'] = 'Automatisch beantwoorden is voor %s gedeactiveerd!'; $PALANG['pVacation_result_added'] = 'Automatisch beantwoorden is voor %s geactiveerd!'; +$PALANG['pVacation_result_added'] = 'Automatisch beantwoorden is geactiveerd!'; +$PALANG['pVacation_reply_type'] = 'Keuze van beantwoording'; +$PALANG['pVacation_reply_delay_time'] = 'Interval tijd'; +$PALANG['pVacation_reply_delay_time_text'] = 'Tijd in seconds'; $PALANG['pViewlog_welcome'] = 'Laat de laatste 10 actie\'s zien van '; $PALANG['pViewlog_timestamp'] = 'Tijd'; @@ -272,6 +276,7 @@ $PALANG['pAdminList_virtual_mailbox_quota'] = 'Quota (MB)'; $PALANG['pAdminList_virtual_mailbox_modified'] = 'Laatst bewerkt'; $PALANG['pAdminList_virtual_mailbox_active'] = 'Actief'; +$PALANG['pAdminList_domain_userscontrol'] = 'Gebruikers<br />Beheer'; $PALANG['pAdminCreate_domain_welcome'] = 'Voeg een nieuw domein toe'; $PALANG['pAdminCreate_domain_domain'] = 'Domein'; # obsolete @@ -313,6 +318,7 @@ $PALANG['pAdminEdit_domain_active'] = 'Actief'; $PALANG['pAdminEdit_domain_button'] = 'Bewerk domein'; # XXX text no longer used $PALANG['pAdminEdit_domain_result_error'] = 'Mislukt het domein te bewerken.'; +$PALANG['pAdminEdit_domain_userscontrol'] = 'Sta contorle door gebruikers toe'; $PALANG['pAdminCreate_admin_welcome'] = 'Voeg een nieuw domein beheerder toe'; $PALANG['pAdminCreate_admin_username'] = 'Beheerder'; # obsolete Modified: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/model/VacationHandler.php 2012-04-19 21:55:36 UTC (rev 1373) @@ -16,15 +16,15 @@ function remove() { if (!$this->updateAlias(0)) return false; - // tidy up vacation table. - $vacation_data = array( + // tidy up vacation table. + $vacation_data = array( 'active' => db_get_boolean(false), - ); - $result = db_update('vacation', 'email', $this->username, $vacation_data); - $result = db_delete('vacation_notification', 'on_vacation', $this->username); -# TODO db_log() call (maybe except if called from set_away?) - /* crap error handling; oh for exceptions... */ - return true; + ); + $result = db_update('vacation', 'email', $this->username, $vacation_data); + $result = db_delete('vacation_notification', 'on_vacation', $this->username); + # TODO db_log() call (maybe except if called from set_away?) + /* crap error handling; oh for exceptions... */ + return true; } /** @@ -81,6 +81,8 @@ 'subject' => $row['subject'], 'body' => $row['body'], 'active' => $boolean , + 'reply_type' => $row['reply_type'], + 'interval_time' => $row['interval_time'], 'activeFrom' => $row['activefrom'], 'activeUntil' => $row['activeuntil'], ); @@ -88,10 +90,12 @@ /** * @param string $subject * @param string $body + * @param string $reply_type + * @param string $interval_time * @param date $activeFrom * @param date $activeUntil */ - function set_away($subject, $body, $activeFrom, $activeUntil) { + function set_away($subject, $body, $reply_type, $interval_time, $activeFrom, $activeUntil) { $this->remove(); // clean out any notifications that might already have been sent. $E_username = escape_string($this->username); @@ -104,6 +108,8 @@ 'domain' => $domain, 'subject' => $subject, 'body' => $body, + 'reply_type' => $reply_type, + 'interval_time' => $interval_time, 'active' => db_get_boolean(true), 'activefrom' => $activeFrom, 'activeuntil' => $activeUntil, @@ -117,13 +123,13 @@ } else { $result = db_insert('vacation', $vacation_data); } -# TODO error check -# TODO wrap whole function in db_begin / db_commit (or rollback)? + # TODO error check + # TODO wrap whole function in db_begin / db_commit (or rollback)? return $this->updateAlias(1); } - /** + /** * add/remove the vacation alias * @param int $vacationActive */ @@ -137,7 +143,7 @@ $values = array ( 'on_vacation' => $vacationActive, - ); + ); if (!$handler->set($values)) { # print_r($handler->errormsg); # TODO: error handling Modified: trunk/templates/vacation.tpl =================================================================== --- trunk/templates/vacation.tpl 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/templates/vacation.tpl 2012-04-19 21:55:36 UTC (rev 1373) @@ -42,6 +42,19 @@ </td> <td> </td> </tr> + + <tr> + <td class="label"><label>{$PALANG.pVacation_reply_type}:</label></td> + <td><select class="flat" name="fReply_Type">{$select_options}</select></td> + <td> </td> + </tr> + <tr> + <td class="label"><label>{$PALANG.pVacation_reply_delay_time}:</label></td> + <td><input class="flat" type="text" name="fInterval_Time" value="{$tInterval_Time}" /></td> + <td>{$PALANG.pVacation_reply_delay_time_text}</td> + <td> </td> + </tr> + <tr> <td class="label"><label>{$PALANG.pUsersVacation_subject}:</label></td> <td><textarea class="flat" rows="3" cols="60" name="fSubject" >{$tSubject}</textarea></td> Modified: trunk/upgrade.php =================================================================== --- trunk/upgrade.php 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/upgrade.php 2012-04-19 21:55:36 UTC (rev 1373) @@ -1322,7 +1322,13 @@ } } +function upgrade_1345_mysql() { + $table_vacation = table_by_key('vacation'); + db_query_parsed("ALTER TABLE `$table_vacation` ADD `reply_type` VARCHAR( 20 ) NOT NULL AFTER `domain` "); + db_query_parsed("ALTER TABLE `$table_vacation` ADD `interval_time` INT NOT NULL DEFAULT '0' AFTER `reply_type` "); +} + # TODO MySQL: # - various varchar fields do not have a default value # https://sourceforge.net/projects/postfixadmin/forums/forum/676076/topic/3419725 Modified: trunk/vacation.php =================================================================== --- trunk/vacation.php 2012-04-19 21:19:15 UTC (rev 1372) +++ trunk/vacation.php 2012-04-19 21:55:36 UTC (rev 1373) @@ -76,11 +76,15 @@ $tActiveFrom = ''; $tActiveUntil = ''; $tUseremail = $fUsername; + $tReply_Type = ''; + $tInterval_Time = ''; $details = $vh->get_details(); if($details != false) { $tSubject = $details['subject']; $tBody = $details['body']; + $tReply_Type = $details['reply_type']; + $tInterval_Time = $details['interval_time']; $tActiveFrom = $details['activeFrom']; $tActiveUntil = $details['activeUntil']; } @@ -93,6 +97,13 @@ //set a default, reset fields for coming back selection if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); } if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } + + if ($tReply_Type =='') { $tReply_Type = $CONF['replytype_default'];} + if ($tReply_Type =='One Reply') { $tInterval_Time = '0';} + if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['autoreplydelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['intervaldelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['autoreplydelay_default'])) { $tInterval_Time = $CONF['intervaldelay_default'];} + } if ($_SERVER['REQUEST_METHOD'] == "POST") @@ -110,6 +121,9 @@ $tBody = safepost('fBody'); $fBody = $tBody; + $tReply_Type = safepost('fReply_Type'); + $tInterval_Time = safepost('fInterval_Time'); + $fChange = escape_string (safepost('fChange')); $fBack = escape_string (safepost('fBack')); @@ -118,14 +132,22 @@ //set a default, reset fields for coming back selection if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); } if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } + if ($tReply_Type =='') { $tReply_Type = $CONF['replytype_default'];} + if ($tReply_Type =='One Reply') { $tInterval_Time = '0';} + if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['autoreplydelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['intervaldelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['autoreplydelay_default'])) { $tInterval_Time = $CONF['intervaldelay_default'];} + $fReply_Type = $tReply_Type ; + $fInterval_Time = $tInterval_Time; + // if they've set themselves change OR back, delete any record of vacation emails. // the user is going away - set the goto alias and vacation table as necessary. //Set the vacation data for $fUsername if (!empty ($fChange)) { - if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) { + if(!$vh->set_away($fSubject, $fBody, $fReply_Type, $fInterval_Time, $tActiveFrom, $tActiveUntil)) { $error = 1; } } @@ -165,6 +187,8 @@ $smarty->assign ('tBody', $tBody); $smarty->assign ('tActiveFrom', date ("d.m.Y", strtotime ($tActiveFrom))); $smarty->assign ('tActiveUntil', date ("d.m.Y", strtotime ($tActiveUntil))); +$smarty->assign ('select_options', select_options ( $CONF ['choice_of_reply'], array ($tReply_Type)),false); +$smarty->assign ('tInterval_Time', $tInterval_Time); $smarty->assign ('smarty_template', 'vacation'); $smarty->display ('index.tpl'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2012-04-23 21:18:01
|
Revision: 1374 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1374&view=rev Author: GingerDog Date: 2012-04-23 20:57:54 +0000 (Mon, 23 Apr 2012) Log Message: ----------- patch from Jan Kruis - see http://sourceforge.net/tracker/?func=detail&aid=3520749&group_id=191583&atid=937966 (Tracker id 3520749) ; thank you! Modified Paths: -------------- trunk/VIRTUAL_VACATION/vacation.pl trunk/config.inc.php trunk/vacation.php Modified: trunk/VIRTUAL_VACATION/vacation.pl =================================================================== --- trunk/VIRTUAL_VACATION/vacation.pl 2012-04-19 21:55:36 UTC (rev 1373) +++ trunk/VIRTUAL_VACATION/vacation.pl 2012-04-23 20:57:54 UTC (rev 1374) @@ -71,7 +71,7 @@ # Add configuration parameter $smtp_client in order to get mails through # postfix helo-checks, using check_helo_access whitelist without permitting 'localhost' default style stuff # -# 2012-04-19 Jan Kruis <jan at crossreferenc dot nl> +# 2012-04-19 Jan Kruis <jan at crossreference dot nl> # change SQL query for vacation into function. # Add sub get_interval() # Gives the user the option to set the interval time ( 0 = one reply, 1 = autoreply, > 1 = Delay reply ) @@ -304,8 +304,8 @@ } $stm->execute($to,$from); - my $query = qq{INSERT into vacation_notification (on_vacation,notified) values (?,?)}; - my $stm = $dbh->prepare($query); + $query = qq{INSERT into vacation_notification (on_vacation,notified) values (?,?)}; + $stm = $dbh->prepare($query); if (!$stm) { $logger->error("Could not prepare query '$query' to: $to, from:$from"); return 1; Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2012-04-19 21:55:36 UTC (rev 1373) +++ trunk/config.inc.php 2012-04-23 20:57:54 UTC (rev 1374) @@ -299,12 +299,17 @@ // You should define default transport. It must be in array above. $CONF['transport_default'] = 'virtual'; -$CONF['usercontol'] = 'YES'; -// Virtual Vacation +// +// +// Virtual Vacation Stuff +// +// + // If you want to use virtual vacation for you mailbox users set this to 'YES'. // NOTE: Make sure that you install the vacation module. (See VIRTUAL-VACATION/) $CONF['vacation'] = 'NO'; + // This is the autoreply domain that you will need to set in your Postfix // transport maps to handle virtual vacations. It does not need to be a // real domain (i.e. you don't need to setup DNS for it). @@ -318,23 +323,53 @@ // Set to 'YES' if your domain admins should be able to edit user vacation. $CONF['vacation_control_admin'] = 'YES'; -// Get the user ofr Admin a chioce of reply -$CONF['choice_of_reply'] = array ( - 'One Reply', // Only Reply ones on a email - 'Auto Reply', // Only Reply to this Sender if last email from this sender - 'Interval Reply' // same as above but delay time is +// Alllow ReplyType Control +// This varible will be checked in ./templates/vacation.tpl +// YES means it show the reply option, everything else means it will not show +$CONF['vacation_replytype_control'] = 'YES'; + +// AllowUser Reply +// You can Allow or Disable User control over Reply Type +// This variable will be checked in ./templates/vacation.tpl +// YES means it show the reply option, anything else means it will not show +$CONF['vacation_allow_user_reply'] = 'YES'; + +// ReplyType options +// If you want to define additional reply options put them in array below. +$CONF['vacation_choice_of_reply'] = array ( + 'One Reply', // Sends only Once the message during Out of Office + 'Auto Reply', // Reply on every email but not within autoreplydelay + 'Interval Reply' // Reply on every email but not within intervaldelay_default ); -$CONF['replytype_default'] = 'One Reply'; -$CONF['autoreplydelay_default'] = '10'; // Send no email if last email was send within 10 sec. -$CONF['intervaldelay_default'] = '3600'; // Send only a reply to a email if the last 1 hour ago. +// ReplyType default +// You should define default replytype. It must be in array above. +$CONF['vacation_replytype_default'] = 'One Reply'; +// autoreplydelay +// You should define autodefaultdelay is seconds +// if a new message comes in within this delay it most likely that that the sender is +// autoreplying on our autoreply message. +$CONF['vacation_autoreplydelay_default'] = '10'; + +// Replydelay default +// You should define default replydelay time here time in in seconds. +$CONF['vacation_intervaldelay_default'] = '86400'; // is 1 day = 60 sec * 60 min * 24 hours + +// +// End Vacation Stuff. +// + // Users Control for Domain Admin -// Set to "Yes" if your doamain admins schould be able to edit field userscontrole in table domain +// Set to "Yes" if your domain admins schould be able to edit field userscontrole in table domain // Userscontrol is edited in admin_create-domain.tpl and admin_edit-domain.tpl // Userscontrol is default set to on when creating a domain $CONF['users_domain_controle'] = 'YES'; + +$CONF['usercontol'] = 'YES'; + + // Alias Control // Postfix Admin inserts an alias in the alias table for every mailbox it creates. // The reason for this is that when you want catch-all and normal mailboxes Modified: trunk/vacation.php =================================================================== --- trunk/vacation.php 2012-04-19 21:55:36 UTC (rev 1373) +++ trunk/vacation.php 2012-04-23 20:57:54 UTC (rev 1374) @@ -98,11 +98,11 @@ if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); } if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } - if ($tReply_Type =='') { $tReply_Type = $CONF['replytype_default'];} + if ($tReply_Type =='') { $tReply_Type = $CONF['vacation_replytype_default'];} if ($tReply_Type =='One Reply') { $tInterval_Time = '0';} - if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['autoreplydelay_default'];} - if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['intervaldelay_default'];} - if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['autoreplydelay_default'])) { $tInterval_Time = $CONF['intervaldelay_default'];} + if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['vacation_autoreplydelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['vacation_intervaldelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['vacation_autoreplydelay_default'])) { $tInterval_Time = $CONF['vacation_intervaldelay_default'];} } @@ -132,11 +132,11 @@ //set a default, reset fields for coming back selection if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); } if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } - if ($tReply_Type =='') { $tReply_Type = $CONF['replytype_default'];} + if ($tReply_Type =='') { $tReply_Type = $CONF['vacation_replytype_default'];} if ($tReply_Type =='One Reply') { $tInterval_Time = '0';} - if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['autoreplydelay_default'];} - if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['intervaldelay_default'];} - if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['autoreplydelay_default'])) { $tInterval_Time = $CONF['intervaldelay_default'];} + if ($tReply_Type =='Auto Reply') { $tInterval_Time = $CONF['vacation_autoreplydelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time =='')) { $tInterval_Time = $CONF['vacation_intervaldelay_default'];} + if (($tReply_Type =='Interval Reply') and ($tInterval_Time <= $CONF['vacation_autoreplydelay_default'])) { $tInterval_Time = $CONF['vacation_intervaldelay_default'];} $fReply_Type = $tReply_Type ; $fInterval_Time = $tInterval_Time; @@ -187,7 +187,7 @@ $smarty->assign ('tBody', $tBody); $smarty->assign ('tActiveFrom', date ("d.m.Y", strtotime ($tActiveFrom))); $smarty->assign ('tActiveUntil', date ("d.m.Y", strtotime ($tActiveUntil))); -$smarty->assign ('select_options', select_options ( $CONF ['choice_of_reply'], array ($tReply_Type)),false); +$smarty->assign ('select_options', select_options ( $CONF ['vacation_choice_of_reply'], array ($tReply_Type)),false); $smarty->assign ('tInterval_Time', $tInterval_Time); $smarty->assign ('smarty_template', 'vacation'); $smarty->display ('index.tpl'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-05-07 22:53:10
|
Revision: 1386 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1386&view=rev Author: christian_boltz Date: 2012-05-07 22:53:04 +0000 (Mon, 07 May 2012) Log Message: ----------- functions.inc.php: - change list_admins() to use AdminHandler (code from list-admin.php) Note: this changes the return value format to include all details, not only the usernames. Use array_keys(list_admins()) if you need the previous return format. list-admin.php: - replace code with a list_admins() call list-domain.php: - adopt to new list_admins() return value Modified Paths: -------------- trunk/functions.inc.php trunk/list-admin.php trunk/list-domain.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/functions.inc.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -266,6 +266,7 @@ * @param String $email - a string that may be an email address. * @return boolean true if it's an email address, else false. * TODO: make check_email able to handle already added domains + * TODO: don't use flash_error, use return value instead */ function check_email ($email) { global $CONF; @@ -857,18 +858,15 @@ // was admin_list_admins // function list_admins () { - # TODO: use AdminHandler - global $table_admin; - $list = ""; + $handler = new AdminHandler(); - $result = db_query ("SELECT username FROM $table_admin ORDER BY username"); - if ($result['rows'] > 0) { - $i = 0; - while ($row = db_array ($result['result'])) { - $list[$i] = $row['username']; - $i++; - } + if ($handler->getList('1=1')) { + $list = $handler->result(); + } else { + $list = array(); + # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...) } + return $list; } Modified: trunk/list-admin.php =================================================================== --- trunk/list-admin.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/list-admin.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -25,16 +25,8 @@ authentication_require_role('global-admin'); -# TODO: move code to list_admins() in functions.inc.php? -$handler = new AdminHandler(0 /*, $admin_username*/ ); +$admin_properties = list_admins(); -if ($handler->getList('1=1')) { - $admin_properties = $handler->result(); -} else { - $admin_properties = array(); - # TODO: check if there was an error or simply no admins (which shouldn't happen because nobody could login then...) -} - $smarty->assign ('admin_properties', $admin_properties); $smarty->assign ('smarty_template', 'adminlistadmin'); $smarty->display ('index.tpl'); Modified: trunk/list-domain.php =================================================================== --- trunk/list-domain.php 2012-05-06 20:01:32 UTC (rev 1385) +++ trunk/list-domain.php 2012-05-07 22:53:04 UTC (rev 1386) @@ -27,7 +27,7 @@ $fUsername = ""; if (authentication_has_role('global-admin')) { # more permissions? Fine! - $list_admins = list_admins (); + $list_admins = array_keys(list_admins()); $is_superadmin = 1; $fUsername = safepost('fUsername', safeget('username', authentication_get_username())); # prefer POST over GET variable This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-05-28 18:01:37
|
Revision: 1395 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1395&view=rev Author: christian_boltz Date: 2012-05-28 18:01:31 +0000 (Mon, 28 May 2012) Log Message: ----------- smarty.inc.php: - replace (last) usage of $CONF['postfix_admin_url'] with $rel_path (relative path to CSS etc., set to '../' in users/*) users/*.php: - set $rel_path to '../' https://sourceforge.net/tracker/?func=detail&aid=3039042&group_id=191583&atid=937964 Modified Paths: -------------- trunk/smarty.inc.php trunk/users/edit-alias.php trunk/users/login.php trunk/users/main.php trunk/users/password.php trunk/users/vacation.php Modified: trunk/smarty.inc.php =================================================================== --- trunk/smarty.inc.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/smarty.inc.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -53,10 +53,12 @@ } $smarty = new PFASmarty(); -$CONF['theme_css'] = $CONF['postfix_admin_url'].'/'.htmlentities($CONF['theme_css']); -if ($CONF['theme_custom_css'] != "") $CONF['theme_custom_css'] = $CONF['postfix_admin_url'].'/'.htmlentities($CONF['theme_custom_css']); -$CONF['theme_logo'] = $CONF['postfix_admin_url'].'/'.htmlentities($CONF['theme_logo']); +if (!isset($rel_path)) $rel_path = ''; # users/* sets this to '../' +$CONF['theme_css'] = $rel_path . htmlentities($CONF['theme_css']); +if ($CONF['theme_custom_css'] != "") $CONF['theme_custom_css'] = $rel_path . htmlentities($CONF['theme_custom_css']); +$CONF['theme_logo'] = $rel_path . htmlentities($CONF['theme_logo']); + $smarty->assign ('CONF', $CONF); $smarty->assign ('PALANG', $PALANG); $smarty->assign('url_domain', ''); Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/users/edit-alias.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -19,6 +19,7 @@ * */ +$rel_path = '../'; require_once('../common.php'); $smarty->assign ('smarty_template', 'users_edit-alias'); Modified: trunk/users/login.php =================================================================== --- trunk/users/login.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/users/login.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -27,6 +27,7 @@ * lang */ +$rel_path = '../'; require_once("../common.php"); Modified: trunk/users/main.php =================================================================== --- trunk/users/main.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/users/main.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -23,6 +23,7 @@ * Form POST \ GET Variables: -none- */ +$rel_path = '../'; require_once('../common.php'); authentication_require_role('user'); $USERID_USERNAME = authentication_get_username(); Modified: trunk/users/password.php =================================================================== --- trunk/users/password.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/users/password.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -27,6 +27,7 @@ * fPassword2 */ +$rel_path = '../'; require_once('../common.php'); authentication_require_role('user'); Modified: trunk/users/vacation.php =================================================================== --- trunk/users/vacation.php 2012-05-28 17:43:39 UTC (rev 1394) +++ trunk/users/vacation.php 2012-05-28 18:01:31 UTC (rev 1395) @@ -17,6 +17,7 @@ * */ +$rel_path = '../'; require_once('../common.php'); require_once('../vacation.php'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-05-28 18:07:40
|
Revision: 1396 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1396&view=rev Author: christian_boltz Date: 2012-05-28 18:07:33 +0000 (Mon, 28 May 2012) Log Message: ----------- config.inc.php: - remove the (now superfluous) $CONF['postfix_admin_url'] config option debian/patches/db_credentials: - remove the section that sets $CONF['postfix_admin_url'] functions.inc.php - authentication_require_role(): - also remove $CONF['postfix_admin_url'] from comments - remove the './' part from the redirect Combined with the previous two commits, this fixes https://sourceforge.net/tracker/?func=detail&aid=3039042&group_id=191583&atid=937964 Modified Paths: -------------- trunk/config.inc.php trunk/debian/patches/db_credentials trunk/functions.inc.php Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2012-05-28 18:01:31 UTC (rev 1395) +++ trunk/config.inc.php 2012-05-28 18:07:33 UTC (rev 1396) @@ -29,10 +29,6 @@ // To create the hash, visit setup.php in a browser and type a password into the field, // on submission it will be echoed out to you as a hashed value. $CONF['setup_password'] = 'changeme'; -// Postfix Admin Path -// Set the location of your Postfix Admin installation here. -// YOU MUST ENTER THE COMPLETE URL e.g. http://domain.tld/postfixadmin -$CONF['postfix_admin_url'] = ''; // Language config // Language files are located in './languages', change as required.. Modified: trunk/debian/patches/db_credentials =================================================================== --- trunk/debian/patches/db_credentials 2012-05-28 18:01:31 UTC (rev 1395) +++ trunk/debian/patches/db_credentials 2012-05-28 18:07:33 UTC (rev 1396) @@ -1,7 +1,7 @@ Description: This patch sets the dbconfig placeholders in config.inc.php. Forwarded: not-needed Author: Norman Messtorff <no...@no...> -Last-Update: 2011-12-18 +Last-Update: 2012-05-28 Index: postfixadmin/config.inc.php =================================================================== @@ -28,15 +28,6 @@ // In order to setup Postfixadmin, you MUST specify a hashed password here. // To create the hash, visit setup.php in a browser and type a password into the field, -@@ -32,7 +37,7 @@ - // Postfix Admin Path - // Set the location of your Postfix Admin installation here. - // YOU MUST ENTER THE COMPLETE URL e.g. http://domain.tld/postfixadmin --$CONF['postfix_admin_url'] = ''; -+$CONF['postfix_admin_url'] = '/postfixadmin'; - - // Language config - // Language files are located in './languages', change as required.. @@ -85,11 +90,11 @@ // mysql = MySQL 3.23 and 4.0, 4.1 or 5 // mysqli = MySQL 4.1+ Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-05-28 18:01:31 UTC (rev 1395) +++ trunk/functions.inc.php 2012-05-28 18:07:33 UTC (rev 1396) @@ -78,8 +78,7 @@ /** * Used to enforce that $user has a particular role when * viewing a page. - * If they are lacking a role, redirect them to - * $CONF['postfix_admin_url']/login.php + * If they are lacking a role, redirect them to login.php * * Note, user < admin < global-admin */ @@ -90,7 +89,7 @@ return True; } - header("Location: ./login.php"); + header("Location: login.php"); exit(0); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-05-28 20:05:54
|
Revision: 1397 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1397&view=rev Author: christian_boltz Date: 2012-05-28 20:05:48 +0000 (Mon, 28 May 2012) Log Message: ----------- functions.inc.php: - pacrypt(): no longer escape_string() the result. This fixes https://sourceforge.net/tracker/index.php?func=detail&aid=3094804&group_id=191583&atid=937964 create-mailbox.php, password.php: - escape_string() the pacrypt() result login.php: - simplify code to require one query less (this also removes the need to escape_string() the password) I also checked the other files using pacrypt() - they don't need escaping or already do it. Modified Paths: -------------- trunk/create-mailbox.php trunk/functions.inc.php trunk/login.php trunk/password.php Modified: trunk/create-mailbox.php =================================================================== --- trunk/create-mailbox.php 2012-05-28 18:07:33 UTC (rev 1396) +++ trunk/create-mailbox.php 2012-05-28 20:05:48 UTC (rev 1397) @@ -139,7 +139,7 @@ $tQuota = $fQuota; $tDomain = $fDomain; } else { - $password = pacrypt ($fPassword); + $password = escape_string(pacrypt ($fPassword)); if($CONF['maildir_name_hook'] != 'NO' && function_exists($CONF['maildir_name_hook'])) { $hook_func = $CONF['maildir_name_hook']; Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2012-05-28 18:07:33 UTC (rev 1396) +++ trunk/functions.inc.php 2012-05-28 20:05:48 UTC (rev 1397) @@ -1184,7 +1184,6 @@ die ('unknown/invalid $CONF["encrypt"] setting: ' . $CONF['encrypt']); } - $password = escape_string ($password); # TODO: disable escaping - https://sourceforge.net/tracker/?func=detail&aid=3301752&group_id=191583&atid=937964 return $password; } Modified: trunk/login.php =================================================================== --- trunk/login.php 2012-05-28 18:07:33 UTC (rev 1396) +++ trunk/login.php 2012-05-28 20:05:48 UTC (rev 1397) @@ -48,14 +48,13 @@ # (language preference cookie is processed even if username and/or password are invalid) } + # TODO: move to AdminHandler->login $result = db_query ("SELECT password FROM $table_admin WHERE username='$fUsername' AND active='1'"); if ($result['rows'] == 1) { $row = db_array ($result['result']); - $password = pacrypt ($fPassword, $row['password']); - $result = db_query ("SELECT * FROM $table_admin WHERE username='$fUsername' AND password='$password' AND active='1'"); - if ($result['rows'] != 1) - { + $crypt_password = pacrypt ($fPassword, $row['password']); + if ($row['password'] != $crypt_password) { $error = 1; flash_error($PALANG['pLogin_failed']); } Modified: trunk/password.php =================================================================== --- trunk/password.php 2012-05-28 18:07:33 UTC (rev 1396) +++ trunk/password.php 2012-05-28 20:05:48 UTC (rev 1397) @@ -56,7 +56,7 @@ if ($result['rows'] == 1) { $row = db_array ($result['result']); - $checked_password = pacrypt ($fPassword_current, $row['password']); + $checked_password = escape_string(pacrypt ($fPassword_current, $row['password'])); $result = db_query ("SELECT * FROM $table_admin WHERE username='$username' AND password='$checked_password'"); if ($result['rows'] != 1) @@ -79,7 +79,7 @@ if ($error != 1) { - $password = pacrypt ($fPassword); + $password = escape_string(pacrypt ($fPassword)); $result = db_query ("UPDATE $table_admin SET password='$password',modified=NOW() WHERE username='$username'"); if ($result['rows'] == 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2012-12-29 00:14:04
|
Revision: 1416 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1416&view=rev Author: christian_boltz Date: 2012-12-29 00:13:57 +0000 (Sat, 29 Dec 2012) Log Message: ----------- list-virtual_mailbox.tpl: - use edit.php to edit mailboxes edit-mailbox.php: - delete, obsoleted by edit.php + MailboxHandler Modified Paths: -------------- trunk/templates/list-virtual_mailbox.tpl Removed Paths: ------------- trunk/edit-mailbox.php Deleted: trunk/edit-mailbox.php =================================================================== --- trunk/edit-mailbox.php 2012-12-28 23:48:33 UTC (rev 1415) +++ trunk/edit-mailbox.php 2012-12-29 00:13:57 UTC (rev 1416) @@ -1,183 +0,0 @@ -<?php -/** - * Postfix Admin - * - * LICENSE - * This source file is subject to the GPL license that is bundled with - * this package in the file LICENSE.TXT. - * - * Further details on the project are available at : - * http://www.postfixadmin.com or http://postfixadmin.sf.net - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * File: edit-mailbox.php - * Used to update an existing mailboxes settings. - * Template File: edit-mailbox.tpl - * - * Template Variables: - * - * tName - * tQuota - * - * Form POST \ GET Variables: - * - * fUsername - * fDomain - * fPassword - * fPassword2 - * fName - * fQuota - * fActive - */ - -require_once('common.php'); - -authentication_require_role('admin'); -$SESSID_USERNAME = authentication_get_username(); - -$fUsername = 'x'; -$fDomain = 'y'; -$error = 0; - -if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']); -$fUsername = strtolower ($fUsername); -if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - -$pEdit_mailbox_quota_text_error = ""; -$mailbox_password_text_error = ""; - -if (!(check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) ) -{ - $error = 1; - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - flash_error($PALANG['pEdit_mailbox_domain_error'] . "$fDomain"); -} - -$result = db_query("SELECT * FROM $table_mailbox WHERE username = '$fUsername' AND domain = '$fDomain'"); -if($result['rows'] != 1) { - die("Invalid username chosen; user does not exist in mailbox table"); -} -$user_details = db_array($result['result']); - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - if (check_owner($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) - { - $tName = $user_details['name']; - $tQuota = divide_quota($user_details['quota']); - $tActive = $user_details['active']; - if ('pgsql'==$CONF['database_type']) { - $tActive = ('t'==$user_details['active']) ? 1 : 0; - } - - $tMaxquota = allowed_quota($fDomain, $user_details['quota']); - } -} - -if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['cancel'])) { - header("Location: list-virtual.php?domain=$fDomain"); - exit(0); -} - -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); - if (isset ($_POST['fName'])) $fName = escape_string ($_POST['fName']); - if (isset ($_POST['fQuota'])) $fQuota = intval ($_POST['fQuota']); - if (isset ($_POST['fActive'])) $fActive = escape_string ($_POST['fActive']); - - if($fPassword != $user_details['password'] || $fPassword2 != $user_details['password']){ - if($fPassword == $fPassword2) { - if ($fPassword != "") { - $validpass = validate_password($fPassword); - if(count($validpass) > 0) { - $mailbox_password_text_error = $validpass[0]; # TODO: honor all error messages, not only the first one - $error = 1; - } - $formvars['password'] = pacrypt($fPassword); - } - } - else { - $mailbox_password_text_error = $PALANG['pEdit_mailbox_password_text_error']; - $error = 1; - } - } - if ($CONF['quota'] == "YES") - { - if (!check_quota ($fQuota, $fDomain, $fUsername)) - { - $error = 1; - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - $tMaxquota = allowed_quota($fDomain, $user_details['quota']); - - $pEdit_mailbox_quota_text_error = $PALANG['pEdit_mailbox_quota_text_error']; - } - } - if ($error != 1) - { - if (!empty ($fQuota)) - { - $quota = multiply_quota ($fQuota); - } - else - { - $quota = 0; - } - - if ($fActive == "on") - { - $sqlActive = db_get_boolean(True); - $fActive = 1; - } - else - { - $sqlActive = db_get_boolean(False); - $fActive = 0; - } - - $formvars['name'] = $fName; - $formvars['quota'] =$quota; - $formvars['active']=$sqlActive; - if(preg_match('/^(.*)@/', $fUsername, $matches)) { - $formvars['local_part'] = $matches[1]; - } - $result = db_update_q('mailbox', "username='$fUsername' AND domain='$fDomain'", $formvars); # TODO: check if we need the AND domain=... clause, if not, switch to db_update() - $maildir = $user_details['maildir']; - if ($result != 1 || !mailbox_postedit($fUsername,$fDomain,$maildir, $quota)) { - flash_error($PALANG['pEdit_mailbox_result_error']); - } - else { - db_log ($fDomain, 'edit_mailbox', $fUsername); - - header ("Location: list-virtual.php?domain=$fDomain"); - exit(0); - } - } - else - { - # error detected. Put the values the user entered in the form again. - $tName = $fName; - $tQuota = $fQuota; - $tActive = $fActive; - } -} - -$smarty->assign ('mode', 'edit'); -$smarty->assign ('fUsername', $fUsername); -$smarty->assign ('tName', $tName, false); -$smarty->assign ('tMaxquota', $tMaxquota); -$smarty->assign ('tQuota', $tQuota); -$smarty->assign ('mailbox_quota_text_error', $pEdit_mailbox_quota_text_error); -$smarty->assign ('mailbox_password_text_error', $mailbox_password_text_error); -if ($tActive) $smarty->assign ('tActive', ' checked="checked"'); -$smarty->assign ('smarty_template', 'edit-mailbox'); -$smarty->display ('index.tpl'); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?> Modified: trunk/templates/list-virtual_mailbox.tpl =================================================================== --- trunk/templates/list-virtual_mailbox.tpl 2012-12-28 23:48:33 UTC (rev 1415) +++ trunk/templates/list-virtual_mailbox.tpl 2012-12-29 00:13:57 UTC (rev 1416) @@ -85,7 +85,7 @@ {if $edit_aliases==1} <td><a href="edit.php?table=alias&edit={$item.username|escape:"url"}">{$PALANG.pOverview_alias_edit}</a></td> {/if} - <td><a href="edit-mailbox.php?username={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}">{$PALANG.edit}</a></td> + <td><a href="edit.php?table=mailbox&edit={$item.username|escape:"url"}">{$PALANG.edit}</a></td> <td><a href="delete.php?table=mailbox&delete={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}" onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_mailboxes}: {$item.username}');">{$PALANG.del}</a></td> </tr> {/foreach} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2013-01-27 19:52:21
|
Revision: 1422 http://sourceforge.net/p/postfixadmin/code/1422 Author: christian_boltz Date: 2013-01-27 19:52:19 +0000 (Sun, 27 Jan 2013) Log Message: ----------- edit.php: - prefill all $formconf['prefill'] fields from URL parameters (typically used for the domain) model/AliasdomainHandler.php: - allow to prefill alias_domain and target_domain from URL parameters model/AliasHandler.php: - allow to prefill domain from URL parameters - some whitespace changes - add storemore() with a TODO note model/MailboxHandler.php: - allow to prefill domain from URL parameters - some whitespace changes - add some TODO notes Modified Paths: -------------- trunk/edit.php trunk/model/AliasHandler.php trunk/model/AliasdomainHandler.php trunk/model/MailboxHandler.php Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2013-01-27 18:24:03 UTC (rev 1421) +++ trunk/edit.php 2013-01-27 19:52:19 UTC (rev 1422) @@ -63,8 +63,14 @@ $form_fields = $handler->getStruct(); $id_field = $handler->getId_field(); -if ($edit != "") { - if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { # read values from database (except if $active is set to save some CPU cycles) +if ($_SERVER['REQUEST_METHOD'] == "GET" && $active == '') { + if ($edit == '') { # new - prefill fields from URL parameters if allowed in $formconf['prefill'] + if ( isset($formconf['prefill']) ) { + foreach ($formconf['prefill'] as $field) { + if (isset ($_GET[$field])) $form_fields[$field]['default'] = safeget($field); + } + } + } else { # edit mode - read values from database if (!$handler->view()) { flash_error($handler->errormsg); header ("Location: " . $formconf['listview']); @@ -141,7 +147,7 @@ header ("Location: " . $formconf['listview']); exit; } else { - header("Location: edit.php?table=$table"); + header("Location: edit.php?table=$table"); # TODO: hand over last used domain etc. ($formconf['prefill'] ?) exit; } } Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2013-01-27 18:24:03 UTC (rev 1421) +++ trunk/model/AliasHandler.php 2013-01-27 19:52:19 UTC (rev 1422) @@ -95,8 +95,9 @@ # various settings 'required_role' => 'admin', - 'listview' => 'list-virtual.php', - 'early_init' => 0, + 'listview' => 'list-virtual.php', + 'early_init' => 0, + 'prefill' => array('domain'), ); } @@ -237,6 +238,11 @@ $this->values['goto'] = join(',', $values['goto']); } + protected function storemore() { + # TODO: if alias belongs to a mailbox, update mailbox active status + return true; + } + protected function read_from_db_postprocess($db_result) { foreach ($db_result as $key => $value) { # split comma-separated 'goto' into an array Modified: trunk/model/AliasdomainHandler.php =================================================================== --- trunk/model/AliasdomainHandler.php 2013-01-27 18:24:03 UTC (rev 1421) +++ trunk/model/AliasdomainHandler.php 2013-01-27 19:52:19 UTC (rev 1422) @@ -87,6 +87,7 @@ 'required_role' => 'admin', 'listview' => 'list-virtual.php', 'early_init' => 1, # 0 for create-domain + 'prefill' => array('alias_domain', 'target_domain'), ); } Modified: trunk/model/MailboxHandler.php =================================================================== --- trunk/model/MailboxHandler.php 2013-01-27 18:24:03 UTC (rev 1421) +++ trunk/model/MailboxHandler.php 2013-01-27 19:52:19 UTC (rev 1422) @@ -89,8 +89,9 @@ # various settings 'required_role' => 'admin', - 'listview' => 'list-virtual.php', - 'early_init' => 0, + 'listview' => 'list-virtual.php', + 'early_init' => 0, + 'prefill' => array('domain'), ); } @@ -161,10 +162,14 @@ protected function storemore() { if ($this->new) { +# TODO: create alias # TODO: postcreate hook # TODO: send welcome mail # TODO: create mailbox subfolders +# TODO: --- most of this is probably already in $this->add() already --- } else { +# TODO: update alias (active status) + # postedit hook # TODO: implement a poststore() function? - would make handling of old and new values much easier... list(/*NULL*/,$domain) = explode('@', $this->id); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2013-02-09 23:52:06
|
Revision: 1426 http://sourceforge.net/p/postfixadmin/code/1426 Author: christian_boltz Date: 2013-02-09 23:52:03 +0000 (Sat, 09 Feb 2013) Log Message: ----------- displaying the available quota on $new is harder than it looks... edit.php: - call $handler->prefill for all prefill fields - refresh $form_fields after handling prefill fields model/PFAHandler.php: - add prefill() to handle prefill fields. If $this->_prefill_$field() exists, it will be called model/MailboxHandler.php: - init(): error out early if parent::init fails (no need to check the available quota if $this->id is invalid ;-) - move updating the allowed quota to updateMaxquota() - update the available quota based on the prefill domain. If no prefill domain is given, default to the first domain. - new method _prefill_domain() Modified Paths: -------------- trunk/edit.php trunk/model/MailboxHandler.php trunk/model/PFAHandler.php Modified: trunk/edit.php =================================================================== --- trunk/edit.php 2013-02-04 23:18:01 UTC (rev 1425) +++ trunk/edit.php 2013-02-09 23:52:03 UTC (rev 1426) @@ -67,9 +67,13 @@ if ($edit == '') { # new - prefill fields from URL parameters if allowed in $formconf['prefill'] if ( isset($formconf['prefill']) ) { foreach ($formconf['prefill'] as $field) { - if (isset ($_GET[$field])) $form_fields[$field]['default'] = safeget($field); + if (isset ($_GET[$field])) { + $form_fields[$field]['default'] = safeget($field); + $handler->prefill($field, safeget($field)); + } } } + $form_fields = $handler->getStruct(); # refresh $form_fields - a prefill field might have changed something } else { # edit mode - read values from database if (!$handler->view()) { flash_error($handler->errormsg); Modified: trunk/model/MailboxHandler.php =================================================================== --- trunk/model/MailboxHandler.php 2013-02-04 23:18:01 UTC (rev 1425) +++ trunk/model/MailboxHandler.php 2013-02-09 23:52:03 UTC (rev 1426) @@ -41,24 +41,48 @@ 'modified' => pacol( 0, 0, 1, 'ts', 'pAdminList_domain_modified' , '' ), # TODO: add virtual 'notified' column and allow to display who received a vacation response? ); + + # update allowed quota + if (count($this->struct['domain']['options']) > 0) $this->prefill('domain', $this->struct['domain']['options'][0]); } public function init($id) { - $retval = parent::init($id); + if (!parent::init($id)) { + return false; + } if ($this->new) { - # handled in validate_new_id() + $domain = $this->struct['domain']['default']; + $currentquota = 0; } else { - # show max allowed quota in quota field description list(/*NULL*/,$domain) = explode('@', $this->id); $currentquota = $this->return['quotabytes']; # parent::init called ->view() - $maxquota = allowed_quota($domain, $currentquota); - $this->struct['quota']['desc'] = sprintf(Lang::Read('mb_max'), $maxquota); } - return $retval; + $this->updateMaxquota($domain, $currentquota); + + return true; # still here? good. } + /** + * show max allowed quota in quota field description + * @param string - domain + * @param int - current quota + */ + protected function updateMaxquota ($domain, $currentquota) { + if ($domain == '') return false; + + $maxquota = allowed_quota($domain, $currentquota); + + if ($maxquota == 0) { + # TODO: show 'unlimited' + # } elseif ($maxquota < 0) { + # TODO: show 'disabled' - at the moment, just shows '-1' + } else { + $this->struct['quota']['desc'] = sprintf(Lang::Read('mb_max'), $maxquota); + } + } + protected function initMsg() { $this->msg['error_already_exists'] = 'pCreate_mailbox_username_text_error2'; $this->msg['error_does_not_exist'] = 'pCreate_mailbox_username_text_error1'; @@ -258,6 +282,12 @@ } */ + protected function _prefill_domain($field, $val) { + if (in_array($val, $this->struct[$field]['options'])) { + $this->struct[$field]['default'] = $val; + $this->updateMaxquota($val, 0); + } + } /** * check if quota is allowed Modified: trunk/model/PFAHandler.php =================================================================== --- trunk/model/PFAHandler.php 2013-02-04 23:18:01 UTC (rev 1425) +++ trunk/model/PFAHandler.php 2013-02-09 23:52:03 UTC (rev 1426) @@ -185,6 +185,19 @@ abstract protected function validate_new_id(); /** + * web interface can prefill some fields + * if a _prefill_$field method exists, call it (it can for example modify $struct) + * @param string - field + * @param string - prefill value + */ + public function prefill($field, $val) { + $func="_prefill_".$field; + if (method_exists($this, $func) ) { + $this->{$func}($field, $val); # call _missing_$fieldname() + } + } + + /** * set and verify values * @param array values - associative array with ($field1 => $value1, $field2 => $value2, ...) * @return bool - true if all values are valid, otherwise false This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |