#!/usr/bin/env perl
# conf.pl
#
-# Copyright (c) 1999-2006 The SquirrelMail Project Team
+# Copyright (c) 1999-2007 The SquirrelMail Project Team
# Licensed under the GNU GPL. For full terms see COPYING.
#
# A simple configure script to configure SquirrelMail
$smtp_sitewide_user = '' if ( !$smtp_sitewide_user );
$smtp_sitewide_pass = '' if ( !$smtp_sitewide_pass );
$icon_theme_def = '' if ( !$icon_theme_def );
+$disable_plugins = 'false' if ( !$disable_plugins );
+$disable_plugins_user = '' if ( !$disable_plugins_user );
if ( $ARGV[0] eq '--install-plugin' ) {
print "Activating plugin " . $ARGV[1] . "\n";
@plugins = @newplugins;
save_data();
exit(0);
+} elsif ( $ARGV[0] eq '--update-plugins' or $ARGV[0] eq '-u') {
+ build_plugin_hook_array();
+ exit(0);
+} elsif ( $ARGV[0] eq '--help' or $ARGV[0] eq '-h') {
+ print "SquirrelMail Configuration Script\n";
+ print "Usage:\n";
+ print " * No arguments: initiates the configuration dialog\n";
+ print " * --install-plugin <plugin> : activates the specified plugin\n";
+ print " * --remove-plugin <plugin> : deactivates the specified plugin\n";
+ print " * --update-plugins , -u : rebuilds plugin_hooks.php according\n";
+ print " to plugins activated in config.php\n";
+ print " * --help , -h : Displays this help\n";
+ print "\n";
+ exit(0);
}
+
+
+####################################################################################
+
+# used in multiple places, define once
+$list_supported_imap_servers =
+ " bincimap = Binc IMAP server\n" .
+ " courier = Courier IMAP server\n" .
+ " cyrus = Cyrus IMAP server\n" .
+ " dovecot = Dovecot Secure IMAP server\n" .
+ " exchange = Microsoft Exchange IMAP server\n" .
+ " hmailserver = hMailServer\n" .
+ " macosx = Mac OS X Mailserver\n" .
+ " mercury32 = Mercury/32\n" .
+ " uw = University of Washington's IMAP server\n";
+
#####################################################################################
if ( $config_use_color == 1 ) {
$WHT = "\x1B[37;1m";
print "\n";
print "R Return to Main Menu\n";
} elsif ( $menu == 8 ) {
- print $WHT. "Plugins\n" . $NRM;
+ if (lc($disable_plugins) eq 'true' && $disable_plugins_user ne '') {
+ print $WHT. "Plugins (WARNING: All plugins are currently disabled\n for the user \"$disable_plugins_user\"!)\n" . $NRM;
+ } elsif (lc($disable_plugins) eq 'true') {
+ print $WHT. "Plugins (WARNING: All plugins are currently disabled!)\n" . $NRM;
+ } else {
+ print $WHT. "Plugins\n" . $NRM;
+ }
print " Installed Plugins\n";
$num = 0;
for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
closedir DIR;
print "\n";
+ if (lc($disable_plugins) eq 'true' && $disable_plugins_user ne '') {
+ print "E Enable active plugins (all plugins currently\n disabled for the user \"$disable_plugins_user\")\n";
+ } elsif (lc($disable_plugins) eq 'true') {
+ print "E Enable active plugins (all plugins currently\n disabled)\n";
+ } else {
+ print "D Disable all plugins\n";
+ }
+ print "U Set the user for whom plugins can be disabled\n";
print "R Return to Main Menu\n";
} elsif ( $menu == 9 ) {
print $WHT. "Database\n" . $NRM;
} elsif ( $menu == 7 ) {
if ( $command == 1 ) { $motd = command71(); }
} elsif ( $menu == 8 ) {
- if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
+ if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
+ elsif ( $command eq "u" ) { $disable_plugins_user = command82(); }
+ elsif ( $command eq "d" ) { $disable_plugins = 'true'; }
+ elsif ( $command eq "e" ) { $disable_plugins = 'false'; }
} elsif ( $menu == 9 ) {
if ( $command == 1 ) { $addrbook_dsn = command91(); }
elsif ( $command == 2 ) { $addrbook_table = command92(); }
if ( $new_domain eq "\n" ) {
$new_domain = $domain;
} else {
- $new_domain =~ s/[\r\n]//g;
+ $new_domain =~ s/\s//g;
}
return $new_domain;
}
print "these servers. If you would like to use them, please select your\n";
print "IMAP server. If you do not wish to use these work-arounds, you can\n";
print "set this to \"other\", and none will be used.\n";
- print " courier = Courier IMAP server\n";
- print " cyrus = Cyrus IMAP server\n";
- print " dovecot = Dovecot Secure IMAP server\n";
- print " exchange = Microsoft Exchange IMAP server\n";
- print " hmailserver = hMailServer\n";
- print " macosx = Mac OS X Mailserver\n";
- print " mercury32 = Mercury Mail Transport System\n";
- print " uw = University of Washington's IMAP server\n";
+ print $list_supported_imap_servers;
print "\n";
print " other = Not one of the above servers\n";
print "\n";
return @plugins;
}
+# disable_plugins_user
+sub command82 {
+ print "When all active plugins are disabled, they can be disabled only\n";
+ print "for the one user named here. If left blank, plugins will be\n";
+ print "disabled for ALL users. This setting has no effect if plugins\n";
+ print "are not disabled.\n";
+ print "\n";
+ print "This must be the exact IMAP login name for the desired user.\n";
+ print "\n";
+ print "[$WHT$disable_plugins_user$NRM]: $WHT";
+ $new_disable_plugins_user = <STDIN>;
+ if ( $new_disable_plugins_user eq "\n" ) {
+ $new_disable_plugins_user = $disable_plugins_user;
+ } else {
+ $new_disable_plugins_user =~ s/[\r\n]//g;
+ }
+ return $new_disable_plugins_user;
+}
+
################# FOLDERS ###################
# default_folder_prefix
# string
print CF "\$config_location_base = '$config_location_base';\n";
print CF "\n";
+ # boolean
+ print CF "\$disable_plugins = $disable_plugins;\n";
+ # string
+ print CF "\$disable_plugins_user = '$disable_plugins_user';\n";
+ print CF "\n";
# all plugins are strings
for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
$continue = 0;
while ( $continue != 1 ) {
print "Please select your IMAP server:\n";
- print " bincimap = Binc IMAP server\n";
- print " courier = Courier IMAP server\n";
- print " cyrus = Cyrus IMAP server\n";
- print " dovecot = Dovecot Secure IMAP server\n";
- print " exchange = Microsoft Exchange IMAP server\n";
- print " hmailserver = hMailServer\n";
- print " macosx = Mac OS X Mailserver\n";
- print " mercury32 = Mercury/32\n";
- print " uw = University of Washington's IMAP server\n";
+ print $list_supported_imap_servers;
print "\n";
print " quit = Do not change anything\n";
print "\n";
$inside_init_fxn = 1;
- # throw away lines that are not exactly one "brace set" deep
- #
- if ($brace_count > 1) {
- next;
- }
-
-
# count open braces
#
if ($line =~ /{/) {
}
+ # throw away lines that are not exactly one "brace set" deep
+ #
+ if ($brace_count > 1) {
+ next;
+ }
+
+
# also not interested in lines that are not
# hook registration points
#
$options[1] =~ s/\\'/'/g;
$options[1] =~ s/\\\\/\\/g;
- if ( $options[0] =~ /^squirrelmail_plugin_hooks\s*\[\s*['"]([a-z0-9._-]+)['"]\s*\]\s*\[\s*['"]([0-9a-z._-]+)['"]\s*\]/i ) {
+ if ( $options[0] =~ /^squirrelmail_plugin_hooks\s*\[\s*['"]([a-z0-9 \/._*-]+)['"]\s*\]\s*\[\s*['"]([0-9a-z._-]+)['"]\s*\]/i ) {
$hook_name = $1;
$hooked_plugin_name = $2;
-# FIXME: what to do with this? shouldn't ever be necessary, but...
-if ($hooked_plugin_name ne $plugins[$ct]) {
- print "ummmm, plugin is tring to hook in under different name.... what do we do with this???\n";
-}
+ # Note: if we wanted to stop plugins from registering
+ # a *different* plugin on a hook, we could catch
+ # it here, however this has actually proven to be
+ # a useful *feature*
+ #if ($hooked_plugin_name ne $plugins[$ct]) {
+ # print "...plugin is tring to hook in under different name...\n";
+ #}
#FIXME: do we want to count the number of hook registrations for each plugin and warn if a plugin doesn't have any?
# hook registration has been found!
if ($verbose) {
- print " registering on hook \"" . $hook_name . "\"\n";
+ if ($hooked_plugin_name ne $plugins[$ct]) {
+ print " registering on hook \"" . $hook_name . "\" (as \"$hooked_plugin_name\" plugin)\n";
+ } else {
+ print " registering on hook \"" . $hook_name . "\"\n";
+ }
}
$line =~ s/ {2,}/ /g;
+ $line =~ s/=/\n =/;
print HOOKFILE "\$$line";
}