[system] / trunk / webwork / system / scripts / export_permission-database.pl Repository:
ViewVC logotype

Annotation of /trunk/webwork/system/scripts/export_permission-database.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1533 - (view) (download) (as text)

1 : sh002i 1533 #!/usr/bin/env perl
2 : sam 2
3 :    
4 : sam 70 BEGIN {
5 :     my $useLibDir = '.';
6 :     if ($0 =~ m|^(/.*)/|) { $useLibDir = $1; }
7 :     elsif ($0 =~ m|^(\..*)/|) { $useLibDir = $1; }
8 :     elsif ($0 =~ m|^(.+)/|) { $useLibDir = "./$1"; }
9 :     unshift @INC, $useLibDir;
10 :     }
11 : sam 2
12 : sam 70 use webworkInit; # WeBWorKInitLine
13 :    
14 : sam 2 use Global;
15 :     use Auth;
16 :     use strict;
17 :    
18 :     if (@ARGV != 2)
19 :     {
20 :     print "\nSyntax is export_permission-database.pl courseID outputTextFile\n";
21 :     print " (e.g. export_permission-database.pl demoCourse textDatabase)\n\n";
22 :     exit(0);
23 :     }
24 :    
25 :     my $course = $ARGV[0];
26 :     my $outFileName = $ARGV[1];
27 :    
28 :     # establish environment for this script
29 :    
30 :     &Global::getCourseEnvironment($course);
31 :    
32 :     # File names
33 :    
34 :     my $perm_file = &Global::getCoursePermissionsFile($course);
35 :    
36 :     my %perm_hash;
37 :     my $perm_obj;
38 :    
39 :     &Global::tie_hash('PERM_FILE',\$perm_obj,\%perm_hash, $perm_file,'R',$Global::standard_tie_permission);
40 :    
41 :     my ($key,$item);
42 :     my @keys = sort keys %perm_hash;
43 :    
44 :     open(OUTFILE,">$outFileName") or wwerror("$0","can't open $outFileName for writing");
45 :    
46 :     foreach $key (@keys) {
47 :     print OUTFILE "[$key]\n";
48 :     print OUTFILE "\t$perm_hash{$key}\n";
49 :     }
50 :    
51 :     close(OUTFILE);
52 : sam 70 &Global::untie_hash('PERM_FILE',\$perm_obj,\%perm_hash, $perm_file);

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9