# MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE. http://www.calendarscript.com/support/forum/Forum5/HTML/000045.html #
#----[ OPEN ]----------------------------------------------------
#
\calendarscript\lib\Event.inc
Note: We need to pass an additional parameter holding the handle to the Event
Database. This all goes in the subroutine beginning at line called
"sub scheduleEvent". On line where the passed parameters get loaded
we add our event database to the end:
#
#----[ FIND ]----------------------------------------------------
#
my ($db,$schedule,$event_id) = @_;
#
#----[ REPLACE WITH ]----------------------------------------------------
#
# START OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
my ($db,$schedule,$event_id,$edb) = @_;
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
#
#----[ FIND ]----------------------------------------------------
#
foreach $start (@start_dates) {
Note: The guts go into the "Static schedule" portion of the code which begins
with "foreach $start (@start_dates) {" command which writes out a separate
schedule record for each date. This is where we'll modify the code to also
write out a separate event record for each date. We add two lines of code
before the "foreach".
#
#----[ BEFORE, ADD ]----------------------------------------------------
#
# START OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
# MULTIPLE EVENT RECORD
# This just creates and sets a flag for the first pass to know that we DON'T
# need to create a NEW record the first time. We'll use the one already created.
my ($fpass);
$fpass = 0;
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
#
#----[ FIND ]----------------------------------------------------
#
foreach $start (@start_dates) {
if ($start =~ /^(\d\d\d\d)(\d\d)(\d\d)$/o) {
($yy,$mm,$dd) = ($1,$2,$3);
$start = Time::Local::timegm(0,$schedule->{'start_time_mm'},$schedule->{'start_time_hh'},$dd,$mm-1,$yy);
}
if ($schedule->{'static_dates_range'} eq "dates") {
$end = $start;
}
if (!$end && $all_day) {
$end = $start;
}
elsif (!$end) {
$end = Time::Local::timegm(0,$schedule->{'end_time_mm'},$schedule->{'end_time_hh'},$dd,$mm-1,$yy);
}
#if (!$schedule->{'static_end_date'} && $all_day) {
# $schedule->{'static_end_date'} = $start;
# }
if (!$db->addRecord( { 'event_id'=>$event_id
Note: This part creates the event records
#
#----[ REPLACE WITH ]----------------------------------------------------
#
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
foreach $start (@start_dates) {
if ($start =~ /^(\d\d\d\d)(\d\d)(\d\d)$/o) {
($yy,$mm,$dd) = ($1,$2,$3);
$start = Time::Local::timegm(0,$schedule->{'start_time_mm'},$schedule->{'start_time_hh'},$dd,$mm-1,$yy);
}
if ($schedule->{'static_dates_range'} eq "dates") {
$end = $start;
}
if (!$end && $all_day) {
$end = $start;
}
elsif (!$end) {
$end = Time::Local::timegm(0,$schedule->{'end_time_mm'},$schedule->{'end_time_hh'},$dd,$mm-1,$yy);
}
#if (!$schedule->{'static_end_date'} && $all_day) {
# $schedule->{'static_end_date'} = $start;
# }
# MULTIPLE EVENT RECORD MODS
# This is where we put out multiple events for
# multiple dates if its not the first pass
if ($fpass) {
if ($event_id = $edb->addRecord($eproperties)) {
$eproperties->{'id'} = $event_id;
}
else {
&setErrorMessage(&main::getMessage("EVENT_SAVE_ERROR",$edb->getErrorMessage()));
return 0;
}
}
# If it's the first pass we just reread the event record for use
# in writing out the new records and set the first pass flag.
else {
$eproperties = $edb->getRecord( { 'id'=>$event_id} );
$fpass = 1;
}
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
if (!$db->addRecord( { 'event_id'=>$event_id,
#
#----[ OPEN ]----------------------------------------------------
#
calendar_admin.pl
Note: The other change we need to make is to setup and pass the handle for the
events database.
#
#----[ FIND ]----------------------------------------------------
#
elsif ($in{'command'} eq "schedule_event") {
#
#----[ AFTER, ADD ]----------------------------------------------------
#
# BEGIN OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
# MULTIPLE EVENT RECORD MOD
my ($edb) = new DBFile($events_db);
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
#
#----[ FIND ]----------------------------------------------------
#
if (&Event::scheduleEvent($db, $schedule, $event_id)) {
Note: We change the line that calls the previously modified ScheduleEvent procedure
to add the variable we just created to the parameters:
#
#----[ REPLACE WITH ]----------------------------------------------------
#
# BEGIN OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE
# MULTIPLE EVENT RECORD MOD (added $edb parameter)
if (&Event::scheduleEvent($db, $schedule, $event_id, $edb)) {
# END OF MAKING REOCCURING EVENTS SEPERATEDLY EDITABLE