Trying to get the DeleteOld plugin to work with EmailNotify2 now that I have it working. I can delete the events from the DeleteOld plugin but I get no notification from EmaiNotify2 that the events were deleted. I tried to modify the command_delete_old.pl file to this see below but no luck.
sub command_delete_old
{
foreach (keys %in)
{
if ($_ =~ /^DELETE_(.*)$/)
{
#if anything fails, somebody is trying to hack your calendar.
&checkPermissions($1, "EDIT_EVENTS");
}
}
my $deldate = $in{DELETEDATE};
$deldate =~ /^(\d\d\d\d)(\d\d)(\d\d)$/;
$deldate = Time::Local::timegm(0,0,0,$3,$2-1,$1-1900);
foreach (keys %in)
{
if ($_ =~ /^DELETE_(.*)$/)
{
my $key = $1;
my $name = $in{$_}; #I saved the calendar name in the value to save looking it up.
my $edb = new DBFile($BASE_DIR . "calendars/" . $key . "/events");
my $sdb = new DBFile($BASE_DIR . "calendars/" . $key . "/schedule");
my $deadsched = $sdb->getRecords({'end' => "=<$deldate"}); #save records about to delete
my (%goodids, %deadids);
foreach (@$deadsched)
{
if ($_->{start} && $_->{end}) #don't delete unbounded recurring events.
{
$sdb->deleteRecords( {'id'=>$_->{id}} );
$deadids{$_->{event_id}} = 1;
}
}
my $schedleft = $sdb->getRecords( {} ); #get all events left in schedule db
foreach (@$schedleft) #save the good ids that are left in schedule db
{ $goodids{$_->{event_id}} = 1; }
my $count = 0;
foreach (keys %deadids)
{
unless ($goodids{$_}) #if it's not still in the schedule database
{
$edb->deleteRecords( { 'id' => $_ } ); #remove it from the events database
#Added to include event deleted with Email Notify 2
$in{'EVENT_id'} = $id;
&handleCustomFunction("before_delete_event");
#/Added to include event deleted with Email Notify 2
$count++;
}
}
if ($count == 0)
{ &addUserMessage("No events to delete from $name."); }
else
{ &addUserMessage("Deleted $count event".($count > 1 ? "s" : "") ." from $name."); }
#we have to do all that in case we deleted the first few occurences of an event but not
#the last ones. We don't want to delete an event from the events database that still
#has entries in the schedule database.
#I know this is slow (O(n^2) where it could be O(n)), but it shouldn't cause a problem,
#since this not run often. Let me know if it gets to be a problem.
}
}
}
1;
When I figure this one out I will work on a similar change to the MoveEvents plug-in that has the same problem.
Thanks for any help.