[LON-CAPA-cvs] cvs: loncom(GCI_3) /auth lonroles.pm
raeburn
raeburn@source.lon-capa.org
Tue, 15 Dec 2009 05:04:18 -0000
raeburn Tue Dec 15 05:04:18 2009 EDT
Modified files: (Branch: GCI_3)
/loncom/auth lonroles.pm
Log:
- Customization for GCI_3.
- For GCI users:
- Replace standard roles screen with custom main menu.
- First item displayed for CCs after selecting Concept Test is Course Contents instead of What's New?
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.240.2.2 loncom/auth/lonroles.pm:1.240.2.3
--- loncom/auth/lonroles.pm:1.240.2.2 Mon Dec 7 04:38:22 2009
+++ loncom/auth/lonroles.pm Tue Dec 15 05:04:17 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.240.2.2 2009/12/07 04:38:22 raeburn Exp $
+# $Id: lonroles.pm,v 1.240.2.3 2009/12/15 05:04:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,7 @@
use Apache::lonlocal;
use Apache::lonpageflip();
use Apache::lonnavdisplay();
+use Apache::lonmainmenu();
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities;
@@ -224,6 +225,7 @@
my %dcroles = ();
my $numdc = &check_fordc(\%dcroles,$then);
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+ my $custommenu = &Apache::loncommon::needs_gci_custom();
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
@@ -318,10 +320,9 @@
}
}
}
- if (($env{'form.cm'}) && ($env{'form.orgurl'})) {
+ if (($env{'form.cm'}) && ($env{'form.orgurl'})) {
$r->internal_redirect($env{'form.orgurl'});
}
-
foreach $envkey (keys %env) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -494,7 +495,7 @@
$courseid = substr($courseid, 1);
}
$courseid =~ s/\//_/;
- if ((($role eq 'cc') || ($role eq 'co'))
+ if (($cdom ne 'gcitest') && (($role eq 'cc') || ($role eq 'co'))
&& ($env{'course.' . $courseid .'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
@@ -518,7 +519,7 @@
.$env{'request.course.sec'})
) {
my $startpage = &courseloadpage($courseid);
- unless ($startpage eq 'firstres') {
+ unless (($startpage eq 'firstres') || ($cdom eq 'gcitest')) {
$msg = &mt('Entering [_1] ...',
$env{'course.'.$courseid.'.description'});
&redirect_user($r,&mt('New in course'),
@@ -533,6 +534,9 @@
# Guess not ...
$furl=&Apache::lonpageflip::first_accessible_resource();
}
+ if (($cdom eq 'gcitest') && ($custommenu)) {
+ $furl = '/adm/navmaps';
+ }
$msg = &mt('Entering [_1] ...',
$env{'course.'.$courseid.'.description'});
&redirect_user($r,&mt('Entering [_1]',
@@ -575,7 +579,6 @@
}
}
-
# =============================================================== No Roles Init
&Apache::loncommon::content_type($r,'text/html');
@@ -583,23 +586,34 @@
$r->send_http_header;
return OK if $r->header_only;
- my $crumbtext = 'User Roles';
- my $pagetitle = 'My Roles';
- my $recent = &mt('Recent Roles');
- my $show_course=&Apache::loncommon::show_course();
- if ($show_course) {
- $crumbtext = 'Courses';
- $pagetitle = 'My Courses';
- $recent = &mt('Recent Courses');
- }
- my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
- my $swinfo=&Apache::lonmenu::rawconfig();
- my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
- my $standby=&mt('Role selected. Please stand by.');
- $standby=~s/\n/\\n/g;
+ my ($crumbtext,$pagetitle,$recent,$show_course);
my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
-
- $r->print(<<ENDHEADER);
+ if ($custommenu) {
+ my $start_page = &Apache::loncommon::start_page('Main Menu',undef,
+ {'bread_crumbs' => 1});
+ $r->print(<<"ENDCUSTOM");
+$start_page
+<br />
+<noscript>
+$noscript
+</noscript>
+ENDCUSTOM
+ } else {
+ $crumbtext = 'User Roles';
+ $pagetitle = 'My Roles';
+ $recent = &mt('Recent Roles');
+ $show_course=&Apache::loncommon::show_course();
+ if ($show_course) {
+ $crumbtext = 'Courses';
+ $pagetitle = 'My Courses';
+ $recent = &mt('Recent Courses');
+ }
+ my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
+ my $swinfo=&Apache::lonmenu::rawconfig();
+ my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
+ my $standby=&mt('Role selected. Please stand by.');
+ $standby=~s/\n/\\n/g;
+ $r->print(<<ENDHEADER);
$start_page
<br />
<noscript>
@@ -626,6 +640,7 @@
// ]]>
</script>
ENDHEADER
+ }
# ------------------------------------------ Get Error Message from Environment
@@ -693,10 +708,12 @@
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
}
- $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
- $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
- $r->print('<input type="hidden" name="selectrole" value="1" />');
- $r->print('<input type="hidden" name="newrole" value="" />');
+ unless ($custommenu) {
+ $r->print('<form method="post" name="rolechoice" action="'.(($fn)?$fn:$r->uri).'">');
+ $r->print('<input type="hidden" name="orgurl" value="'.$fn.'" />');
+ $r->print('<input type="hidden" name="selectrole" value="1" />');
+ $r->print('<input type="hidden" name="newrole" value="" />');
+ }
}
my (%roletext,%sortrole,%roleclass,%futureroles,%timezones);
@@ -706,6 +723,32 @@
$refresh = $now;
&Apache::lonnet::appenv({'user.refresh.time' => $refresh});
+ if ($custommenu) {
+ my %courses = &Apache::loncommon::existing_gcitest_courses();
+ $env{'browser.interface'}='faketextual';
+ $env{'environment.remote'}='off';
+ my $numcourses = keys(%courses);
+ my $switcher;
+ if ($numcourses > 0) {
+ $switcher = &Apache::lonmainmenu::gcitest_switcher(%courses);
+ my $current;
+ if ($env{'request.course.id'}) {
+ $current = 'cc./'.$env{'course.'.$env{'request.course.id'}.'.domain'}.
+ '/'.$env{'course.'.$env{'request.course.id'}.'.num'};
+ }
+ my $switcher_js = &Apache::lonmainmenu::gcitest_switcher_js($current,$numcourses);
+ $r->print(<<"ENDSCRIPT");
+<script type="text/javascript">
+// <![CDATA[
+$switcher_js
+// ]]>
+</script>
+ENDSCRIPT
+ }
+ $r->print(&Apache::lonmenu::inlinemenu('gcicustom',$switcher).
+ &Apache::loncommon::end_page());
+ return OK;
+ }
if ($env{'user.adv'}) {
$r->print('<p><label><input type="checkbox" name="showall"');
if ($env{'form.showall'}) { $r->print(' checked="checked" '); }