version 1.236, 2008/05/30 20:24:25
|
version 1.260, 2009/04/23 17:28:59
|
Line 36
|
Line 36
|
# browser.interface is 'textual' |
# browser.interface is 'textual' |
# |
# |
|
|
|
=head1 NAME |
|
|
|
Apache::lonmenu |
|
|
|
=head1 SYNOPSIS |
|
|
|
Coordinates the response to clicking an image. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=head1 SUBROUTINES |
|
|
|
=over |
|
|
|
=item show_course() |
|
|
|
Little texts |
|
|
|
=item initlittle() |
|
|
|
=item menubuttons() |
|
|
|
This gets called at the top of the body section |
|
|
|
=item show_return_link() |
|
|
|
=item registerurl() |
|
|
|
This gets called in the header section |
|
|
|
=item innerregister() |
|
|
|
This gets called in order to register a URL, both with the Remote |
|
and in the body of the document |
|
|
|
=item loadevents() |
|
|
|
=item unloadevents() |
|
|
|
=item startupremote() |
|
|
|
=item setflags() |
|
|
|
=item maincall() |
|
|
|
=item load_remote_msg() |
|
|
|
=item get_menu_name() |
|
|
|
=item reopenmenu() |
|
|
|
=item open() |
|
|
|
Open the menu |
|
|
|
=item clear() |
|
|
|
=item switch() |
|
|
|
Switch a button or create a link |
|
Switch acts on the javascript that is executed when a button is clicked. |
|
The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". |
|
|
|
=item secondlevel() |
|
|
|
=item openmenu() |
|
|
|
=item inlinemenu() |
|
|
|
=item rawconfig() |
|
|
|
=item close() |
|
|
|
=item footer() |
|
|
|
=item utilityfunctions() |
|
|
|
=item serverform() |
|
|
|
=item constspaceform() |
|
|
|
=item get_nav_status() |
|
|
|
=item convert_menu_function() |
|
|
|
FIXME this needs to move into mydesktab and the other locations |
|
the text is generated |
|
|
|
=item hidden_button_check() |
|
|
|
=item roles_selector() |
|
|
|
=item jump_to_role() |
|
|
|
=back |
|
|
|
=cut |
|
|
package Apache::lonmenu; |
package Apache::lonmenu; |
|
|
use strict; |
use strict; |
Line 53 my @inlineremote;
|
Line 152 my @inlineremote;
|
|
|
|
|
|
|
# ================================================================ Little texts |
|
sub show_course { |
sub show_course { |
my $course = !$env{'user.adv'}; |
my $course = !$env{'user.adv'}; |
if (!$env{'user.adv'}) { |
if (!$env{'user.adv'}) { |
Line 76 sub initlittle {
|
Line 174 sub initlittle {
|
'Courses':'Roles'), |
'Courses':'Roles'), |
'other' => 'Other Roles', |
'other' => 'Other Roles', |
'docs' => 'Edit Course', |
'docs' => 'Edit Course', |
'exit' => 'Exit', |
'exit' => 'Logout', |
'login' => 'Log In', |
'login' => 'Log In', |
'launch' => 'Launch Remote Control', |
'launch' => 'Launch Remote Control', |
'groups' => 'Groups', |
'groups' => 'Groups', |
Line 84 sub initlittle {
|
Line 182 sub initlittle {
|
); |
); |
} |
} |
|
|
# ============================= This gets called at the top of the body section |
|
|
|
sub menubuttons { |
sub menubuttons { |
my $forcereg=shift; |
my $forcereg=shift; |
my $registration=shift; |
my $registration=shift; |
Line 110 sub menubuttons {
|
Line 206 sub menubuttons {
|
my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); |
my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); |
|
|
my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); |
my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); |
$logo = '<td class="LC_top_nav_logo"><a href="/adm/about.html"><img src="'. |
$logo = '<a href="/adm/about.html"><img src="'. |
$logo.'" alt="LON-CAPA Logo" /></a></td>'; |
$logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>'; |
|
|
if ($env{'request.state'} eq 'construct') { |
if ($env{'request.state'} eq 'construct') { |
if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { |
if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { |
Line 196 ENDMAINMENU
|
Line 292 ENDMAINMENU
|
return (<<ENDINLINEMENU); |
return (<<ENDINLINEMENU); |
<table id="LC_top_nav"> |
<table id="LC_top_nav"> |
<tr> |
<tr> |
$logo |
<td>$logo</td> |
<td></td> |
<td></td> |
<td class="LC_top_nav_login"> |
<td class="LC_top_nav_login"> |
<a href="/adm/roles" target="_top">$lt{'login'}</a> |
<a href="/adm/roles" target="_top">$lt{'login'}</a> |
</td> |
</td> |
</tr> |
</tr> |
</table> |
</table> |
</font> |
|
ENDINLINEMENU |
ENDINLINEMENU |
} |
} |
$roles = '<td><a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a></td>'; |
$roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>'; |
# 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 215 ENDINLINEMENU
|
Line 310 ENDINLINEMENU
|
$link="javascript:gonav('".$link."')"; |
$link="javascript:gonav('".$link."')"; |
} |
} |
$navmaps=(<<ENDNAV); |
$navmaps=(<<ENDNAV); |
<td><a href="$link" target="_top">$lt{'nav'}</a></td> |
<li><a href="$link" target="_top">$lt{'nav'}</a></li> |
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); |
<td><a href="/adm/coursedocs" target="_top">$text</a></td> |
<li><a href="/adm/coursedocs" target="_top">$text</a></li> |
ENDDOCS |
ENDDOCS |
} |
} |
if ($showgroups) { |
if ($showgroups) { |
$groups =(<<ENDGROUPS); |
$groups =(<<ENDGROUPS); |
<td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td> |
<li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li> |
ENDGROUPS |
ENDGROUPS |
} |
} |
if (&show_return_link()) { |
if (&show_return_link()) { |
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> |
<li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li> |
ENDRELOAD |
ENDRELOAD |
} |
} |
if ($role_selector) { |
if ($role_selector) { |
$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>'; |
#$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>'; |
|
$role_selector = '<li>'.$role_selector.'</li>'; |
} |
} |
} |
} |
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:'); |
$reloadlink=(<<ENDCRELOAD); |
$reloadlink=(<<ENDCRELOAD); |
<td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td> |
<li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li> |
ENDCRELOAD |
ENDCRELOAD |
} |
} |
my $reg=''; |
my $reg=''; |
Line 251 ENDCRELOAD
|
Line 347 ENDCRELOAD
|
} |
} |
my $form=&serverform(); |
my $form=&serverform(); |
my $utility=&utilityfunctions(); |
my $utility=&utilityfunctions(); |
my $remote; |
|
if ($env{'user.adv'}) { |
|
$remote = '<td><a href="/adm/remote?action=launch&url='.$escurl.'" target="_top">'.$lt{'launch'}.'</a></td>' |
|
} |
|
|
|
|
my $messagelink = ""; |
|
if(&Apache::lonmsg::mynewmail()){ |
|
$messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message(new)</a>' |
|
}else{ |
|
$messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message</a>' |
|
} |
my $helplink=&Apache::loncommon::top_nav_help('Help'); |
my $helplink=&Apache::loncommon::top_nav_help('Help'); |
return (<<ENDINLINEMENU); |
return (<<ENDINLINEMENU); |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 264 ENDCRELOAD
|
Line 362 ENDCRELOAD
|
$utility |
$utility |
// ]]> |
// ]]> |
</script> |
</script> |
<table id="LC_top_nav"> |
<ol class="LC_smallMenu LC_right"> |
<tr> |
<li>$logo</li> |
$logo |
<li>$messagelink</li> |
<td><a href="/adm/menu" target="_top">$lt{'main'}</a></td> |
<li>$roles</li> |
|
<li>$helplink</li> |
|
<li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li> |
|
</ol> |
|
<ol id="LC_TabMainMenuContent"> |
|
<li><a href="/adm/menu" target="_top">$lt{'main'}</a></li> |
$reloadlink |
$reloadlink |
$navmaps |
$navmaps |
$docs |
$docs |
$groups |
$groups |
$remote |
$role_selector |
$roles |
</ol> |
<td class="LC_top_nav_help">$helplink</td> |
|
<td class="LC_top_nav_exit"><a href="/adm/logout" target="_top">$lt{'exit'}</a></td> |
|
</tr> |
|
</table> |
|
$form |
$form |
<script type="text/javascript"> |
<script type="text/javascript"> |
// END LON-CAPA Internal |
// END LON-CAPA Internal |
</script> |
</script> |
|
<br clear="all" /> |
$reg |
$reg |
ENDINLINEMENU |
ENDINLINEMENU |
} else { |
} else { |
Line 302 sub show_return_link {
|
Line 402 sub show_return_link {
|
)); |
)); |
} |
} |
|
|
# ====================================== This gets called in the header section |
|
|
|
sub registerurl { |
sub registerurl { |
my ($forcereg) = @_; |
my ($forcereg) = @_; |
Line 327 sub registerurl {
|
Line 426 sub registerurl {
|
return $result.$force_title; |
return $result.$force_title; |
} |
} |
|
|
# =========== This gets called in order to register a URL, both with the Remote |
|
# =========== and in the body of the document |
|
|
|
sub innerregister { |
sub innerregister { |
my ($forcereg, $titletable) = @_; |
my ($forcereg, $titletable) = @_; |
my $result = ''; |
my $result = ''; |
Line 406 sub innerregister {
|
Line 502 sub innerregister {
|
if ($env{'request.symb'} ne '' && |
if ($env{'request.symb'} ne '' && |
$env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { |
$env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { |
if (&Apache::lonnet::allowed('mgr',$crs)) { |
if (&Apache::lonnet::allowed('mgr',$crs)) { |
$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', |
$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]', |
"gocmd('/adm/grades','gradingmenu')", |
"gocmd('/adm/grades','gradingmenu')", |
'Modify user grades for this assessment resource'); |
'Modify user grades for this assessment resource'); |
} elsif (&Apache::lonnet::allowed('vgr',$crs)) { |
} elsif (&Apache::lonnet::allowed('vgr',$crs)) { |
Line 427 sub innerregister {
|
Line 523 sub innerregister {
|
### resource |
### resource |
### |
### |
my $editbutton = ''; |
my $editbutton = ''; |
|
my $noeditbutton = 1; |
|
my ($cnum,$cdom); |
|
if ($env{'request.course.id'}) { |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
} |
if ($env{'user.author'}) { |
if ($env{'user.author'}) { |
if ($env{'request.role'}=~/^(aa|ca|au)/) { |
if ($env{'request.role'}=~/^(aa|ca|au)/) { |
# Set defaults for authors |
# Set defaults for authors |
Line 454 sub innerregister {
|
Line 556 sub innerregister {
|
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
if (!$allowed) { |
if (!$allowed) { |
$editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); |
$editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); |
|
$noeditbutton = 0; |
} |
} |
} |
} |
## |
## |
Line 462 sub innerregister {
|
Line 565 sub innerregister {
|
my $cfile=''; |
my $cfile=''; |
my $cfuname=''; |
my $cfuname=''; |
my $cfudom=''; |
my $cfudom=''; |
|
my $uploaded; |
if ($env{'request.filename'}) { |
if ($env{'request.filename'}) { |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
$file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; |
if (defined($cnum) && defined($cdom)) { |
# Check that the user has permission to edit this resource |
$uploaded = &is_course_upload($file,$cnum,$cdom); |
($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); |
} |
if (defined($cfudom)) { |
if (!$uploaded) { |
my $home=&Apache::lonnet::homeserver($cfuname,$cfudom); |
$file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; |
my $allowed=0; |
# Check that the user has permission to edit this resource |
my @ids=&Apache::lonnet::current_machine_ids(); |
($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
if (defined($cfudom)) { |
if ($allowed) { |
my $home=&Apache::lonnet::homeserver($cfuname,$cfudom); |
$cfile=$file; |
my $allowed=0; |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
|
if ($allowed) { |
|
$cfile=$file; |
|
} |
} |
} |
} |
} |
} |
} |
# Finally, turn the button on or off |
# Finally, turn the button on or off |
if ($cfile && !$const_space) { |
if ($cfile && !$const_space) { |
$editbutton=&switch |
$editbutton=&switch |
('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', |
('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', |
"go('".$cfile."');","Edit this resource"); |
"go('".$cfile."');","Edit this resource"); |
|
$noeditbutton = 0; |
} elsif ($editbutton eq '') { |
} elsif ($editbutton eq '') { |
$editbutton=&clear(6,1); |
$editbutton=&clear(6,1); |
} |
} |
} |
} |
|
if (($noeditbutton) && ($env{'request.filename'})) { |
|
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { |
|
my $file=&Apache::lonnet::declutter($env{'request.filename'}); |
|
if (defined($cnum) && defined($cdom)) { |
|
if (&is_course_upload($file,$cnum,$cdom)) { |
|
my $cfile = &edit_course_upload($file,$cnum,$cdom); |
|
if ($cfile) { |
|
$editbutton=&switch |
|
('','',6,1,'pcstr.gif','edit[_1]', |
|
'resource[_2]',"go('".$cfile."');", |
|
'Edit this resource'); |
|
} |
|
} |
|
} |
|
} |
|
} |
### |
### |
### |
### |
# Prepare the rest of the buttons |
# Prepare the rest of the buttons |
Line 503 sub innerregister {
|
Line 629 sub innerregister {
|
$menuitems=(<<ENDMENUITEMS); |
$menuitems=(<<ENDMENUITEMS); |
s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory |
s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory |
s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version |
s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version |
s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource |
s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource |
s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource |
s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource |
s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document |
s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document |
ENDMENUITEMS |
ENDMENUITEMS |
Line 519 c&8&1
|
Line 645 c&8&1
|
c&8&2 |
c&8&2 |
s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document |
s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document |
s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1 |
s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1 |
s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1 |
|
ENDMENUITEMS |
ENDMENUITEMS |
|
|
|
my $currentURL = &Apache::loncommon::get_symb(); |
|
my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL); |
|
my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc); |
|
$menuitems.="s&9&3&"; |
|
if(length($annotation) > 0){ |
|
$menuitems.="anot2.gif"; |
|
}else{ |
|
$menuitems.="anot.gif"; |
|
} |
|
$menuitems.="&anno-[_1]&tations[_1]&annotate()&"; |
|
$menuitems.="Make notes and annotations about this resource&&1\n"; |
|
|
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { |
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { |
if (!$env{'request.enc'}) { |
if (!$env{'request.enc'}) { |
$menuitems.=(<<ENDREALRES); |
$menuitems.=(<<ENDREALRES); |
s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information |
s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata |
ENDREALRES |
ENDREALRES |
} |
} |
$menuitems.=(<<ENDREALRES); |
$menuitems.=(<<ENDREALRES); |
Line 709 ENDDONOTREGTHIS
|
Line 846 ENDDONOTREGTHIS
|
return $result; |
return $result; |
} |
} |
|
|
|
sub is_course_upload { |
|
my ($file,$cnum,$cdom) = @_; |
|
my $uploadpath = &LONCAPA::propath($cdom,$cnum); |
|
$uploadpath =~ s{^\/}{}; |
|
if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) || |
|
($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) { |
|
return 1; |
|
} |
|
return; |
|
} |
|
|
|
sub edit_course_upload { |
|
my ($file,$cnum,$cdom) = @_; |
|
my $cfile; |
|
if ($file =~/\.(htm|html|css|js|txt)$/) { |
|
my $ext = $1; |
|
my $url = &Apache::lonnet::hreflocation('',$file); |
|
my $home = &Apache::lonnet::homeserver($cnum,$cdom); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
my $dest; |
|
if ($home && grep(/^\Q$home\E$/,@ids)) { |
|
$dest = $url.'?forceedit=1'; |
|
} else { |
|
unless (&Apache::lonnet::get_locks()) { |
|
$dest = '/adm/switchserver?otherserver='. |
|
$home.'&role='.$env{'request.role'}. |
|
'&url='.$url.'&forceedit=1'; |
|
} |
|
} |
|
if ($dest) { |
|
$cfile = &HTML::Entities::encode($dest,'"<>&'); |
|
} |
|
} |
|
return $cfile; |
|
} |
|
|
sub loadevents() { |
sub loadevents() { |
if ($env{'request.state'} eq 'construct' || |
if ($env{'request.state'} eq 'construct' || |
$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } |
$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } |
Line 721 sub unloadevents() {
|
Line 894 sub unloadevents() {
|
return 'LONCAPAstale();'; |
return 'LONCAPAstale();'; |
} |
} |
|
|
# ============================================================= Start up remote |
|
|
|
sub startupremote { |
sub startupremote { |
my ($lowerurl)=@_; |
my ($lowerurl)=@_; |
Line 835 sub get_menu_name {
|
Line 1007 sub get_menu_name {
|
return 'LCmenu'.$hostid; |
return 'LCmenu'.$hostid; |
} |
} |
|
|
# ================================================================= Reopen menu |
|
|
|
sub reopenmenu { |
sub reopenmenu { |
if (($env{'browser.interface'} eq 'textual') || |
if (($env{'browser.interface'} eq 'textual') || |
Line 845 sub reopenmenu {
|
Line 1016 sub reopenmenu {
|
return('window.open('.$nothing.',"'.$menuname.'","",false);'); |
return('window.open('.$nothing.',"'.$menuname.'","",false);'); |
} |
} |
|
|
# =============================================================== Open the menu |
|
|
|
sub open { |
sub open { |
my $returnval=''; |
my $returnval=''; |
Line 898 sub switch {
|
Line 1068 sub switch {
|
$top=&mt($top); |
$top=&mt($top); |
$bot=&mt($bot); |
$bot=&mt($bot); |
$desc=&mt($desc); |
$desc=&mt($desc); |
$img=&mt($img); |
if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) { |
|
$img=&mt($img); |
|
} |
my $idx=10*$row+$col; |
my $idx=10*$row+$col; |
$category_members{$cat}.=':'.$idx; |
$category_members{$cat}.=':'.$idx; |
|
|
Line 932 sub switch {
|
Line 1103 sub switch {
|
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). |
'" align="'.($nobreak==3?'right':'left').'" />'; |
'" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />'; |
if ($env{'browser.interface'} eq 'faketextual') { |
if ($env{'browser.interface'} eq 'faketextual') { |
# Accessibility |
# Accessibility |
if ($nobreak==3) { |
if ($nobreak==3) { |
$inlineremote[$idx]="\n". |
$inlineremote[$idx]="\n". |
'<td class="LC_menubuttons_text" align="right">'.$text. |
'<td class="LC_menubuttons_text" align="right">'.$text. |
'</td><td class="LC_menubuttons_img" align="left">'. |
'</td><td align="left">'. |
'<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>'; |
'<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>'; |
} elsif ($nobreak) { |
} elsif ($nobreak) { |
$inlineremote[$idx]="\n<tr>". |
$inlineremote[$idx]="\n<tr>". |
'<td class="LC_menubuttons_img" align="left">'. |
'<td align="left">'. |
'<a href="javascript:'.$act.';">'.$pic.'</a></td> |
'<a href="javascript:'.$act.';">'.$pic.'</a></td> |
<td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>'; |
<td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>'; |
} else { |
} else { |
$inlineremote[$idx]="\n<tr>". |
$inlineremote[$idx]="\n<tr>". |
'<td class="LC_menubuttons_img" align="left">'. |
'<td align="left">'. |
'<a href="javascript:'.$act.';">'.$pic. |
'<a href="javascript:'.$act.';">'.$pic. |
'</a></td><td class="LC_menubuttons_text" colspan="3">'. |
'</a></td><td class="LC_menubuttons_text" colspan="3">'. |
'<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>'; |
'<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>'; |
Line 994 sub inlinemenu {
|
Line 1165 sub inlinemenu {
|
&rawconfig(1); |
&rawconfig(1); |
my $output='<table id="LC_mainmenu"><tr>'; |
my $output='<table id="LC_mainmenu"><tr>'; |
for (my $col=1; $col<=2; $col++) { |
for (my $col=1; $col<=2; $col++) { |
$output.='<td class="LC_mainmenu_column">'; |
$output.='<td class="LC_mainmenu_col_fieldset">'; |
for (my $row=1; $row<=8; $row++) { |
for (my $row=1; $row<=8; $row++) { |
foreach my $cat (keys(%category_members)) { |
foreach my $cat (keys(%category_members)) { |
if ($category_positions{$cat} ne "$col,$row") { next; } |
if ($category_positions{$cat} ne "$col,$row") { next; } |
$output.='<table id="LC_menubuttons_mainmenu"><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>'; |
#$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>'; |
|
$output.='<div class="LC_ContentBoxSpecial">'; |
|
$output.='<h4 class="LC_hcell">'.&mt($category_names{$cat}).'</h4>'; |
|
$output.='<table>'; |
my %active=(); |
my %active=(); |
foreach my $menu_item (split(/\:/,$category_members{$cat})) { |
foreach my $menu_item (split(/\:/,$category_members{$cat})) { |
if ($inlineremote[$menu_item]) { |
if ($inlineremote[$menu_item]) { |
Line 1009 sub inlinemenu {
|
Line 1183 sub inlinemenu {
|
$output.=$inlineremote[$item]; |
$output.=$inlineremote[$item]; |
} |
} |
$output.='</table>'; |
$output.='</table>'; |
|
$output.='</div>'; |
} |
} |
} |
} |
$output.="</td>"; |
$output.="</td>"; |
Line 1125 sub rawconfig {
|
Line 1300 sub rawconfig {
|
} |
} |
} |
} |
} |
} |
|
} elsif ($pro eq 'tools') { |
|
my @tools = ('aboutme','blog','portfolio'); |
|
if (grep(/^\Q$prt\E$/,@tools)) { |
|
if (!&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'}, |
|
$prt,undef,'tools')) { |
|
$output.=&clear($row,$col); |
|
next; |
|
} |
|
} elsif ($prt eq 'reqcrs') { |
|
my $showreqcrs = 0; |
|
foreach my $type ('official','unofficial') { |
|
if (&Apache::lonnet::usertools_access($env{'user.name'}, |
|
$env{'user.domain'}, |
|
$type,undef,'requestcourses')) { |
|
$showreqcrs = 1; |
|
last; |
|
} |
|
} |
|
if (!$showreqcrs) { |
|
$output.=&clear($row,$col); |
|
next; |
|
} |
|
} |
|
$prt='any'; |
|
$output.=&secondlevel( |
|
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); |
} |
} |
} |
} |
unless (($env{'browser.interface'} eq 'textual') || |
unless (($env{'browser.interface'} eq 'textual') || |
Line 1341 function set_bookmark() {
|
Line 1543 function set_bookmark() {
|
bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); |
bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); |
bmquery.document.write( |
bmquery.document.write( |
'$start_page_bookmark' |
'$start_page_bookmark' |
+"<center><form method='post'" |
+'<center><form method="post"' |
+" name='newlink' action='/adm/bookmarks' target='bmquery' " |
+' name="newlink" action="/adm/bookmarks" target="bmquery" ' |
+">\\n <table width=340 height=150 " |
+'> <table width="340" height="150" ' |
+"bgcolor='ffffff' align=center><tr><td>Link Name:<br /><input " |
+'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input ' |
+"type='text' name='title' size=45 value='"+clienttitle+"' />" |
+'type="text" name="title" size="45" value="'+clienttitle+'" />' |
+"<br />Address:<br /><input type='text' name='address' size='45' " |
+'<br />Address:<br /><input type="text" name="address" size="45" ' |
+"value='"+clienthref+"' /><br /><center><input type='submit' " |
+'value="'+clienthref+'" /><br /><center><input type="submit" ' |
+"value='Save' /> <input type='button' value='Close (no save)' " |
+'value="Save" /> <input type="button" value="Close" ' |
+"onclick='javascript:window.close();' /><\\/center><\\/td>" |
+'onclick="javascript:window.close();" /></center></td>' |
+"<\\/tr><\\/table><\\/form><\\/center>" |
+'</tr></table></form></center>' |
+'$end_page_bookmark' ); |
+'$end_page_bookmark' ); |
bmquery.document.close(); |
bmquery.document.close(); |
} |
} |
Line 1426 sub hidden_button_check {
|
Line 1628 sub hidden_button_check {
|
sub roles_selector { |
sub roles_selector { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum) = @_; |
my $now = time; |
my $now = time; |
my %courseroles; |
my (%courseroles,%seccount,%gotnosection); |
my $is_cc; |
my $is_cc; |
my $role_selector; |
my $role_selector; |
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { |
if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { |
Line 1443 sub roles_selector {
|
Line 1645 sub roles_selector {
|
if ($is_cc) { |
if ($is_cc) { |
my %adv_roles = |
my %adv_roles = |
&Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); |
&Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); |
foreach my $role (keys(%adv_roles),'st') { |
foreach my $role (keys(%adv_roles)) { |
my ($urole,$usec) = split(/:/,$role); |
my ($urole,$usec) = split(/:/,$role); |
@{$courseroles{$urole}} = 'none'; |
if (!$gotnosection{$urole}) { |
|
$seccount{$urole} ++; |
|
$gotnosection{$urole} = 1; |
|
} |
|
if (ref($courseroles{$urole}) eq 'ARRAY') { |
|
if ($usec ne '') { |
|
if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) { |
|
push(@{$courseroles{$urole}},$usec); |
|
$seccount{$urole} ++; |
|
} |
|
} |
|
} else { |
|
@{$courseroles{$urole}} = (); |
|
if ($usec ne '') { |
|
$seccount{$urole} ++; |
|
push(@{$courseroles{$urole}},$usec); |
|
} |
|
} |
|
} |
|
my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); |
|
@{$courseroles{'st'}} = (); |
|
if (keys(%sections_count) > 0) { |
|
push(@{$courseroles{'st'}},keys(%sections_count)); |
} |
} |
} else { |
} else { |
foreach my $item (keys(%env)) { |
foreach my $item (keys(%env)) { |
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) { |
if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { |
my $role = $1; |
my $role = $1; |
my $sec = $2; |
my $sec = $2; |
next if ($role eq 'gr'); |
next if ($role eq 'gr'); |
my ($start,$end) = split(/\./,$env{$item}); |
my ($start,$end) = split(/\./,$env{$item}); |
next if (($start && $start > $now) || ($end && $end < $now)); |
next if (($start && $start > $now) || ($end && $end < $now)); |
if ($sec eq '') { |
if ($sec eq '') { |
$sec = 'none'; |
if (!$gotnosection{$role}) { |
|
$seccount{$role} ++; |
|
$gotnosection{$role} = 1; |
|
} |
} |
} |
if (ref($courseroles{$role}) eq 'ARRAY') { |
if (ref($courseroles{$role}) eq 'ARRAY') { |
if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) { |
if ($sec ne '') { |
push(@{$courseroles{$role}},$sec); |
if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) { |
|
push(@{$courseroles{$role}},$sec); |
|
$seccount{$role} ++; |
|
} |
} |
} |
} else { |
} else { |
@{$courseroles{$role}} = ($sec); |
@{$courseroles{$role}} = (); |
|
if ($sec ne '') { |
|
$seccount{$role} ++; |
|
push(@{$courseroles{$role}},$sec); |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
my @roles_order = ('cc','in','ta','ep','ad','st'); |
my @roles_order = ('cc','in','ta','ep','ad','st'); |
if (keys(%courseroles) > 1) { |
if (keys(%courseroles) > 1) { |
$role_selector = &jump_to_role($cdom,$cnum); |
$role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); |
$role_selector .= '<form name="rolechooser" method="post" action="/adm/roles"> |
$role_selector .= '<form name="rolechooser" method="post" action="/adm/roles"> |
<select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">'; |
<select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">'; |
$role_selector .= '<option value="">'.&mt('Switch course role to..').'</option>'; |
$role_selector .= '<option value="">'.&mt('Switch course role to...').'</option>'; |
foreach my $role (@roles_order) { |
foreach my $role (@roles_order) { |
if (defined($courseroles{$role})) { |
if (defined($courseroles{$role})) { |
$role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; |
$role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; |
Line 1496 sub roles_selector {
|
Line 1730 sub roles_selector {
|
} |
} |
|
|
sub jump_to_role { |
sub jump_to_role { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum,$seccount,$courseroles) = @_; |
|
my %lt = &Apache::lonlocal::texthash( |
|
this => 'This role has section(s) associated with it.', |
|
ente => 'Enter a specific section.', |
|
orlb => 'Enter a specific section, or leave blank for no section.', |
|
avai => 'Available sections are:', |
|
youe => 'You entered an invalid section choice:', |
|
plst => 'Please try again', |
|
); |
|
my $js; |
|
if (ref($courseroles) eq 'HASH') { |
|
$js = ' var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". |
|
' var numsec = new Array();'."\n". |
|
' var rolesections = new Array();'."\n". |
|
' var rolenames = new Array();'."\n". |
|
' var roleseclist = new Array();'."\n"; |
|
my @items = keys(%{$courseroles}); |
|
for (my $i=0; $i<@items; $i++) { |
|
$js .= ' rolenames['.$i.'] = "'.$items[$i].'";'."\n"; |
|
my ($secs,$secstr); |
|
if (ref($courseroles->{$items[$i]}) eq 'ARRAY') { |
|
my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}}; |
|
$secs = join('","',@sections); |
|
$secstr = join(', ',@sections); |
|
} |
|
$js .= ' rolesections['.$i.'] = new Array("'.$secs.'");'."\n". |
|
' roleseclist['.$i.'] = "'.$secstr.'";'."\n". |
|
' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; |
|
} |
|
} |
my $output = <<"END"; |
my $output = <<"END"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
function adhocRole(roleitem) { |
function adhocRole(roleitem) { |
|
$js |
var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value; |
var newrole = document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value; |
if (newrole == '') { |
if (newrole == '') { |
return; |
return; |
} |
} |
newrole += './$cdom/$cnum'; |
var fullrole = newrole+'./$cdom/$cnum'; |
if (newrole == "$env{'request.role'}") { |
var selidx = ''; |
|
for (var i=0; i<rolenames.length; i++) { |
|
if (rolenames[i] == newrole) { |
|
selidx = i; |
|
} |
|
} |
|
var secok = 1; |
|
var secchoice = ''; |
|
if (selidx >= 0) { |
|
if (numsec[selidx] > 1) { |
|
secok = 0; |
|
var numrolesec = rolesections[selidx].length; |
|
var msgidx = numsec[selidx] - numrolesec; |
|
secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],""); |
|
if (secchoice == '') { |
|
if (msgidx > 0) { |
|
secok = 1; |
|
} |
|
} else { |
|
for (var j=0; j<rolesections[selidx].length; j++) { |
|
if (rolesections[selidx][j] == secchoice) { |
|
secok = 1; |
|
} |
|
} |
|
} |
|
} else { |
|
if (rolesections[selidx].length == 1) { |
|
secchoice = rolesections[selidx][0]; |
|
} |
|
} |
|
} |
|
if (secok == 1) { |
|
if (secchoice != '') { |
|
fullrole += '/'+secchoice; |
|
} |
|
} else { |
|
document.rolechooser.elements[roleitem].selectedIndex = 0; |
|
if (secchoice != null) { |
|
alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}"); |
|
} |
|
return; |
|
} |
|
if (fullrole == "$env{'request.role'}") { |
return; |
return; |
} |
} |
itemid = retrieveIndex('gotorole'); |
itemid = retrieveIndex('gotorole'); |
if (itemid != -1) { |
if (itemid != -1) { |
document.rolechooser.elements[itemid].name = newrole; |
document.rolechooser.elements[itemid].name = fullrole; |
} |
} |
document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = newrole; |
document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole; |
document.rolechooser.selectrole.value = '1'; |
document.rolechooser.selectrole.value = '1'; |
document.rolechooser.submit(); |
document.rolechooser.submit(); |
return; |
return; |