From 69af472ede32a8e1808418e3ea863584e35e3aa3 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 17 Jul 2002 04:11:32 +0000 Subject: [PATCH] Added options to exclude wobjects, macros, and hourly plugins. --- etc/WebGUI.conf.original | 4 +++- lib/WebGUI/Session.pm | 21 +++++++++++++++------ lib/WebGUI/Utility.pm | 27 +-------------------------- lib/WebGUI/Wobject/DownloadManager.pm | 22 ++++++++++++++++++++++ sbin/runHourly.pl | 8 ++++---- 5 files changed, 45 insertions(+), 37 deletions(-) diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 6cc8cad3f..1d41472ae 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -5,5 +5,7 @@ logfile = /data/webgui.log extras = /extras uploadsURL = /uploads uploadsPath = /data/WebGUI/www/uploads -#skipHourly = +#excludeMacro = +#excludeWobject = +#excludeHourly = #scripturl = / diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 7215679b6..7d22c6173 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -18,6 +18,7 @@ use strict; use Tie::CPHash; use WebGUI::ErrorHandler; use WebGUI::SQL; +use WebGUI::Utility; our @ISA = qw(Exporter); our @EXPORT = qw(%session); @@ -106,7 +107,7 @@ sub _getUserInfo { #------------------------------------------------------------------- sub _loadMacros { - my ($slash, $namespace, $cmd, @files, $file, $dir); + my ($slash, $namespace, $cmd, @files, $file, $dir, $exclude); $slash = ($^O =~ /Win/i) ? "\\" : "/"; $dir = $slash."lib".$slash."WebGUI".$slash."Macro"; opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!"); @@ -117,7 +118,11 @@ sub _loadMacros { $cmd = "use WebGUI::Macro::".$1; eval($cmd); WebGUI::ErrorHandler::fatalError("Macro failed to compile: $namespace.") if($@); - $session{macro}{$namespace} = $namespace; + $exclude = $session{config}{excludeMacro}; + $exclude =~ s/ //g; + unless (isIn($namespace, split(/,/,$exclude))) { + $session{macro}{$namespace} = $namespace; + } } } closedir(DIR); @@ -125,7 +130,7 @@ sub _loadMacros { #------------------------------------------------------------------- sub _loadWobjects { - my ($dir, @files, $slash, $file, $cmd, $namespace); + my ($dir, @files, $slash, $file, $cmd, $namespace, $exclude); $slash = ($^O =~ /Win/i) ? "\\" : "/"; $dir = $slash."lib".$slash."WebGUI".$slash."Wobject"; opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open wobject directory!"); @@ -136,9 +141,13 @@ sub _loadWobjects { $cmd = "use WebGUI::Wobject::".$namespace; eval($cmd); WebGUI::ErrorHandler::fatalError("Wobject failed to compile: $namespace. ".$@) if($@); - $cmd = "\$WebGUI::Wobject::".$namespace."::name"; - $session{wobject}{$namespace} = eval($cmd); - WebGUI::ErrorHandler::fatalError("No name method in wobject: $namespace. ".$@) if($@); + $exclude = $session{config}{excludeWobject}; + $exclude =~ s/ //g; + unless (isIn($namespace, split(/,/,$exclude))) { + $cmd = "\$WebGUI::Wobject::".$namespace."::name"; + $session{wobject}{$namespace} = eval($cmd); + WebGUI::ErrorHandler::fatalError("No name method in wobject: $namespace. ".$@) if($@); + } } } closedir(DIR); diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 55d686592..ac50df3d0 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -13,13 +13,9 @@ package WebGUI::Utility; use Exporter; use strict; use Tie::IxHash; -use WebGUI::International; -use WebGUI::Session; -use WebGUI::SQL; -use WebGUI::URL; our @ISA = qw(Exporter); -our @EXPORT = qw(&sortByColumn &sortHashDescending &sortHash &isIn &randint &round); +our @EXPORT = qw(&sortHashDescending &sortHash &isIn &randint &round); #------------------------------------------------------------------- sub isIn { @@ -56,27 +52,6 @@ sub round { return sprintf("%.0f", $_[0]); } -#------------------------------------------------------------------- -# example: sortByColumn(columnToSort,columnLabel); -sub sortByColumn { - my ($output); - $output = ''; - if ($session{form}{sort} eq $_[0]) { - if ($session{form}{sortDirection} eq "desc") { - $output .= ' '; - } else { - $output .= ' '; - } - } - return $output; -} - #------------------------------------------------------------------- sub sortHash { my (%hash, %reversedHash, %newHash, $key); diff --git a/lib/WebGUI/Wobject/DownloadManager.pm b/lib/WebGUI/Wobject/DownloadManager.pm index 0c2998005..400b4ee86 100644 --- a/lib/WebGUI/Wobject/DownloadManager.pm +++ b/lib/WebGUI/Wobject/DownloadManager.pm @@ -29,6 +29,28 @@ our @ISA = qw(WebGUI::Wobject); our $namespace = "DownloadManager"; our $name = WebGUI::International::get(1,$namespace); +#------------------------------------------------------------------- +# example: sortByColumn(columnToSort,columnLabel); +sub sortByColumn { + my ($output); + $output = ''; + if ($session{form}{sort} eq $_[0]) { + if ($session{form}{sortDirection} eq "desc") { + $output .= ' '; + } else { + $output .= ' '; + } + } + return $output; +} + + #------------------------------------------------------------------- sub _reorderDownloads { diff --git a/sbin/runHourly.pl b/sbin/runHourly.pl index a1ff9524a..b8c6b26b0 100644 --- a/sbin/runHourly.pl +++ b/sbin/runHourly.pl @@ -22,7 +22,7 @@ use Data::Config; use WebGUI::Utility; -my (@files, $cmd, $namespace, $file, $slash, $confdir, %plugins, $plugdir, $skip); +my (@files, $cmd, $namespace, $file, $slash, $confdir, %plugins, $plugdir, $exclude); $slash = ($^O =~ /Win/i) ? "\\" : "/"; $confdir = $webguiRoot.$slash."etc".$slash; $plugdir = $webguiRoot.$slash."sbin".$slash."Hourly".$slash; @@ -55,9 +55,9 @@ if (opendir (CONFDIR,$confdir)) { print "Can't connect to ".$config->param('dsn')." with info provided. Skipping.\n"; } else { foreach $namespace (keys %plugins) { - $skip = $config->param('skipHourly'); - $skip =~ s/ //g; - unless (isIn($namespace, split(/,/,$skip))) { + $exclude = $config->param('excludeHourly'); + $exclude =~ s/ //g; + unless (isIn($namespace, split(/,/,$exclude))) { $cmd = $plugins{$namespace}; &$cmd($dbh); }