version 1.225, 2007/08/30 22:35:41
|
version 1.236, 2008/05/30 20:24:25
|
Line 54 my @inlineremote;
|
Line 54 my @inlineremote;
|
|
|
|
|
# ================================================================ Little texts |
# ================================================================ Little texts |
|
sub show_course { |
|
my $course = !$env{'user.adv'}; |
|
if (!$env{'user.adv'}) { |
|
foreach my $env (keys(%env)) { |
|
next if ($env !~ m/^user\.priv\./); |
|
if ($env !~ m/^user\.priv\.(?:st|cm)/) { |
|
$course = 0; |
|
last; |
|
} |
|
} |
|
} |
|
return $course; |
|
} |
|
|
sub initlittle { |
sub initlittle { |
return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', |
return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', |
'nav' => 'Navigate Contents', |
'nav' => 'Navigate Contents', |
'main' => 'Main Menu', |
'main' => 'Main Menu', |
'roles' => ($env{'user.adv'}? |
'roles' => (&show_course()? |
'Roles':'Courses'), |
'Courses':'Roles'), |
|
'other' => 'Other Roles', |
'docs' => 'Edit Course', |
'docs' => 'Edit Course', |
'exit' => 'Exit', |
'exit' => 'Exit', |
'login' => 'Log In', |
'login' => 'Log In', |
Line 88 sub menubuttons {
|
Line 102 sub menubuttons {
|
my $reloadlink=''; |
my $reloadlink=''; |
my $docs=''; |
my $docs=''; |
my $groups=''; |
my $groups=''; |
|
my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>'; |
|
my $role_selector; |
my $showgroups=0; |
my $showgroups=0; |
|
my ($cnum,$cdom); |
my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); |
my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); |
my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); |
my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); |
|
|
Line 104 sub menubuttons {
|
Line 121 sub menubuttons {
|
} |
} |
} |
} |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my %coursegroups; |
my %coursegroups; |
my $viewgrps_permission = |
my $viewgrps_permission = |
&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
&Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); |
if (!$viewgrps_permission) { |
if (!$viewgrps_permission) { |
%coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); |
%coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum); |
} |
} |
if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) { |
if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) { |
$showgroups = 1; |
$showgroups = 1; |
} |
} |
|
$role_selector = &roles_selector($cdom,$cnum); |
|
if ($role_selector) { |
|
$roles = '<span class="LC_nobreak">'.$role_selector.' <a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>'; |
|
} |
} |
} |
|
|
if ($env{'browser.interface'} eq 'textual') { |
if ($env{'browser.interface'} eq 'textual') { |
Line 121 sub menubuttons {
|
Line 144 sub menubuttons {
|
$navmaps=(<<ENDNAV); |
$navmaps=(<<ENDNAV); |
<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a> |
<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a> |
ENDNAV |
ENDNAV |
if (($env{'request.noversionuri'}=~/^\/adm\//) && |
if (&show_return_link()) { |
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && |
|
($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { |
|
my $escreload=&escape('return:'); |
my $escreload=&escape('return:'); |
$reloadlink=(<<ENDRELOAD); |
$reloadlink=(<<ENDRELOAD); |
<a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a> |
<a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a> |
Line 149 $utility
|
Line 170 $utility
|
</script> |
</script> |
<div id="LC_top_nav"> |
<div id="LC_top_nav"> |
<a href="/adm/menu" target="_top">$lt{'main'}</a> |
<a href="/adm/menu" target="_top">$lt{'main'}</a> |
$reloadlink $navmaps $docs $groups |
$reloadlink $navmaps $docs $groups $roles |
<a href="/adm/roles" target="_top">$lt{'roles'}</a> |
|
<a href="/adm/logout" target="_top">$lt{'exit'}</a> |
<a href="/adm/logout" target="_top">$lt{'exit'}</a> |
</div> |
</div> |
<br /> |
<br /> |
Line 186 ENDMAINMENU
|
Line 206 ENDMAINMENU
|
</font> |
</font> |
ENDINLINEMENU |
ENDINLINEMENU |
} |
} |
|
$roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>'; |
# Do we have a NAV link? |
# Do we have a NAV link? |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. |
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. |
Line 196 ENDINLINEMENU
|
Line 217 ENDINLINEMENU
|
$navmaps=(<<ENDNAV); |
$navmaps=(<<ENDNAV); |
<td><a href="$link" target="_top">$lt{'nav'}</a></td> |
<td><a href="$link" target="_top">$lt{'nav'}</a></td> |
ENDNAV |
ENDNAV |
my $is_group = (&Apache::loncommon::course_type() eq 'Group'); |
my $is_group = (&Apache::loncommon::course_type() eq 'Group'); |
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { |
my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; |
my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; |
$docs=(<<ENDDOCS); |
$docs=(<<ENDDOCS); |
Line 208 ENDDOCS
|
Line 229 ENDDOCS
|
<td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td> |
<td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td> |
ENDGROUPS |
ENDGROUPS |
} |
} |
if ( |
if (&show_return_link()) { |
($env{'request.noversionuri'}=~m[^/(res|public)/] && |
|
$env{'request.symb'} eq '') |
|
|| |
|
(($env{'request.noversionuri'}=~/^\/adm\//) && |
|
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && |
|
($env{'request.noversionuri'}!~ |
|
m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) |
|
) |
|
) { |
|
my $escreload=&escape('return:'); |
my $escreload=&escape('return:'); |
$reloadlink=(<<ENDRELOAD); |
$reloadlink=(<<ENDRELOAD); |
<td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td> |
<td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td> |
ENDRELOAD |
ENDRELOAD |
} |
} |
|
if ($role_selector) { |
|
$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>'; |
|
} |
} |
} |
if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { |
if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { |
my $escreload=&escape('return:'); |
my $escreload=&escape('return:'); |
Line 258 $navmaps
|
Line 273 $navmaps
|
$docs |
$docs |
$groups |
$groups |
$remote |
$remote |
<td><a href="/adm/roles" target="_top">$lt{'roles'}</a></td> |
$roles |
<td class="LC_top_nav_help">$helplink</td> |
<td class="LC_top_nav_help">$helplink</td> |
<td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td> |
<td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td> |
</tr> |
</tr> |
Line 274 ENDINLINEMENU
|
Line 289 ENDINLINEMENU
|
} |
} |
} |
} |
|
|
|
sub show_return_link { |
|
return (($env{'request.noversionuri'}=~m{^/(res|public)/} && |
|
$env{'request.symb'} eq '') |
|
|| |
|
($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl}) |
|
|| |
|
(($env{'request.noversionuri'}=~/^\/adm\//) && |
|
($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && |
|
($env{'request.noversionuri'}!~ |
|
m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) |
|
)); |
|
} |
|
|
# ====================================== This gets called in the header section |
# ====================================== This gets called in the header section |
|
|
sub registerurl { |
sub registerurl { |
Line 334 sub innerregister {
|
Line 362 sub innerregister {
|
} else { |
} else { |
$newmail= 'swmenu.setstatus("you have","messages");'; |
$newmail= 'swmenu.setstatus("you have","messages");'; |
} |
} |
} elsif (($textual) |
} |
|
if (($textual) |
&& ($env{'request.symb'}) |
&& ($env{'request.symb'}) |
&& ($env{'request.course.id'})) { |
&& ($env{'request.course.id'})) { |
$newmail.= '<td class="LC_current_location">'; |
$newmail.= '<td class="LC_current_location">'; |
my ($mapurl,$rid,$resurl)= |
my ($mapurl,$rid,$resurl)= |
&Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); |
&Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); |
$newmail.=$env{'course.'.$env{'request.course.id'}.'.description'}; |
my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'}; |
|
$newmail.=$coursetitle; |
my $maptitle=&Apache::lonnet::gettitle($mapurl); |
my $maptitle=&Apache::lonnet::gettitle($mapurl); |
my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread()); |
my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread()); |
if ($maptitle && $maptitle ne 'default.sequence') { |
if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) { |
$newmail.=', '.$maptitle; |
$newmail.=', '.$maptitle; |
} |
} |
if ($restitle) { |
if ($restitle) { |
Line 398 sub innerregister {
|
Line 428 sub innerregister {
|
### |
### |
my $editbutton = ''; |
my $editbutton = ''; |
if ($env{'user.author'}) { |
if ($env{'user.author'}) { |
if ($env{'request.role'}=~/^(ca|au)/) { |
if ($env{'request.role'}=~/^(aa|ca|au)/) { |
# Set defaults for authors |
# Set defaults for authors |
my ($top,$bottom) = ('con-','struct'); |
my ($top,$bottom) = ('con-','struct'); |
my $action = "go('/priv/".$env{'user.name'}."');"; |
my $action = "go('/priv/".$env{'user.name'}."');"; |
my $cadom = $env{'request.role.domain'}; |
my $cadom = $env{'request.role.domain'}; |
my $caname = $env{'user.name'}; |
my $caname = $env{'user.name'}; |
my $desc = "Enter my resource construction space"; |
my $desc = "Enter my construction space"; |
# Set defaults for co-authors |
# Set defaults for co-authors |
if ($env{'request.role'} =~ /^ca/) { |
if ($env{'request.role'} =~ /^ca/) { |
($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); |
($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); |
($top,$bottom) = ('co con-','struct'); |
($top,$bottom) = ('co con-','struct'); |
$action = "go('/priv/".$caname."');"; |
$action = "go('/priv/".$caname."');"; |
$desc = "Enter construction space as co-author"; |
$desc = "Enter construction space as co-author"; |
|
} elsif ($env{'request.role'} =~ /^aa/) { |
|
($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); |
|
($top,$bottom) = ('co con-','struct'); |
|
$action = "go('/priv/".$caname."');"; |
|
$desc = "Enter construction space as assistant co-author"; |
} |
} |
# Check that we are on the correct machine |
# Check that we are on the correct machine |
my $home = &Apache::lonnet::homeserver($caname,$cadom); |
my $home = &Apache::lonnet::homeserver($caname,$cadom); |
Line 573 ENDLINE
|
Line 608 ENDLINE
|
$timesync |
$timesync |
$tablestart |
$tablestart |
$inlinebuttons |
$inlinebuttons |
$newmail |
|
$tableend |
$tableend |
|
$newmail |
<script type="text/javascript"> |
<script type="text/javascript"> |
// END LON-CAPA Internal |
// END LON-CAPA Internal |
</script> |
</script> |
Line 793 sub load_remote_msg {
|
Line 828 sub load_remote_msg {
|
<p>$link</p> |
<p>$link</p> |
ENDREMOTEFORM |
ENDREMOTEFORM |
} |
} |
|
|
|
sub get_menu_name { |
|
my $hostid = $Apache::lonnet::perlvar{'lonHostID'}; |
|
$hostid =~ s/\W//g; |
|
return 'LCmenu'.$hostid; |
|
} |
|
|
# ================================================================= Reopen menu |
# ================================================================= Reopen menu |
|
|
sub reopenmenu { |
sub reopenmenu { |
if (($env{'browser.interface'} eq 'textual') || |
if (($env{'browser.interface'} eq 'textual') || |
($env{'environment.remote'} eq 'off')) { return ''; } |
($env{'environment.remote'} eq 'off')) { return ''; } |
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; |
my $menuname = &get_menu_name(); |
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
return('window.open('.$nothing.',"'.$menuname.'","",false);'); |
return('window.open('.$nothing.',"'.$menuname.'","",false);'); |
} |
} |
Line 811 sub open {
|
Line 853 sub open {
|
($env{'environment.remote'} eq 'off')) { |
($env{'environment.remote'} eq 'off')) { |
return '<script type="text/javascript">self.name="loncapaclient";</script>'; |
return '<script type="text/javascript">self.name="loncapaclient";</script>'; |
} |
} |
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; |
my $menuname = &get_menu_name(); |
|
|
# unless (shift eq 'unix') { |
# unless (shift eq 'unix') { |
# resizing does not work on linux because of virtual desktop sizes |
# resizing does not work on linux because of virtual desktop sizes |
Line 887 sub switch {
|
Line 929 sub switch {
|
my $text=$top.' '.$bot; |
my $text=$top.' '.$bot; |
$text=~s/\s*\-\s*//gs; |
$text=~s/\s*\-\s*//gs; |
|
|
my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; |
|
if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } |
|
my $pic= |
my $pic= |
'<img alt="'.$text.'" src="'. |
'<img alt="'.$text.'" src="'. |
&Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img). |
&Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img). |
Line 941 sub secondlevel {
|
Line 981 sub secondlevel {
|
} |
} |
|
|
sub openmenu { |
sub openmenu { |
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; |
my $menuname = &get_menu_name(); |
if (($env{'browser.interface'} eq 'textual') || |
if (($env{'browser.interface'} eq 'textual') || |
($env{'environment.remote'} eq 'off')) { return ''; } |
($env{'environment.remote'} eq 'off')) { return ''; } |
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); |
Line 991 sub rawconfig {
|
Line 1031 sub rawconfig {
|
my $uname=$env{'user.name'}; |
my $uname=$env{'user.name'}; |
my $udom=$env{'user.domain'}; |
my $udom=$env{'user.domain'}; |
my $adv=$env{'user.adv'}; |
my $adv=$env{'user.adv'}; |
|
my $show_course=&show_course(); |
my $author=$env{'user.author'}; |
my $author=$env{'user.author'}; |
my $crs=''; |
my $crs=''; |
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
Line 1030 sub rawconfig {
|
Line 1071 sub rawconfig {
|
$output.=&secondlevel( |
$output.=&secondlevel( |
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); |
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); |
} |
} |
|
} elsif ($pro eq 'shc') { |
|
if ($show_course) { |
|
$output.=&secondlevel( |
|
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); |
|
} |
|
} elsif ($pro eq 'nsc') { |
|
if (!$show_course) { |
|
$output.=&secondlevel( |
|
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); |
|
} |
} elsif (($pro=~/^p(\w+)/) && ($prt)) { |
} elsif (($pro=~/^p(\w+)/) && ($prt)) { |
if (&Apache::lonnet::allowed($1,$prt)) { |
if (&Apache::lonnet::allowed($1,$prt)) { |
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); |
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); |
Line 1054 sub rawconfig {
|
Line 1105 sub rawconfig {
|
} elsif ($pro eq 'author') { |
} elsif ($pro eq 'author') { |
if ($author) { |
if ($author) { |
if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) || |
if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) || |
|
(($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || |
(($prt eq 'rau') && ($env{'request.role'}=~/^au/))) { |
(($prt eq 'rau') && ($env{'request.role'}=~/^au/))) { |
# Check that we are on the correct machine |
# Check that we are on the correct machine |
my $cadom=$requested_domain; |
my $cadom=$requested_domain; |
my $caname=$env{'user.name'}; |
my $caname=$env{'user.name'}; |
if ($prt eq 'rca') { |
if (($prt eq 'rca') || ($prt eq 'raa')) { |
($cadom,$caname)= |
($cadom,$caname)= |
($env{'request.role'}=~/($match_domain)\/($match_username)$/); |
($env{'request.role'}=~/($match_domain)\/($match_username)$/); |
} |
} |
Line 1091 sub rawconfig {
|
Line 1143 sub rawconfig {
|
sub close { |
sub close { |
if (($env{'browser.interface'} eq 'textual') || |
if (($env{'browser.interface'} eq 'textual') || |
($env{'environment.remote'} eq 'off')) { return ''; } |
($env{'environment.remote'} eq 'off')) { return ''; } |
my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; |
my $menuname = &get_menu_name(); |
return(<<ENDCLOSE); |
return(<<ENDCLOSE); |
<script type="text/javascript"> |
<script type="text/javascript"> |
window.status='Accessing Remote Control'; |
window.status='Accessing Remote Control'; |
Line 1367 sub hidden_button_check {
|
Line 1419 sub hidden_button_check {
|
if ($env{'request.role.adv'}) { |
if ($env{'request.role.adv'}) { |
return; |
return; |
} |
} |
return &Apache::lonnet::EXT('resource.0.buttonshide'); |
my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide'); |
|
return $buttonshide; |
} |
} |
|
|
|
sub roles_selector { |
|
my ($cdom,$cnum) = @_; |
|
my $now = time; |
|
my %courseroles; |
|
my $is_cc; |
|
my $role_selector; |
|
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { |
|
my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum}); |
|
|
|
if ((($start) && ($start<0)) || |
|
(($end) && ($end<$now)) || |
|
(($start) && ($now<$start))) { |
|
$is_cc = 0; |
|
} else { |
|
$is_cc = 1; |
|
} |
|
} |
|
if ($is_cc) { |
|
my %adv_roles = |
|
&Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); |
|
foreach my $role (keys(%adv_roles),'st') { |
|
my ($urole,$usec) = split(/:/,$role); |
|
@{$courseroles{$urole}} = 'none'; |
|
} |
|
} else { |
|
foreach my $item (keys(%env)) { |
|
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) { |
|
my $role = $1; |
|
my $sec = $2; |
|
next if ($role eq 'gr'); |
|
my ($start,$end) = split(/\./,$env{$item}); |
|
next if (($start && $start > $now) || ($end && $end < $now)); |
|
if ($sec eq '') { |
|
$sec = 'none'; |
|
} |
|
if (ref($courseroles{$role}) eq 'ARRAY') { |
|
if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) { |
|
push(@{$courseroles{$role}},$sec); |
|
} |
|
} else { |
|
@{$courseroles{$role}} = ($sec); |
|
} |
|
} |
|
} |
|
} |
|
my @roles_order = ('cc','in','ta','ep','ad','st'); |
|
if (keys(%courseroles) > 1) { |
|
$role_selector = &jump_to_role($cdom,$cnum); |
|
$role_selector .= '<form name="rolechooser" method="post" action="/adm/roles"> |
|
<select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">'; |
|
$role_selector .= '<option value="">'.&mt('Switch course role to..').'</option>'; |
|
foreach my $role (@roles_order) { |
|
if (defined($courseroles{$role})) { |
|
$role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; |
|
} |
|
} |
|
foreach my $role (sort(keys(%courseroles))) { |
|
if ($role =~ /^cr/) { |
|
$role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; |
|
} |
|
} |
|
$role_selector .= '</select>'."\n". |
|
'<input type="hidden" name="destinationurl" value="'. |
|
$ENV{'REQUEST_URI'}.'" />'."\n". |
|
'<input type="hidden" name="gotorole" value="1" />'."\n". |
|
'<input type="hidden" name="selectrole" value="" />'."\n". |
|
'<input type="hidden" name="switch" value="1" />'."\n". |
|
'</form>'; |
|
} |
|
return $role_selector; |
|
} |
|
|
|
sub jump_to_role { |
|
my ($cdom,$cnum) = @_; |
|
my $output = <<"END"; |
|
<script type="text/javascript"> |
|
function adhocRole(roleitem) { |
|
var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value; |
|
if (newrole == '') { |
|
return; |
|
} |
|
newrole += './$cdom/$cnum'; |
|
if (newrole == "$env{'request.role'}") { |
|
return; |
|
} |
|
itemid = retrieveIndex('gotorole'); |
|
if (itemid != -1) { |
|
document.rolechooser.elements[itemid].name = newrole; |
|
} |
|
document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = newrole; |
|
document.rolechooser.selectrole.value = '1'; |
|
document.rolechooser.submit(); |
|
return; |
|
} |
|
|
|
function retrieveIndex(item) { |
|
for (var i=0;i<document.rolechooser.elements.length;i++) { |
|
if (document.rolechooser.elements[i].name == item) { |
|
return i; |
|
} |
|
} |
|
return -1; |
|
} |
|
|
|
|
|
</script> |
|
END |
|
return $output; |
|
} |
|
|
|
|
# ================================================================ Main Program |
# ================================================================ Main Program |
|
|
BEGIN { |
BEGIN { |