#!/usr/bin/perl
use Time::Local;
use IO::Socket;
require "plans_config.pl";
require "plans_lib.pl";


print <<p1;
  This utility adjusts passwords for Plans events.
p1

&load_calendars("all");

foreach $cal_id (sort {$a cmp $b} keys %calendars)
{
  next if ($cal_id =~ /^r/);
  next if ($cal_id eq "");
  next if (lc $calendars{$cal_id}{type} eq "ical");
  
  print "Please type the password for calendar $cal_id: '$calendars{$cal_id}{title}' (hit enter to skip)\n";
  
  my $new_password = <STDIN>;
  chomp $new_password;
  
  next if ($new_password !~ /\w/);
  
  $calendars{$cal_id}{password} = crypt($new_password, $options{salt});
  &update_calendar($cal_id);
  print "updated!\n";
}


# done already?!
