Ajcody-Calendar-Issues

Revision as of 22:39, 27 August 2010 by Ajcody (talk | contribs) (→‎zmfixtz)


Calendar Issues

Calendar Issues Homepage

Please see Ajcody-Calendar-Issues

Specific Client Application Issues

Please see this page instead, this page will try to deal with server internals or "calendar" issues as within the ics itself.

Some Helpful Scripts To Run Against ICS File

parseics.pl

Will determine if an event has attendees but is missing an organizer. Normally, customers will delete the event and just recreate it with the information that is present from the output.

usage : ./parseics.pl filename.ics

#!/usr/bin/perl

$file = $ARGV[0];

if (!$file)
{
	print "Must specify filename.\n";
	exit;
}
elsif (!-e $file)
{
	print "File does not exist!\n";
	exit;
}
else
{
	#print "File exists. Continuing...\n";
	open(ICS, "<$file");
	@ics = <ICS>;
	$errors=0;
	$events=0;
	for ($i=0;$i<=$#ics;$i++)
	{
		if ($ics[$i] =~ "BEGIN:VEVENT")
		{
			$organizer=0;
			$attendee=0;
			$event="";
			#print "vevent start\n";
			while ($ics[$i+1] !~ "END:VEVENT")
			{
				$event .= $ics[$i];
				if ($ics[$i] =~ "ORGANIZER")
				{
					$organizer=1;
				}
				if ($ics[$i] =~ "ATTENDEE")
				{
					$attendee=1;
				}
				$i++;
			}
			#print "vevent end\n";
			if ($attendee && !$organizer)
			{
				$event .= $ics[$i];
				$event .= $ics[$i+1];
				print "Invalid event.  Attendee but no organizer present!\n";
				print $event;
				$errors++;
			}
			$events++;
		}
	}
	print "$errors error(s) out of a total of $events events present.\n";
}

ical-split.pl

Will break up an ics dump into one file per vevent.

#!/usr/bin/perl
# ical-parse.pl
# b 2008 03 12
#insist on an input file
if ( scalar(@ARGV) < 1 ) { print "Please specify a filename.\n" and usage() and exit; }
my $infile = shift @ARGV;
$numevents = qx/grep BEGIN:VEVENT $infile | wc -l/;
chomp $numevents;
$numevents =~ s/[^0-9]//g;

$TRUE=1;$FALSE=0;
$eventcount=0;
$summary='';
$inVEVENT = $FALSE; # track whether we are in the middle of a vevent
@currentVEVENT=(''); # hold the lines of the current vevent in this array (this will hog memory :()

open( INFILE, $infile ) or die "Could not open $infile for read: $!";
while ($line = <INFILE> ) {
	chomp $line;
	if ( $line =~ m/^BEGIN:VEVENT$/ ) { # case I.
		($inVEVENT) and die "Error: found new BEGIN:VEVENT without END:VEVENT\n";
		$inVEVENT = $TRUE;
		$eventcount++;
		@currentVEVENT=($line);
	}
	elsif ( $line =~ m/^END:VEVENT$/ ) { # case II.
		(!$inVEVENT) and die "Error: found END:VEVENT without BEGIN:VEVENT\n";
		push(@currentVEVENT, $line);
		$size = $#currentVEVENT;
		$zeros = zeropad($eventcount, $numevents); #eh ever heard of sprintf
		$outfile = "${zeros}${eventcount}-${summary}-${size}.ics";
		open( OUTFILE, ">>", $outfile ) or die "Could not open $outfile for write: $!";
		foreach $l (@currentVEVENT) {
			print OUTFILE "$l\n";
		}
		close OUTFILE;
		$inVEVENT=$FALSE; $summary=''; $size=0; @currentVEVENT=('');
	}
	elsif ( ($temp) = ( $line =~ m/^SUMMARY:(.*)$/ ) ) { # case III.A.
		$summary = $temp; #forget why temp
		$summary =~ s/[^-a-zA-Z0-9.]/_/g;
		push(@currentVEVENT, $line);
	}
	elsif ($inVEVENT) { # case III.
		push(@currentVEVENT, $line);
	}

}

$cases='
I. BEGIN:VEVENT
 A. (inVEVENT) and error: previous event not closed
 B. (else) set inVEVENT, start array, push line
II. END:VEVENT
 A. (inVEVENT) push line, write array, unset inVEVENT, unset summary, empty array
 B. (else) error: no event started
III. <event line>
 A (matches ^SUMMARY:) and set summary, push line
IV. <non event line>


';

exit;
sub usage {
    print "Usage: $0 <ical file>\nWrites a new file for each VEVENT\n";
}
sub zeropad() { #num-to-pad, total-with-max-digits, return 0...
	$num=shift;
	$total=shift;
	$curr=length($num);
	$max=length($total);
	$pad='';
	for ($x=0; $x < ($max-$curr); $x++) {
		$pad .= '0';
	}
	return "$pad";
}

zmcalchk

Help output from ZCS 5.0.23

$zmcalchk 
Usage: zmcalchk [-d] [-n <type>] <user> <start-time-spec> <end-time-spec>

   See the output of 'zmmailbox help appointment' for details on time-specs.

   -d        DEBUG: extremely verbose details
   -m        Max attendees to check, (default 50)
   -n        <none|user|organizer|attendee|all> whom to notify (default none)

zmfixtz

Other wiki reference: Time_Zone_Changes_for_2007_and_ZCS

Help output from ZCS 5.0.23

$ zmfixtz -h
usage: zmfixtz -a <account(s)> [options]
 -a,--account <arg>         account email addresses seperated by white
                            space or "all" for all accounts
    --after <arg>           fixup calendar items after this time; defaults
                            to beginning of 2007
    --country <arg>         two-letter country code if running
                            country-specific fixup
 -h,--help                  Displays this help message.
 -s,--server <arg>          Mail server hostname. Default is localhost.
    --sync                  run synchronously; default is asynchronous
 -Y,--authtokenfile <arg>   use auth token string(has to be in JSON
                            format) from command line
 -y,--authtoken <arg>       use auth token string(has to be in JSON
                            format) from command line
Jump to: navigation, search