Index: lib/Scoop/DB.pm =================================================================== RCS file: /cvs/scoop/scoop/lib/Scoop/DB.pm,v retrieving revision 1.26 diff -u -r1.26 DB.pm --- lib/Scoop/DB.pm 15 Jan 2005 17:45:26 -0000 1.26 +++ lib/Scoop/DB.pm 10 Jun 2005 17:51:52 -0000 @@ -427,4 +427,26 @@ } } +sub db_get_last_insert { + my $S = shift; + my $args = shift; + my $eid = undef; + + if ( lc($S->{CONFIG}->{DBType}) eq "mysql" ) { + # mySQL + $eid = $S->dbh->{'mysql_insertid'}; + } elsif ( $S->{CONFIG}->{DBType} eq "Pg" ) { + # PostgreSQL + my $catalog = $args->{CATALOG}; + my $schema = $args->{SCHEMA}; + my $table = $args->{TABLE}; + my $field = $args->{FIELD}; + my $attr = $args->{ATTR}; + $eid = $S->dbh->last_insert_id( $catalog, $schema, $table, $field, $attr ); + } else { + warn "(db_get_last_insert) not implemented for database type \"$S->{CONFIG}->{DBType}\"" if $DEBUG; + } + return $eid; +} + 1; Index: lib/Scoop/Admin/Calendar.pm =================================================================== RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/Calendar.pm,v retrieving revision 1.1 diff -u -r1.1 Calendar.pm --- lib/Scoop/Admin/Calendar.pm 21 Jan 2005 14:14:30 -0000 1.1 +++ lib/Scoop/Admin/Calendar.pm 10 Jun 2005 17:51:53 -0000 @@ -515,8 +515,8 @@ my ($rv,$sth) = $S->db_insert({ DEBUG => $DEBUG, INTO => 'calendars', - COLS => 'cal_id,title,owner,public_view,public_submit', - VALUES => qq|NULL, $title, '0', $view, $submit| + COLS => 'title,owner,public_view,public_submit', + VALUES => qq|$title, '0', $view, $submit| }); if ( $rv == 1 ) { $msg = "created calendar $title"; Index: lib/Scoop/Calendar/Events.pm =================================================================== RCS file: /cvs/scoop/scoop/lib/Scoop/Calendar/Events.pm,v retrieving revision 1.2 diff -u -r1.2 Events.pm --- lib/Scoop/Calendar/Events.pm 28 May 2005 01:56:28 -0000 1.2 +++ lib/Scoop/Calendar/Events.pm 10 Jun 2005 17:51:54 -0000 @@ -460,7 +460,7 @@ $msg .= "
End Date ($tmp2) is not a valid date"; } } else { - $event->{date_end} = 0; + $event->{date_end} = undef; } map { $event->{$_} = $S->dbh->quote($event->{$_}) } (keys %$event); @@ -474,13 +474,18 @@ ($rv, $sth) = $S->db_insert({ DEBUG => $DEBUG, INTO => 'events', - COLS => 'eid,last_update,owner,date_start,date_end,public_view,public_submit,is_parent,parent,volunteers', - VALUES => qq|NULL,NULL,$uid,$event->{date_start},$event->{date_end},$event->{public_view},$event->{public_submit},$event->{is_parent},$event->{parent},$event->{volunteers}| + COLS => 'last_update,owner,date_start,date_end,public_view,public_submit,is_parent,parent,volunteers', + VALUES => qq|NOW(),$uid,$event->{date_start},$event->{date_end},$event->{public_view},$event->{public_submit},$event->{is_parent},$event->{parent},$event->{volunteers}| }); - $eid = $S->dbh->{'mysql_insertid'}; + $eid = $S->db_get_last_insert({ + TABLE => 'events', + FIELD => 'eid' + }); + if ( ! defined $eid ) { + return "(_save_event) db_get_last_insert failed\n"; + } if ( $rv == 1 ) { $S->run_hook('event_new',$uid,$eid); - my $other_cals = $S->cgi->param('other_cals'); ($rv,$sth) = $S->db_insert({ DEBUG => $DEBUG, INTO => 'calendar_link', @@ -488,6 +493,7 @@ VALUES => qq|$eid,$q_cal_id,1,$event->{displaystatus}| }); # primary calendar + my $other_cals = $S->cgi->param('other_cals'); my $values; if ( ref($other_cals) eq 'ARRAY' ) { warn " (_save_event) submitting to multiple secondary calendars" if $DEBUG; @@ -505,7 +511,7 @@ VALUES => $values }); # secondary calendars } - } else { # just one + } elsif( $other_cals ) { # just one warn " (_save_event) submitting to one secondary calendar" if $DEBUG; my $secondary_perm = $S->have_calendar_perm('submit',$other_cals); if ( $secondary_perm =~ /mod/ ) {