[LON-CAPA-cvs] cvs: loncom(GCI_2) /interface lonrequestcourse.pm

raeburn raeburn@source.lon-capa.org
Sat, 24 Oct 2009 03:56:01 -0000


raeburn		Sat Oct 24 03:56:01 2009 EDT

  Modified files:              (Branch: GCI_2)
    /loncom/interface	lonrequestcourse.pm 
  Log:
  - Backport 1.37.
  
  
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.36.2.2 loncom/interface/lonrequestcourse.pm:1.36.2.3
--- loncom/interface/lonrequestcourse.pm:1.36.2.2	Fri Oct  2 16:15:49 2009
+++ loncom/interface/lonrequestcourse.pm	Sat Oct 24 03:56:01 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.36.2.2 2009/10/02 16:15:49 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.36.2.3 2009/10/24 03:56:01 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,10 +52,6 @@
 
 =item onload_action()
 
-=item check_can_request() 
-
-=item course_types()
-
 =item print_main_menu()
 
 =item request_administration()
@@ -277,7 +273,7 @@
     my $loaditems = &onload_action($action,$state);
 
     my %can_request;
-    my $canreq = &check_can_request($dom,\%can_request);
+    my $canreq = &Apache::lonnet::check_can_request($dom,\%can_request);
     if ($action eq 'new') {
         if ($canreq) {
             if ($state eq 'crstype') {
@@ -594,52 +590,9 @@
     return \%loaditems;
 }
 
-sub check_can_request {
-    my ($dom,$can_request) = @_;
-    my $canreq = 0;
-    my ($types,$typename) = &course_types();
-    my @options = ('approval','validate','autolimit');
-    my $optregex = join('|',@options);
-    if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
-        foreach my $type (@{$types}) {
-            if (&Apache::lonnet::usertools_access($env{'user.name'},
-                                                  $env{'user.domain'},
-                                                  $type,undef,'requestcourses')) {
-                $canreq ++;
-                if ($dom eq $env{'user.domain'}) {
-                    $can_request->{$type} = 1;
-                }
-            }
-            if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
-                my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
-                if (@curr > 0) {
-                    $canreq ++;
-                    unless ($dom eq $env{'user.domain'}) {
-                        if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {
-                            $can_request->{$type} = 1;
-                        }
-                    }
-                }
-            }
-        }
-    }
-    return $canreq;
-}
-
-sub course_types {
-    my @types = ('unofficial'); 
-    my %typename = (
-                         official   => 'Official course',
-                         unofficial => 'Unofficial course',
-                         community  => 'Community',
-                   );
-    return (\@types,\%typename);
-}
-
-
 sub print_main_menu {
     my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
-    my ($types,$typename) = &course_types();
+    my ($types,$typename) = &Apache::loncommon::course_types();
     my $onchange;
     unless ($env{'form.interface'} eq 'textual') {
         $onchange = 1;
@@ -1951,7 +1904,7 @@
     my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
                                            $env{'user.name'},'^status:'.$dom);
     my ($output,$formname,%queue_by_date);
-    my ($types,$typenames) = &course_types();
+    my ($types,$typenames) = &Apache::loncommon::course_types();
     foreach my $key (keys(%statusinfo)) {
         if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { 
             (undef,my($cdom,$cnum)) = split(':',$key);
@@ -2073,7 +2026,7 @@
             }
             $output = &mt('No further action will be taken');
         } elsif (ref($history{'details'}) eq 'HASH') {
-            my ($types,$typename) = &course_types();
+            my ($types,$typename) = &Apache::loncommon::course_types();
             my $showtype = $crstype;
             if (defined($typename->{$crstype})) {
                 $showtype = $typename->{$crstype}; 
@@ -2159,7 +2112,7 @@
 sub print_review {
     my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
         $disallowed,$disallowmsg) = @_;
-    my ($types,$typename) = &course_types();
+    my ($types,$typename) = &Apache::loncommon::course_types();
     my ($owner,$ownername,$owneremail);
     if ($uname eq '' || $udom eq '') {
         $uname = $env{'user.name'};
@@ -2625,7 +2578,7 @@
         }
     }
     if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
-        my ($types,$typename) = &course_types();
+        my ($types,$typename) = &Apache::loncommon::course_types();
         if (ref($types) eq 'ARRAY') {
             foreach my $type (@{$types}) {
                 if (&Apache::lonnet::usertools_access($env{'user.name'},
@@ -3290,7 +3243,7 @@
     my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
     my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
                                         'userroles',['active','future'],['cc'],[$dom]);
-    my ($types,$typename) = &course_types();
+    my ($types,$typename) = &Apache::loncommon::course_types();
     my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);
     my %count;
     if (ref($types) eq 'ARRAY') {