]>
Commit | Line | Data |
---|---|---|
1964ff67 | 1 | #!/moira/bin/perl -Tw |
2 | ||
3 | # $Id$ | |
4 | ||
5 | # The following exit codes are defined and MUST BE CONSISTENT with the | |
6 | # error codes the library uses: | |
7 | $MR_DBMS_ERR = 47836421; | |
1964ff67 | 8 | |
9 | $ENV{PATH} = "/bin:/usr/bin:/sbin:/usr/sbin"; | |
10 | ||
7801b5f4 | 11 | $outfile = '/moira/dcm/confluence.out'; |
1964ff67 | 12 | umask 022; |
13 | ||
14 | use DBI; | |
15 | ||
16 | $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") | |
17 | || exit $MR_DBMS_ERR; | |
18 | ||
7801b5f4 | 19 | open(OUT, ">$outfile"); |
1964ff67 | 20 | |
7801b5f4 | 21 | $sth = $dbh->prepare("SELECT l.name, l.gid FROM list l " . |
22 | "WHERE l.name LIKE 'confluence-%' AND l.active = 1 " . | |
23 | "AND l.grouplist = 1 ORDER by l.name") || exit $MR_DBMS_ERR; | |
1964ff67 | 24 | |
7801b5f4 | 25 | $sth->execute; |
1964ff67 | 26 | |
7801b5f4 | 27 | while (($name, $gid) = $sth->fetchrow_array) { |
28 | $sth2 = $dbh->prepare("SELECT UNIQUE i.member_type, i.member_id " . | |
29 | "FROM imembers i, list l " . | |
30 | "WHERE l.name = " . $dbh->quote($name) . | |
31 | "AND i.list_id = l.list_id " . | |
32 | "AND (i.member_type = 'USER' " . | |
33 | "OR i.member_type = 'STRING')") || | |
34 | exit $MR_DBMS_ERR; | |
35 | $sth2->execute; | |
36 | ||
37 | $row = "$name:$gid:"; | |
38 | $row =~ s/\0//g; | |
39 | print OUT $row; | |
40 | $maybecomma = ""; | |
41 | ||
42 | while (($type, $id) = $sth2->fetchrow_array) { | |
43 | if ($type eq "USER") { | |
44 | ($member) = $dbh->selectrow_array("SELECT login FROM users " . | |
45 | "WHERE users_id = " . | |
46 | $dbh->quote($id)) || | |
47 | exit $MR_DBMS_ERR; | |
48 | $member = $member . "\@mit.edu"; | |
49 | } | |
50 | elsif ($type eq "STRING") { | |
51 | ($member) = $dbh->selectrow_array("SELECT string " . | |
52 | "FROM strings " . | |
53 | "WHERE string_id = " . | |
54 | $dbh->quote($id)) || | |
55 | exit $MR_DBMS_ERR; | |
1964ff67 | 56 | } |
7801b5f4 | 57 | $row = "$maybecomma$member"; |
1964ff67 | 58 | $row =~ s/\0//g; |
59 | print OUT $row; | |
7801b5f4 | 60 | $maybecomma = ","; |
1964ff67 | 61 | } |
7801b5f4 | 62 | |
63 | $row = "\n"; | |
64 | $row =~ s/\0//g; | |
65 | print OUT $row; | |
1964ff67 | 66 | } |
67 | ||
7801b5f4 | 68 | close(OUT); |
1964ff67 | 69 | $dbh->disconnect; |
70 | ||
71 | exit 0; |