--- loncom/interface/loncommon.pm 2009/08/06 04:05:38 1.880
+++ loncom/interface/loncommon.pm 2009/12/07 20:04:18 1.925.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.880 2009/08/06 04:05:38 raeburn Exp $
+# $Id: loncommon.pm,v 1.925.2.2 2009/12/07 20:04:18 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -482,8 +482,11 @@ ENDAUTHORBRW
}
sub coursebrowser_javascript {
- my ($domainfilter,$sec_element,$formname)=@_;
- my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Community - for which you wish to add/modify a user role');
+ my ($domainfilter,$sec_element,$formname,$role_element,$crstype) = @_;
+ my $wintitle = &mt('Course Browser');
+ if ($crstype ne '') {
+ $wintitle = &mt($crstype);
+ }
my $id_functions = &javascript_index_functions();
my $output = '
END_MYBLOCK
+
+ $output = Apache::lonhtmlcommon::scripttag($output);
+
my $popupUrl = "/adm/blockingstatus/$querystring";
+ my $text = mt('Communication Blocked');
+
$output .= <<"END_BLOCK";
END_BLOCK
@@ -4032,7 +4116,7 @@ sub determinedomain {
my $domain=shift;
if (! $domain) {
# Determine domain if we have not been given one
- $domain = $Apache::lonnet::perlvar{'lonDefDomain'};
+ $domain = &Apache::lonnet::default_login_domain();
if ($env{'user.domain'}) { $domain=$env{'user.domain'}; }
if ($env{'request.role.domain'}) {
$domain=$env{'request.role.domain'};
@@ -4283,18 +4367,30 @@ sub CSTR_pageheader {
} else {
$lastitem = $thisdisfn;
}
- return
+
+ my $output =
'
'
.&Apache::loncommon::help_open_menu('','',3,'Authoring') #FIXME: Broken? Where is it?
.''.&mt('Construction Space:').' '
.''
.&Apache::lonmenu::constspaceform()
.'
';
+
+ return $output;
}
###############################################
@@ -4382,6 +4478,9 @@ sub bodytag {
if ($env{'request.role'} !~ /^cr/) {
$role = &Apache::lonnet::plaintext($role,&course_type());
}
+ if ($env{'request.course.sec'}) {
+ $role .= (' 'x2).'- '.&mt('section:').' '.$env{'request.course.sec'};
+ }
$realm = $env{'course.'.$env{'request.course.id'}.'.description'};
} else {
$role = &Apache::lonnet::plaintext($role);
@@ -4416,40 +4515,73 @@ sub bodytag {
$env{'course.'.$env{'request.course.id'}.
'.domain'}.'/'})) {
my $cid = $env{'request.course.id'};
- $dc_info.= $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
+ $dc_info = $cid.' '.$env{'course.'.$cid.'.internal.coursecode'};
$dc_info =~ s/\s+$//;
- $dc_info = '('.$dc_info.')';
}
- $role = "($role)" if $role;
+ $role = '('.$role.')' if $role;
&get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
if ($env{'environment.remote'} eq 'off') {
# No Remote
- if ($env{'request.state'} eq 'construct') {
- $forcereg=1;
- }
+ if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') {
+ return $bodytag;
+ }
+ my $custommenu = &needs_gci_custom();
-# if ($env{'request.state'} eq 'construct') {
-# $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
-# }
+ if ($env{'request.state'} eq 'construct') { $forcereg=1; }
- my $titletable = '
'
- ."
$titleinfo $dc_info
"
- .'
';
+ # if ($env{'request.state'} eq 'construct') {
+ # $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
+ # }
- if ($no_nav_bar) {
- $bodytag .= $titletable;
- } else {
- $bodytag .= qq|
';
$itemcount ++;
}
- $output .= &Apache::loncommon::end_data_table();
+ if ($itemcount) {
+ $output = &Apache::loncommon::start_data_table().
+ $table.
+ &Apache::loncommon::end_data_table();
+ }
}
}
}
@@ -9852,12 +10028,26 @@ sub check_clone {
my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
my $clonemsg;
my $can_clone = 0;
-
+ my $lctype = lc($args->{'type'});
+ if ($lctype ne 'community') {
+ $lctype = 'course';
+ }
if ($clonehome eq 'no_host') {
- $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ if ($args->{'type'} eq 'Community') {
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a non-existent community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ } else {
+ $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ }
} else {
my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
- if ($env{'request.role.domain'} eq $args->{'clonedomain'}) {
+ if ($args->{'type'} eq 'Community') {
+ if ($clonedesc{'type'} ne 'Community') {
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('A new community could not be cloned from the specified original - [_1] - because it is a course not a community.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});
+ return ($can_clone, $clonemsg, $cloneid, $clonehome);
+ }
+ }
+ if (($env{'request.role.domain'} eq $args->{'clonedomain'}) &&
+ (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
$can_clone = 1;
} else {
my %clonehash = &Apache::lonnet::get('environment',['cloners'],
@@ -9868,15 +10058,23 @@ sub check_clone {
} elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) {
$can_clone = 1;
} else {
+ my $ccrole = 'cc';
+ if ($args->{'type'} eq 'Community') {
+ $ccrole = 'co';
+ }
my %roleshash =
&Apache::lonnet::get_my_roles($args->{'ccuname'},
$args->{'ccdomain'},
- 'userroles',['active'],['cc'],
+ 'userroles',['active'],[$ccrole],
[$args->{'clonedomain'}]);
- if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':cc'}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
+ if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':'.$ccrole}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
$can_clone = 1;
} else {
- $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
+ if ($args->{'type'} eq 'Community') {
+ $clonemsg = &mt('No new community created.').$linefeed.&mt('The new community could not be cloned from the existing community because the new community owner ([_1]) does not have cloning rights in the existing community ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
+ } else {
+ $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
+ }
}
}
}
@@ -9885,7 +10083,7 @@ sub check_clone {
}
sub construct_course {
- my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;
+ my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context,$cnum,$category) = @_;
my $outcome;
my $linefeed = ' '."\n";
if ($context eq 'auto') {
@@ -9923,7 +10121,8 @@ sub construct_course {
$args->{'crscode'},
$args->{'ccuname'}.':'.
$args->{'ccdomain'},
- $args->{'crstype'});
+ $args->{'crstype'},
+ $cnum,$context,$category);
# Note: The testing routines depend on this being output; see
# Utils::Course. This needs to at least be output as a comment
@@ -10237,6 +10436,16 @@ sub group_term {
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]);
@@ -10507,6 +10716,86 @@ sub clean_symb {
return ($symb,$enc);
}
+sub needs_gci_custom {
+ my $custommenu;
+ my $numdc = &check_for_gci_dc();
+ unless ($numdc) {
+ my $then=$env{'user.login.time'};
+ my $now = time;
+ my %cnums = (
+ review => '9615072b469884921gcil1',
+ submit => '1H96711d710194bfegcil1',
+ );
+ if ($env{'user.role.st./gci/'.$cnums{'review'}}) {
+ my ($start,$end) =
+ split('.',$env{'user.role.st./gci/'.$cnums{'review'}});
+ if (((!$start) || ($start && $start <= $now)) &&
+ ((!$end) || ($end > $now))) {
+ $custommenu = 1;
+ if ($env{'user.role.cc./gci/'.$cnums{'review'}}) {
+ my ($ccstart,$ccend) =
+ split('.',$env{'user.role.cc./gci/'.$cnums{'review'}});
+ if (((!$start) || ($start && $start <= $now)) &&
+ ((!$end) || ($end > $now))) {
+ $custommenu = '';
+ }
+ }
+ }
+ }
+ }
+ return $custommenu;
+}
+
+sub check_for_gci_dc {
+ my $then=$env{'user.login.time'};
+ my $numdc = 0;
+ foreach my $dom ('gci','gcitest') {
+ if ($env{'user.role.dc./'.$dom.'/'}) {
+ my $livedc = 1;
+ my ($tstart,$tend)=split(/\./,$env{'user.role.dc./'.$dom.'/'});
+ if ($tstart && $tstart>$then) { $livedc = 0; }
+ if ($tend && $tend <$then) { $livedc = 0; }
+ if ($livedc) {
+ $numdc++;
+ }
+ }
+ }
+ return $numdc;
+}
+
+sub existing_gcitest_courses {
+ my %courses;
+ my $cdom = 'gcitest';
+ my $role = 'cc';
+ my $now = time;
+ foreach my $envkey (keys(%env)) {
+ my $cnum;
+ if ($envkey =~ m{^user\.role\.\Q$role\E\./\Q$cdom\E/($match_courseid)$}) {
+ $cnum = $1;
+ } else {
+ next;
+ }
+ my ($tstart,$tend) = split(':',$env{$envkey});
+ if (((!$tstart) || ($tstart < $now)) && ((!$tend) || ($tend > $now))) {
+ my %coursehash = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);
+ $courses{$cdom.'_'.$cnum}{'description'} = $coursehash{'description'};
+ $courses{$cdom.'_'.$cnum}{'owner'} = $coursehash{'internal.courseowner'};
+ if (defined($coursehash{'default_enrollment_start_date'}) ) {
+ $courses{$cdom.'_'.$cnum}{'startaccess'} =
+ &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_start_date'});
+ }
+ if (defined($coursehash{'default_enrollment_end_date'}) ) {
+ $courses{$cdom.'_'.$cnum}{'endaccess'} =
+ &Apache::lonlocal::locallocaltime($coursehash{'default_enrollment_end_date'});
+ if ($coursehash{'default_enrollment_end_date'} == 0) {
+ $courses{$cdom.'_'.$cnum}{'endaccess'} = &mt('No ending date');
+ }
+ }
+ }
+ }
+ return %courses;
+}
+
=pod
=back