$lt{'roles'}
-$helplink |
-$lt{'exit'} |
+$roles
+$helplink |
+$lt{'exit'} |
$form
@@ -274,7 +379,19 @@ ENDINLINEMENU
}
}
-# ====================================== This gets called in the header section
+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)($|\?)])
+ ));
+}
+
sub registerurl {
my ($forcereg) = @_;
@@ -299,9 +416,6 @@ sub registerurl {
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 {
my ($forcereg, $titletable) = @_;
my $result = '';
@@ -334,16 +448,18 @@ sub innerregister {
} else {
$newmail= 'swmenu.setstatus("you have","messages");';
}
- } elsif (($textual)
+ }
+ if (($textual)
&& ($env{'request.symb'})
&& ($env{'request.course.id'})) {
$newmail.= '';
my ($mapurl,$rid,$resurl)=
&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 $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- if ($maptitle && $maptitle ne 'default.sequence') {
+ if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
$newmail.=', '.$maptitle;
}
if ($restitle) {
@@ -398,19 +514,24 @@ sub innerregister {
###
my $editbutton = '';
if ($env{'user.author'}) {
- if ($env{'request.role'}=~/^(ca|au)/) {
+ if ($env{'request.role'}=~/^(aa|ca|au)/) {
# Set defaults for authors
my ($top,$bottom) = ('con-','struct');
my $action = "go('/priv/".$env{'user.name'}."');";
my $cadom = $env{'request.role.domain'};
my $caname = $env{'user.name'};
- my $desc = "Enter my resource construction space";
+ my $desc = "Enter my construction space";
# Set defaults for co-authors
if ($env{'request.role'} =~ /^ca/) {
($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
($top,$bottom) = ('co con-','struct');
$action = "go('/priv/".$caname."');";
$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
my $home = &Apache::lonnet::homeserver($caname,$cadom);
@@ -484,9 +605,20 @@ c&8&1
c&8&2
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&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&&1
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)(\?|$)/) {
if (!$env{'request.enc'}) {
$menuitems.=(<$link
ENDREMOTEFORM
}
-# ================================================================= Reopen menu
+
+sub get_menu_name {
+ my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
+ $hostid =~ s/\W//g;
+ return 'LCmenu'.$hostid;
+}
+
sub reopenmenu {
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) { return ''; }
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
+ my $menuname = &get_menu_name();
my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
return('window.open('.$nothing.',"'.$menuname.'","",false);');
}
-# =============================================================== Open the menu
sub open {
my $returnval='';
@@ -811,7 +947,7 @@ sub open {
($env{'environment.remote'} eq 'off')) {
return '';
}
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
+ my $menuname = &get_menu_name();
# unless (shift eq 'unix') {
# resizing does not work on linux because of virtual desktop sizes
@@ -856,8 +992,9 @@ sub switch {
$top=&mt($top);
$bot=&mt($bot);
$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;
$category_members{$cat}.=':'.$idx;
@@ -890,22 +1027,22 @@ sub switch {
my $pic=
'';
+ '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
if ($env{'browser.interface'} eq 'faketextual') {
# Accessibility
if ($nobreak==3) {
$inlineremote[$idx]="\n".
''.
''.$pic.' | ';
} elsif ($nobreak) {
$inlineremote[$idx]="\n".
- ''.
''.$pic.' |
';
} else {
$inlineremote[$idx]="\n ".
- ''.
''.$pic.
' | ';
@@ -939,7 +1076,7 @@ sub secondlevel {
}
sub openmenu {
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
+ my $menuname = &get_menu_name();
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) { return ''; }
my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
@@ -952,11 +1089,14 @@ sub inlinemenu {
&rawconfig(1);
my $output='';
for (my $col=1; $col<=2; $col++) {
- $output.='';
+ $output.=' | ';
for (my $row=1; $row<=8; $row++) {
foreach my $cat (keys(%category_members)) {
if ($category_positions{$cat} ne "$col,$row") { next; }
- $output.=' ';
+ #$output.=' ';
+ $output.='';
+ $output.=' '.&mt($category_names{$cat}).'';
+ $output.=' ';
my %active=();
foreach my $menu_item (split(/\:/,$category_members{$cat})) {
if ($inlineremote[$menu_item]) {
@@ -967,6 +1107,7 @@ sub inlinemenu {
$output.=$inlineremote[$item];
}
$output.=' ';
+ $output.=' ';
}
}
$output.="";
@@ -989,6 +1130,7 @@ sub rawconfig {
my $uname=$env{'user.name'};
my $udom=$env{'user.domain'};
my $adv=$env{'user.adv'};
+ my $show_course=&show_course();
my $author=$env{'user.author'};
my $crs='';
if ($env{'request.course.id'}) {
@@ -1028,6 +1170,16 @@ sub rawconfig {
$output.=&secondlevel(
$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)) {
if (&Apache::lonnet::allowed($1,$prt)) {
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
@@ -1052,11 +1204,12 @@ sub rawconfig {
} elsif ($pro eq 'author') {
if ($author) {
if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
+ (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) ||
(($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
# Check that we are on the correct machine
my $cadom=$requested_domain;
my $caname=$env{'user.name'};
- if ($prt eq 'rca') {
+ if (($prt eq 'rca') || ($prt eq 'raa')) {
($cadom,$caname)=
($env{'request.role'}=~/($match_domain)\/($match_username)$/);
}
@@ -1071,6 +1224,18 @@ 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)) {
+ $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') ||
@@ -1089,7 +1254,7 @@ sub rawconfig {
sub close {
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) { return ''; }
- my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
+ my $menuname = &get_menu_name();
return(<
window.status='Accessing Remote Control';
@@ -1365,9 +1530,225 @@ sub hidden_button_check {
if ($env{'request.role.adv'}) {
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,%seccount,%gotnosection);
+ 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)) {
+ my ($urole,$usec) = split(/:/,$role);
+ 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 {
+ 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 '') {
+ if (!$gotnosection{$role}) {
+ $seccount{$role} ++;
+ $gotnosection{$role} = 1;
+ }
+ }
+ if (ref($courseroles{$role}) eq 'ARRAY') {
+ if ($sec ne '') {
+ if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) {
+ push(@{$courseroles{$role}},$sec);
+ $seccount{$role} ++;
+ }
+ }
+ } else {
+ @{$courseroles{$role}} = ();
+ if ($sec ne '') {
+ $seccount{$role} ++;
+ push(@{$courseroles{$role}},$sec);
+ }
+ }
+ }
+ }
+ }
+ my @roles_order = ('cc','in','ta','ep','ad','st');
+ if (keys(%courseroles) > 1) {
+ $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
+ $role_selector .= '';
+ }
+ return $role_selector;
+}
+
+sub jump_to_role {
+ 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";
+
+END
+ return $output;
+}
+
+
# ================================================================ Main Program
BEGIN {
|
|