Diff for /loncom/interface/lonmenu.pm between versions 1.532 and 1.551

version 1.532, 2023/06/11 20:45:35 version 1.551, 2024/05/01 22:08:11
Line 210  use Apache::lonenc(); Line 210  use Apache::lonenc();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonmsg();  use Apache::lonmsg();
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
 use LONCAPA::ltiutils;  
 use HTML::Entities();  use HTML::Entities();
 use Apache::lonwishlist();  use Apache::lonwishlist();
   
Line 246  sub prep_menuitem { Line 245  sub prep_menuitem {
 # @primary_menu is filled within the BEGIN block of this module with   # @primary_menu is filled within the BEGIN block of this module with 
 # entries from mydesk.tab  # entries from mydesk.tab
 sub primary_menu {  sub primary_menu {
     my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target) = @_;      my ($crstype,$ltimenu,$menucoll,$menuref,$links_disabled,$links_target,$collapsible) = @_;
     my (%menu,%ltiexc,%menuopts);      my (%menu,%ltiexc,%menuopts);
     # each element of @primary contains following array:      # each element of @primary contains following array:
     # (link url, icon path, alt text, link text, condition, position)      # (link url, icon path, alt text, link text, condition, position)
Line 367  sub primary_menu { Line 366  sub primary_menu {
                              ($item->[2] eq 'blog')) &&                               ($item->[2] eq 'blog')) &&
                              (!&Apache::lonnet::usertools_access('','',$item->[2],                               (!&Apache::lonnet::usertools_access('','',$item->[2],
                                                            undef,'tools')));                                                             undef,'tools')));
                       if (($item->[2] eq 'browsepub') && ($item->[0] eq '/res/')) {
                           if ($env{'request.role'} =~ /^au\./) {
                               $item->[0] .= $env{'request.role.domain'}.'/?launch=1';
                           } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)$}) {
                               $item->[0] .= $1.'/'.$2.'/?launch=1';
                           } elsif (&Apache::lonnet::allowed('bre',$env{'user.domain'})) {
                               $item->[0] .= $env{'user.domain'}.'/?launch=1';
                           } elsif (&Apache::lonnet::allowed('bro','/res/')) {
                               $item->[0] .= '?launch=1';
                           } else {
                               next;
                           }
                       }
                     if ($env{'request.course.id'} && $menucoll) {                      if ($env{'request.course.id'} && $menucoll) {
                         next if ($item->[3]) && (!$menuopts{$item->[3]});                          next if ($item->[3]) && (!$menuopts{$item->[3]});
                     }                      }
Line 422  sub primary_menu { Line 434  sub primary_menu {
     }      }
     my @output = ('','');      my @output = ('','');
     if ($menu{'left'} ne '') {      if ($menu{'left'} ne '') {
           if ($collapsible) {
               $menu{'left'} = ($listclass?'<li class="'.$listclass.'">':'<li>').
                               '&nbsp;</li>'.$menu{'left'};
           }
         $output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>";          $output[0] = "<ol class=\"LC_primary_menu LC_floatleft\">$menu{'left'}</ol>";
     }      }
     if ($menu{'right'} ne '') {      if ($menu{'right'} ne '') {
Line 437  sub primary_menu { Line 453  sub primary_menu {
 #  #
 #TODO this should probably be moved somewhere more central  #TODO this should probably be moved somewhere more central
 #since it can be used by different parts of the system  #since it can be used by different parts of the system
 sub getauthor{  sub getauthor {
     return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author      return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
   
                         #co- or assistent author?                          #co- or assistant author?
     my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)      my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
                        ? ($1, $2) #domain, username of the parent author                         ? ($1, $2) #domain, username of the parent author
                        : @env{ ('request.role.domain', 'user.name') }; #own domain, username                         : @env{ ('request.role.domain', 'user.name') }; #own domain, username
Line 481  sub secondary_menu { Line 497  sub secondary_menu {
     my $canplc        = &Apache::lonnet::allowed('plc', $crs_sec);      my $canplc        = &Apache::lonnet::allowed('plc', $crs_sec);
     my $author        = &getauthor();      my $author        = &getauthor();
   
       my ($is_author,$is_coauthor);
       if ($author) {
           if ($env{'request.role'} =~ /^au\./) {
               $is_author = 1;
           } elsif ($env{'request.role'} =~ /^ca\./) {
               $is_coauthor = 1;
           }
       }
   
     my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,      my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,
         $lti,$ltimapres,%ltiexc,%menuopts);          $lti,$ltimapres,%ltiexc,%menuopts);
     $grouptools = 0;      $grouptools = 0;
Line 540  sub secondary_menu { Line 565  sub secondary_menu {
         $linkattr = 'aria-disabled="true"';          $linkattr = 'aria-disabled="true"';
     }      }
   
     my ($canmodifycoauthor);       my ($canlistcoauthors,$canmodifycoauthor);
     if ($env{'request.role'} eq "au./$env{'user.domain'}/") {      if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
         my $extent = "$env{'user.domain'}/$env{'user.name'}";          my $extent = "$env{'user.domain'}/$env{'user.name'}";
         if ((&Apache::lonnet::allowed('cca',$extent)) ||          if ((&Apache::lonnet::allowed('cca',$extent)) ||
             (&Apache::lonnet::allowed('caa',$extent))) {              (&Apache::lonnet::allowed('caa',$extent))) {
             $canmodifycoauthor = 1;              $canmodifycoauthor = 1;
         }          }
       } elsif ($env{'request.role'} =~ m{^(aa|ca)\./($match_domain/$match_username)$}) {
           my ($role,$extent) = ($1,$2);
           if (&Apache::lonnet::allowed('vca',$extent)) {
               if ($env{"environment.internal.manager./$extent"}) {
                   $canmodifycoauthor = 1;
               } else {
                   $canlistcoauthors = 1;
               }
           } elsif (&Apache::lonnet::allowed('vaa',$extent)) {
               $canlistcoauthors = 1;
           }
     }      }
   
     my ($roleswitcher_js,$roleswitcher_form);      my ($roleswitcher_js,$roleswitcher_form);
     if ($links_target ne '') {      if ($links_target ne '') {
         $target = $links_target;          $target = $links_target;
Line 571  sub secondary_menu { Line 606  sub secondary_menu {
         # evaluate conditions           # evaluate conditions 
         next if    ref($menuitem)  ne 'ARRAY';          next if    ref($menuitem)  ne 'ARRAY';
         next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));          next if (($crstype eq 'Placement') && ($$menuitem[3] ne 'Roles') && (!$env{'request.role.adv'}));
         next if    $$menuitem[4]   ne 'always'          next if    $$menuitem[4]  ne 'always'
                 && ($$menuitem[4]   ne 'author' && $$menuitem[4] ne 'cca')                  && $$menuitem[4]  ne 'coauthor'
                   && $$menuitem[4]  ne 'author'
                   && $$menuitem[4]  ne 'authorspace'
                   && $$menuitem[4]  ne 'vca'
                   && $$menuitem[4]  ne 'mca'
                 && !$env{'request.course.id'};                  && !$env{'request.course.id'};
         next if    $$menuitem[4]   =~ /^crsedit/          next if    $$menuitem[4]   =~ /^crsedit/
                 && (!$canedit && !$canvieweditor);                  && (!$canedit && !$canvieweditor);
Line 600  sub secondary_menu { Line 639  sub secondary_menu {
                 && !$showfeeds;                  && !$showfeeds;
         next if     $$menuitem[4]  eq 'plc'          next if     $$menuitem[4]  eq 'plc'
                 && !$canplc;                  && !$canplc;
         next if    $$menuitem[4]    eq 'author'          next if    $$menuitem[4]   eq 'authorspace'
                 && !$author;                  && !$author;
         next if    $$menuitem[4]    eq 'cca'          next if    $$menuitem[4]   eq 'author'
                   && !$is_author;
           next if    $$menuitem[4]   eq 'coauthor'
                   && !$is_coauthor;
           next if    $$menuitem[4]    eq 'vca'
                   && (!$canlistcoauthors || $canmodifycoauthor);
           next if    $$menuitem[4]    eq 'vaa'
                   && (!$canlistcoauthors || $canmodifycoauthor);
           next if    $$menuitem[4]    eq 'mca'
                 && !$canmodifycoauthor;                  && !$canmodifycoauthor;
         next if    $$menuitem[4]    eq 'notltimapres'          next if    $$menuitem[4]    eq 'notltimapres'
                 && $ltimapres;                  && $ltimapres;
Line 638  sub secondary_menu { Line 685  sub secondary_menu {
                         next if ($item->[2] eq 'vcg' && !$canviewgrps);                          next if ($item->[2] eq 'vcg' && !$canviewgrps);
                         next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);                          next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor);
                         next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);                          next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara);
                         next if ($item->[2] eq 'author' && !$author);                          next if ($item->[2] eq 'author' && !$is_author);
                         next if ($item->[2] eq 'cca' && !$canmodifycoauthor);                          next if ($item->[2] eq 'vca' && !$canlistcoauthors);
                         next if ($item->[2] eq 'lti' && !$lti);                          next if ($item->[2] eq 'lti' && !$lti);
                         if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {                          if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) {
                             my $tool = $1;                              my $tool = $1;
Line 725  sub secondary_menu { Line 772  sub secondary_menu {
         }          }
         $menu =~ s/\[url\]/$escurl/g;          $menu =~ s/\[url\]/$escurl/g;
         $menu =~ s/\[symb\]/$escsymb/g;          $menu =~ s/\[symb\]/$escsymb/g;
       } elsif (($menu =~ m{/adm/preferences\?}) && ($menu =~ /\[returnurl\]/)) {
           my $returnurl = $ENV{'REQUEST_URI'};
           if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=authorsettings\&returnurl=([^\&]+)$}) {
               $returnurl = $1;
           }
           if (($returnurl =~ m{^/adm/createuser($|\?action=)}) ||
               ($returnurl =~ m{^/priv/$match_domain/$match_username}) ||
               ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) {
               $returnurl =~ s{\?.*$}{};
               $returnurl = '&amp;returnurl='.&HTML::Entities::encode($returnurl,'"<>&\'');
           } else {
               undef($returnurl);
           }
           $menu =~ s/\[returnurl\]/$returnurl/;
     }      }
     $menu =~ s/\[uname\]/$$author{user}/g;      $menu =~ s/\[uname\]/$$author{user}/g;
     $menu =~ s/\[udom\]/$$author{dom}/g;      $menu =~ s/\[udom\]/$$author{dom}/g;
Line 849  sub innerregister { Line 910  sub innerregister {
     my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,      my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,
         $ltiscope,$ltiuri,$showncrumbsref) = @_;          $ltiscope,$ltiuri,$showncrumbsref) = @_;
     my $const_space = ($env{'request.state'} eq 'construct');      my $const_space = ($env{'request.state'} eq 'construct');
     my $is_const_dir = 0;      my $in_daxe = 0;
   
     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }      if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
   
Line 969  sub innerregister { Line 1030  sub innerregister {
                     $$showncrumbsref = 1;                      $$showncrumbsref = 1;
                 }                  }
                 return $trail;                  return $trail;
               } elsif (($resurl eq '/public'.$courseurl.'/syllabus') &&
                        ($env{'form.folderpath'})) {
                   if ($env{'form.title'}) {
                       $title = $env{'form.title'};
                   } else {
                       $title = 'Syllabus';
                   }
                   &prepare_functions($resurl,$forcereg,$group,undef,undef,1,$hostname);
                   $title = &HTML::Entities::encode($title,'\'"<>&');
                   my ($trail) =
                       &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1,1);
                   return $trail;
             }              }
             unless ($env{'request.state'} eq 'construct') {              unless ($env{'request.state'} eq 'construct') {
                 &Apache::lonhtmlcommon::clear_breadcrumbs();                  &Apache::lonhtmlcommon::clear_breadcrumbs();
Line 1070  sub innerregister { Line 1143  sub innerregister {
         if (($env{'request.symb'} ne '') &&          if (($env{'request.symb'} ne '') &&
             ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&              ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
             (($perms{'mgr'}) || ($perms{'vgr'}))) {              (($perms{'mgr'}) || ($perms{'vgr'}))) {
             my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom,$righticon);              my ($viewas,$text,$change,$visibility,$vuname,$vudom,$vid,$leftvis,$defdom,
                   $domselector,$righticon);
             my %lt = &Apache::lonlocal::texthash(              my %lt = &Apache::lonlocal::texthash(
                                                  view => 'View',                                                   view => 'View',
                                                  upda => 'Update',                                                   upda => 'Update',
             );              );
               my $possdomstr = $env{'course.'.$env{'request.course.id'}.'.internal.userdomains'};
               if ($possdomstr =~ /,/) {
                   my @possdoms = split(/,/,$possdomstr);
                   if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
                       $defdom = $1;
                   } elsif (grep(/^\Q$cdom\E$/,@possdoms)) {
                       $defdom = $cdom;
                   } elsif (&Apache::lonnet::domain($possdoms[0]) ne '') {
                       $defdom = $possdoms[0];
                   }
                   $domselector = &Apache::loncommon::select_dom_form($defdom,'vudom','','','',\@possdoms);
               } elsif (($possdomstr ne '') && (&Apache::lonnet::domain($possdomstr) ne '')) {
                   if ($env{'request.user_in_effect'} =~ /^$match_username:($match_domain)$/) {
                       $defdom = $1;
                   } else {
                       $defdom = $possdomstr;
                   }
               }
             if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) {              if ($env{'request.user_in_effect'} =~ /^($match_username):($match_domain)$/) {
                 ($vuname,$vudom) = ($1,$2);                  ($vuname,$vudom) = ($1,$2);
                 unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) {                  unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) {
Line 1092  sub innerregister { Line 1184  sub innerregister {
                 $change = 'on';                  $change = 'on';
                 $visibility = 'none';                  $visibility = 'none';
                 $leftvis = 'inline';                  $leftvis = 'inline';
                 $defdom = $cdom;                  if ($defdom eq '') {
                       $defdom = $cdom;
                   }
             }              }
             my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom');              my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier');
             my $selscript=&Apache::loncommon::studentbrowser_javascript();              my $selscript=&Apache::loncommon::studentbrowser_javascript();
             my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"');              my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"');
             my $input = &mt('User: [_1] or ID: [_2] at: [_3]',              my $input;
                             '<input name="vuname" type="text" size="8" value="'.$vuname.'" />',              my @items = (
                             '<input name="vid" type="text" size="8" value="'.$vid.'" />',                           '<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />',
                             &Apache::loncommon::select_dom_form($defdom,'vudom')).                           '</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />',
                             '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',                           '<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />',
                             '<input name="symb" type="hidden" value="'.$shownsymb.'" />';                           '</label><input name="vid" type="hidden" size="6" value="'.$vid.'" id="LC_vid" />'
                           );
               if ($domselector) {
                   push(@items,$domselector);
                   $input = &mt('[_1]User:[_2] or [_3]ID:[_4] at [_5] | ',@items);
               } else {
                   $input = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',@items).
                            '<input name="vudom" type="hidden" value="'.$defdom.'" />';
               }
               $input .= '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',
                         '<input name="symb" type="hidden" value="'.$shownsymb.'" />';
             my $chooser = <<END;              my $chooser = <<END;
 $selscript  $selscript
 <a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link">  <a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link">
Line 1131  END Line 1235  END
 # End course context  # End course context
   
 # Prepare the rest of the buttons  # Prepare the rest of the buttons
         my ($menuitems,$got_prt,$got_wishlist);      my ($menuitems,$got_prt,$got_wishlist,$crsauthor,$toplevel_cstr,$crsauthor_cstr);
         if ($const_space) {      if ($const_space) {
 #  #
 # We are in construction space  # We are in construction space
 #  #
Line 1140  END Line 1244  END
             my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};              my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
     my ($udom,$uname,$thisdisfn) =      my ($udom,$uname,$thisdisfn) =
  ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});   ($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
               if (($env{'request.course.id'}) &&
                   ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
                   ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
                   $crsauthor_cstr = 1;
               }
             my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;              my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
             if ($currdir =~ m-/$-) {              if ($currdir =~ m-/$-) {
                 $is_const_dir = 1;  
                 if ($thisdisfn eq '') {                  if ($thisdisfn eq '') {
                     unless (($env{'request.course.id'}) &&                       $toplevel_cstr = 1;
                             ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&  
                             ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {   
                         $is_const_dir = 2;  
                     }  
                 }                  }
                 my $esc_currdir = &Apache::loncommon::escape_single($currdir);                  my $esc_currdir = &Apache::loncommon::escape_single($currdir);
                 $menuitems=(<<ENDMENUITEMS);                  $menuitems=(<<ENDMENUITEMS);
Line 1171  ENDMENUITEMS Line 1275  ENDMENUITEMS
 #  #
 # Probably should be in mydesk.tab  # Probably should be in mydesk.tab
 #  #
                 $menuitems=(<<ENDMENUITEMS);                  if (($crsauthor_cstr) && ($pubfile eq "/res/$udom/$uname/default.rights")) {
                       $menuitems=(<<ENDMENUITEMS);
   s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
   s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
   ENDMENUITEMS
                   } else {
                       $menuitems=(<<ENDMENUITEMS);
 s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory  s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
 s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version  s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
 s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource  s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
 s&7&3&copy.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource  s&7&3&copy.png&Copy&resource[_4]&gocstr('/adm/cfile?action=copy','/priv/$udom/$uname/$cleandisfn')&Copy this resource
 ENDMENUITEMS  ENDMENUITEMS
                   }
 #  #
 # Rename and Delete only available if obsolete or unpublished  # Rename and Delete only available if obsolete or unpublished
 #  #
Line 1186  s&7&4&rename.png&Rename&resource[_5]&goc Line 1297  s&7&4&rename.png&Rename&resource[_5]&goc
 s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource  s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
 ENDMENUITEMS  ENDMENUITEMS
                 }                  }
                 $menuitems .= (<<ENDMENUITEMS);  #
   # Print only makes sense for certain mime types
   #
                   if ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm|tex)$/ || $thisdisfn=~/$LONCAPA::assess_re/) {
                       $menuitems .= (<<ENDMENUITEMS);
 s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document  s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
 ENDMENUITEMS  ENDMENUITEMS
                   }
   #
   # "Exit Daxe" in Functions menu when using Daxe
   #
                   if ((($env{'form.editmode'} eq 'daxe') &&
                        ($thisdisfn=~/\.(xml|html|htm|xhtml|xhtm)$/)) ||
                       (($env{'form.problemmode'} eq 'daxe') &&
                        ($thisdisfn=~/$LONCAPA::assess_re/))) {
                       my %editors = &Apache::loncommon::permitted_editors();
                       if ($editors{'daxe'}) {
                           my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
                           $in_daxe = 1;
                           $menuitems .= (<<ENDMENUITEMS);
   my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
   s&7&6&tolastloc.png&Exit Daxe&resource[_1]&go('$privfile')&Exit editing this resource
   ENDMENUITEMS
                       }
                   }
               }
   #
   # Editing options usually accessed via "Settings" in inline menu need to be
   # accessed in a different way, when Authoring Space is accessed in course
   # context
   #
               if ($env{'request.role'} !~/^(aa|ca|au)/) {
                   my $privfile = &Apache::loncommon::escape_single("/priv/$udom/$uname/$thisdisfn");
                   $menuitems .= (<<ENDMENUITEMS);
   s&7&5&editops.png&Options&edit[_1]&gocstr('/adm/preferences?action=authorsettings','$privfile')&Authoring Space Options
   ENDMENUITEMS
             }              }
                 if (ref($bread_crumbs) eq 'ARRAY') {                  if (ref($bread_crumbs) eq 'ARRAY') {
                     &Apache::lonhtmlcommon::clear_breadcrumbs();                      &Apache::lonhtmlcommon::clear_breadcrumbs();
Line 1262  ENDMENUITEMS Line 1406  ENDMENUITEMS
             $got_prt = 1;              $got_prt = 1;
             if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)              if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
                 && (!$env{'request.enc'})) {                  && (!$env{'request.enc'})) {
                 my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($env{'request.uri'});                  my $privurl = $env{'request.uri'};
                 unless ($cnum) {                  $privurl =~ s{^/res/}{/priv/};
                   my ($cnum,$cdom) = &Apache::loncommon::crsauthor_url($privurl);
                   if ($cnum) {
                       $crsauthor = 1;
                   } else {
                     # wishlist is only available for users with access to resource-pool                      # wishlist is only available for users with access to resource-pool
                     # and links can only be set for resources within the resource-pool                      # and links can only be set for resources within the resource-pool
                     $menuitems .= (<<ENDMENUITEMS);                      $menuitems .= (<<ENDMENUITEMS);
Line 1318  s&8&3&prt.png&Print&printout[_1]&gopost( Line 1466  s&8&3&prt.png&Print&printout[_1]&gopost(
 ENDMENUITEMS  ENDMENUITEMS
                 $got_prt = 1;                  $got_prt = 1;
             }              }
             unless ($got_wishlist) {              unless (($got_wishlist) || ($crsauthor)) {
                 if (($env{'user.adv'}) && (!$env{'request.enc'})) {                  if (($env{'user.adv'}) && (!$env{'request.enc'})) {
                     # wishlist is only available for users with access to resource-pool                      # wishlist is only available for users with access to resource-pool
                     $menuitems .= (<<ENDMENUITEMS);                      $menuitems .= (<<ENDMENUITEMS);
Line 1395  ENDMENUITEMS Line 1543  ENDMENUITEMS
             &Apache::lonhtmlcommon::add_breadcrumb_tool(              &Apache::lonhtmlcommon::add_breadcrumb_tool(
                 'tools',@tools);                  'tools',@tools);
   
               #exit editing link/icon when using daxe in construction space 
             #publish button in construction space              #publish button in construction space
             if ($env{'request.state'} eq 'construct'){              if ($env{'request.state'} eq 'construct'){
                   if ($in_daxe) {
                       &Apache::lonhtmlcommon::add_breadcrumb_tool(
                            'advtools', $inlineremote[76]);
                   }
                 &Apache::lonhtmlcommon::add_breadcrumb_tool(                  &Apache::lonhtmlcommon::add_breadcrumb_tool(
                      'advtools', $inlineremote[63]);                       'advtools', $inlineremote[63]);
             } else {              } else {
Line 1404  ENDMENUITEMS Line 1557  ENDMENUITEMS
                      'tools', $inlineremote[63]);                       'tools', $inlineremote[63]);
             }              }
             &advtools_crumbs(@inlineremote);              &advtools_crumbs(@inlineremote);
               #options link/icon in constructions space viewed with course role
               if (($env{'request.state'} eq 'construct') &&
                   ($env{'request.role'} !~/^(aa|ca|au)/)) {
                   &Apache::lonhtmlcommon::add_breadcrumb_tool(
                            'advtools', $inlineremote[75]);
               }
         }          }
     } else {      } else {
         if ($showprogress) {          if ($showprogress) {
Line 1414  ENDMENUITEMS Line 1573  ENDMENUITEMS
         }          }
     }      }
     my ($topic_help,$topic_help_text);      my ($topic_help,$topic_help_text);
     if ($is_const_dir == 2) {      if ($toplevel_cstr && !$crsauthor_cstr) {
         if ((($ENV{'SERVER_PORT'} == 443) ||           if ((($ENV{'SERVER_PORT'} == 443) || 
              ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) &&                ($Apache::lonnet::protocol{$Apache::lonnet::perlvar{'lonHostID'}} eq 'https')) && 
             (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {              (&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},'webdav'))) {
Line 1504  sub prepare_functions { Line 1663  sub prepare_functions {
             $editbutton = &get_editbutton($cfile,$home,$switchserver,              $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                           $forceedit,$forceview,$forcereg);                                            $forceedit,$forceview,$forcereg);
         }          }
     } elsif ((!$env{'request.course.id'}) &&      } elsif (!$env{'request.course.id'}) {
              ($env{'user.author'}) && ($env{'request.filename'}) &&          if (($env{'user.author'}) && ($resurl eq '/adm/viewcoauthors')) {
              ($env{'request.role'} !~/^(aa|ca|au)/)) {              if ($env{'request.role'} =~/^(ca|au)/) {
                   my ($audom,$auname);
                   if ($env{'request.role'} eq "au./$env{'user.domain'}/") {
                       ($audom,$auname) = ($env{'user.domain'},$env{'user.name'});
                   } elsif ($env{'request.role'} =~ m{^ca\./($match_domain)/($match_username)}) {
                       ($audom,$auname) = ($1,$2);
                   }
                   if (($audom ne '') && ($auname ne '')) {
                       my $file=&Apache::lonnet::declutter($env{'request.filename'});
                       ($cfile,$home,$switchserver,$forceedit,$forceview) =
                       &Apache::lonnet::can_edit_resource($file,$auname,$audom,
                                                          $resurl);
                       if ($cfile) {
                           $editbutton = &get_editbutton($resurl,'','',$forceedit,
                                                         $forceview);
                       }
                   }
               }
           } elsif (($env{'user.author'}) && ($env{'request.filename'}) &&
                    ($env{'request.role'} !~/^(aa|ca|au)/)) {
 #  #
 # Currently do not have the role of author or co-author.  # Currently do not have the role of author or co-author.
 # Do we have authoring privileges for the resource?  # Do we have authoring privileges for the resource?
 #  #
         my $file=&Apache::lonnet::declutter($env{'request.filename'});              my $file=&Apache::lonnet::declutter($env{'request.filename'});
         ($cfile,$home,$switchserver,$forceedit,$forceview) =              ($cfile,$home,$switchserver,$forceedit,$forceview) =
             &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,                  &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
                 &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);                      &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
         if (($cfile) && ($home ne '') && ($home ne 'no_host')) {              if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
             $editbutton = &get_editbutton($cfile,$home,$switchserver,                  $editbutton = &get_editbutton($cfile,$home,$switchserver,
                                           $forceedit,$forceview,$forcereg);                                                $forceedit,$forceview,$forcereg);
               }
         }          }
     } elsif ($env{'request.course.id'}) {      } elsif ($env{'request.course.id'}) {
 #  #
Line 1568  sub prepare_functions { Line 1747  sub prepare_functions {
         } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&          } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) &&
                  ($resurl ne '/cgi-bin/printout.pl')) {                   ($resurl ne '/cgi-bin/printout.pl')) {
             if ($env{'request.filename'}) {              if ($env{'request.filename'}) {
                 my $file=&Apache::lonnet::declutter($env{'request.filename'});                  my $file;
                   my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
                   if ($env{'request.filename'} =~ m{^\Q$londocroot\E/priv/}) {
                       $file = $env{'request.filename'};
                       $file =~ s{^\Q$londocroot\E/}{};
                   } else {
                       $file=&Apache::lonnet::declutter($env{'request.filename'});
                   }
                 ($cfile,$home,$switchserver,$forceedit,$forceview) =                  ($cfile,$home,$switchserver,$forceedit,$forceview) =
                     &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,                      &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
                         &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);                          &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
Line 1925  sub rawconfig { Line 2111  sub rawconfig {
                 } else {                  } else {
                     next;                      next;
                 }                  }
               } elsif ($priv eq 'cca') {
                   next if ($rol eq 'cm');
             }              }
             if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||              if ((($priv eq 'bre') && (&Apache::lonnet::allowed($priv,$prt) eq 'F')) ||
                 (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {                  (($priv ne 'bre') && (&Apache::lonnet::allowed($priv,$prt)))) {
Line 2006  sub rawconfig { Line 2194  sub rawconfig {
                     }                      }
                 }                  }
             }              }
           } elsif ($pro eq 'coauthor') {
               if ($env{'request.role'}=~ m{^(ca|aa)\./($match_domain)/($match_username)$}) {
                   my ($role,$audom,$auname) = ($1,$2,$3);
                   if ((($prt eq 'raa') && ($role eq 'aa')) ||
                       (($prt eq 'rca') && ($role eq 'ca') &&
                        (!$env{"environment.internal.manager./$audom/$auname"}))) {
                       $output.=&switch($auname,$audom,
                                        $row,$col,$img,$top,$bot,$act,$desc,$cat);
                   }
               }
           } elsif ($pro eq 'coauthorenv_manager') {
               if ($env{'request.role'}=~ m{^ca\./($match_domain)/($match_username)$}) {
                   my ($audom,$auname) = ($1,$2);
                   if ($env{"environment.internal.manager./$audom/$auname"}) {
                       $output.=&switch($auname,$audom,
                                        $row,$col,$img,$top,$bot,$act,$desc,$cat);
                   }
               }
         } elsif ($pro eq 'tools') {          } elsif ($pro eq 'tools') {
             my @tools = ('aboutme','blog','portfolio');              my @tools = ('aboutme','blog','portfolio');
             if (grep(/^\Q$prt\E$/,@tools)) {              if (grep(/^\Q$prt\E$/,@tools)) {
Line 2337  sub view_as_js { Line 2543  sub view_as_js {
     return <<"END";      return <<"END";
   
 function toggleViewAsUser(change) {  function toggleViewAsUser(change) {
     var seluserid = document.getElementById('LC_selectuser');      if (document.getElementById('LC_selectuser')) {
     var currstyle = seluserid.style.display;          var seluserid = document.getElementById('LC_selectuser');
     if (change == 'off') {          var currstyle = seluserid.style.display;
         document.userview.elements['LC_viewas'].value = '';          if (change == 'off') {
         document.userview.elements['vuname'].value = '';              document.userview.elements['LC_viewas'].value = '';
         document.userview.elements['vid'].value = '';              document.userview.elements['vuname'].value = '';
         document.userview.submit();              document.userview.elements['vid'].value = '';
         return;              document.userview.submit();
     }              return;
     if (currstyle == 'inline') {          }
         seluserid.style.display = 'none';          if ((document.getElementById('usexpand')) && (document.getElementById('uscollapse'))) {
         document.getElementById('usexpand').innerHTML='&#9658;&nbsp;';              if (currstyle == 'inline') {
         document.getElementById('uscollapse').innerHTML='';                  seluserid.style.display = 'none';
     } else {                  document.getElementById('usexpand').innerHTML='&#9658;&nbsp;';
         seluserid.style.display = 'inline';                  document.getElementById('uscollapse').innerHTML='';
         document.getElementById('usexpand').innerHTML='';              } else {
         document.getElementById('uscollapse').innerHTML='&#9668;&nbsp;';                  seluserid.style.display = 'inline';
                   document.getElementById('usexpand').innerHTML='';
                   document.getElementById('uscollapse').innerHTML='&#9668;&nbsp;';
                   toggleIdentifier(document.userview);
               }
           }
     }      }
     return;      return;
 }  }
Line 2361  function toggleViewAsUser(change) { Line 2572  function toggleViewAsUser(change) {
 function validCourseUser(form,change) {  function validCourseUser(form,change) {
     var possuname = form.elements['vuname'].value;      var possuname = form.elements['vuname'].value;
     var possuid = form.elements['vid'].value;      var possuid = form.elements['vid'].value;
     var possudom = form.elements['vudom'].options[form.elements['vudom'].selectedIndex].value;      var domelem = form.elements['vudom'];
       var possudom = '';
       if ((domelem.tagName === 'INPUT') && ((domelem.type === 'text') || (domelem.type === 'hidden'))) {
           possudom = domelem.value;
       } else if (domelem.tagName === 'SELECT') {
           possudom = domelem.options[domelem.selectedIndex].value;
       }
     if ((possuname == '') && (possuid == '')) {      if ((possuname == '') && (possuid == '')) {
         if (change == 'off') {          if (change == 'off') {
             form.elements['LC_viewas'].value = '';              form.elements['LC_viewas'].value = '';
Line 2397  function validCourseUser(form,change) { Line 2614  function validCourseUser(form,change) {
     return false;      return false;
 }  }
   
   function toggleIdentifier(form) {
       if ((document.getElementById('LC_vuname')) && (document.getElementById('LC_vid'))) {
           var radioelem = form.elements['vuidentifier'];
           if (radioelem.length > 0) {
               var i;
               for (i=0; i<radioelem.length; i++) {
                   if (radioelem[i].checked == true) {
                       if (radioelem[i].value == 'uname') {
                           document.getElementById('LC_vuname').type = 'text';
                           document.getElementById('LC_vid').type = 'hidden';
                           document.getElementById('LC_vid').value = '';
                       } else {
                           document.getElementById('LC_vuname').type = 'hidden';
                           document.getElementById('LC_vuname').value = '';
                           document.getElementById('LC_vid').type = 'text';
                       }
                       break;
                   }
               }
           }
       }
       return;
   }
   
 END  END
 }  }
   
Line 2571  function gocstr(url,filename) { Line 2812  function gocstr(url,filename) {
         this.document.cstrprint.submit();          this.document.cstrprint.submit();
         return;          return;
     }      }
       if (url == '/adm/preferences?action=authorsettings') {
           document.location.href=url+'&returnurl='+filename;
           return;
       }
     if (url !='') {      if (url !='') {
         this.document.constspace.filename.value = filename;          this.document.constspace.filename.value = filename;
         this.document.constspace.action = url;          this.document.constspace.action = url;

Removed from v.1.532  
changed lines
  Added in v.1.551


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>