SF.net SVN: postfixadmin:[1275] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-11-13 22:48:29
|
Revision: 1275 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1275&view=rev Author: christian_boltz Date: 2011-11-13 22:48:22 +0000 (Sun, 13 Nov 2011) Log Message: ----------- Use edit.php to edit/create for alias domains (yes, we get edit mode "for free") model/AliasdomainHandler.php: - add webformConfig() configs/menu.conf: - change url_create_alias_domain to edit.php?table=aliasdomain templates/list-virtual_alias_domain.tpl - change ?target_domain to &target_domain (TODO: this is currently ignored by edit.php) - add edit link (TODO: add log action to avoid the error message) create-alias-domain.php: - deleted :-) Modified Paths: -------------- trunk/configs/menu.conf trunk/model/AliasdomainHandler.php trunk/templates/list-virtual_alias_domain.tpl Removed Paths: ------------- trunk/create-alias-domain.php Modified: trunk/configs/menu.conf =================================================================== --- trunk/configs/menu.conf 2011-11-13 22:34:40 UTC (rev 1274) +++ trunk/configs/menu.conf 2011-11-13 22:48:22 UTC (rev 1275) @@ -9,7 +9,7 @@ url_list_virtual = list-virtual.php url_create_mailbox = create-mailbox.php url_create_alias = create-alias.php -url_create_alias_domain = create-alias-domain.php +url_create_alias_domain = edit.php?table=aliasdomain # fetchmail url_fetchmail = fetchmail.php url_fetchmail_new_entry = fetchmail.php?new=1 Deleted: trunk/create-alias-domain.php =================================================================== --- trunk/create-alias-domain.php 2011-11-13 22:34:40 UTC (rev 1274) +++ trunk/create-alias-domain.php 2011-11-13 22:48:22 UTC (rev 1275) @@ -1,148 +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-domain.php - * Template File: create-alias-domain.tpl - * Responsible for allowing for the creation of alias domains. - * - * @version $Id$ - * @license GNU GPL v2 or later. - * - * Template Variables: - * - * none - * - * Form POST \ GET Variables: - * - * fAliasDomain - * fTargetDomain - * fActive - * - */ - -require_once('common.php'); - -authentication_require_role('admin'); - -if (!boolconf('alias_domain')) { - header("Location: main.php"); - exit; -} - -$fAliasDomain = ''; -$fTargetDomain= ''; -$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); -} - -# read alias_domain table to see which domains in $list_domains -# are still available as an alias- or target-domain -$list_aliases = Array(); -$result = db_query ("SELECT alias_domain, target_domain FROM $table_alias_domain"); -if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) - { - $list_aliases[ $row['alias_domain'] ] = $row['target_domain']; - } -} - -# filter available alias domains -$alias_domains = array(); -foreach ($list_domains as $dom) { - if (isset($list_aliases[$dom]) || in_array($dom,$list_aliases)) continue; - $alias_domains[] = $dom; -} - -if (count($alias_domains) == 0) { - $error = 1; - flash_error($PALANG['pCreate_alias_domain_error4']); -} - -# filter available target domains -foreach ($list_domains as $dom) { - if (isset($list_aliases[$dom])) continue; - $target_domains[] = $dom; -} - - -if (isset ($_REQUEST['alias_domain'])) { - $fAliasDomain = escape_string ($_REQUEST['alias_domain']); - $fAliasDomain = strtolower ($fAliasDomain); -} -if (isset ($_REQUEST['target_domain'])) { - $fTargetDomain = escape_string ($_REQUEST['target_domain']); - $fTargetDomain = strtolower ($fTargetDomain); -} -//*** ????? -if (isset ($_REQUEST['active'])) { - $fActive = (bool)$_REQUEST['active']; -} else { - $fActive = false; -} -if (!isset ($_REQUEST['submit'])) - $fActive = true; - -if ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if(!authentication_has_role ('global-admin') && - !(check_owner ($SESSID_USERNAME, $fAliasDomain) && - check_owner ($SESSID_USERNAME, $fTargetDomain))) - { - $error = 1; - flash_error($PALANG['pCreate_alias_domain_error1']); - } - - if (isset($list_aliases[$fAliasDomain]) || // alias_domain is unique (primary key, a domain can't be an alias for multiple others) - in_array($fAliasDomain,$list_aliases) || // an alias_domain can't be a target_domain for a third domain. - isset($list_aliases[$fTargetDomain]) || // same as above, other way around - ($fAliasDomain == $fTargetDomain) || // i really don't have to - empty($fAliasDomain) || empty($fTargetDomain)) // explain this, do i? - { - $error = 1; - flash_error($PALANG['pCreate_alias_domain_error2']); - } - - $sqlActive = db_get_boolean($fActive); - - if ($error != 1) { - $result = db_query ("INSERT INTO $table_alias_domain (alias_domain,target_domain,created,modified,active) VALUES ('$fAliasDomain','$fTargetDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) { - $error = 1; - flash_error($PALANG['pCreate_alias_domain_error3']); - } - else { - db_log ($fAliasDomain, 'create_alias_domain', "$fAliasDomain -> $fTargetDomain"); - - flash_info($PALANG['pCreate_alias_domain_success']); - # we would have to update the list of domains available for aliasing. Doing a redirect is easier. - header("Location: create-alias-domain.php"); - exit; - } - } - - flash_info("<br />($fAliasDomain -> $fTargetDomain)<br />\n"); -} - - -$smarty->assign ('alias_domains', (count($alias_domains) > 0)); -$smarty->assign ('select_options_alias', select_options ($alias_domains, array ($fAliasDomain)), false); -$smarty->assign ('select_options_target', select_options ($target_domains, array ($fTargetDomain)), false); -if ($fActive) $smarty->assign ('fActive', ' checked="checked"'); -$smarty->assign ('smarty_template', 'create-alias-domain'); -$smarty->display ('index.tpl'); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?> Modified: trunk/model/AliasdomainHandler.php =================================================================== --- trunk/model/AliasdomainHandler.php 2011-11-13 22:34:40 UTC (rev 1274) +++ trunk/model/AliasdomainHandler.php 2011-11-13 22:48:22 UTC (rev 1275) @@ -80,6 +80,24 @@ } } + /* + * Configuration for the web interface + */ + public function webformConfig() { + return array( + # $PALANG labels + 'formtitle_create' => 'pCreate_alias_domain_welcome', + 'formtitle_edit' => 'pCreate_alias_domain_welcome', + 'create_button' => 'pCreate_alias_domain_button', + 'successmessage' => 'pCreate_alias_domain_success', + + # various settings + 'required_role' => 'admin', + 'listview' => 'list-virtual.php', + 'early_init' => 1, # 0 for create-domain + ); + } + protected function validate_new_id() { return true; # alias_domain is enum, so we don't need to check its syntax etc. } Modified: trunk/templates/list-virtual_alias_domain.tpl =================================================================== --- trunk/templates/list-virtual_alias_domain.tpl 2011-11-13 22:34:40 UTC (rev 1274) +++ trunk/templates/list-virtual_alias_domain.tpl 2011-11-13 22:48:22 UTC (rev 1275) @@ -1,7 +1,7 @@ {*** Domain Aliases ***} <table id="alias_domain_table"> <tr> - <th colspan="5">{$PALANG.pOverview_alias_domain_title}</th> + <th colspan="6">{$PALANG.pOverview_alias_domain_title}</th> </tr> {if $tAliasDomains|@count>0 || $tTargetDomain|@count>1} {if $tAliasDomains|@count>0} {* -> HAT alias-domains *} @@ -11,6 +11,7 @@ <td>{$PALANG.pOverview_alias_domain_modified}</td> <td>{$PALANG.pOverview_alias_domain_active}</td> <td> </td> + <td> </td> </tr> {foreach from=$tAliasDomains item=item} {#tr_hilightoff#} @@ -30,6 +31,7 @@ {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"}">{$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> {/foreach} @@ -38,6 +40,6 @@ </table> {if $can_create_alias_domain} <br/> - <br /><a href="{#url_create_alias_domain#}?target_domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias_domain}</a><br /> + <br /><a href="{#url_create_alias_domain#}&target_domain={$fDomain|escape:"url"}" class="button">{$PALANG.pMenu_create_alias_domain}</a><br /> {/if} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |