? cgi-bin/openwebmail/etc/sharedcal/README
Index: cgi-bin/openwebmail/openwebmail-cal.pl
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/openwebmail-cal.pl,v
retrieving revision 1.1.1.1
retrieving revision 1.20
diff -u -r1.1.1.1 -r1.20
--- cgi-bin/openwebmail/openwebmail-cal.pl	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/openwebmail-cal.pl	12 Aug 2003 20:21:14 -0000	1.20
@@ -55,13 +55,33 @@
 use vars qw($miscbuttonsstr);
 use vars qw(@slottime);
 
+use vars qw($loginuser $logindomain);
+use vars qw($other_loginname $other_logindomain $other_loginuser);
+use vars qw($other_domain $other_user $other_userrealname
+            $other_uuid $other_ugid $other_homedir);
+use vars qw($other_folderdir);
+use vars qw($otheruserdefined);
+
 ########################## MAIN ##############################
 openwebmail_requestbegin();
 $SIG{PIPE}=\&openwebmail_exit;	# for user stop
 $SIG{TERM}=\&openwebmail_exit;	# for user stop
 
+$other_loginname = param('other_loginname');
+$otheruserdefined = (defined($other_loginname) && ($other_loginname ne ''));
+
 userenv_init();
 
+use vars qw($calfolderdir);
+use vars qw($callockfile);
+use vars qw($calendarfile);
+$calfolderdir = $folderdir;
+if ($otheruserdefined) {
+   $calfolderdir = $other_folderdir;
+}
+$calendarfile = "$calfolderdir/.calendar.book";
+$callockfile  = "$calfolderdir/.calendar.book";
+
 $messageid = param("message_id");
 $escapedmessageid = escapeURL($messageid);
 
@@ -119,6 +139,7 @@
 my $eventcolor=param('eventcolor')||'none';
 my $dayfreq=param('dayfreq')||'thisdayonly';
 my $thisandnextndays=param('thisandnextndays')||0;
+my $private = param('private') || 0;
 my $ndays=param('ndays')||0;
 my $monthfreq=param('monthfreq')||0;
 my $everyyear=param('everyyear')||0;
@@ -128,14 +149,29 @@
 }
 
 if ($action eq "calyear") {
+   if ($otheruserdefined) {
+      checkpermission('read');
+   }
    yearview($year);
 } elsif ($action eq "calmonth") {
+   if ($otheruserdefined) {
+      checkpermission('read');
+   }
    monthview($year, $month);
 } elsif ($action eq "calweek") {
+   if ($otheruserdefined) {
+      checkpermission('read');
+   }
    weekview($year, $month, $day);
 } elsif ($action eq "calday") {
+   if ($otheruserdefined) {
+      checkpermission('read');
+   }
    dayview($year, $month, $day);
 } elsif ($action eq "callist") {
+   if ($otheruserdefined) {
+      checkpermission('read');
+   }
    listview($year);
 } elsif ($action eq "caledit") {
    edit_item($year, $month, $day, $index);
@@ -146,7 +182,7 @@
             $endhour, $endmin, $endampm,
             $dayfreq,
             $thisandnextndays, $ndays, $monthfreq, $everyyear,
-            $link, $email, $eventcolor);
+            $link, $email, $eventcolor, $private);
    dayview($year, $month, $day);
 } elsif ($action eq "caldel") {
    del_item($index);
@@ -159,12 +195,17 @@
    update_item($index, $string,
                $starthour, $startmin, $startampm,
                $endhour, $endmin, $endampm,
-               $link, $email, $eventcolor);
+               $link, $email, $eventcolor, $private);
    if (defined(param('callist'))) {
       listview($year);
    } else {
       dayview($year, $month, $day);
    }
+} elsif ($action eq "viewshares") {
+   viewshares($user);
+} elsif ($action eq "editshares") {
+   editshares();
+   viewshares($user);
 } else {
    openwebmailerror(__FILE__, __LINE__, "Action $lang_err{'has_illegal_chars'}");
 }
@@ -172,6 +213,322 @@
 openwebmail_requestend();
 ########################## END MAIN ##########################
 
+######################## CHECKPERMISSION ########################
+sub checkpermission {
+   local $> = 0;                # in this subroutine we are root user.
+   my $youwantto = shift() || 'read'; # 'read', 'create', 'edit'
+   $youwantto = 'read' unless (($youwantto eq 'read')
+                               or ($youwantto eq 'create')
+                               or ($youwantto eq 'edit'));
+
+   my $file = "$config{'ow_cgidir'}/etc/sharedcal/$other_user\@$other_domain";
+
+   local *SHARES;
+   unless (open(SHARES, $file)) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'sharedcal_noread'}");
+   }
+   while (<SHARES>) {
+      chomp;
+      my ($address, $theyallow) = split();
+      next unless defined($address);
+      $theyallow ||= 'read';
+      if ($address eq "$loginuser\@$logindomain"
+          or $address eq "$user\@$domain") {
+         if ($youwantto eq 'read') {
+            return 1 if $theyallow eq 'edit' or $theyallow eq 'create'
+               or $theyallow eq 'read';
+         }
+         elsif ($youwantto eq 'create') {
+            return 1 if $theyallow eq 'edit' or $theyallow eq 'create';
+         }
+         elsif ($youwantto eq 'edit') {
+            return 1 if $theyallow eq 'edit';
+         }
+      }
+   }
+   close(SHARES);
+   if ($youwantto eq 'edit') {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_noedit'});
+   } elsif ($youwantto eq 'create') {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_nocreate'});
+   } elsif ($youwantto eq 'read') {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_noread'});
+   }
+}
+######################## END CHECKPERMISSION ########################
+
+######################## GETSHAREDCALUSERLIST ########################
+sub getsharedcaluserlist
+    # simply return the list of users that are sharing their calendars.
+    # it will be slow to grep each one for your username.
+{
+   my $dir = "$config{'ow_cgidir'}/etc/sharedcal";
+   my @users;
+   local *DIR;
+   return unless opendir(DIR, $dir);
+   my @dir = readdir(DIR);
+   closedir(DIR);
+   return grep {
+      ($_ ne '.') and ($_ ne '..') and ($_ ne 'README') and (not /\~$/);
+   } @dir;
+}
+######################## END GETSHAREDCALUSERLIST ########################
+
+######################## READSHARES ########################
+sub readshares {                #INTERFACE CHANGE#
+   my $file = "$config{'ow_cgidir'}/etc/sharedcal/$user\@$domain";
+
+   local *SHARES;
+   open(SHARES, $file) or return ();
+   my @shares;
+   while (<SHARES>) {
+      chomp();
+      my ($address, $level) = split();
+      next unless defined($address);
+      $level ||= 'read';
+
+      # --- normalize ---
+      unless ($address =~ /\@/) {
+         my ($d, $u) = login_name2domainuser($address);
+         $address = join('@', $u, $d);
+      }
+
+      push(@shares, {
+         address => $address,
+         level => $level
+      });
+   }
+   close(SHARES);
+   return @shares;
+}
+######################## END READSHARES ########################
+
+######################## EDITSHARES ########################
+sub editshares {                #INTERFACE CHANGE#
+   local $> = 0;                # in this subroutine we are root user.
+   my $saveumask = umask(002);  # and all the stuff we create will be
+                                # world-readable.
+
+   my $num_entries = param('num_entries');
+   my @shares;
+   foreach my $counter (0 .. ($num_entries - 1)) {
+      my $address = param('user_' . $counter);
+      my $level   = param('level_' . $counter);
+      $address =~ s/\s+//;
+      next unless $address =~ /\S/;
+      my ($d, $u) = login_name2domainuser($address);
+      $address = join('@', $u, $d);
+      push(@shares, { address => $address, level => $level });
+   }
+
+   my $file = "$config{'ow_cgidir'}/etc/sharedcal/$user\@$domain";
+   if (@shares) {
+      my $dir  = "$config{'ow_cgidir'}/etc/sharedcal";
+      mkdir($dir, 0775);
+
+      local *SHARES;
+      open(SHARES, ">$file") or
+         openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_write'} $file: $!");
+      for (@shares) {
+         printf SHARES ("%s %s\n", $_->{'address'}, $_->{'level'});
+      }
+      close(SHARES);
+      my $book = "$folderdir/.calendar.book";
+      addperms(0444, $book);
+      my $d = $book;
+      do {
+         $d =~ s/\/+[^\/]+\/*$//; # remove last element (assuming Unix)
+         addperms(0111, $d);
+      } until (($d eq $homedir) or ($dir eq ''));
+   } else {
+      unlink($file);
+   }
+   umask($saveumask);
+}
+
+# utility functions to add and remove permission bits from files.
+sub addperms {
+   my ($addperms, @file) = @_;
+   foreach my $file (@file) {
+      my $perms = (lstat($file))[2];
+      next unless defined($perms);
+      next if (($perms & $addperms) == $addperms);
+      $perms = $perms | $addperms;
+      chmod($perms, $file);
+   }
+}
+sub delperms {
+   my ($delperms, @file) = @_;
+   foreach my $file (@file) {
+      my $perms = (lstat($file))[2];
+      next unless defined($perms);
+      next if (($perms & $delperms) == 0);
+      $perms = $perms & ~$delperms;
+      chmod($perms, $file);
+   }
+}
+######################## END EDITSHARES ########################
+
+######################## VIEWSHARES ########################
+sub viewshares {
+   my ($yourusername) = @_;
+   my $g2l=time()+timeoffset2seconds($prefs{'timeoffset'}); # trick makes gmtime($g2l) return localtime in timezone of timeoffsset
+   my ($current_year, $current_month, $current_day)=(gmtime($g2l))[5,4,3];
+   $current_year+=1900; $current_month++;
+
+   my $day;
+   $year = $current_year if (!$year);
+   $year=2037 if ($year>2037);
+   $year=1970 if ($year<1970);
+
+   my ($html, $temphtml);
+   $html = readtemplate("sharedcal.template");
+   $html = applystyle($html);
+
+   my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=calmonth&amp;year=$year&amp;month=$current_month";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
+   $temphtml  = iconlink("yearview.gif" ,"$lang_calendar{'yearview'} ".formatted_date($year), qq|accesskey="Y" href="$cal_url&amp;action=calyear&year=$year"|);
+   $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year, $current_month), qq|accesskey="M" href="$cal_url&amp;action=calmonth&year=$year&month=$current_month"|);
+   $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="W" href="$cal_url&amp;action=calweek&year=$year&month=$current_month&day=$current_day"|);
+   $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="T" href="$cal_url&amp;action=calday&year=$year&month=$current_month&day=$current_day"|);
+   $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|accesskey="L" href="$cal_url&amp;action=callist&year=$year"|);
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|accesskey="S" href="$cal_url&amp;action=viewshares"|);
+   if ($year != $current_year) {
+      $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} ".formatted_date($current_year), qq|accesskey="R" href="$cal_url&amp;action=calyear&year=$current_year"|);
+   }
+
+   $miscbuttonsstr = iconlink("calendar.gif", "$lang_text{'backto'} $lang_text{'calendar'}", qq|accesskey="K" href="$cal_url&amp;action=calmonth&year=$year&month=$current_month"|) . $miscbuttonsstr;
+
+   $temphtml .= "&nbsp;\n$miscbuttonsstr";
+   $html =~ s/\@\@\@MENUBARLINKS\@\@\@/$temphtml/g;
+
+   $temphtml =
+       (startform(-name => 'editsharesform',
+                  -action => "$config{ow_cgiurl}/openwebmail-cal.pl")
+        . hidden(-name => 'action',
+                 -default => 'editshares',
+                 -override => 1)
+        . hidden(-name => 'sessionid',
+                 -default => $thissession,
+                 -override => 1)
+        . hidden(-name=>'folder',
+                 -default=>$folder,
+                 -override=>'1')
+        . hidden(-name=>'message_id',
+                 -default=>$messageid,
+                 -override=>'1')
+        );
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname',
+                          -default => $other_loginname,
+                          -override => 1);
+   }
+   $html =~ s/\@\@\@STARTFORM1\@\@\@/$temphtml/g;
+
+   $temphtml = '';
+   my @shares = readshares();
+   my $counter = 0;
+   push(@shares, {}, {}, {}, {}); # add four blank entries
+   foreach my $share (@shares) {
+      my $address = $share->{address} || '';
+      my $level   = $share->{level}   || 'read';
+      $temphtml .= textfield(-size => 32,
+                             -name => 'user_' . $counter,
+                             -default => $address,
+                             -override => 1);
+      $temphtml .= popup_menu(-name => 'level_' . $counter,
+                              -values => ['read', 'create', 'edit'],
+                              -labels => {
+                                 read => 'read-only',
+                                 create => 'create new entries',
+                                 edit => 'full editing',
+                              },
+                              -default => $level,
+                              -override => 1);
+      $temphtml .= br();
+      ++$counter;
+   }
+   $temphtml .= hidden(-name => 'num_entries',
+                       -value => $counter,
+                       -override => 1);
+
+   $html =~ s/\@\@\@USERLIST1\@\@\@/$temphtml/g;
+   $temphtml = end_form();
+   $html =~ s/\@\@\@ENDFORM1\@\@\@/$temphtml/g;
+   $html =~ s/\@\@\@STARTERROR1\@\@\@.*?\@\@\@ENDERROR1\@\@\@//gs;
+
+   $temphtml =
+       (startform(-name => 'viewsharedcalendarform',
+                  -action => "$config{ow_cgiurl}/openwebmail-cal.pl")
+        . hidden(-name => 'action',
+                 -default => 'calmonth',
+                 -override => 1)
+        . hidden(-name => 'sessionid',
+                 -default => $thissession,
+                 -override => 1)
+        . hidden(-name=>'folder',
+                 -default=>$folder,
+                 -override=>'1')
+        . hidden(-name=>'message_id',
+                 -default=>$messageid,
+                 -override=>'1'));
+   $html =~ s/\@\@\@STARTFORM2\@\@\@/$temphtml/g;
+
+   my $choosetextbox = 0;
+   my @userlist = grep { $_ ne "$user\@$domain" } getsharedcaluserlist();
+
+   if ($choosetextbox) {
+      # just display a text box.  Right now, this code is never reached.
+      $html =~ s/\@\@\@CHOOSETEXTBOX\@\@\@//g;
+      $html =~ s/\@\@\@ENDCHOOSETEXTBOX\@\@\@//g;
+      $html =~ s/\@\@\@CHOOSEPULLDOWN\@\@\@.*?\@\@\@ENDCHOOSEPULLDOWN\@\@\@//gs;
+      $html =~ s/\@\@\@CHOOSENOUSERS\@\@\@.*?\@\@\@ENDCHOOSENOUSERS\@\@\@//gs;
+      $temphtml = textfield(-name => 'other_loginname', -default => '', -override => 1);
+      $temphtml .= "<br />";
+      $html =~ s/\@\@\@USERTEXTBOX\@\@\@/$temphtml/g;
+   } elsif (@userlist) {
+      # display a userlist pulldown.
+      $html =~ s/\@\@\@CHOOSEPULLDOWN\@\@\@//g;
+      $html =~ s/\@\@\@ENDCHOOSEPULLDOWN\@\@\@//g;
+      $html =~ s/\@\@\@CHOOSETEXTBOX\@\@\@.*?\@\@\@ENDCHOOSETEXTBOX\@\@\@//gs;
+      $html =~ s/\@\@\@CHOOSENOUSERS\@\@\@.*?\@\@\@ENDCHOOSENOUSERS\@\@\@//gs;
+      $temphtml = popup_menu(-name => 'other_loginname',
+                             -values => \@userlist);
+      $temphtml .= "<br />";
+      $html =~ s/\@\@\@USERPULLDOWN\@\@\@/$temphtml/g;
+   } else {
+      # display a "no users" message.
+      $html =~ s/\@\@\@CHOOSEPULLDOWN\@\@\@.*?\@\@\@ENDCHOOSEPULLDOWN\@\@\@//gs;
+      $html =~ s/\@\@\@CHOOSETEXTBOX\@\@\@.*?\@\@\@ENDCHOOSETEXTBOX\@\@\@//gs;
+      $html =~ s/\@\@\@CHOOSENOUSERS\@\@\@//g;
+      $html =~ s/\@\@\@ENDCHOOSENOUSERS\@\@\@//g;
+   }
+
+   $temphtml = end_form();
+   $html =~ s/\@\@\@ENDFORM2\@\@\@/$temphtml/g;
+   $html =~ s/\@\@\@STARTERROR2\@\@\@.*?\@\@\@ENDERROR2\@\@\@//gs;
+
+   httpprint([],
+             [htmlheader(), htmlplugin($config{'header_pluginfile'}),
+              $html,
+              htmlplugin($config{'footer_pluginfile'}), htmlfooter(2)] );
+}
+######################## END VIEWSHARES ########################
+
 ########################## YEARVIEW ##########################
 sub yearview {
    my $year=$_[0];
@@ -210,6 +567,9 @@
                hidden(-name=>'message_id',
                       -default=>$messageid,
                       -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/g;
 
    $html =~ s/\@\@\@DATESELMENU\@\@\@/$lang_text{'calfmt_year'}/g;
@@ -230,14 +590,30 @@
 
    # put the calbook timestamp in request url so cache directive can be used
    # for the two most time-consuming operstion --- yearview and listview
-   my $stamp=(stat("$folderdir/.calendar.book"))[9];
+   my $stamp=(stat($calendarfile))[9];
    my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;stamp=$stamp|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=calyear&amp;year=$year";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
 
    $temphtml  = iconlink("yearview.gif" ,"$lang_calendar{'yearview'} ".formatted_date($year), qq|accesskey="Y" href="$cal_url&amp;action=calyear&amp;year=$year"|);
    $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year, $current_month), qq|accesskey="M" href="$cal_url&amp;action=calmonth&amp;year=$year&amp;month=$current_month"|);
    $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="W" href="$cal_url&amp;action=calweek&amp;year=$year&amp;month=$current_month&amp;day=$current_day"|);
    $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="T" href="$cal_url&amp;action=calday&amp;year=$year&amp;month=$current_month&amp;day=$current_day"|);
    $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|accesskey="L" href="$cal_url&amp;action=callist&amp;year=$year"|);
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|accesskey="S" href="$cal_url&amp;action=viewshares"|);
    if ($year != $current_year) {
       $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} ".formatted_date($current_year), qq|accesskey="R" href="$cal_url&amp;action=calyear&amp;year=$current_year"|);
    }
@@ -255,17 +631,22 @@
    $html =~ s/\@\@\@NEXT_LINK\@\@\@/$temphtml/g;
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    my @accesskey=qw(0 1 2 3 4 5 6 7 8 9 0 J Q);
    my ($easter_month, $easter_day) = gregorian_easter($year); # compute once
@@ -314,6 +695,7 @@
                foreach ($date, '*') {
                   next if (!defined($indexes{$_}));
                   foreach my $index (@{$indexes{$_}}) {
+                     next if $otheruserdefined and $items{$index}{'private'};
                      if ($date =~/$items{$index}{'idate'}/ ||
                          $date2=~/$items{$index}{'idate'}/ ||
                          easter_match($year,$month,$day, $easter_month,$easter_day,
@@ -324,7 +706,7 @@
                }
                @indexlist=sort { $items{$a}{'starthourmin'}<=>$items{$b}{'starthourmin'} || 
                                  $items{$a}{'endhourmin'}<=>$items{$b}{'endhourmin'} || 
-                                 $b<=>$a } @indexlist;
+                                 $b cmp $a } @indexlist;
 
                my $eventstr="";
                for my $index (@indexlist) {
@@ -409,6 +791,9 @@
                hidden(-name=>'message_id',
                       -default=>$messageid,
                       -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/g;
 
    $html =~ s/\@\@\@DATESELMENU\@\@\@/$lang_text{'calfmt_yearmonth'}/g;
@@ -438,14 +823,30 @@
 
    # put the calbook timestamp in request url so cache directive can be used
    # for the two most time-consuming operstion --- yearview and listview
-   my $stamp=(stat("$folderdir/.calendar.book"))[9];
+   my $stamp=(stat($calendarfile))[9];
    my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;stamp=$stamp|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=calmonth&amp;year=$year&amp;month=$month";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
 
    $temphtml  = iconlink("yearview.gif", "$lang_calendar{'yearview'} ".formatted_date($year), qq|accesskey="Y" href="$cal_url&amp;action=calyear&amp;year=$year"|);
    $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year,$month), qq|accesskey="M" href="$cal_url&amp;action=calmonth&amp;year=$year&amp;month=$month"|);
    $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year,$month,$current_day), qq|accesskey="W" href="$cal_url&amp;action=calweek&amp;year=$year&amp;month=$month&amp;day=$current_day"|);
    $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year,$month,$current_day), qq|accesskey="T" href="$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$current_day"|);
    $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|accesskey="L" href="$cal_url&amp;action=callist&amp;year=$year"|);
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|accesskey="S" href="$cal_url&amp;action=viewshares"|);
    if ($year!=$current_year || $month!=$current_month) {
       $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} ".formatted_date($current_year,$current_month), qq|accesskey="R" href="$cal_url&amp;action=calmonth&amp;year=$current_year&amp;month=$current_month"|);
    }
@@ -480,17 +881,22 @@
    }
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    $temphtml = start_form(-action=>"$config{'ow_cgiurl'}/openwebmail-cal.pl");
    $temphtml .= hidden(-name=>'sessionid',
@@ -511,6 +917,9 @@
    $temphtml .= hidden(-name=>'month',
                        -value=>$month,
                        -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTDAYFORM\@\@\@/$temphtml/;
 
    my ($easter_month, $easter_day) = gregorian_easter($year); # compute once
@@ -553,6 +962,7 @@
             foreach ($date, '*') {
                next if (!defined($indexes{$_}));
                foreach my $index (@{$indexes{$_}}) {
+                  next if $otheruserdefined and $items{$index}{'private'};
                   if ($date =~/$items{$index}{'idate'}/ ||
                       $date2=~/$items{$index}{'idate'}/ ||
                       easter_match($year,$month,$day, $easter_month,$easter_day,
@@ -563,12 +973,13 @@
             }
             @indexlist=sort { $items{$a}{'starthourmin'}<=>$items{$b}{'starthourmin'} || 
                               $items{$a}{'endhourmin'}<=>$items{$b}{'endhourmin'} || 
-                              $b<=>$a } @indexlist;
+                              $b cmp $a } @indexlist;
 
             $temphtml .= qq|<tr><td>|;
             for my $index (@indexlist) {
                if ($i<$prefs{'calendar_monthviewnumitems'}) {
-                  $temphtml .= month_week_item($items{$index}, qq|$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day|, ($index>=1E6))
+                  $temphtml .= month_week_item($items{$index}, qq|$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day|,
+                                               $index =~ /{[gh]}/);
                }
                $i++;
             }
@@ -637,6 +1048,9 @@
                hidden(-name=>'message_id',
                       -default=>$messageid,
                       -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/g;
 
    $html =~ s/\@\@\@DATESELMENU\@\@\@/$lang_text{'calfmt_yearmonthday'}/g;
@@ -674,14 +1088,30 @@
 
    # put the calbook timestamp in request url so cache directive can be used
    # for the two most time-consuming operstion --- yearview and listview
-   my $stamp=(stat("$folderdir/.calendar.book"))[9];
+   my $stamp=(stat($calendarfile))[9];
    my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;stamp=$stamp|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=calweek&amp;year=$year&amp;month=$month&amp;day=$day";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
 
    $temphtml  = iconlink("yearview.gif", "$lang_calendar{'yearview'} ".formatted_date($year), qq|href="$cal_url&amp;action=calyear&amp;year=$year"|). qq| \n|;
    $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year,$month), qq|href="$cal_url&amp;action=calmonth&amp;year=$year&amp;month=$month"|). qq| \n|;
    $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year,$month,$day), qq|href="$cal_url&amp;action=calweek&amp;year=$year&amp;month=$month&amp;day=$day"|). qq| \n|;
    $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year,$month,$day), qq|href="$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day"|). qq| \n|;
    $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|href="$cal_url&amp;action=callist&amp;year=$year"|). qq| \n|;
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|href="$cal_url&amp;action=viewshares"|) . qq| \n|;
    if ($year!=$current_year || $month!=$current_month || $day!=$current_day) {
       $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} $lang_calendar{'weekview'} ".formatted_date($current_year,$current_month,$current_day), qq|href="$cal_url&amp;action=calweek&amp;year=$current_year&amp;month=$current_month&amp;day=$current_day"|). qq| \n|;
    }
@@ -718,17 +1148,22 @@
    my $start_time = $time - 86400 * (($wdaynum+7-$prefs{'calendar_weekstart'})%7);
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    for my $x (0..6) {
       ($year, $month, $day)=(gmtime($start_time+$x*86400))[5,4,3];
@@ -770,6 +1205,9 @@
       $temphtml .= hidden(-name=>'day',
                           -value=>$day,
                           -override=>'1');
+      if ($otheruserdefined) {
+         $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+      }
       $temphtml .= qq|<tr><td align="right">|.
                    lunar_str($year, $month, $day, $prefs{'charset'}).
                    submit("$daystr").
@@ -788,6 +1226,7 @@
       foreach ($date, '*') {
          next if (!defined($indexes{$_}));
          foreach my $index (@{$indexes{$_}}) {
+            next if $otheruserdefined and $items{$index}{'private'};
             if ($date =~/$items{$index}{'idate'}/ ||
                 $date2=~/$items{$index}{'idate'}/ ||
                 easter_match($year,$month,$day, $easter_month,$easter_day,
@@ -798,11 +1237,12 @@
       }
       @indexlist=sort { $items{$a}{'starthourmin'}<=>$items{$b}{'starthourmin'} || 
                         $items{$a}{'endhourmin'}<=>$items{$b}{'endhourmin'} || 
-                        $b<=>$a } @indexlist;
+                        $b cmp $a } @indexlist;
 
       $temphtml .= qq|<tr><td valign=bottom>|;
       for my $index (@indexlist) {
-         $temphtml .= month_week_item($items{$index}, qq|$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day|, ($index>=1E6));
+         $temphtml .= month_week_item($items{$index}, qq|$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day|,
+                                      $index =~ /{[gh]}/);
          $i++;
       }
       $temphtml .= qq|&nbsp;<br>\n| if ($i==0);
@@ -899,6 +1339,9 @@
                hidden(-name=>'message_id',
                       -default=>$messageid,
                       -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/g;
 
    $html =~ s/\@\@\@DATESELMENU\@\@\@/$lang_text{'calfmt_yearmonthday'}/g;
@@ -933,14 +1376,30 @@
 
    # put the calbook timestamp in request url so cache directive can be used
    # for the two most time-consuming operstion --- yearview and listview
-   my $stamp=(stat("$folderdir/.calendar.book"))[9];
+   my $stamp=(stat($calendarfile))[9];
    my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;stamp=$stamp|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
 
    $temphtml  = iconlink("yearview.gif", "$lang_calendar{'yearview'} ".formatted_date($year), qq|accesskey="Y" href="$cal_url&amp;action=calyear&amp;year=$year"|);
    $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year,$month), qq|accesskey="M" href="$cal_url&amp;action=calmonth&amp;year=$year&amp;month=$month"|);
    $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year,$month,$day), qq|accesskey="W" href="$cal_url&amp;action=calweek&amp;year=$year&amp;month=$month&amp;day=$day"|);
    $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year,$month,$day), qq|accesskey="T" href="$cal_url&amp;action=calday&amp;year=$year&amp;month=$month&amp;day=$day"|);
    $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|accesskey="L" href="$cal_url&amp;action=callist&amp;year=$year"|);
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|accesskey="S" href="$cal_url&amp;action=viewshares"|);
    if ($year!=$current_year || $month!=$current_month || $day!=$current_day) {
       $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} ".formatted_date($current_year,$current_month,$current_day), qq|accesskey="R" href="$cal_url&amp;action=calday&amp;year=$current_year&amp;month=$current_month&amp;day=$current_day"|);
    }
@@ -968,17 +1427,22 @@
 
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    my $t=timegm(1, 1, 1, $day, $month-1, $year-1900);
    my $wdaynum=(gmtime($t))[6];
@@ -1000,6 +1464,7 @@
    foreach ($date, '*') {
       next if (!defined($indexes{$_}));
       foreach my $index (@{$indexes{$_}}) {
+         next if $otheruserdefined and $items{$index}{'private'};
          if ($date =~/$items{$index}{'idate'}/ ||
              $date2=~/$items{$index}{'idate'}/ ||
              easter_match($year,$month,$day, $easter_month,$easter_day,
@@ -1010,7 +1475,7 @@
    }
    @indexlist=sort { $items{$a}{'starthourmin'}<=>$items{$b}{'starthourmin'} || 
                      $items{$a}{'endhourmin'}<=>$items{$b}{'endhourmin'} || 
-                     $b<=>$a } @indexlist;
+                     $b cmp $a } @indexlist;
 
    my @bgcolor=($style{"tablerow_light"}, $style{"tablerow_dark"});
    my $colornum=0;
@@ -1072,7 +1537,7 @@
       $temphtml .= qq|<tr>|.
                    qq|<td bgcolor=$bgcolor[$colornum] valign="top" colspan="|.($colmax+1).qq|">\n|.
                    qq|<table width="100%" cellpadding="2" cellspacing="0"><tr><td $bgcolorstr valign="top" align="left">|;
-      if ($index>=1E6) {
+      if ($index =~ /{[gh]}/) {
          $temphtml .= qq|$eventtime${$r_event}{'string'} *|.
                       $eventlink.$eventemail;
       } else {
@@ -1211,7 +1676,7 @@
                $temphtml .= qq|<td $bgcolorstr $bdstylestr valign="top" width="|.
                             int(100 * $layout{$index}{'colspan'}/($colmax+1)).
                             qq|%" rowspan="$layout{$index}{'rowspan'}" colspan="$layout{$index}{'colspan'}">|;
-               if ($index > 1E6) {
+               if ($index =~ /{[gh]}/) {
                   $temphtml .=qq|$eventtime ${$r_event}{'string'} *|.
                               $eventlink.$eventemail;
                } else {
@@ -1262,6 +1727,9 @@
    $temphtml .= hidden(-name=>'day',
                        -value=>$day,
                        -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTADDITEMFORM\@\@\@/$temphtml/;
 
    $temphtml = textfield(-name=>'string',
@@ -1355,6 +1823,9 @@
                         -label=>'');
    $html =~ s/\@\@\@THISANDNEXTNDAYSCHECKBOX\@\@\@/$temphtml/g;
 
+   $temphtml = checkbox(-name => 'private', -value => '1', -checked => 0, -label => '', -override => 1);
+   $html =~ s/\@\@\@PRIVATECHECKBOX\@\@\@/$temphtml/g;
+
    $temphtml = textfield(-name=>'ndays',
                          -default=>'',
                          -size=>'2',
@@ -1426,7 +1897,7 @@
    $html =~ s/\@\@\@SUBMITBUTTON\@\@\@/$temphtml/;
 
    $temphtml = end_form();
-   $html =~ s/\@\@\@ENDFORM\@\@\@/$temphtml/g;
+   $html =~ s/\@\@\@ENDADDITEMFORM\@\@\@/$temphtml/g;
 
    httpprint([], 
              [htmlheader(), htmlplugin($config{'header_pluginfile'}), 
@@ -1629,6 +2100,9 @@
                hidden(-name=>'message_id',
                       -default=>$messageid,
                       -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname', -default => $other_loginname, -override => 1);
+   }
    $html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/g;
 
    $html =~ s/\@\@\@DATESELMENU\@\@\@/$lang_text{'calfmt_year'}/g;
@@ -1648,14 +2122,30 @@
 
    # put the calbook timestamp in request url so cache directive can be used
    # for the two most time-consuming operstion --- yearview and listview
-   my $stamp=(stat("$folderdir/.calendar.book"))[9];
+   my $stamp=(stat($calendarfile))[9];
    my $cal_url=qq|$config{'ow_cgiurl'}/openwebmail-cal.pl?sessionid=$thissession&amp;folder=$escapedfolder&amp;message_id=$escapedmessageid&amp;stamp=$stamp|;
+   my $your_cal_url = $cal_url;
+   if ($otheruserdefined) {
+      $cal_url .= "&amp;other_loginname=" . escapeURL($other_loginname);
+   }
+   $your_cal_url .= "&amp;action=callist&amp;year=$year";
+
+   if ($otheruserdefined) {
+      $temphtml = readtemplate("viewingsharedcal.template");
+      $temphtml = applystyle($temphtml);
+      $temphtml =~ s/\@\@\@SHAREDCALUSER\@\@\@/$other_user/g;
+      $temphtml =~ s/\@\@\@YOURCALLINK\@\@\@/$your_cal_url/g;
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@/$temphtml/g;
+   } else {
+      $html =~ s/\@\@\@VIEWINGSHAREDCALENDAR\@\@\@//g;
+   }
 
    $temphtml  = iconlink("yearview.gif" ,"$lang_calendar{'yearview'} ".formatted_date($year), qq|accesskey="Y" href="$cal_url&amp;action=calyear&amp;year=$year"|);
    $temphtml .= iconlink("monthview.gif", "$lang_calendar{'monthview'} ".formatted_date($year, $current_month), qq|accesskey="M" href="$cal_url&amp;action=calmonth&amp;year=$year&amp;month=$current_month"|);
    $temphtml .= iconlink("weekview.gif", "$lang_calendar{'weekview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="W" href="$cal_url&amp;action=calweek&amp;year=$year&amp;month=$current_month&amp;day=$current_day"|);
    $temphtml .= iconlink("dayview.gif", "$lang_calendar{'dayview'} ".formatted_date($year, $current_month, $current_day), qq|accesskey="T" href="$cal_url&amp;action=calday&amp;year=$year&amp;month=$current_month&amp;day=$current_day"|);
    $temphtml .= iconlink("listview.gif", "$lang_calendar{'listview'} ".formatted_date($year), qq|accesskey="L" href="$cal_url&amp;action=callist&amp;year=$year"|);
+   $temphtml .= iconlink("sharedcal.gif", "$lang_calendar{'sharedcal'}", qq|accesskey="S" href="$cal_url&amp;action=viewshares"|);
    if ($year != $current_year) {
       $temphtml .= iconlink("refresh.gif", "$lang_text{'backto'} ".formatted_date($current_year), qq|accesskey="R" href="$cal_url&amp;action=callist&amp;year=$current_year"|);
    }
@@ -1673,17 +2163,22 @@
    $html =~ s/\@\@\@NEXT_LINK\@\@\@/$temphtml/g;
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    my $t0 = timegm(1,1,1, $current_day, $current_month-1, $current_year-1900);
    my @accesskey=qw(0 1 2 3 4 5 6 7 8 9 0 J Q);
@@ -1702,6 +2197,7 @@
          foreach ($date, '*') {
             next if (!defined($indexes{$_}));
             foreach my $index (@{$indexes{$_}}) {
+               next if $otheruserdefined and $items{$index}{'private'};
                if ($date =~/$items{$index}{'idate'}/ ||
                    $date2=~/$items{$index}{'idate'}/ ||
                    easter_match($year,$month,$day, $easter_month,$easter_day,
@@ -1712,11 +2208,12 @@
          }
          @indexlist=sort { $items{$a}{'starthourmin'}<=>$items{$b}{'starthourmin'} || 
                            $items{$a}{'endhourmin'}<=>$items{$b}{'endhourmin'} || 
-                           $b<=>$a } @indexlist;
+                           $b cmp $a } @indexlist;
 
          my $dayhtml="";
          for my $index (@indexlist) {
-            $dayhtml .= listview_item($index, \%items, $cal_url, "year=$year&amp;month=$month&amp;day=$day&amp;index=$index&amp;callist=1", ($index>=1E6))
+            $dayhtml .= listview_item($index, \%items, $cal_url, "year=$year&amp;month=$month&amp;day=$day&amp;index=$index&amp;callist=1",
+                                      $index =~ /{[gh]}/);
          }
 
          my $bgcolor;
@@ -1823,14 +2320,34 @@
    $html = applystyle(readtemplate("editcalendar.template"));
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_SH | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if (! defined($items{$index}) ) {
       openwebmailerror(__FILE__, __LINE__, "$lang_text{'calendar'} $index $lang_err{'doesnt_exist'}");
       writelog("edit calitem error - item missing, index=$index");
       writehistory("edit calitem error - item missing, index=$index");
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
+
+   if ($otheruserdefined) {
+      my $creator = $items{$index}{'creator'};
+      if (defined($creator) and ($creator eq "$loginuser\@$logindomain")) {
+         # you created this item; you can edit it right?
+         checkpermission('create');
+      } else {
+         # assume other user created this entry.
+         checkpermission('edit');
+      }
+   }
+
+   if ($otheruserdefined and $items{$index}{'private'}) {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_private'});
+   }
 
    $temphtml = formatted_date($year, $month, $day);
    $html =~ s/\@\@\@DATE\@\@\@/$temphtml/;
@@ -1861,6 +2378,11 @@
    $temphtml .= hidden(-name=>'index',
                        -value=>$index,
                        -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname',
+                          -default => $other_loginname,
+                          -override => 1);
+   }
    if (defined(param('callist'))) {
       $temphtml .= hidden(-name=>'callist',
                           -value=>1,
@@ -1983,6 +2505,10 @@
    $temphtml .= qq|</tr></table>|;
    $html =~ s/\@\@\@EVENTCOLORMENU\@\@\@/$temphtml/;
 
+   my $private = $items{$index}{'private'};
+   $temphtml = checkbox(-name => 'private', -value => '1', -checked => $private, -label => '', -override => 1);
+   $html =~ s/\@\@\@PRIVATECHECKBOX\@\@\@/$temphtml/g;
+
    $temphtml = submit("$lang_text{'save'}");
    $html =~ s/\@\@\@SUBMITBUTTON\@\@\@/$temphtml/;
 
@@ -2000,6 +2526,11 @@
    $temphtml .= hidden(-name=>'year',
                        -value=>$year,
                        -override=>'1');
+   if ($otheruserdefined) {
+      $temphtml .= hidden(-name => 'other_loginname',
+                          -default => $other_loginname,
+                          -override => 1);
+   }
    if (defined(param('callist'))) {
       $temphtml .= hidden(-name=>'action',
                           -value=>'callist',
@@ -2038,7 +2569,7 @@
        $thisandnextndays, $ndays,
        $monthfreq,
        $everyyear,
-       $link, $email, $eventcolor)=@_;
+       $link, $email, $eventcolor, $private)=@_;
    my $line;
    return if ($string=~/^\s?$/);
 
@@ -2083,8 +2614,15 @@
    }
 
    my ($item_count, %items, %indexes);
-   if ( ($item_count=readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)) <0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_EX | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( ($item_count=readcalbook($calendarfile, \%items, \%indexes, '')) <0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
+   }
+
+   if ($otheruserdefined) {
+      checkpermission('create');
    }
 
    my $index = $item_count+19690404;	# avoid collision with old records
@@ -2154,18 +2692,24 @@
       }
    }
 
+   my $creator = "$loginuser\@$logindomain";
+
    $items{$index}{'starthourmin'}="$starthourmin"; # " is required or "0000" will be treated as 0?
    $items{$index}{'endhourmin'}="$endhourmin";
    $items{$index}{'string'}=$string;
    $items{$index}{'link'}=$link;
    $items{$index}{'email'}=$email;
    $items{$index}{'eventcolor'}=$eventcolor;
+   $items{$index}{'creator'}=$creator;
+   $items{$index}{'private'}=$private;
 
-   if ( writecalbook("$folderdir/.calendar.book", \%items) <0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ( writecalbook($calendarfile, \%items) <0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
 
    reset_notifycheck_for_newitem($items{$index});
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
 
    my $msg="add calitem - start=$starthourmin, end=$endhourmin, str=$string";
    writelog($msg);
@@ -2179,16 +2723,39 @@
    my $index=$_[0];
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_EX | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
+   }
+   if (! defined($items{$index}) ) {
+      if ($otheruserdefined) { switch_yourself(); }
+      return;
+   }
+
+   if ($otheruserdefined) {
+      my $creator = $items{$index}{'creator'};
+      if (defined($creator) and ($creator eq "$loginuser\@$logindomain")) {
+         # you created this item; you can delete it.
+         checkpermission('create');
+      } else {
+         # assume other user created this entry.
+         checkpermission('edit');
+      }
+   }
+
+   if ($otheruserdefined and $items{$index}{'private'}) {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_private'});
    }
-   return if (! defined($items{$index}) );
 
    my $msg="delete calitem - index=$index, t=$items{$index}{'starthourmin'}, str=$items{$index}{'string'}";
    delete $items{$index};
-   if ( writecalbook("$folderdir/.calendar.book", \%items) <0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ( writecalbook($calendarfile, \%items) <0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
    writelog($msg);
    writehistory($msg);
 }
@@ -2200,7 +2767,7 @@
    my ($index, $string,
        $starthour, $startmin, $startampm,
        $endhour, $endmin, $endampm,
-       $link, $email, $eventcolor)=@_;
+       $link, $email, $eventcolor, $private)=@_;
    my $line;
 
    return if ($string=~/^\s?$/);
@@ -2246,8 +2813,11 @@
    }
 
    my (%items, %indexes);
-   if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ($otheruserdefined) { switch_otheruser(); }
+   filelock($callockfile, LOCK_EX | LOCK_NB) or
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_lock'} $callockfile");
+   if ( readcalbook($calendarfile, \%items, \%indexes, '')<0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
    if (! defined($items{$index}) ) {
       openwebmailerror(__FILE__, __LINE__, "$lang_text{'calendar'} $index $lang_err{'doesnt_exist'}");
@@ -2255,20 +2825,37 @@
       writehistory("update calitem error - item missing, index=$index");
    }
 
+   if ($otheruserdefined) {
+      my $creator = $items{$index}{'creator'};
+      if (defined($creator) and ($creator eq "$loginuser\@$logindomain")) {
+         checkpermission('create');
+      } else {
+         # assume other user created this entry.
+         checkpermission('edit');
+      }
+   }
+
+   if ($otheruserdefined and $items{$index}{'private'}) {
+      openwebmailerror(__FILE__, __LINE__, $lang_err{'sharedcal_private'});
+   }
+
    $items{$index}{'starthourmin'}="$starthourmin"; # " is required or "0000" will be treated as 0?
    $items{$index}{'endhourmin'}="$endhourmin";
    $items{$index}{'string'}=$string;
    $items{$index}{'link'}=$link;
    $items{$index}{'email'}=$email;
    $items{$index}{'eventcolor'}=$eventcolor;
+   $items{$index}{'private'}=$private;
 
-   if ( writecalbook("$folderdir/.calendar.book", \%items) <0 ) {
-      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $folderdir/.calendar.book");
+   if ( writecalbook($calendarfile, \%items) <0 ) {
+      openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_open'} $calendarfile");
    }
 
    reset_notifycheck_for_newitem($items{$index});
 
    my $msg="update calitem - index=$index, start=$starthourmin, end=$endhourmin, str=$string";
+   filelock($callockfile, LOCK_UN);
+   if ($otheruserdefined) { switch_yourself(); }
    writelog($msg);
    writehistory($msg);
 }
Index: cgi-bin/openwebmail/openwebmail-tool.pl
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/openwebmail-tool.pl,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- cgi-bin/openwebmail/openwebmail-tool.pl	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/openwebmail-tool.pl	12 Aug 2003 20:41:25 -0000	1.3
@@ -1049,17 +1049,25 @@
    my $date2=sprintf("%04d,%02d,%02d,%s", $year,$month,$day,$dow);
 
    my (%items, %indexes);
+
+   my $callockfile = "$folderdir/.calendar.book.lock";
+   unless (filelock($callockfile, LOCK_SH | LOCK_NB)) {
+      warn("couldn't lock $callockfile: $!\n");
+      return -1;
+   }
+
    if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
       return -1;
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
 
    my ($easter_month, $easter_day) = gregorian_easter($year); # compute once
 
@@ -1129,17 +1137,24 @@
 
    my (%items, %indexes);
 
+   my $callockfile = "$folderdir/.calendar.book.lock";
+   unless (filelock($callockfile, LOCK_SH | LOCK_NB)) {
+      warn("couldn't lock $callockfile: $!\n");
+      return -3;
+   }
+
    if ( readcalbook("$folderdir/.calendar.book", \%items, \%indexes, 0)<0 ) {
       return -3;
    }
    if ($prefs{'calendar_reminderforglobal'}) {
-      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, 1E6);
+      readcalbook("$config{'global_calendarbook'}", \%items, \%indexes, '{g}');
       if ($prefs{'calendar_holidaydef'} eq 'auto') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'language'}", \%items, \%indexes, '{h}');
       } elsif ($prefs{'calendar_holidaydef'} ne 'none') {
-         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, 1E7);
+         readcalbook("$config{'ow_holidaysdir'}/$prefs{'calendar_holidaydef'}", \%items, \%indexes, '{h}');
       }
    }
+   filelock($callockfile, LOCK_UN);
 
    my ($easter_month, $easter_day) = gregorian_easter($year); # compute once
 
Index: cgi-bin/openwebmail/ow-shared.pl
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/ow-shared.pl,v
retrieving revision 1.1.1.1
retrieving revision 1.7
diff -u -r1.1.1.1 -r1.7
--- cgi-bin/openwebmail/ow-shared.pl	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/ow-shared.pl	12 Aug 2003 21:32:13 -0000	1.7
@@ -27,6 +27,11 @@
 use vars qw(%months @monthstr @wdaystr %tzoffset %fontsize);
 use vars qw(%pop3error);
 
+use vars qw($other_loginname $other_logindomain $other_loginuser);
+use vars qw($other_domain $other_user $other_userrealname $other_uuid $other_ugid $other_homedir);
+use vars qw($other_folderdir);
+use vars qw($otheruserdefined);
+
 # The language name for each language abbreviation
 %languagenames = (
    'ar.CP1256'    => 'Arabic - Windows',
@@ -223,6 +228,13 @@
    undef($quotausage);
    undef($quotalimit);
 
+   undef($other_domain);
+   undef($other_user);
+   undef($other_userrealname);
+   undef($other_uuid);
+   undef($other_ugid);
+   undef($other_homedir);
+
    undef($folderdir);
    undef(@validfolders);
    undef($folderusage);
@@ -295,6 +307,11 @@
 
    ($logindomain, $loginuser)=login_name2domainuser($loginname, $default_logindomain);
 
+   # set in openwebmail-cal.pl.
+   if ($otheruserdefined) {
+      ($other_logindomain, $other_loginuser) = login_name2domainuser($other_loginname, $default_logindomain);
+   }
+
    if (!is_localuser("$loginuser\@$logindomain") &&  -f "$config{'ow_sitesconfdir'}/$logindomain") {
       readconf(\%config, \%config_raw, "$config{'ow_sitesconfdir'}/$logindomain");
    }
@@ -313,6 +330,12 @@
    ($domain, $user, $userrealname, $uuid, $ugid, $homedir)
 	=get_domain_user_userinfo($logindomain, $loginuser) if (!$user||$uuid==0||$ugid=~/\b0\b/);
 
+   if ($otheruserdefined) {
+      ($other_domain, $other_user, $other_userrealname, $other_uuid, $other_ugid, $other_homedir)
+          = get_domain_user_userinfo($other_logindomain, $other_loginuser)
+              if (!$other_user||$other_uuid==0||$other_ugid=~/\b0\b/);
+   }
+
    if ($user eq "") {
       sleep $config{'loginerrordelay'};	# delayed response
       openwebmailerror(__FILE__, __LINE__, "$loginuser@$logindomain $lang_err{'user_not_exist'}!");
@@ -342,15 +365,31 @@
    if ( !$config{'use_syshomedir'} ) {
       $homedir = "$config{'ow_usersdir'}/$user";
       $homedir = "$config{'ow_usersdir'}/$domain/$user" if ($config{'auth_withdomain'});
+
+      if ($otheruserdefined) {
+          $other_homedir = "$config{'ow_usersdir'}/$other_user";
+          $other_homedir = "$config{'ow_usersdir'}/$other_domain/$other_user" if ($config{'auth_withdomain'});
+      }
    }
    $folderdir = "$homedir/$config{'homedirfolderdirname'}";
+   $other_folderdir = "$other_homedir/$config{'homedirfolderdirname'}";
 
    ($user =~ /^(.+)$/) && ($user = $1);  # untaint ...
+   ($domain =~ /^(.+)$/) && ($domain = $1);
    ($uuid =~ /^(.+)$/) && ($uuid = $1);
    ($ugid =~ /^(.+)$/) && ($ugid = $1);
    ($homedir =~ /^(.+)$/) && ($homedir = $1);
    ($folderdir =~ /^(.+)$/) && ($folderdir = $1);
 
+   if ($otheruserdefined) {
+       ($other_user =~ /^(.+)$/) && ($other_user = $1);  # untaint ...
+       ($other_domain =~ /^(.+)$/) && ($other_domain = $1);
+       ($other_uuid =~ /^(.+)$/) && ($other_uuid = $1);
+       ($other_ugid =~ /^(.+)$/) && ($other_ugid = $1);
+       ($other_homedir =~ /^(.+)$/) && ($other_homedir = $1);
+       ($other_folderdir =~ /^(.+)$/) && ($other_folderdir = $1);
+   }
+
    umask(0077);
    if ( $>==0 ) {			# switch to uuid:mailgid if script is setuid root.
       my $mailgid=getgrnam('mail');	# for better compatibility with other mail progs
@@ -410,6 +449,36 @@
 }
 #################### END USERENV_INIT ###################
 
+######################## USER SWITCHING ########################
+# routines for switching users to edit shared calendars.
+# switch_otheruser switches to the user whose shared calendar
+# you are editing; switch_yourself switches back to you.
+sub switch_otheruser {
+   $<=0; $>=0;
+   if ($otheruserdefined) {
+      if ( $>==0 ) {                       # switch to uuid:mailgid if script is setuid root.
+         my $mailgid=getgrnam('mail');     # for better compatibility with other mail progs
+         set_euid_egids($other_uuid, $mailgid, $other_ugid);
+         if ( $)!~/\b$mailgid\b/) { # group mail doesn't exist?
+            openwebmailerror(__FILE__, __LINE__, "Set effective gid to mail($mailgid) failed!");
+         }
+      }
+   }
+}
+sub switch_yourself {
+   $<=0; $>=0;
+   if ($otheruserdefined) {
+      if ( $>==0 ) {                       # switch to uuid:mailgid if script is setuid root.
+         my $mailgid=getgrnam('mail');     # for better compatibility with other mail progs
+         set_euid_egids($uuid, $mailgid, $ugid);
+         if ( $)!~/\b$mailgid\b/) { # group mail doesn't exist?
+            openwebmailerror(__FILE__, __LINE__, "Set effective gid to mail($mailgid) failed!");
+         }
+      }
+   }
+}
+######################## END USER SWITCHING ########################
+
 ############ LOGINNAME 2 LOGINDOMAIN LOGINUSER ##############
 sub login_name2domainuser {
    my ($loginname, $default_logindomain)=@_;
@@ -462,7 +531,7 @@
       } else {
          $line=~s/#.*$//;
          $line=~s/^\s+//; $line=~s/\s+$//;
-         next if ($line=~/^#/);
+         next if ($line=~/^\#/);
 
          if ( $line =~ m!^<(.+)>$! ) {
             $key=$1; $key=~s/^\s+//; $key=~s/\s+$//;
@@ -1235,29 +1304,49 @@
 # read the user calendar, put records into 2 hash,
 # %items: index -> item fields
 # %indexes: date -> indexes belong to this date
-# ps: $indexshift is used to shift index so records in multiple calendar
-#     won't collide on index
+# NOTE: indexes are no longer sequentially numbered, since owm supports
+#       shared calendars and concurrent editing; we generate unique IDs now
+#       and use them in the index field.
+# ps: $indexappend is appended to index so records in multiple
+#     calendars can be differentiated from one another.  It is blank,
+#     or a string like '{g}' for global or '{h}' for holiday.
 sub readcalbook {
-   my ($calbook, $r_items, $r_indexes, $indexshift)=@_;
+   my ($calbook, $r_items, $r_indexes, $indexappend)=@_;
    my $item_count=0;
-
    return 0 if (! -f $calbook);
 
+   $indexappend = '' unless $indexappend; # replace 0 with ''
+
    open(CALBOOK, "$calbook") or return -1;
 
    while (<CALBOOK>) {
-      next if (/^#/);
+      next if (/^\#/);
       chomp;
       my @a=split(/\@{3}/, $_);
-      my $index=$a[0]+$indexshift;
+      my $index = $a[0] . $indexappend;
 
-      ${$r_items}{$index}={ idate        => $a[1],
+      my $creator = $a[8];
+      unless ($creator) {
+         # if creator field does not exist (old calbook files),
+         # we assume that the user whose calendar book we are
+         # reading created them.
+         if ($otheruserdefined) {
+            $creator = "$other_loginuser\@$other_logindomain";
+         } else {
+            $creator = "$loginuser\@$logindomain";
+         }
+      }
+
+      ${$r_items}{$index}={ index        => $a[0],
+                            idate        => $a[1],
                             starthourmin => $a[2],
                             endhourmin   => $a[3],
                             string       => $a[4],
                             link         => $a[5],
                             email        => $a[6],
-                            eventcolor   => $a[7]||'none' };
+                            eventcolor   => $a[7]||'none',
+                            creator      => $creator,
+                            private      => $a[9] };
 
       my $idate=$a[1]; $idate= '*' if ($idate=~/[^\d]/); # use '*' for regex date
       if ( !defined(${$r_indexes}{$idate}) ) {
@@ -1273,6 +1362,32 @@
    return($item_count);
 }
 
+use vars qw($indexcounter);
+use vars qw($randseeded);
+
+# generate a unique id to be used as an index for calendar entries.
+sub createuniqueid {
+   my $self = shift();
+   my $random;
+   local *RANDOM;
+   if (open(RANDOM, "/dev/urandom")) {
+      read(RANDOM, $random, 4);
+      close(RANDOM);
+      $random = unpack('N', $random);
+   } elsif (open(RANDOM, "/dev/random")) {
+      read(RANDOM, $random, 4);
+      close(RANDOM);
+      $random = unpack('N', $random);
+   } else {
+      unless ($randseeded) {
+         $randseeded = 1;
+         srand(time ^ $$ ^ unpack "%L*", `ps axww | gzip`);
+      }
+      $random = rand(0x80000000);
+   }
+   return sprintf("%08x%04x%04x%08x", time(), $$, $indexcounter++, $random);
+}
+
 sub writecalbook {
    my ($calbook, $r_items)=@_;
    my @indexlist=sort { ${$r_items}{$a}{'idate'}<=>${$r_items}{$b}{'idate'} }
@@ -1288,12 +1403,25 @@
    open (CALBOOK, ">$calbook") or return -1;
    my $newindex=1;
    foreach (@indexlist) {
-      print CALBOOK join('@@@', $newindex, ${$r_items}{$_}{'idate'},
+      my $creator = $r_items->{$_}->{'creator'};
+      unless ($creator) {
+         if ($otheruserdefined) {
+            $creator = "$other_loginuser\@$other_logindomain";
+         } else {
+            $creator = "$loginuser\@$logindomain";
+         }
+      }
+
+      print CALBOOK join('@@@',
+                       ${$r_items}{$_}{'index'} || createuniqueid(),
+                       ${$r_items}{$_}{'idate'},
                        ${$r_items}{$_}{'starthourmin'}, ${$r_items}{$_}{'endhourmin'},
                        ${$r_items}{$_}{'string'},
                        ${$r_items}{$_}{'link'},
                        ${$r_items}{$_}{'email'},
-                       ${$r_items}{$_}{'eventcolor'})."\n";
+                       ${$r_items}{$_}{'eventcolor'},
+                       $creator,
+                       ${$r_items}{$_}{'private'})."\n";
       $newindex++;
    }
    close(CALBOOK);
Index: cgi-bin/openwebmail/etc/lang/en
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/lang/en,v
retrieving revision 1.1.1.1
retrieving revision 1.4
diff -u -r1.1.1.1 -r1.4
--- cgi-bin/openwebmail/etc/lang/en	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/lang/en	1 Aug 2003 15:41:40 -0000	1.4
@@ -128,7 +128,8 @@
    monthview => 'Monthview',
    weekview  => 'Weekview',
    dayview   => 'Dayview',
-   listview  => 'Listview'
+   listview  => 'Listview',
+   sharedcal => 'Shared Calendars',
    );
 
 %lang_month =
@@ -420,6 +421,7 @@
    couldnt_seek      => 'Couldn\'t seek to the beginning of',
    couldnt_close     => 'Couldn\'t close',
    couldnt_updatedb  => 'Couldn\'t update index db ',
+   couldnt_write     => 'Couldn\'t write',
    disallowed_pop3   => 'Disallowed POP3 server',
    disallowed_client => 'You are not allowed to connect from this client',
    disallowed_receiverdomain => 'You are not allowed to send message to this email address',
@@ -470,6 +472,10 @@
    quotahit_alert    => 'Sorry, you\'ve hit your quota limit. Please delete some messages from mail folders or some files from the webdisk to free disk space.',
    quotahit_delmail  => 'Warning, since the quota limit(@@@QUOTALIMIT@@@) were hit, oldest messages in folders have been removed automatcially',
    quotahit_delfile  => 'Warning, since the quota limit(@@@QUOTALIMIT@@@) were hit, some files in the webdisk have been removed automatcially',
+   sharedcal_noread       => 'Sorry, this user does not allow you to read his calendar.',
+   sharedcal_nocreate     => 'Sorry, this user does not allow you to create new entries in his calendar.',
+   sharedcal_noedit       => 'Sorry, this user does not allow you to edit his calendar entries.',
+   sharedcal_private      => 'Sorry, this entry is marked private.',
    spool_overlimit   => 'Sorry, your INBOX has exceeded the spool limit(@@@SPOOLLIMIT@@@). Please move some messages from INBOX to other folders.',
    vdomain_toomanyuser  => 'Sorry, the user count of this domain has reached its maximum limit',
    vdomain_toomanyalias => 'Sorry, the E-MAIL alias count of this user has reached its maximum limit',
Index: cgi-bin/openwebmail/etc/templates/ar.CP1256/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ar.CP1256/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ar.ISO8859-6/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ar.ISO8859-6/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/bg/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/bg/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ca/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ca/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/cs/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/cs/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/da/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/da/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/de/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/de/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/el/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/el/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/en/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.4
diff -u -r1.1.1.1 -r1.4
--- cgi-bin/openwebmail/etc/templates/en/dayview.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/dayview.template	1 Aug 2003 16:19:20 -0000	1.4
@@ -14,6 +14,9 @@
 @@@DATESELMENU@@@&nbsp;
 </td></tr>
 @@@ENDFORM@@@
+<tr><td colspan="2" bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>
 
@@ -48,6 +51,7 @@
 @@@EMAILEND@@@
 <tr><td nowrap>Event Color</td><td nowrap>@@@EVENTCOLORMENU@@@</td></tr>
 <tr><td colspan=2>@@@COLORTABLE@@@</td></tr>
+<tr><td colspan=2 nowrap>@@@PRIVATECHECKBOX@@@ Private</td></tr>
 <tr><td colspan=2 align=center>@@@SUBMITBUTTON@@@</td></tr>
 @@@ENDFORM@@@
 </table>
Index: cgi-bin/openwebmail/etc/templates/en/editcalendar.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/editcalendar.template,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cgi-bin/openwebmail/etc/templates/en/editcalendar.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/editcalendar.template	1 Aug 2003 16:36:39 -0000	1.2
@@ -34,6 +34,10 @@
 <B>Event Color:</B>
 </td><td bgcolor=@@@WINDOW_DARK@@@>
 @@@EVENTCOLORMENU@@@
+</td></tr><tr><td align="right" bgcolor=@@@WINDOW_DARK@@@>
+<B>Private:</B>
+</td><td bgcolor=@@@WINDOW_DARK@@@>
+@@@PRIVATECHECKBOX@@@ 
 </td></tr><tr><td colspan="2" align="center" bgcolor=@@@WINDOW_DARK@@@>
 <table border=0 cellpading=5 align=center width="40%"><tr>
 <td align=center>@@@SUBMITBUTTON@@@</td>
Index: cgi-bin/openwebmail/etc/templates/en/listview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/listview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cgi-bin/openwebmail/etc/templates/en/listview.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/listview.template	13 Jul 2003 20:13:20 -0000	1.2
@@ -11,6 +11,9 @@
 @@@DATESELMENU@@@&nbsp;
 </td></tr>
 @@@ENDFORM@@@
+<tr><td colspan="2" bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>
 
Index: cgi-bin/openwebmail/etc/templates/en/monthview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/monthview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cgi-bin/openwebmail/etc/templates/en/monthview.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/monthview.template	13 Jul 2003 20:13:20 -0000	1.2
@@ -11,6 +11,9 @@
 @@@DATESELMENU@@@&nbsp;
 </td></tr>
 @@@ENDFORM@@@
+<tr><td colspan="2" bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>
 
Index: cgi-bin/openwebmail/etc/templates/en/sharedcal.template
===================================================================
RCS file: cgi-bin/openwebmail/etc/templates/en/sharedcal.template
diff -N cgi-bin/openwebmail/etc/templates/en/sharedcal.template
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cgi-bin/openwebmail/etc/templates/en/sharedcal.template	22 Jul 2003 16:58:52 -0000	1.3
@@ -0,0 +1,84 @@
+<table border="0" align="center" width="90%" cellpadding="1" cellspacing="0">
+<tr><td bgcolor=@@@TITLEBAR@@@>
+<font color=@@@TITLEBAR_TEXT@@@ face=@@@FONTFACE@@@ size="3">
+<B>Shared Calendars Panel</B></font>
+</td></tr>
+<tr><td bgcolor=@@@MENUBAR@@@>
+@@@MENUBARLINKS@@@
+</td></tr>
+<tr><td bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
+</table>
+&nbsp;
+<table border="0" align="center" width="90%" cellpadding="1" cellspacing="1" bgcolor=@@@BACKGROUND@@@><tr><td>
+
+<div align="center">
+
+	@@@STARTFORM2@@@
+
+	<p><b>View Shared Calendar</b></p>
+
+	@@@CHOOSETEXTBOX@@@
+
+	<p>Type in a username to view that user's shared calendar, and
+	press the "View Calendar" button.  If this installation
+	supports multiple domains, you can specify
+	"<i>user</i>@<i>domain</i>".</p>
+
+	<p>
+	@@@USERTEXTBOX@@@
+	<input type="submit" value="View Calendar" />
+	</p>
+
+	@@@ENDCHOOSETEXTBOX@@@
+
+	@@@CHOOSEPULLDOWN@@@
+
+	<p>Choose a username to view that user's shared calendar, and
+	press the "View Calendar" button.</p>
+
+	<p>
+	@@@USERPULLDOWN@@@
+	<input type="submit" value="View Calendar" />
+	</p>
+
+	@@@ENDCHOOSEPULLDOWN@@@
+
+	@@@CHOOSENOUSERS@@@
+
+	<p>Sorry, there are no other users with shared calendars you
+	can view.</p>
+
+	@@@ENDCHOOSENOUSERS@@@
+
+	@@@ENDFORM2@@@
+
+</div>
+
+<div align="center">
+
+	@@@STARTFORM1@@@
+
+	<p><b>Edit Shares</b></p>
+
+	<p><small>You can choose which users are allowed to view your
+	calendar.  To add a user, type their username into one of the
+	text boxes.  To remove a user, delete their username from one
+	of the text boxes.  If this installation supports multiple
+	domains, you can specify "<i>user</i>@<i>domain</i>".  When
+	you click "Update Shares", extra spaces will be
+	provided so you can enter more users.</small></p>
+
+	<p>
+	@@@USERLIST1@@@
+	<input type="submit" value="Update Shares" />
+	<input type="reset" value="Reset" /><br />
+	</p>
+	@@@ENDFORM1@@@
+
+</div>
+
+</td></tr>
+</table>
+
Index: cgi-bin/openwebmail/etc/templates/en/viewingsharedcal.template
===================================================================
RCS file: cgi-bin/openwebmail/etc/templates/en/viewingsharedcal.template
diff -N cgi-bin/openwebmail/etc/templates/en/viewingsharedcal.template
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ cgi-bin/openwebmail/etc/templates/en/viewingsharedcal.template	18 Jul 2003 21:57:05 -0000	1.2
@@ -0,0 +1,9 @@
+    <table border="0" cellspacing="0" cellpadding="0" width="100%">
+      <tr>
+        <td align="left" bgcolor=@@@MENUBAR@@@>
+          <b>Viewing unprivileged user @@@SHAREDCALUSER@@@'s calendar.</b>
+        </td><td align="right" bgcolor=@@@MENUBAR@@@>
+          <small>switch to <a href="@@@YOURCALLINK@@@">your calendar</a></small>
+        </td>
+      </tr>
+    </table>
Index: cgi-bin/openwebmail/etc/templates/en/weekview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/weekview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cgi-bin/openwebmail/etc/templates/en/weekview.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/weekview.template	13 Jul 2003 20:13:20 -0000	1.2
@@ -11,6 +11,9 @@
 @@@DATESELMENU@@@&nbsp;
 </td></tr>
 @@@ENDFORM@@@
+<tr><td colspan="2" bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>
 
Index: cgi-bin/openwebmail/etc/templates/en/yearview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/en/yearview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- cgi-bin/openwebmail/etc/templates/en/yearview.template	13 Jul 2003 19:30:20 -0000	1.1.1.1
+++ cgi-bin/openwebmail/etc/templates/en/yearview.template	13 Jul 2003 20:13:20 -0000	1.2
@@ -11,6 +11,9 @@
 @@@DATESELMENU@@@&nbsp;
 </td></tr>
 @@@ENDFORM@@@
+<tr><td colspan="2" bgcolor=@@@MENUBAR@@@>
+@@@VIEWINGSHAREDCALENDAR@@@
+</td></tr>
 <tr><td colspan="2">&nbsp;</td></tr>
 </table>
 
Index: cgi-bin/openwebmail/etc/templates/es/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/es/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/fi/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/fi/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/fr/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/fr/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/hu/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/hu/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/id/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/id/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/it/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/it/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ja_JP.Shift_JIS/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ja_JP.Shift_JIS/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ja_JP.eucJP/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ja_JP.eucJP/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/kr/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/kr/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/lt/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/lt/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/nl/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/nl/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/no/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/no/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/pl/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/pl/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/pt/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/pt/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/pt_BR/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/pt_BR/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ro/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ro/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/ru/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/ru/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/sk/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/sk/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/sr/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/sr/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/sv/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/sv/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/th/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/th/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/tr/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/tr/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/uk/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/uk/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/zh_CN.GB2312/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/zh_CN.GB2312/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: cgi-bin/openwebmail/etc/templates/zh_TW.Big5/dayview.template
===================================================================
RCS file: /var/cvs/moatware-openwebmail-2.10/cgi-bin/openwebmail/etc/templates/zh_TW.Big5/dayview.template,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
Index: data/openwebmail/images/iconsets/Default/sharedcal.gif
===================================================================
RCS file: data/openwebmail/images/iconsets/Default/sharedcal.gif
diff -N data/openwebmail/images/iconsets/Default/sharedcal.gif
Binary files /dev/null and /tmp/cvsmkvvH2 differ
