Update of /cvs/scoop/scoop/lib/Scoop
In directory lithium.sabren.com:/tmp/cvs-serv12208/lib/Scoop

Modified Files:
	Calendar.pm 
Log Message:
I'll get this damn patch committed someday.

Calendar module bugfixes and block updates.

--rusty


Index: Calendar.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Calendar.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Calendar.pm	21 Jan 2005 14:14:30 -0000	1.1
--- Calendar.pm	25 Jan 2005 15:22:20 -0000	1.2
***************
*** 38,42 ****
  	my ($rv, $sth, $calendar, $cal_ids, $title);
  
! 	if ( $cal_id eq 'personal' && $S->var('allow_personal_calendar_view') ) {
  		$cal_ids = $S->_personal_calendar_list($uid);
  		$title = $S->{UI}->{BLOCKS}->{personal_calendar_title};
--- 38,42 ----
  	my ($rv, $sth, $calendar, $cal_ids, $title);
  
! 	if ( $cal_id eq 'personal' && $S->var('allow_personal_calendar_view') && $S->have_perm('edit_own_calendar')) {
  		$cal_ids = $S->_personal_calendar_list($uid);
  		$title = $S->{UI}->{BLOCKS}->{personal_calendar_title};
***************
*** 182,219 ****
  			$keys->{child_events} = $parent;
  		}
! 		($rv,$sth) = $S->db_select({
! 			DEBUG => $DEBUG,
! 			WHAT => '*',
! 			FROM => 'event_watch',
! 			WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
! 		});
  
! 		# subscribe/unsubscribe link for event
! 		if ( $rv == 1 ) {
! 			if ( $sth->fetchrow_hashref()->{subscribed} == 1 ) {
! 				$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_unsubscribe_link};
! 				$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
  			} else {
  				warn "(display_event) not subscribed to event $eid" if $DEBUG;
  				$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_subscribe_link};
  				$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
  			}
- 			$sth->finish();
- 			warn "(display_event) we're watching event $eid - updating timestamp" if $DEBUG;
- 			# update the "last_viewed" for this event
- 			($rv,$sth) = $S->db_update({
- 				DEBUG => $DEBUG,
- 				WHAT => 'event_watch',
- 				SET => 'last_viewed=NULL',
- 				WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
- 			});
- 			$sth->finish();
- 		} else {
- 			warn "(display_event) not subscribed to event $eid" if $DEBUG;
- 			$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_subscribe_link};
- 			$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
- 			$sth->finish();
  		}
! 
  		# event RSVP
  		if ( $keys->{owner} == $S->{UID} ) {
--- 182,222 ----
  			$keys->{child_events} = $parent;
  		}
! 		
! 		if ($S->{UID} > 0) {
! 			($rv,$sth) = $S->db_select({
! 				DEBUG => $DEBUG,
! 				WHAT => '*',
! 				FROM => 'event_watch',
! 				WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
! 			});
  
! 			# subscribe/unsubscribe link for event
! 			if ( $rv == 1 ) {
! 				if ( $sth->fetchrow_hashref()->{subscribed} == 1 ) {
! 					$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_unsubscribe_link};
! 					$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
! 				} else {
! 					warn "(display_event) not subscribed to event $eid" if $DEBUG;
! 					$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_subscribe_link};
! 					$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
! 				}
! 				$sth->finish();
! 				warn "(display_event) we're watching event $eid - updating timestamp" if $DEBUG;
! 				# update the "last_viewed" for this event
! 				($rv,$sth) = $S->db_update({
! 					DEBUG => $DEBUG,
! 					WHAT => 'event_watch',
! 					SET => 'last_viewed=NULL',
! 					WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
! 				});
! 				$sth->finish();
  			} else {
  				warn "(display_event) not subscribed to event $eid" if $DEBUG;
  				$keys->{event_sub_link} = $S->{UI}->{BLOCKS}->{event_subscribe_link};
  				$keys->{event_sub_link} =~ s/%%eid%%/$eid/g;
+ 				$sth->finish();
  			}
  		}
! 		
  		# event RSVP
  		if ( $keys->{owner} == $S->{UID} ) {
***************
*** 250,254 ****
  				WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
  			});
! 			if ( $rv == 1 ) {
  				$keys->{rsvp} = $S->{UI}->{BLOCKS}->{rsvp_received};
  			} else {
--- 253,260 ----
  				WHERE => qq|eid = $q_eid AND uid = $S->{UID}|
  			});
! 			
! 			if ($S->{UID} <= 0) {
! 				$keys->{rsvp} = $S->{UI}->{BLOCKS}->{anonymous_rsvp_form};
! 			} elsif ( $rv == 1 ) {
  				$keys->{rsvp} = $S->{UI}->{BLOCKS}->{rsvp_received};
  			} else {