Rework the CS mail fetching interval so that it can't have crazy values like never, every second or yearly. Fixes bug #12043
This commit is contained in:
parent
016df9aa32
commit
f3e340fa3a
4 changed files with 198 additions and 11 deletions
|
|
@ -2,6 +2,7 @@
|
|||
- fixed #12035: Story Manager - make keywords from Story view work
|
||||
- fixed #12042: userDefined variables have no template variable help
|
||||
- fixed #12045: Job listing template, missing summary
|
||||
- fixed #12043: Collaboration Systems don't pull mail that fast!
|
||||
|
||||
7.10.9
|
||||
- fixed #12030: Calendar Feed Time Zone Issue
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ my $quiet; # this line required
|
|||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
convertCsMailInterval($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -44,6 +45,33 @@ finish($session); # this line required
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub convertCsMailInterval {
|
||||
my $session = shift;
|
||||
print "\tConvert the getMailInterval from seconds to enumeration... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->db->write('alter table Collaboration modify column getMailInterval char(64)');
|
||||
my $get_row = $session->db->read('select assetId, revisionDate, getMailInterval from Collaboration');
|
||||
my $change_row = $session->db->prepare('update Collaboration set getMailInterval=? where assetId=? and revisionDate=?');
|
||||
while (my ($assetId, $revisionDate, $seconds ) = $get_row->array) {
|
||||
my $interval;
|
||||
if ($seconds <= 60) { $interval = 'every minute'; }
|
||||
elsif ($seconds <= 120) { $interval = 'every other minute'; }
|
||||
elsif ($seconds <= 300) { $interval = 'every 5 minutes'; }
|
||||
elsif ($seconds <= 600) { $interval = 'every 10 minutes'; }
|
||||
elsif ($seconds <= 900) { $interval = 'every 15 minutes'; }
|
||||
elsif ($seconds <= 1200) { $interval = 'every 20 minutes'; }
|
||||
elsif ($seconds <= 1800) { $interval = 'every 30 minutes'; }
|
||||
elsif ($seconds <= 3600) { $interval = 'every hour'; }
|
||||
elsif ($seconds <= 7200) { $interval = 'every other hour'; }
|
||||
else { $interval = 'once per day'; }
|
||||
$change_row->execute([$interval, $assetId, $revisionDate]);
|
||||
}
|
||||
$get_row->finish;
|
||||
$change_row->finish;
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -418,19 +418,19 @@ sub commit {
|
|||
unless (defined $cron) {
|
||||
$cron = WebGUI::Workflow::Cron->create($self->session, {
|
||||
title=>$self->getTitle." ".$i18n->get("mail"),
|
||||
minuteOfHour=>"*/".($self->get("getMailInterval")/60),
|
||||
className=>(ref $self),
|
||||
methodName=>"new",
|
||||
parameters=>$self->getId,
|
||||
workflowId=>"csworkflow000000000001"
|
||||
workflowId=>"csworkflow000000000001",
|
||||
$self->getCronIntervals,
|
||||
});
|
||||
$self->update({getMailCronId=>$cron->getId});
|
||||
}
|
||||
if ($self->get("getMail")) {
|
||||
$cron->set({enabled=>1,title=>$self->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($self->get("getMailInterval")/60)});
|
||||
} else {
|
||||
$cron->set({enabled=>0,title=>$self->getTitle." ".$i18n->get("mail"), minuteOfHour=>"*/".($self->get("getMailInterval")/60)});
|
||||
}
|
||||
$cron->set({
|
||||
enabled => $self->get('getMail') ? 1 : 0,
|
||||
title => $self->getTitle." ".$i18n->get("mail"),
|
||||
$self->getCronIntervals(),
|
||||
});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -488,6 +488,20 @@ sub definition {
|
|||
($useKarma? (karmaRank=>$i18n->get('karma rank')) : ()),
|
||||
);
|
||||
|
||||
tie my %mailIntervalOptions, 'Tie::IxHash';
|
||||
%mailIntervalOptions = (
|
||||
'every minute' => $i18n->get('every minute'),
|
||||
"every other minute" => $i18n->get('every other minute'),
|
||||
'every 5 minutes' => $i18n->get('every 5 minutes'),
|
||||
'every 10 minutes' => $i18n->get('every 10 minutes'),
|
||||
'every 15 minutes' => $i18n->get('every 15 minutes'),
|
||||
'every 20 minutes' => $i18n->get('every 20 minutes'),
|
||||
'every 30 minutes' => $i18n->get('every 30 minutes'),
|
||||
'every hour' => $i18n->get('every hour'),
|
||||
'every other hour' => $i18n->get('every other hour'),
|
||||
'once per day' => $i18n->get('once per day'),
|
||||
);
|
||||
|
||||
my %properties;
|
||||
tie %properties, 'Tie::IxHash';
|
||||
%properties = (
|
||||
|
|
@ -593,8 +607,11 @@ sub definition {
|
|||
hoverHelp=>$i18n->get("get mail help"),
|
||||
},
|
||||
getMailInterval=>{
|
||||
fieldType=>"interval",
|
||||
defaultValue=>300,
|
||||
#fieldType=>"interval",
|
||||
#defaultValue=>300,
|
||||
fieldType=>"selectBox",
|
||||
defaultValue => 'every 10 minutes',
|
||||
options => \%mailIntervalOptions,
|
||||
tab=>'mail',
|
||||
label=>$i18n->get("get mail interval"),
|
||||
hoverHelp=>$i18n->get("get mail interval help"),
|
||||
|
|
@ -921,11 +938,11 @@ sub duplicate {
|
|||
my $i18n = WebGUI::International->new($self->session, "Asset_Collaboration");
|
||||
my $newCron = WebGUI::Workflow::Cron->create($self->session, {
|
||||
title=>$self->getTitle." ".$i18n->get("mail"),
|
||||
minuteOfHour=>"*/".($self->get("getMailInterval")/60),
|
||||
className=>(ref $self),
|
||||
methodName=>"new",
|
||||
parameters=>$self->getId,
|
||||
workflowId=>"csworkflow000000000001"
|
||||
workflowId=>"csworkflow000000000001",
|
||||
$self->getCronIntervals(),
|
||||
});
|
||||
$newAsset->update({getMailCronId=>$newCron->getId});
|
||||
$newAsset->incrementReplies('','');
|
||||
|
|
@ -949,6 +966,87 @@ sub duplicateBranch {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getCronIntervals
|
||||
|
||||
Translate the settings for getCsMailInterval into options for Spectre's Cron,
|
||||
minuteOfHour, hourOfDay and so on.
|
||||
|
||||
Returns a hash of those options that can be folded into a hash of property settings for the
|
||||
Cron job.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCronIntervals {
|
||||
my $self = shift;
|
||||
my $interval = $self->get('getMailInterval');
|
||||
##My kingdom for a switch statement!
|
||||
if ($interval eq 'every minute') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/1',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every other minute') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/2',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every 5 minutes') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/5',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every 10 minutes') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/10',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every 15 minutes') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/15',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every 20 minutes') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/20',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every 30 minutes') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '*/30',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every hour') {
|
||||
return(
|
||||
hourOfDay => '*',
|
||||
minuteOfHour => '0',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'every other hour') {
|
||||
return(
|
||||
hourOfDay => '*/2',
|
||||
minuteOfHour => '0',
|
||||
);
|
||||
}
|
||||
elsif ($interval eq 'once per day') {
|
||||
return(
|
||||
hourOfDay => '7',
|
||||
minuteOfHour => '0',
|
||||
);
|
||||
}
|
||||
return(
|
||||
minuteOfHour => '*/10',
|
||||
);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditTabs
|
||||
|
||||
Add a tab for the mail interface.
|
||||
|
|
|
|||
|
|
@ -1749,6 +1749,66 @@ the Collaboration Asset, the user will be notified.|,
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every minute' => {
|
||||
message => q{Every minute},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every other minute' => {
|
||||
message => q{Every other minute},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every 5 minutes' => {
|
||||
message => q{Every 5 minutes},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every 10 minutes' => {
|
||||
message => q{Every 10 minutes},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every 15 minutes' => {
|
||||
message => q{Every 15 minutes},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every 20 minutes' => {
|
||||
message => q{Every 20 minutes},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every 30 minutes' => {
|
||||
message => q{Every 30 minutes},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every hour' => {
|
||||
message => q{Every hour},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'every other hour' => {
|
||||
message => q{Every other hour},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'once per day' => {
|
||||
message => q{Once per day},
|
||||
context => q{label in the asset edit form},
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue