#!/usr/local/bin/perl # # postfix-module by Guillaume Cottenceau , # for webmin by Jamie Cameron # # Copyright (c) 2000 by Mandrakesoft # # Permission to use, copy, modify, and distribute this software and its # documentation under the terms of the GNU General Public License is hereby # granted. No representations are made about the suitability of this software # for any purpose. It is provided "as is" without express or implied warranty. # See the GNU General Public License for more details. # # # Manages aliases for Postfix # # << Here are all options seen in Postfix sample-aliases.cf >> require './postfix-lib.pl'; $access{'aliases'} || &error($text{'aliases_ecannot'}); &ui_print_header(undef, $text{'aliases_title'}, "", "aliases"); # alias general options print "
\n"; print "\n"; print "\n"; print "
$text{'aliasopts_title'}
\n"; $none = $text{'opts_none'}; print "\n"; &option_mapfield("alias_maps", 60, $none); print "\n"; print "\n"; &option_mapfield("alias_database", 60, $none); print "\n"; print "

\n"; print "$text{'aliases_warning'}


\n"; print "

\n"; print "
\n"; print "
\n"; # double-table displaying all aliases my @aliases = &list_postfix_aliases(); if ($config{'sort_mode'} == 1) { @aliases = sort { lc($a->{'name'}) cmp lc($b->{'name'}) } @aliases; } # find a good place to split $lines = 0; for($i=0; $i<@aliases; $i++) { $aline[$i] = $lines; $al = scalar(@{$aliases[$i]->{'values'}}); $lines += ($al ? $al : 1); } $midline = int(($lines+1) / 2); for($mid=0; $mid<@aliases && $aline[$mid] < $midline; $mid++) { } # render tables print &ui_form_start("delete_aliases.cgi", "post"); @links = ( &select_all_link("d", 1), &select_invert_link("d", 1) ); print &ui_links_row(\@links); if ($config{'columns'} == 2) { print "
\n"; &aliases_table(@aliases[0..$mid-1]); print "\n"; if ($mid < @aliases) { &aliases_table(@aliases[$mid..$#aliases]); } print "
\n"; } else { &aliases_table(@aliases); } print &ui_links_row(\@links); print &ui_form_end([ [ "delete", $text{'aliases_delete'} ] ]); # new alias button print &ui_buttons_start(); print &ui_buttons_row("edit_alias.cgi", $text{'new_alias'}, $text{'new_aliasmsg'}, &ui_hidden("new", 1)); # manual edit button if ($access{'manual'} && &can_map_manual($_[0])) { print &ui_buttons_row("edit_manual.cgi", $text{'new_manual'}, $text{'new_manualmsg'}, &ui_hidden("map_name", "alias_maps")); } print &ui_buttons_end(); &ui_print_footer("", $text{'index_return'}); sub aliases_table { local @tds = ( "width=5", "valign=top", "valign=top" ); print &ui_columns_start([ "", $text{'aliases_addr'}, $text{'aliases_to'}, $config{'show_cmts'} ? ( $text{'mapping_cmt'} ) : ( ) ], 100, 0, \@tds); foreach $a (@_) { local @cols; push(@cols, "{'num'}\">". ($a->{'enabled'} ? "" : "").&html_escape($a->{'name'}). ($a->{'enabled'} ? "" : "").""); local $vstr; foreach $v (@{$a->{'values'}}) { ($anum, $astr) = &alias_type($v); $vstr .= &text("aliases_type$anum", "".&html_escape($astr)."")."
\n"; } $vstr ||= "$text{'aliases_none'}\n"; push(@cols, $vstr); push(@cols, &html_escape($a->{'cmt'})) if ($config{'show_cmts'}); print &ui_checked_columns_row(\@cols, \@tds, "d", $a->{'name'}); } print &ui_columns_end(); }