';
# Do we have a NAV link?
if ($env{'request.course.id'}) {
my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='.
@@ -189,9 +217,11 @@ ENDINLINEMENU
$navmaps=(<$lt{'nav'}
ENDNAV
+ my $is_group = (&Apache::loncommon::course_type() eq 'Group');
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
+ my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
$docs=(<$lt{'docs'}
+
';
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) {
@@ -378,7 +414,7 @@ sub innerregister {
&Apache::lonnet::allowed('opa',$crs)) {
$hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
"gocmd('/adm/parmset','set')",
- 'Modify deadlines, etc, for this resource');
+ 'Modify parameter settings for this resource');
}
# -- End Homework
###
@@ -387,19 +423,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'}=~/(\w+)\/(\w+)$/);
+ ($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);
@@ -418,7 +459,7 @@ sub innerregister {
my $cfudom='';
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
- $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
+ $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
# Check that the user has permission to edit this resource
($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
if (defined($cfudom)) {
@@ -434,13 +475,10 @@ sub innerregister {
# Finally, turn the button on or off
if ($cfile && !$const_space) {
$editbutton=&switch
- ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',
+ ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
"go('".$cfile."');","Edit this resource");
} elsif ($editbutton eq '') {
- $editbutton=&switch('','',6,1,'port.gif',
- 'port-[_1]','folio[_1]',
- "go('/adm/portfolio');",
- "Enter my portfolio space");
+ $editbutton=&clear(6,1);
}
}
###
@@ -455,42 +493,63 @@ sub innerregister {
$is_const_dir = 1;
} else {
$currdir =~ s#[^/]+$##;
+ my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
+ my $esc_currdir = &Apache::loncommon::escape_single($currdir);
$menuitems=(<
+$inlineremote[21] $inlineremote[23]
+ENDARROWSINLINE
+ if (&hidden_button_check() ne 'yes') {
+ $inlinebuttons .= (<
+ENDINLINEICONS
+ }
+ } else {
+ if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
+ $inlinebuttons=(<
$inlineremote[21]
$inlineremote[23]
-
$inlineremote[61]
$inlineremote[62]
$inlineremote[63]
-
$inlineremote[71]
$inlineremote[72]
$inlineremote[73]
-
$inlineremote[81]
$inlineremote[82]
$inlineremote[83]
-
$inlineremote[91]
$inlineremote[92]
$inlineremote[93]
-ENDINLINE
- }
+ENDFIRSTLINE
+ }
+ if (&hidden_button_check() ne 'yes') {
+ foreach my $row (6..9) {
+ if ($inlineremote[${row}.'1'] ne ''
+ || $inlineremote[$row.'2'] ne ''
+ || $inlineremote[$row.'3'] ne '') {
+ $inlinebuttons .= <<"ENDLINE";
+
$inlineremote["${row}1"]
$inlineremote["${row}2"]
$inlineremote["${row}3"]
+ENDLINE
+ }
+ }
+ }
+ }
+ }
}
$result =(<
// BEGIN LON-CAPA Internal
$timesync
-$newmail
$tablestart
$inlinebuttons
$tableend
+$newmail
@@ -531,7 +613,7 @@ ENDREGTEXT
# Registered, graphical output
} else {
my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri));
+ $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
my $navstatus=&get_nav_status();
my $clearcstr;
@@ -646,7 +728,7 @@ sub startupremote {
# The Remote actually gets launched!
#
my $configmenu=&rawconfig();
- my $esclowerurl=&Apache::lonnet::escape($lowerurl);
+ my $esclowerurl=&escape($lowerurl);
my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
return(<
@@ -729,9 +811,9 @@ sub load_remote_msg {
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) { return ''; }
- my $esclowerurl=&Apache::lonnet::escape($lowerurl);
+ my $esclowerurl=&escape($lowerurl);
my $link=&mt('Continue on in Inline Menu mode',
- "/adm/remote?action=collapse?url=$esclowerurl");
+ "/adm/remote?action=collapse&url=$esclowerurl");
return(<
';
}
} else {
# Inline Menu
- $inlineremote[10*$row+$col]=
- ''.$pic.
- ''.$desc.'';
+ if ($env{'environment.icons'} eq 'iconsonly') {
+ $inlineremote[$idx]=''.$pic.'';
+ } else {
+ $inlineremote[$idx]=
+ ''.$pic.
+ ''.$desc.'';
+ }
}
}
return '';
@@ -866,19 +965,19 @@ sub switch {
sub secondlevel {
my $output='';
my
- ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
+ ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
if ($prt eq 'any') {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
} elsif ($prt=~/^r(\w+)/) {
if ($rol eq $1) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
}
return $output;
}
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();
@@ -886,10 +985,32 @@ sub openmenu {
}
sub inlinemenu {
- @inlineremote=();
- undef @inlineremote;
+ undef(@inlineremote);
+ undef(%category_members);
&rawconfig(1);
- return join('',map { (defined($_)?$_:'') } @inlineremote);
+ my $output='
';
+ for (my $col=1; $col<=2; $col++) {
+ $output.='
';
+ for (my $row=1; $row<=8; $row++) {
+ foreach my $cat (keys(%category_members)) {
+ if ($category_positions{$cat} ne "$col,$row") { next; }
+ $output.='
'.&mt($category_names{$cat}).'
';
+ my %active=();
+ foreach my $menu_item (split(/\:/,$category_members{$cat})) {
+ if ($inlineremote[$menu_item]) {
+ $active{$menu_item}=1;
+ }
+ }
+ foreach my $item (sort(keys(%active))) {
+ $output.=$inlineremote[$item];
+ }
+ $output.='
';
+ }
+ }
+ $output.="
";
+ }
+ $output.="
";
+ return $output;
}
sub rawconfig {
@@ -906,6 +1027,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'}) {
@@ -919,39 +1041,54 @@ sub rawconfig {
my $con=($env{'request.state'} eq 'construct');
my $rol=$env{'request.role'};
my $requested_domain = $env{'request.role.domain'};
- foreach (@desklines) {
- my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
+ foreach my $line (@desklines) {
+ my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
$prt=~s/\$uname/$uname/g;
$prt=~s/\$udom/$udom/g;
$prt=~s/\$crs/$crs/g;
$prt=~s/\$requested_domain/$requested_domain/g;
+ if ($category_names{$cat}!~/\w/) { $cat='oth'; }
+ my $type = &Apache::loncommon::course_type();
+ if ($type eq 'Group') {
+ $desc = &convert_menu_function($desc,$type);
+ }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
} elsif ($pro eq 'smp') {
unless ($adv) {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro eq 'adv') {
if ($adv) {
$output.=&secondlevel(
- $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
+ $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);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro eq 'course') {
if ($env{'request.course.fn'}) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro =~ /^courseenv_(.*)$/) {
my $key = $1;
if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro =~ /^course_(.*)$/) {
# Check for permissions inside of a course
@@ -959,18 +1096,19 @@ sub rawconfig {
(&Apache::lonnet::allowed($1,$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
)) {
- $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} 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'}=~/(\w+)\/(\w+)$/);
+ ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
}
$act =~ s/\$caname/$caname/g;
my $home = &Apache::lonnet::homeserver($caname,$cadom);
@@ -978,8 +1116,8 @@ sub rawconfig {
my @ids=&Apache::lonnet::current_machine_ids();
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if ($allowed) {
- $output.=switch($caname,$cadom,
- $row,$col,$img,$top,$bot,$act,$desc);
+ $output.=&switch($caname,$cadom,
+ $row,$col,$img,$top,$bot,$act,$desc,$cat);
}
}
}
@@ -1001,7 +1139,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';
@@ -1045,7 +1183,7 @@ sub utilityfunctions {
unless (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
- $currenturl=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($currenturl));
+ $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
my $nav_control=&nav_control_js();
@@ -1058,13 +1196,16 @@ sub utilityfunctions {
'add_entries' => {
'onload' => 'javascript:document.goannotate.submit();'}});
+ my $end_page_annotate =
+ &Apache::loncommon::end_page({'js_ready' => 1});
+
my $start_page_bookmark =
&Apache::loncommon::start_page('Bookmarks',undef,
{'only_body' => 1,
'js_ready' => 1,
'bgcolor' => '#BBBBBB',});
- my $end_page =
+ my $end_page_bookmark =
&Apache::loncommon::end_page({'js_ready' => 1});
return (<"
- +""
+ +""
+"<\\/form>"
- +'$end_page');
+ +'$end_page_annotate');
annotator.document.close();
}
@@ -1206,7 +1347,7 @@ function set_bookmark() {
+"value='Save' /> <\\/center><\\/td>"
+"<\\/tr><\\/table><\\/form><\\/center>"
- +'$end_page' );
+ +'$end_page_bookmark' );
bmquery.document.close();
}
@@ -1253,6 +1394,246 @@ sub get_nav_status {
return $navstatus;
}
+#FIXME this needs to move into mydesktab and the other locations
+# the text is generated
+sub convert_menu_function {
+ my ($rolename,$type) = @_;
+ if ($type eq 'Group') {
+ $rolename =~ s/student/member/g;
+ $rolename =~ s/group/team/g;
+ $rolename =~ s/course/group/g;
+ $rolename =~ s/Course/Group/g;
+ }
+ return $rolename;
+}
+
+sub hidden_button_check {
+ my $hidden;
+ if ($env{'request.course.id'} eq '') {
+ return;
+ }
+ if ($env{'request.role.adv'}) {
+ return;
+ }
+ 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 {
@@ -1264,7 +1645,11 @@ BEGIN {
$configline=(split(/\#/,$configline))[0];
$configline=~s/^\s+//;
chomp($configline);
- if ($configline) {
+ if ($configline=~/^cat\:/) {
+ my @entries=split(/\:/,$configline);
+ $category_positions{$entries[2]}=$entries[1];
+ $category_names{$entries[2]}=$entries[3];
+ } elsif ($configline) {
push(@desklines,$configline);
}
}