Diff for /loncom/interface/lonmenu.pm between versions 1.534 and 1.548

version 1.534, 2023/07/14 00:54:13 version 1.548, 2024/04/18 17:53:15
Line 245  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 366  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 421  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 436  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 480  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 539  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 570  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 599  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 637  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 724  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 968  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 1069  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 1091  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 1130  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);
         if ($const_space) {          if ($const_space) {
 #  #
 # We are in construction space  # We are in construction space
Line 1194  s&7&4&rename.png&Rename&resource[_5]&goc Line 1299  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
                   }
               }
   #
   # 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 1270  ENDMENUITEMS Line 1391  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 1326  s&8&3&prt.png&Print&printout[_1]&gopost( Line 1451  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 1412  ENDMENUITEMS Line 1537  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 1512  sub prepare_functions { Line 1643  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 1576  sub prepare_functions { Line 1727  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 1933  sub rawconfig { Line 2091  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 2014  sub rawconfig { Line 2174  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 2345  sub view_as_js { Line 2523  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 2369  function toggleViewAsUser(change) { Line 2552  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 2405  function validCourseUser(form,change) { Line 2594  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 2579  function gocstr(url,filename) { Line 2792  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.534  
changed lines
  Added in v.1.548


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