[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonrequestcourse.pm /lonnet/perl lonnet.pm
raeburn
raeburn@source.lon-capa.org
Sat, 24 Oct 2009 03:24:25 -0000
This is a MIME encoded message
--raeburn1256354665
Content-Type: text/plain
raeburn Sat Oct 24 03:24:25 2009 EDT
Modified files:
/loncom/interface lonrequestcourse.pm loncommon.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Facilitate re-use:
- move &check_can_request() from lonrequestcourse.pm to lonnet.pm
- move &course_types() from lonrequestcourse.pm to loncommon.pm
--raeburn1256354665
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091024032425.txt"
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.36 loncom/interface/lonrequestcourse.pm:1.37
--- loncom/interface/lonrequestcourse.pm:1.36 Sun Sep 13 03:13:55 2009
+++ loncom/interface/lonrequestcourse.pm Sat Oct 24 03:24:13 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.36 2009/09/13 03:13:55 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.37 2009/10/24 03:24:13 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 = ('official','unofficial','community');
- 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;
@@ -1751,7 +1704,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);
@@ -1873,7 +1826,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};
@@ -1959,7 +1912,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'};
@@ -2425,7 +2378,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'},
@@ -3090,7 +3043,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') {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.901 loncom/interface/loncommon.pm:1.902
--- loncom/interface/loncommon.pm:1.901 Thu Oct 22 13:41:41 2009
+++ loncom/interface/loncommon.pm Sat Oct 24 03:24:13 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.901 2009/10/22 13:41:41 bisitz Exp $
+# $Id: loncommon.pm,v 1.902 2009/10/24 03:24:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -10244,6 +10244,16 @@
return $names{$crstype};
}
+sub course_types {
+ my @types = ('official','unofficial','community');
+ my %typename = (
+ official => 'Official course',
+ unofficial => 'Unofficial course',
+ community => 'Community',
+ );
+ return (\@types,\%typename);
+}
+
sub icon {
my ($file)=@_;
my $curfext = lc((split(/\./,$file))[-1]);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1034 loncom/lonnet/perl/lonnet.pm:1.1035
--- loncom/lonnet/perl/lonnet.pm:1.1034 Fri Oct 23 00:20:40 2009
+++ loncom/lonnet/perl/lonnet.pm Sat Oct 24 03:24:25 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1034 2009/10/23 00:20:40 raeburn Exp $
+# $Id: lonnet.pm,v 1.1035 2009/10/24 03:24:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4841,6 +4841,38 @@
return $is_adv;
}
+sub check_can_request {
+ my ($dom,$can_request) = @_;
+ my $canreq = 0;
+ my ($types,$typename) = &Apache::loncommon::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 (&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;
+}
+
# ---------------------------------------------- Custom access rule evaluation
sub customaccess {
--raeburn1256354665--