--- loncom/interface/lonmenu.pm 2009/10/15 21:02:13 1.288 +++ loncom/interface/lonmenu.pm 2010/01/15 04:12:54 1.309.2.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.288 2009/10/15 21:02:13 raeburn Exp $ +# $Id: lonmenu.pm,v 1.309.2.12 2010/01/15 04:12:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -131,27 +131,27 @@ use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; +use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); use vars qw(@desklines %category_names %category_members %category_positions $readdesk @primary_menu @secondary_menu); - my @inlineremote; sub prep_menuitem { - my $menuitem = shift; - return '' unless ref $menuitem eq 'ARRAY'; + my ($menuitem) = @_; + return '' unless(ref($menuitem) eq 'ARRAY'); my $link; if ($$menuitem[1]) { # graphical Link $link = "\"""; + . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" + . " alt=\"" . &mt($$menuitem[2]) . "\" />"; } else { # textual Link - $link = mt($$menuitem[3]); - } - return "
  • $link
  • "; + $link = &mt($$menuitem[3]); + } + return '
  • '.$link.'
  • '; } # primary_menu() evaluates @primary_menu and returns XHTML for the menu @@ -161,34 +161,42 @@ sub prep_menuitem { # entries from mydesk.tab sub primary_menu { my $menu; + my $custommenu = &Apache::loncommon::needs_gci_custom(); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition) foreach my $menuitem (@primary_menu) { # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; # next if $$menuitem[4] eq 'nonewmsg' # show links depending on - && Apache::lonmsg::mynewmail(); # whether a new msg + && &Apache::lonmsg::mynewmail(); # whether a new msg next if $$menuitem[4] eq 'newmsg' # arrived or not - && !Apache::lonmsg::mynewmail(); # + && !&Apache::lonmsg::mynewmail(); # next if $$menuitem[4] !~ /public/ ##we've a public user, && $env{'user.name'} eq 'public' ##who should not see all && $env{'user.domain'} eq 'public'; ##links next if $$menuitem[4] eq 'onlypublic'# hide links which are && $env{'user.name'} ne 'public' # only visible to public && $env{'user.domain'} ne 'public'; # users + next if $$menuitem[4] eq 'roles' # hide links which are + && $custommenu; # not visible when GCI + next if $$menuitem[4] eq 'courses' # tabbed interface in use + && $custommenu; # next if $$menuitem[4] eq 'roles' ##show links depending on - && Apache::loncommon::show_course(); ##term 'Courses' or + && &Apache::loncommon::show_course(); ##term 'Courses' or next if $$menuitem[4] eq 'courses' ##'Roles' wanted - && !Apache::loncommon::show_course(); ## - - + && !&Apache::loncommon::show_course(); ## + + if ($$menuitem[3] eq 'Help') { # special treatment for helplink - $menu .= '
  • '.Apache::loncommon::top_nav_help('Help').'
  • '; + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } else { - $menu .= prep_menuitem(\@$menuitem); + my @items = @{$menuitem}; + $items[0] = 'javascript:'.$menuitem->[0].';'; + $menu .= &prep_menuitem(\@items); } - } + } - return "
      $menu
    "; + return "
      $menu
    "; } @@ -207,6 +215,7 @@ sub secondary_menu { $env{'course.' . $env{'request.course.id'} . '.num'}); foreach my $menuitem (@secondary_menu) { # evaluate conditions + next if ref($menuitem) ne 'ARRAY'; next if $$menuitem[4] ne 'always' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' @@ -222,28 +231,41 @@ sub secondary_menu { && $env{'environment.remotenavmap'} ne 'on'; next if $$menuitem[4] =~ /noremotenav/ && $env{'environment.remotenavmap'} eq 'on'; + next if $$menuitem[4] =~ /^(no|)remotenav$/ + && $crstype eq 'Community'; + next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ + && $crstype ne 'Community'; next if $$menuitem[4] =~ /showgroups$/ - && $canviewgrps + && !$canviewgrps && !%groups; if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { # special treatment for role selector - my $roles_selector = roles_selector( + my $roles_selector = &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'} ); $menu .= $roles_selector ? "
  • $roles_selector
  • " : ''; + } elsif ($env{'environment.remotenavmap'} eq 'on') { + # open link using javascript when remote navmap is activated + my @items = @{$menuitem}; + if ($menuitem->[4] eq 'remotenav') { + $items[0] = "javascript:gonav('$menuitem->[0]');"; + } else { + $items[0] = "javascript:go('$menuitem->[0]');"; + } + $menu .= &prep_menuitem(\@items); } else { - $menu .= prep_menuitem(\@$menuitem); + $menu .= &prep_menuitem(\@$menuitem); } } if ($menu =~ /\[url\].*\[symb\]/) { - 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'})); if ( $env{'request.state'} eq 'construct' and ( $env{'request.noversionuri'} eq '' @@ -252,7 +274,7 @@ sub secondary_menu { ($escurl = $env{'request.filename'}) =~ s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2}; - $escurl = escape($escurl); + $escurl = &escape($escurl); } $menu =~ s/\[url\]/$escurl/g; $menu =~ s/\[symb\]/$escsymb/g; @@ -261,6 +283,45 @@ sub secondary_menu { return ""; } +sub gci_secondary_menu { + my %courses = ( + 'review' => 'gci_9615072b469884921gcil1', + 'submit' => 'gci_1H96711d710194bfegcil1', + ); + my %linktext = ( + 'review' => 'Review Questions', + 'submit' => 'Submit Questions', + 'managetest' => 'Manage Tests', + ); + my %links = ( + 'managetest' => '/adm/menu', + ); + my $current = 'managetest'; + if ($env{'form.destinationurl'} eq '/adm/gci_info') { + undef($current); + } + foreach my $key (keys(%courses)) { + $links{$key} = "javascript:switchpage('$key');"; + if ($env{'request.course.id'} eq $courses{$key}) { + $links{$key} = '/adm/navmaps'; + $current = $key; + $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; + } + } + my @menutabs = ('review','submit','managetest'); + my $tabs; + foreach my $item (@menutabs) { + if ($item eq $current) { + $tabs .= '
  • '. + $linktext{$item}.'
  • '; + } else { + $tabs .= '
  • '. + $linktext{$item}.'
  • '; + } + } + return '
    '. + '

    '; +} # # This routine returns a translated hash for the menu items in the top inline menu row @@ -354,7 +415,7 @@ sub menubuttons { my %lt=&initlittle(); my $domain=&Apache::loncommon::determinedomain(); - my $function =&Apache::loncommon::get_users_function(); + my $function=&Apache::loncommon::get_users_function(); my $link=&Apache::loncommon::designparm($function.'.link',$domain); my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); @@ -415,7 +476,7 @@ ENDCRELOAD my $utility = &utilityfunctions(); #Prepare the message link that indicates the arrival of new mail - my $messagelink = Apache::lonmsg::mynewmail() ? "Message (new)" : "Message"; + my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message"; $messagelink = '' . mt($messagelink) .''; @@ -496,7 +557,7 @@ sub registerurl { } sub innerregister { - my ($forcereg, $titletable) = @_; + my ($forcereg,$titletable,$bread_crumbs) = @_; my $result = ''; my ($uname,$thisdisfn); my $const_space = ($env{'request.state'} eq 'construct'); @@ -529,10 +590,19 @@ sub innerregister { my $maptitle = &Apache::lonnet::gettitle($mapurl); my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - my @crumbs = ({text => "Course Content", - href => "Javascript:gonav('/adm/navmaps')"}, - {text => '...', - no_mt => 1}); + my $contentstext; + if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') { + $contentstext = &mt('Community Contents'); + } else { + $contentstext = &mt('Course Contents'); + } + my @crumbs = ({text => $contentstext, + href => "Javascript:gonav('/adm/navmaps')"}); + + if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { + push(@crumbs, {text => '...', + no_mt => 1}); + } push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle && $maptitle ne 'default.sequence' @@ -540,9 +610,9 @@ sub innerregister { push @crumbs, {text => $restitle, no_mt => 1} if $restitle; - Apache::lonhtmlcommon::clear_breadcrumbs(); - Apache::lonhtmlcommon::add_breadcrumb(@crumbs); - $breadcrumb .= Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); + #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); unless (($env{'request.state'} eq 'edit') || ($newmail) || ($env{'request.state'} eq 'construct') || ($env{'form.register'})) { @@ -558,7 +628,7 @@ sub innerregister { my $tableend = ( $noremote ? '' : ''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) { + if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { # -- This applies to homework problems for users with grading privileges my $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { @@ -664,10 +734,22 @@ sub innerregister { } # Finally, turn the button on or off if ($cfile && !$const_space) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', + my $nocrsedit; + # Suppress display where CC has switched to student role. + if ($env{'request.course.id'}) { + unless(&Apache::lonnet::allowed('mdc', + $env{'request.course.id'})) { + $nocrsedit = 1; + } + } + if ($nocrsedit) { + $editbutton=&clear(6,1); + } else { + $editbutton=&switch + ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; + $noeditbutton = 0; + } } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } @@ -716,6 +798,14 @@ s&7&1&del.gif&delete[_1]&resource[_2]&go s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document ENDMENUITEMS } + if ($noremote) { + if (ref($bread_crumbs) eq 'ARRAY') { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + foreach my $crumb (@{$bread_crumbs}){ + &Apache::lonhtmlcommon::add_breadcrumb($crumb); + } + } + } } elsif ( defined($env{'request.course.id'}) && $env{'request.symb'} ne '' ) { # @@ -753,7 +843,7 @@ $menuitems.="Make notes and annotations } } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { - if (!$env{'request.enc'}) { + if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $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] -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 - } - } - } - } - } + if ($addremote) { + + #SD START (work in progress!) + Apache::lonhtmlcommon::clear_breadcrumb_tools(); + # Arrows for navigation + Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] ); + Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] ); + if(hidden_button_check() ne 'yes'){ + # notes + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]); + # bookmark + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]); + # evaluate + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]); + # feedback + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]); + # print + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]); + # metadata + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]); + + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]); + + } + + #SD END +# # Registered, textual output +# if ( $env{'environment.icons'} eq 'iconsonly' ) { +# $inlinebuttons = (< +#$inlineremote[21] $inlineremote[23] +#ENDARROWSINLINE +# if ( &hidden_button_check() ne 'yes' ) { +# $inlinebuttons .= (< +#ENDINLINEICONS +# } +# } else { # not iconsonly +# if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) { +# $inlinebuttons = (<$inlineremote[21] $inlineremote[23] +#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 +# } +# } +# } +# } + } + #SD see below + $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); $result =(< // BEGIN LON-CAPA Internal $timesync $breadcrumb -$tablestart -$inlinebuttons -$tableend + + + $newmail -$separator + @@ -1194,7 +1321,7 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />'; if ($env{'browser.interface'} eq 'faketextual') { # Main Menu if ($nobreak==3) { @@ -1220,7 +1347,7 @@ sub switch { $inlineremote[$idx]=''.$pic.''; } else { $inlineremote[$idx]= - ''.$pic. + ''.$pic. ''.$desc.''; } } @@ -1250,36 +1377,91 @@ sub openmenu { } sub inlinemenu { + my ($context,$switcher) = @_; undef(@inlineremote); undef(%category_members); -# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control - &rawconfig(1); - my $output=''; - for (my $col=1; $col<=2; $col++) { - $output.=''; + } + } else { + $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.='

    '.&mt($category_names{$cat}).'

    '; - $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.=''; + my $output; + if (($context eq 'gcicustom') || ($context eq 'gcistudent') || + ($context eq 'gcinorole')) { + $output=''. + ''. + ''; + } else { + my $navtext = &mt('Table of Contents'); + if ($env{'request.role.domain'} eq 'gcitest') { + $navtext = &mt('Display Test Contents'); + } + $output .= '
    '. + '
    '. + '

    '.&mt('Utilities').'

    '. + ''; + if ($context eq 'gcicustom') { + my $createtext = &mt('Create Concept Test'); + if ($switcher) { + $createtext = &mt('Create New Test'); } - } - $output.=""; + $output .= ''; + } + if ($switcher) { + $output .= ''; + } + $output .= ''. +''; + if ($env{'request.course.id'}) { + if (($context eq 'gcicustom') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + $output.= '
    choose role'.$createtext.'
    choose role'.$switcher.'
    communication'.&mt('Send/Display Messages').'
    user preferences'.&mt('Set my user preferences').'
    '. + '
    course contents'.$navtext.'
    '; + } + if ($context eq 'gcinorole') { + my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle'); + if ($queued) { + $output .= ''. + '
    '. + '

    '.&mt('Pending Enrollment Requests').'

    '. + $queued. + '
    '; + } + } + $output.=''; + } else { + # calling rawconfig with "1" will evaluate mydesk.tab, + # even if there is no active remote control + &rawconfig(1); + $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.='

    '.&mt($category_names{$cat}).'

    '; + $output.=''; + 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.="
    "; } - $output.=""; return $output; } @@ -1304,12 +1486,14 @@ sub rawconfig { my $show_course=&Apache::loncommon::show_course(); my $author=$env{'user.author'}; my $crs=''; + my $crstype=''; if ($env{'request.course.id'}) { $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; + $crstype = &Apache::loncommon::course_type(); } my $pub=($env{'request.state'} eq 'published'); my $con=($env{'request.state'} eq 'construct'); @@ -1319,10 +1503,17 @@ sub rawconfig { 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; + if ($prt =~ /\$crs/) { + next unless ($env{'request.course.id'}); + next if ($crstype eq 'Community'); + $prt=~s/\$crs/$crs/g; + } elsif ($prt =~ /\$cmty/) { + next unless ($env{'request.course.id'}); + next if ($crstype ne 'Community'); + $prt=~s/\$cmty/$crs/g; + } $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } - my $type = &Apache::loncommon::course_type(); if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1349,26 +1540,69 @@ sub rawconfig { $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)) { + my $priv = $1; + if ($priv =~ /^mdc(Course|Community)/) { + if ($crstype eq $1) { + $priv = 'mdc'; + } else { + next; + } + } + if (&Apache::lonnet::allowed($priv,$prt)) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } - } elsif ($pro eq 'course') { - if ($env{'request.course.fn'}) { + } elsif ($pro eq 'course') { + if (($env{'request.course.fn'}) && ($crstype ne 'Community')) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro eq 'community') { + if (($env{'request.course.fn'}) && ($crstype eq 'Community')) { + $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,$cat); + if ($crstype ne 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } + } + } elsif ($pro =~ /^communityenv_(.*)$/) { + my $key = $1; + if ($crstype eq 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course - if (($env{'request.course.id'}) && + if (($env{'request.course.id'}) && ($crstype ne 'Community') && (&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,$cat); } + } elsif ($pro =~ /^community_(.*)$/) { + # Check for permissions inside of a community + if (($env{'request.course.id'}) && ($crstype eq 'Community') && + (&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,$cat); + } } elsif ($pro eq 'author') { if ($author) { if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) || @@ -1496,18 +1730,95 @@ function gonav(url) { NAVCONTROL } +sub dc_popup_js { + my %lt = &Apache::lonlocal::texthash( + more => '(More ...)', + less => '(Less ...)', + ); + return <<"END"; + +function showCourseID() { + document.getElementById('dccid').style.display='block'; + document.getElementById('dccid').style.textAlign='left'; + document.getElementById('dccid').style.textFace='normal'; + document.getElementById('dccidtext').innerHTML ='$lt{'less'}'; + return; +} + +function hideCourseID() { + document.getElementById('dccid').style.display='none'; + document.getElementById('dccidtext').innerHTML ='$lt{'more'}'; + return; +} + +END + +} + sub utilityfunctions { - my $caller = shift; + my ($caller,$custommenu) = @_; unless ($env{'environment.remote'} eq 'off' || $caller eq '/adm/menu') { return ''; } - + + my $gcimenujs; + if ($custommenu) { + my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc'); + my $managetesturl = '/adm/menu'; + my $createtesturl = '/adm/requestcourse'; + if (($env{'request.course.id'}) && + ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) { + my @items = keys(%concepttests); + if (@items== 1) { + my $newrole = $items[0]; + $newrole =~ s{_}{/}; + $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1'; + } else { + $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; + } + } + if ($env{'request.course.id'}) { + $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse'; + } + $gcimenujs = <<"ENDCUSTOM"; + +function switchpage(caller) { + if (caller == 'review') { + document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1'; + } + if (caller == 'submit') { + document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1'; + } + if (caller == 'createtest') { + document.location.href = '$createtesturl'; + } + if (caller == 'managetest') { + document.location.href = '$managetesturl'; + } + return; +} + +ENDCUSTOM + } + my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); + if ($currenturl =~ m{^/adm/wrapper/ext/}) { + if ($env{'request.external.querystring'}) { + $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; + } + } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); my $nav_control=&nav_control_js(); + my $dc_popup_cid; + if ($env{'user.adv'} && exists($env{'user.role.dc./'. + $env{'course.'.$env{'request.course.id'}. + '.domain'}.'/'})) { + $dc_popup_cid = &dc_popup_js(); + } + my $start_page_annotate = &Apache::loncommon::start_page('Annotator',undef, {'only_body' => 1, @@ -1535,6 +1846,9 @@ return (< 1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= '
    @@ -1795,7 +2120,7 @@ sub roles_selector { $role_selector .= ''; foreach my $role (@roles_order) { if (defined($courseroles{$role})) { - $role_selector .= "\n".''; + $role_selector .= "\n".''; } } foreach my $role (sort(keys(%courseroles))) {