Diff for /loncom/interface/lonmenu.pm between versions 1.530 and 1.538

version 1.530, 2023/04/02 03:16:26 version 1.538, 2023/09/28 15:56:48
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 969  sub innerregister { Line 968  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 1077  sub innerregister { Line 1088  sub innerregister {
             );              );
             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);
                 $vid = (&Apache::lonnet::idrget($vudom,$vuname))[1];                  unless (&Apache::lonnet::is_advanced_user($vudom,$vuname)) {
                       $vid = (&Apache::lonnet::idrget($vudom,$vuname))[1];
                   }
                 $viewas = $env{'request.user_in_effect'};                  $viewas = $env{'request.user_in_effect'};
                 $text = $lt{'upda'};                  $text = $lt{'upda'};
                 $change = 'off';                  $change = 'off';
Line 1092  sub innerregister { Line 1105  sub innerregister {
                 $leftvis = 'inline';                  $leftvis = 'inline';
                 $defdom = $cdom;                  $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 = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',
                             '<input name="vuname" type="text" size="8" value="'.$vuname.'" />',                              '<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />',
                             '<input name="vid" type="text" size="8" value="'.$vid.'" />',                              '</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />',
                             &Apache::loncommon::select_dom_form($defdom,'vudom')).                              '<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />',
                             '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',                              '</label><input name="vid" type="hidden" size="6" value="'.$vid.'" id="LC_vid" />').
                             '<input name="symb" type="hidden" value="'.$shownsymb.'" />';                          '<input name="vudom" type="hidden" value="'.$defdom.'" />'.
                           '<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 1129  END Line 1144  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 1138  END Line 1153  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([^/]+)/([^/]+)/(.*)$});
               my $crsauthor;
               if (($env{'request.course.id'}) &&
                   ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
                   ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
                   $crsauthor = 1;
               }
             my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;              my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
             if ($currdir =~ m-/$-) {              if ($currdir =~ m-/$-) {
                 $is_const_dir = 1;                  $is_const_dir = 1;
                 if ($thisdisfn eq '') {                  if (($thisdisfn eq '') && ($crsauthor)) {
                     unless (($env{'request.course.id'}) &&                       $is_const_dir = 2;
                             ($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);
                   $menuitems=(<<ENDMENUITEMS);
   s&6&3&pub.png&Publish&dir[_2]&gocstr('/adm/publish','$esc_currdir')&Publish this Directory
   s&7&4&docs-22x22.png&Edit Metadata&defaults[_1]&gopost('${esc_currdir}default.meta','')&Edit metadata for this Directory
   s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','$esc_currdir')&Print contents of directory
   s&7&1&del.png&Delete&dir[_3]&gocstr('/adm/cfile?action=delete','$esc_currdir')&Delete this Directory
   ENDMENUITEMS
             } else {              } else {
                 $currdir =~ s|[^/]+$||;                  $currdir =~ s|[^/]+$||;
  my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);   my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
Line 1162  END Line 1186  END
 #  #
 # Probably should be in mydesk.tab  # Probably should be in mydesk.tab
 #  #
                 $menuitems=(<<ENDMENUITEMS);                  if (($crsauthor) && ($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 1253  ENDMENUITEMS Line 1284  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 1309  s&8&3&prt.png&Print&printout[_1]&gopost( Line 1344  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 2328  sub view_as_js { Line 2363  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 2352  function toggleViewAsUser(change) { Line 2392  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 possudom = form.elements['vudom'].value;
     if ((possuname == '') && (possuid == '')) {      if ((possuname == '') && (possuid == '')) {
         if (change == 'off') {          if (change == 'off') {
             form.elements['LC_viewas'].value = '';              form.elements['LC_viewas'].value = '';
Line 2388  function validCourseUser(form,change) { Line 2428  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
 }  }
   

Removed from v.1.530  
changed lines
  Added in v.1.538


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