Using EmailNotify2 and Metacalendar together I noticed that users can add events to the metacalendar when they should be directed to the select_calendar.html and receive the following message:
You can not Add Events to the Meta calendar
Select an individual calendar and press continue
This is caused by the EmailNotify2 pluging being promoted above the Metacalendar plugin, thereby, the before_commands.pl in the EmailNotify2 folder is being used not the before_commands.pl in the Metacalendar folder.
To fix this I did the following:
Pasted the code of the Metacalendar folder before_commands.pl into the EmailNotify2 before_commands.pl file
This resulted in the following code
Code starts below line
---------------------------------
sub before_commands()
{
unshift @INC, $BASE_DIR."plugins/EmailNotify2/";
require "EmailUtil.inc";
$EmailConfig = new ConfigFile($plugins_dir . "EmailNotify2/db/emailconfig.txt");
if ($EmailConfig->get("sched_method") eq "always" &&
time() - $EmailConfig->get("last_check_time") > $EmailConfig->get("frequency") * 60)
{
&CheckAndSend();
$EmailConfig->set("last_check_time", time() - 0);
$EmailConfig->save();
}
############START PASTE OF METACALENDAR before_commands.pl #############
$Template::METACALENDAR = &getMetaCalendar();
unless ($Template::METACALENDAR eq $calendar) # $in{'calendar'} ??
{
return 0;
}
my ($c) = $CommandList;
foreach $category (sort {$c->{$a}->{order} <=> $c->{$b}->{order}} keys %$c) {
foreach $command (@{$c->{$category}->{commands}}) {
next unless $category eq "Events";
if ($command->{link} =~ /$in{'template'}/) # Look for destination template in BANNED "Event" options
{
$in{'template'} = "select_calendar.html"; # Redirect to "select calendar" menu
$in{'command'} eq ""; # clear previous command
&addUserMessage("You can not Add Events to the View All calendar");
&addUserMessage("Select an individual calendar and press continue");
last;
}
} # END foreach
} # END foreach
delete $CommandList->{'Events'}; # NOTE: This line can be commented out to maintain original menu display
} # END sub before_commands
#####################################################################
# getMetaCalendar
# Find out which calendar (if any) is a meta calendar
# and set a template variable with the calendar's key
#####################################################################
sub getMetaCalendar {
my ($MetaCalendarConfig) = new ConfigFile($main::plugins_dir . "MetaCalendar/metacalendarconfig.txt");
my ($value) = $MetaCalendarConfig->get('metacalendar'); # ? $MetaCalendarConfig->get($calendar);
return $value;
############END PASTE OF METACALENDAR before_commands.pl #############
}
1;
-------------------------------
Code ends above line
This fixed the problem I was having and might be a solution for anyone else. If someone with more experience at this than me looks at this I hope I am doing it right. I thought I would post the code and see.
Thanks for all the other persons help with my problems, thought I would try to return the favor.