Changed scheduler to use WebGUI session object.
This commit is contained in:
parent
985b45212a
commit
d55f4f1c3c
5 changed files with 29 additions and 24 deletions
|
|
@ -11,11 +11,12 @@ package Hourly::DeleteExpiredSessions;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
WebGUI::SQL->write("delete from userSession where expires<".time(),$_[0]);
|
||||
WebGUI::SQL->write("delete from userSession where expires<".time());
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ package Hourly::SyndicatedContent;
|
|||
use HTTP::Request;
|
||||
use LWP::UserAgent;
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use XML::RSSLite;
|
||||
|
||||
|
|
@ -52,18 +53,17 @@ sub generateHTML {
|
|||
sub process {
|
||||
my ($sth, @data, %rss, $html);
|
||||
$sth = WebGUI::SQL->read("select wobject.wobjectId, SyndicatedContent.rssURL, SyndicatedContent.content
|
||||
from wobject,SyndicatedContent where wobject.wobjectId=SyndicatedContent.wobjectId and wobject.pageId<>3",$_[0]);
|
||||
from wobject,SyndicatedContent where wobject.wobjectId=SyndicatedContent.wobjectId and wobject.pageId<>3");
|
||||
while (@data = $sth->array) {
|
||||
%rss = getRSS($data[1]);
|
||||
$html = generateHTML(%rss);
|
||||
if ($html ne "") {
|
||||
WebGUI::SQL->write("update SyndicatedContent set content=".$_[0]->quote($html).", lastFetched=".time()."
|
||||
where wobjectId=$data[0]",$_[0]);
|
||||
WebGUI::SQL->write("update SyndicatedContent set content=".quote($html).", lastFetched=".time()." where wobjectId=$data[0]");
|
||||
} elsif (substr($data[2],6) ne "Unable" && substr($data[2],7) ne "Not yet") {
|
||||
# then just leave the existing content in place
|
||||
} else {
|
||||
WebGUI::SQL->write("update SyndicatedContent set content='Unable to fetch content. Perhaps the RSS is improperly formated.',
|
||||
lastFetched=".time()." where wobjectId=$data[0]",$_[0]);
|
||||
lastFetched=".time()." where wobjectId=$data[0]");
|
||||
}
|
||||
}
|
||||
$sth->finish;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ BEGIN {
|
|||
use DBI;
|
||||
use strict qw(subs vars);
|
||||
use Data::Config;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
|
|
@ -47,26 +48,17 @@ if (opendir (CONFDIR,$confdir)) {
|
|||
@files = readdir(CONFDIR);
|
||||
foreach $file (@files) {
|
||||
if ($file =~ /(.*?)\.conf$/ && $file ne "some_other_site.conf") {
|
||||
my ($config);
|
||||
$config = new Data::Config $confdir.$file;
|
||||
unless ($config->param('dsn') eq "") {
|
||||
my $dbh;
|
||||
unless (eval {$dbh = DBI->connect($config->param('dsn'),$config->param('dbuser'),$config->param('dbpass'))}) {
|
||||
print "Can't connect to ".$config->param('dsn')." with info provided. Skipping.\n";
|
||||
} else {
|
||||
foreach $namespace (keys %plugins) {
|
||||
$exclude = $config->param('excludeHourly');
|
||||
$exclude =~ s/ //g;
|
||||
unless (isIn($namespace, split(/,/,$exclude))) {
|
||||
$cmd = $plugins{$namespace};
|
||||
&$cmd($dbh);
|
||||
}
|
||||
}
|
||||
$dbh->disconnect();
|
||||
}
|
||||
} else {
|
||||
print "$file has some problems. Skipping\n";
|
||||
WebGUI::Session::open($webguiRoot,$file);
|
||||
WebGUI::Session::refreshUserInfo(3,$session{dbh});
|
||||
foreach $namespace (keys %plugins) {
|
||||
$exclude = $session{config}{excludeHourly};
|
||||
$exclude =~ s/ //g;
|
||||
unless (isIn($namespace, split(/,/,$exclude))) {
|
||||
$cmd = $plugins{$namespace};
|
||||
&$cmd();
|
||||
}
|
||||
}
|
||||
WebGUI::Session::close();
|
||||
}
|
||||
}
|
||||
closedir(CONFDIR);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue