Diff for /loncom/interface/lonmenu.pm between versions 1.540 and 1.541

version 1.540, 2023/10/06 02:04:47 version 1.541, 2023/11/03 01:12:15
Line 436  sub primary_menu { Line 436  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 480  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 548  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 589  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 622  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 668  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 755  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 1559  sub prepare_functions { Line 1604  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 1980  sub rawconfig { Line 2045  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 2061  sub rawconfig { Line 2128  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)) {

Removed from v.1.540  
changed lines
  Added in v.1.541


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