Bring in PrivacyFilterICalFile from SFLC code.
This commit is contained in:
parent
1ea78e94b0
commit
6382f36eba
1 changed files with 55 additions and 2 deletions
|
@ -22,8 +22,9 @@
|
||||||
# along with this program in a file in the toplevel directory called
|
# along with this program in a file in the toplevel directory called
|
||||||
# "GPLv3". If not, see <http://www.gnu.org/licenses/>.
|
# "GPLv3". If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# The functions PrivatizeMergeAndTZIcalFile, BuildTZList, and
|
# The functions PrivatizeMergeAndTZIcalFile, BuildTZList,
|
||||||
# FilterEmacsToICal material copyrighted and licensed as below:
|
# PrivacyFilterICalFile, and FilterEmacsToICal material copyrighted and
|
||||||
|
# licensed as below:
|
||||||
|
|
||||||
# Copyright © 2006 Software Freedom Law Center, Inc.
|
# Copyright © 2006 Software Freedom Law Center, Inc.
|
||||||
#
|
#
|
||||||
|
@ -150,6 +151,58 @@ ELISP_END
|
||||||
DieLog("Unable to remove temporary files")
|
DieLog("Unable to remove temporary files")
|
||||||
unless unlink($icsPublicFile, $icsWillBePrivatizedFile, $icsFullFile) == 3;
|
unless unlink($icsPublicFile, $icsWillBePrivatizedFile, $icsFullFile) == 3;
|
||||||
}
|
}
|
||||||
|
###############################################################################
|
||||||
|
sub PrivacyFilterICalFile ($$) {
|
||||||
|
my($inputFile, $outputFile) = @_;
|
||||||
|
|
||||||
|
my $oldCalendar = Data::ICal->new(filename => $inputFile);
|
||||||
|
my $newCalendar = Data::ICal->new(data => <<END_ICAL
|
||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
|
||||||
|
END:VCALENDAR
|
||||||
|
END_ICAL
|
||||||
|
);
|
||||||
|
my $entries = (defined $oldCalendar) ? $oldCalendar->entries : [];
|
||||||
|
my $x =0;
|
||||||
|
foreach my $entry (@{$entries}) {
|
||||||
|
my @newSubEntries;
|
||||||
|
foreach my $subEntry (@{$entry->{entries}}) {
|
||||||
|
my $refVal = ref $subEntry;
|
||||||
|
if (defined $refVal and $refVal =~ /Alarm/i) {
|
||||||
|
# Don't put it in the list in the public version if is an alarm
|
||||||
|
} else {
|
||||||
|
push(@newSubEntries, $subEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$entry->{entries} = \@newSubEntries;
|
||||||
|
|
||||||
|
my $classes = $entry->property('class');
|
||||||
|
my $class;
|
||||||
|
foreach my $classProp (@{$classes}) {
|
||||||
|
$class = $classProp->value;
|
||||||
|
last if defined $class and
|
||||||
|
$class =~ /^\s*(?:PUBLIC|PRIVATE|CONFIDENTIAL)\s*/i;
|
||||||
|
}
|
||||||
|
if (defined $class and $class =~ /CONFIDENTIAL/i) {
|
||||||
|
foreach my $prop (qw/location summary description/) {
|
||||||
|
my $propList = $entry->property($prop);
|
||||||
|
$entry->add_property($prop => "Private")
|
||||||
|
if (defined $propList and @{$propList} > 0);
|
||||||
|
}
|
||||||
|
} elsif (defined $class and $class =~ /PRIVATE/i){
|
||||||
|
# do not put this event in the output at all
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$newCalendar->add_entry($entry);
|
||||||
|
}
|
||||||
|
open(SCRUBBED_CAL, ">$outputFile") or
|
||||||
|
DieLog("Unable to overwrite $outputFile: $!", $LOCK_CLEANUP_CODE);
|
||||||
|
print SCRUBBED_CAL $newCalendar->as_string;
|
||||||
|
close SCRUBBED_CAL;
|
||||||
|
DieLog("Error when writing $outputFile: $!", $LOCK_CLEANUP_CODE)
|
||||||
|
unless $? == 0;
|
||||||
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
sub PrivatizeMergeAndTZIcalFile ($$$$$$) {
|
sub PrivatizeMergeAndTZIcalFile ($$$$$$) {
|
||||||
my($icsPrivate, $icsPublic, $icsFull, $tzList, $user, $errorUser) = @_;
|
my($icsPrivate, $icsPublic, $icsFull, $tzList, $user, $errorUser) = @_;
|
||||||
|
|
Loading…
Add table
Reference in a new issue