[1954] in Moira
calendar.gen
daemon@ATHENA.MIT.EDU (Mark Silis)
Wed May 15 16:21:26 2002
Date: Wed, 15 May 2002 16:21:24 -0400
From: Mark Silis <mark@MIT.EDU>
To: moiradev@MIT.EDU
Message-ID: <20020515202124.GC2971@localhost.MIT.EDU>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
This is for the new calendaring service. Feedback please, thanks.
-- Mark
--- /dev/null Wed May 15 16:12:14 2002
+++ calendar.gen Wed May 15 09:18:24 2002
@@ -0,0 +1,48 @@
+#!/moira/bin/perl -Tw
+
+# $Id$
+
+# The following exit codes are defined and MUST BE CONSISTENT withh the
+# error codes the library uses:
+$MR_DBMS_ERR = 47836421;
+$MR_OCONFIG = 47836460;
+
+$outfile = '/moira/dcm/calendar.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+ || exit $MR_DBMS_ERR;
+
+$sth = $dbh->prepare("SELECT u.clearid, u.login, u.first, u.middle, u.last, " .
+ "u.office_phone, u.department FROM users u, list l, " .
+ "imembers i WHERE l.name = 'calendar-acl' " .
+ "AND l.list_id = i.list_id AND l.list_id = i.list_id " .
+ "AND i.member_type='USER' AND i.member_id = u.users_id")
+ || exit $MR_DBMS_ERR;
+$sth->execute || exit $MR_DBMS_ERR;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+while (($clearid, $login, $first, $middle, $last, $office_phone, $department) =
+ $sth->fetchrow_array) {
+ $row = "$clearid^UID=$login/S=$last/G=$first/I=$middle/OU1=$department/";
+ if (length($office_phone) == 5) {
+ $office_phone = "617-25" . substr($office_phone, 0, 1) . "-" .
+ substr($office_phone, 1, 4);
+ }
+ elsif (length($office_phone) == 7) {
+ $office_phone = "617-" . substr($office_phone, 0, 3) . "-" .
+ substr($office_phone, 3, 4);
+ }
+ elsif (length($office_phone) == 10) {
+ $office_phone = substr($office_phone, 0, 3) . "-" .
+ substr($office_phone, 3, 3) . "-" . substr($office_phone, 6, 4);
+ }
+ $row .= "PHONE=$office_phone/EMAIL=$login\@mit.edu\n";
+ $row =~ s/\0//g;
+ print OUT $row;
+}
+close OUT;
+exit 0;