Diff for /loncom/interface/loncommon.pm between versions 1.1399 and 1.1423

version 1.1399, 2022/12/01 01:24:53 version 1.1423, 2023/11/27 23:24:05
Line 71  use Apache::lonuserutils(); Line 71  use Apache::lonuserutils();
 use Apache::lonuserstate();  use Apache::lonuserstate();
 use Apache::courseclassifier();  use Apache::courseclassifier();
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   use LONCAPA::ltiutils;
 use LONCAPA::LWPReq;  use LONCAPA::LWPReq;
 use LONCAPA::map();  use LONCAPA::map();
 use HTTP::Request;  use HTTP::Request;
Line 436  sub studentbrowser_javascript { Line 437  sub studentbrowser_javascript {
 <script type="text/javascript" language="Javascript">  <script type="text/javascript" language="Javascript">
 // <![CDATA[  // <![CDATA[
     var stdeditbrowser;      var stdeditbrowser;
     function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv) {      function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv,uident) {
         var url = '/adm/pickstudent?';          var url = '/adm/pickstudent?';
         var filter;          var filter;
  if (!ignorefilter) {   if (!ignorefilter) {
Line 457  sub studentbrowser_javascript { Line 458  sub studentbrowser_javascript {
             }              }
         }          }
         if ((courseadv == 'only') || (courseadv == 'none')) { url+="&courseadv="+courseadv; }          if ((courseadv == 'only') || (courseadv == 'none')) { url+="&courseadv="+courseadv; }
           if (uident !== '') { url+="&identelement="+uident; } 
         var title = 'Student_Browser';          var title = 'Student_Browser';
         var options = 'scrollbars=1,resizable=1,menubar=0';          var options = 'scrollbars=1,resizable=1,menubar=0';
         options += ',width=700,height=600';          options += ',width=700,height=600';
Line 488  ENDRESBRW Line 490  ENDRESBRW
 }  }
   
 sub selectstudent_link {  sub selectstudent_link {
    my ($form,$unameele,$udomele,$courseadv,$clickerid)=@_;     my ($form,$unameele,$udomele,$courseadv,$clickerid,$identelem)=@_;
    my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','".     my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','".
                       &Apache::lonhtmlcommon::entity_encode($unameele)."','".                        &Apache::lonhtmlcommon::entity_encode($unameele)."','".
                       &Apache::lonhtmlcommon::entity_encode($udomele)."'";                        &Apache::lonhtmlcommon::entity_encode($udomele)."'";
Line 505  sub selectstudent_link { Line 507  sub selectstudent_link {
            $callargs .= ",'','','$courseadv'";             $callargs .= ",'','','$courseadv'";
        } elsif ($courseadv eq 'condition') {         } elsif ($courseadv eq 'condition') {
            $callargs .= ",'','','$courseadv'";             $callargs .= ",'','','$courseadv'";
          } elsif ($identelem ne '') {
              $callargs .= ",'','',''";
          }
          if ($identelem ne '') {
              $callargs .= ",'".&Apache::lonhtmlcommon::entity_encode($identelem)."'";
        }         }
        return '<span class="LC_nobreak">'.         return '<span class="LC_nobreak">'.
               '<a href="javascript:openstdbrowser('.$callargs.');">'.                '<a href="javascript:openstdbrowser('.$callargs.');">'.
Line 1233  END Line 1240  END
         $result.=">".&mt($hashref->{$value}->{'text'})."</option>\n";          $result.=">".&mt($hashref->{$value}->{'text'})."</option>\n";
     }      }
     $result .= "</select>\n";      $result .= "</select>\n";
     my %select2 = %{$hashref->{$firstdefault}->{'select2'}};      my %select2;
       if (ref($hashref->{$firstdefault}) eq 'HASH') {
           if (ref($hashref->{$firstdefault}->{'select2'}) eq 'HASH') {
               %select2 = %{$hashref->{$firstdefault}->{'select2'}};
           }
       }
     $result .= $middletext;      $result .= $middletext;
     $result .= "<select size=\"1\" name=\"$secondselectname\"";      $result .= "<select size=\"1\" name=\"$secondselectname\"";
     if ($onchangesecond) {      if ($onchangesecond) {
Line 1816  sub colorfuleditor_js { Line 1828  sub colorfuleditor_js {
             save => 'Save page to make this permanent',              save => 'Save page to make this permanent',
         );          );
         &js_escape(\%js_lt);          &js_escape(\%js_lt);
           my $showfile_js = &show_crsfiles_js();
         $browse_or_search = <<"END";          $browse_or_search = <<"END";
   
       $showfile_js
   
     function toggleChooser(form,element,titleid,only,search) {      function toggleChooser(form,element,titleid,only,search) {
         var disp = 'none';          var disp = 'none';
         if (document.getElementById('chooser_'+element)) {          if (document.getElementById('chooser_'+element)) {
Line 1832  sub colorfuleditor_js { Line 1847  sub colorfuleditor_js {
                 toggleResImport(form,element);                  toggleResImport(form,element);
             }              }
             document.getElementById('chooser_'+element).style.display = disp;              document.getElementById('chooser_'+element).style.display = disp;
               var dirsel = '';
               var filesel = '';
               if (document.getElementById('chooser_'+element+'_crsres')) {
                   var currcrsres = document.getElementById('chooser_'+element+'_crsres').style.display;
                   if (currcrsres == 'none') {
                       dirsel = 'coursepath_'+element;
                       var filesel = 'coursefile_'+element;
                       var include;
                       if (document.getElementById('crsres_include_'+element)) {
                           include = document.getElementById('crsres_include_'+element).value;
                       }
                       populateCrsSelects(form,dirsel,filesel,1,include,1,0,1,1,0);
                   }
               }
               if (document.getElementById('chooser_'+element+'_upload')) {
                   var currcrsupload = document.getElementById('chooser_'+element+'_upload').style.display;
                   if (currcrsupload == 'none') {
                       dirsel = 'crsauthorpath_'+element;
                       filesel = '';
                       populateCrsSelects(form,dirsel,filesel,0,'',1,0,1,0,1);
                   }
               }
         }          }
     }      }
   
     function toggleCrsFile(form,element,numdirs) {      function toggleCrsFile(form,element) {
         if (document.getElementById('chooser_'+element+'_crsres')) {          if (document.getElementById('chooser_'+element+'_crsres')) {
             var curr = document.getElementById('chooser_'+element+'_crsres').style.display;              var curr = document.getElementById('chooser_'+element+'_crsres').style.display;
             if (curr == 'none') {              if (curr == 'none') {
                 if (numdirs) {                  if (document.getElementById('coursepath_'+element)) {
                       var numdirs;
                       if (document.getElementById('coursepath_'+element).length) {
                           numdirs = document.getElementById('coursepath_'+element).length;
                       }
                       if ((document.getElementById('hascrsres_'+element)) &&
                           (document.getElementById('nocrsres_'+element))) {
                           if (numdirs) {
                               document.getElementById('hascrsres_'+element).style.display='inline-block';
                               document.getElementById('nocrsres_'+element).style.display='none';
                           } else {
                               document.getElementById('hascrsres_'+element).style.display='none';
                               document.getElementById('nocrsres_'+element).style.display='inline-block';
                           }
                       }
                     form.elements['coursepath_'+element].selectedIndex = 0;                      form.elements['coursepath_'+element].selectedIndex = 0;
                     if (numdirs > 1) {                      if (numdirs > 1) {
                         window['select1'+element+'_changed']();                          var selelem = form.elements['coursefile_'+element];
                           var i, len = selelem.options.length -1;
                           if (len >=0) {
                               for (i = len; i >= 0; i--) {
                                   selelem.remove(i);
                               }
                               selelem.options[0] = new Option('','');
                           }
                     }                      }
                 }                  }
             }               }
             document.getElementById('chooser_'+element+'_crsres').style.display = 'block';              document.getElementById('chooser_'+element+'_crsres').style.display = 'block';
               
         }          }
         if (document.getElementById('chooser_'+element+'_upload')) {          if (document.getElementById('chooser_'+element+'_upload')) {
             document.getElementById('chooser_'+element+'_upload').style.display = 'none';              document.getElementById('chooser_'+element+'_upload').style.display = 'none';
Line 1858  sub colorfuleditor_js { Line 1915  sub colorfuleditor_js {
         return;          return;
     }      }
   
     function toggleCrsUpload(form,element,numcrsdirs) {      function toggleCrsUpload(form,element) {
         if (document.getElementById('chooser_'+element+'_crsres')) {          if (document.getElementById('chooser_'+element+'_crsres')) {
             document.getElementById('chooser_'+element+'_crsres').style.display = 'none';              document.getElementById('chooser_'+element+'_crsres').style.display = 'none';
         }          }
         if (document.getElementById('chooser_'+element+'_upload')) {          if (document.getElementById('chooser_'+element+'_upload')) {
             var curr = document.getElementById('chooser_'+element+'_upload').style.display;              var curr = document.getElementById('chooser_'+element+'_upload').style.display;
             if (curr == 'none') {              if (curr == 'none') {
                 if (numcrsdirs) {                  form.elements['newsubdir_'+element][0].checked = true;
                    form.elements['crsauthorpath_'+element].selectedIndex = 0;                  toggleNewsubdir(form,element);
                    form.elements['newsubdir_'+element][0].checked = true;                  document.getElementById('chooser_'+element+'_upload').style.display = 'block';
                    toggleNewsubdir(form,element);                  if (document.getElementById('uploadcrsres_'+element)) {
                       document.getElementById('uploadcrsres_'+element).value = '';
                 }                  }
             }              }
             document.getElementById('chooser_'+element+'_upload').style.display = 'block';  
         }          }
         return;          return;
     }      }
Line 1915  sub colorfuleditor_js { Line 1972  sub colorfuleditor_js {
         var filename = form.elements['coursefile_'+element];          var filename = form.elements['coursefile_'+element];
         var path = directory.options[directory.selectedIndex].value;          var path = directory.options[directory.selectedIndex].value;
         var file = filename.options[filename.selectedIndex].value;          var file = filename.options[filename.selectedIndex].value;
         form.elements[element].value = '$respath';          if (file != '') {
         if (path == '/') {              form.elements[element].value = '$respath';
             form.elements[element].value += file;              if (path == '/') {
         } else {                  form.elements[element].value += file;
             form.elements[element].value += path+'/'+file;              } else {
         }                  form.elements[element].value += path+'/'+file;
         unClean();              }
         if (document.getElementById('previewimg_'+element)) {              unClean();
             document.getElementById('previewimg_'+element).src = form.elements[element].value;              if (document.getElementById('previewimg_'+element)) {
             var newsrc = document.getElementById('previewimg_'+element).src;                   document.getElementById('previewimg_'+element).src = form.elements[element].value;
         }                  var newsrc = document.getElementById('previewimg_'+element).src; 
         if (document.getElementById('showimg_'+element)) {              }
             document.getElementById('showimg_'+element).innerHTML = '($js_lt{save})';              if (document.getElementById('showimg_'+element)) {
                   document.getElementById('showimg_'+element).innerHTML = '($js_lt{save})';
               }
         }          }
         toggleChooser(form,element);          toggleChooser(form,element);
         return;          return;
Line 2216  sub crsauthor_url { Line 2275  sub crsauthor_url {
 }  }
   
 sub import_crsauthor_form {  sub import_crsauthor_form {
     my ($form,$firstselectname,$secondselectname,$onchangefirst,$only,$suffix,$disabled) = @_;      my ($firstselectname,$secondselectname,$onchangefirst,$only,$suffix,$disabled) = @_;
     return (0) unless ($env{'request.course.id'});      return (0) unless ($env{'request.course.id'});
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};      my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};      my $crshome = $env{'course.'.$env{'request.course.id'}.'.home'};
     return (0) unless (($cnum ne '') && ($cdom ne ''));      return (0) unless (($cnum ne '') && ($cdom ne ''));
     my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};  
     my @ids=&Apache::lonnet::current_machine_ids();      my @ids=&Apache::lonnet::current_machine_ids();
     my ($output,$is_home,$relpath,%subdirs,%files,%selimport_menus);      my ($output,$is_home,$toppath,%subdirs,%files,%selimport_menus,$include,$exclude);
       
     if (grep(/^\Q$crshome\E$/,@ids)) {      if (grep(/^\Q$crshome\E$/,@ids)) {
         $is_home = 1;          $is_home = 1;
     }      }
     $relpath = "/priv/$cdom/$cnum";      $toppath = "/priv/$cdom/$cnum";
     &Apache::lonnet::recursedirs($is_home,'priv',$londocroot,$relpath,'',\%subdirs,\%files);      my $nonemptydir = 1;
       my $js_only;
       if ($only) {
           map { $include->{$_} = 1; } split(/\s*,\s*/,$only);
           $js_only = join(',',map { &js_escape($_); } sort(keys(%{$include})));
       }
       $exclude = &Apache::lonnet::priv_exclude();
       &Apache::lonnet::recursedirs($is_home,1,$include,$exclude,1,0,$toppath,'',\%subdirs,\%files);
       my $numdirs = scalar(keys(%files));
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
         fnam => 'Filename',          fnam => 'Filename',
         dire => 'Directory',          dire => 'Directory',
           se   => 'Select',
     );      );
     my $numdirs = scalar(keys(%files));      $output = $lt{'dire'}.':&nbsp;'.
     my (%possexts,$singledir,@singledirfiles);                '<select id="'.$firstselectname.'" name="'.$firstselectname.'" '.
     if ($only) {                'onchange="populateCrsSelects(this.form,'."'$firstselectname','$secondselectname',1,'$js_only',0,1,0,0,0".');">'.
         map { $possexts{$_} = 1; } split(/\s*,\s*/,$only);                '<option value="" selected="selected">'.$lt{'se'}.'</option>';
     }      if ($files{'/'}) {
     my (%nonemptydirs,$possdirs);          $output .= '<option value="/">/</option>'."\n";
     if ($numdirs > 1) {      }
         my @order;      foreach my $key (sort { lc($a) cmp lc($b) } (keys(%files))) {
         foreach my $key (sort { lc($a) cmp lc($b) } (keys(%files))) {          next if ($key eq '/');
             if (ref($files{$key}) eq 'HASH') {          $output .= '<option value="'.$key.'">'.$key.'</option>'."\n";
                 my $shown = $key;      }
                 if ($key eq '') {      $output .= '</select><br />'."\n".
                     $shown = '/';                 $lt{'fnam'}.':&nbsp;<select id="'.$secondselectname.'" name="'.$secondselectname.'">'."\n".
                 }                 '<option value="" selected="selected"></option>'."\n".
                 my @ordered = ();                 '</select>'."\n".
                 foreach my $file (sort { lc($a) cmp lc($b) } (keys(%{$files{$key}}))) {                 '<input type="hidden" id="crsres_include_'.$suffix.'" value="'.$only.'" />';
                     next if ($file =~ /\.rights$/);      return ($numdirs,$output);
                     if ($only) {  }
                         my ($ext) = ($file =~ /\.([^.]+)$/);  
                         unless ($possexts{lc($ext)}) {  sub show_crsfiles_js {
                             next;      my $excluderef = &Apache::lonnet::priv_exclude();
                         }      my $se = &js_escape(&mt('Select'));
       my $exclude;
       if (ref($excluderef) eq 'HASH') {
           $exclude = join(',', map { &js_escape($_); } sort(keys(%{$excluderef})));
       }
       my $js = <<"END";
   
   
       function populateCrsSelects (form,dirsel,filesel,exc,include,setdir,setfile,recurse,nonemptydir,addtopdir) {
           var relpath = '';
           if ((setfile) && (dirsel != null) && (dirsel != 'undefined') && (dirsel != '')) {
               var currdir = form.elements[dirsel].options[form.elements[dirsel].selectedIndex].value;
               if (currdir == '') {
                   if ((filesel != null) && (filesel != 'undefined') && (filesel != '')) {
                       selelem = form.elements[filesel];
                       var j, numfiles = selelem.options.length -1;
                       if (numfiles >=0) {
                           for (j = numfiles; j >= 0; j--) {
                               selelem.remove(j);
                           }
                       }
                       if (selelem.options.length == 0) {
                           selelem.options[selelem.options.length] = new Option('','');
                           selelem.selectedIndex = 0;
                     }                      }
                     $selimport_menus{$key}->{'select2'}->{$file} = $file;  
                     push(@ordered,$file);  
                 }  
                 if (@ordered) {  
                     push(@order,$key);  
                     $nonemptydirs{$key} = 1;  
                     $selimport_menus{$key}->{'text'} = $shown;  
                     $selimport_menus{$key}->{'default'} = '';  
                     $selimport_menus{$key}->{'select2'}->{''} = '';  
                     $selimport_menus{$key}->{'order'} = \@ordered;  
                 }                  }
                   return;
               } else {
                   relpath = encodeURIComponent(form.elements[dirsel].options[form.elements[dirsel].selectedIndex].value);
             }              }
         }          }
         $possdirs = scalar(keys(%nonemptydirs));          var http = new XMLHttpRequest();
         if ($possdirs > 1) {          var url = "/adm/courseauthor";
             my @order = sort { lc($a) cmp lc($b) } (keys(%nonemptydirs));          var crsrole = "$env{'request.role'}";
             $output = $lt{'dire'}.          var exclude = '';
                       &linked_select_forms($form,'<br />'.          if (exc) {
                                            $lt{'fnam'},'',              exclude = '$exclude';
                                            $firstselectname,$secondselectname,          }
                                            \%selimport_menus,\@order,          var params = "role=course&files=1&rec="+recurse+"&nonempty="+nonemptydir+"&exc="+exclude+"&inc="+include+"&addtop="+addtopdir+"&path="+relpath;
                                            $onchangefirst,'',$suffix).'<br />';          http.open("POST", url, true);
         } elsif ($possdirs == 1) {          http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
             $singledir = (keys(%nonemptydirs))[0];          http.onreadystatechange = function() {
             if (ref($selimport_menus{$singledir}->{'order'}) eq 'ARRAY') {              if (http.readyState == 4 && http.status == 200) {
                 @singledirfiles = @{$selimport_menus{$singledir}->{'order'}};                  var data = JSON.parse(http.responseText);
             }                  var selelem;
             delete($selimport_menus{$singledir});                  if ((setdir) && (dirsel != null) && (dirsel != 'undefined') && (dirsel != '')) {
         }                      if (Array.isArray(data.dirs)) {
     } elsif ($numdirs == 1) {                          selelem = form.elements[dirsel];
         $singledir = (keys(%files))[0];                          var i, numdirs = selelem.options.length -1;
         foreach my $file (sort { lc($a) cmp lc($b) } (keys(%{$files{$singledir}}))) {                          if (numdirs >=0) {
             if ($only) {                              for (i = numdirs; i >= 0; i--) {
                 my ($ext) = ($file =~ /\.([^.]+)$/);                                  selelem.remove(i);
                 unless ($possexts{lc($ext)}) {                              }
                     next;                          }
                           var len = data.dirs.length;
                           if (len) {
                               selelem.options[selelem.options.length] = new Option('$se','');
                               var j;
                               for (j = 0; j < len; j++) {
                                   selelem.options[selelem.options.length] = new Option(data.dirs[j],data.dirs[j]);
                               }
                               selelem.selectedIndex = 0;
                           }
                           if (!setfile) {
                               if ((filesel != null) && (filesel != 'undefined') && (filesel != '')) {
                                   selelem = form.elements[filesel];
                                   var j, numfiles = selelem.options.length -1;
                                   if (numfiles >=0) {
                                       for (j = numfiles; j >= 0; j--) {
                                           selelem.remove(j);
                                       }
                                   }
                                   if (selelem.options.length == 0) {
                                       selelem.options[selelem.options.length] = new Option('','');
                                       selelem.selectedIndex = 0;
                                   }
                               }
                           }
                       }
                   }
                   if ((setfile) && (filesel != null) && (filesel != 'undefined') && (filesel != '')) {
                       selelem = form.elements[filesel];
                       var i, numfiles = selelem.options.length -1;
                       if (numfiles >=0) {
                           for (i = numfiles; i >= 0; i--) {
                               selelem.remove(i);
                           }
                       }
                       var x;
                       for (x in data.files) {
                           if (Array.isArray(data.files[x])) {
                               if (data.files[x].length > 1) {
                                   selelem.options[selelem.options.length] = new Option('$se','');
                               }
                               var len = data.files[x].length;
                               if (len) {
                                   var k;
                                   for (k = 0; k < len; k++) {
                                       selelem.options[selelem.options.length] = new Option(data.files[x][k],data.files[x][k]);
                                   }
                                   selelem.selectedIndex = 0;
                               }
                           }
                       }
                       if (selelem.options.length == 0) {
                           selelem.options[selelem.options.length] = new Option('','');
                           selelem.selectedIndex = 0;
                       }
                 }                  }
             } else {  
                 next if ($file =~ /\.rights$/);  
             }              }
             push(@singledirfiles,$file);  
         }  
         if (@singledirfiles) {  
             $possdirs = 1;  
         }          }
           http.send(params);
     }      }
     if (($possdirs == 1) && (@singledirfiles)) {  END
         my $showdir = $singledir;  }
         if ($singledir eq '') {  
             $showdir = '/';  =pod
         }  
         $output = $lt{'dire'}.  =item * &iframe_wrapper_headjs()
                   '<select name="'.$firstselectname.'">'.  
                   '<option value="'.$singledir.'">'.$showdir.'</option>'."\n".  #
                   '</select><br />'.  # Where iframe is in use, if window.onload() executes before the custom resize function
                   $lt{'fnam'}.'<select name="'.$secondselectname.'">'."\n".  # has been defined (jQuery), two global javascript vars (LCnotready and LCresizedef)
                   '<option value="" selected="selected">'.$lt{'se'}.'</option>'."\n";  # are used to ensure document.ready() triggers a call to resize, so the iframe contents
         foreach my $file (@singledirfiles) {  # do not obscure the Functions menu.
             $output .= '<option value="'.$file.'">'.$file.'</option>'."\n";  #
   
   =back
   
   =cut
   
   
   sub iframe_wrapper_headjs {
       return <<"ENDJS";
   <script type="text/javascript">
   // <![CDATA[
   var LCnotready = 0;
   var LCresizedef = 0;
   // ]]>
   </script>
   
   ENDJS
   
   }
   
   =pod
   
   =item * &iframe_wrapper_resizejs()
   
   #
   # jQuery to use when iframe is in use and a page resize occurs.
   # This script will ensure that the iframe does not obscure any
   # standard LON-CAPA inline menus (primary, secondary, and/or
   # breadcrumbs and Functions menus. Expects javascript from
   # &iframe_wrapper_headjs() to be in head portion of the web page,
   # e.g., by inclusion in second arg passed to &start_page().
   #
   
   =back
   
   =cut
   
   sub iframe_wrapper_resizejs {
       my $offset = 5;
       &get_unprocessed_cgi($ENV{'QUERY_STRING'},['inhibitmenu']);
       if (($env{'form.inhibitmenu'} eq 'yes') || ($env{'form.only_body'})) {
           $offset = 0;
       }
       return &Apache::lonhtmlcommon::scripttag(<<SCRIPT);
       \$(document).ready( function() {
           \$(window).unbind('resize').resize(function(){
               var header = null;
               var offset = $offset;
               var height = 0;
               var hdrtop = 0;
               if (\$('div.LC_menus_content:first').length) {
                   if (\$('div.LC_menus_content:first').hasClass ("shown")) {
                       header = \$('div.LC_menus_content:first');
                       offset = 12;
                   }
               } else if (\$('div.LC_head_subbox:first').length) {
                   header = \$('div.LC_head_subbox:first');
                   offset = 9;
               } else {
                   if (\$('#LC_breadcrumbs').length) {
                       header = \$('#LC_breadcrumbs');
                   }
               }
               if (header != null && header.length) {
                   height = header.height();
                   hdrtop = header.position().top;
               }
               var pos = height + hdrtop + offset;
               \$('.LC_iframecontainer').css('top', pos);
           });
           LCresizedef = 1;
           if (LCnotready == 1) {
               LCnotready = 0;
               \$(window).trigger('resize');
         }          }
         $output .= '</select><br />'."\n";      });
     }      window.onload = function(){
     return ($possdirs,$output);           if (LCresizedef) {
                LCnotready = 0;
                \$(window).trigger('resize');
            } else {
                LCnotready = 1;
            }
       };
   SCRIPT
   
 }  }
   
 =pod  =pod
Line 2672  sub display_filter { Line 2885  sub display_filter {
     my $onchange = "javascript:toggleHistoryOptions(this,'containingphrase','$context',      my $onchange = "javascript:toggleHistoryOptions(this,'containingphrase','$context',
                                                     '$secondid','$thirdid')";                                                      '$secondid','$thirdid')";
     return '<span class="LC_nobreak"><label>'.&mt('Records: [_1]',      return '<span class="LC_nobreak"><label>'.&mt('Records: [_1]',
        &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,         &Apache::lonmeta::selectbox('show',$env{'form.show'},'',undef,
    (&mt('all'),10,20,50,100,1000,10000))).     (&mt('all'),10,20,50,100,1000,10000))).
    '</label></span> <span class="LC_nobreak">'.     '</label></span> <span class="LC_nobreak">'.
            &mt('Filter: [_1]',             &mt('Filter: [_1]',
Line 6260  Input: (optional) filename from which br Line 6473  Input: (optional) filename from which br
        If page header is being requested for use in a frameset, then         If page header is being requested for use in a frameset, then
        the second (option) argument -- frameset will be true, and         the second (option) argument -- frameset will be true, and
        the target attribute set for links should be target="_parent".         the target attribute set for links should be target="_parent".
          If $title is supplied as the thitd arg, that will be used to 
          the left of the breadcrumbs tail for the current path.
   
 Returns: HTML div with CSTR path and recent box  Returns: HTML div with CSTR path and recent box
          To be included on Authoring Space pages           To be included on Authoring Space pages
Line 6267  Returns: HTML div with CSTR path and rec Line 6482  Returns: HTML div with CSTR path and rec
 =cut  =cut
   
 sub CSTR_pageheader {  sub CSTR_pageheader {
     my ($trailfile,$frameset) = @_;      my ($trailfile,$frameset,$title) = @_;
     if ($trailfile eq '') {      if ($trailfile eq '') {
         $trailfile = $env{'request.filename'};          $trailfile = $env{'request.filename'};
     }      }
Line 6290  sub CSTR_pageheader { Line 6505  sub CSTR_pageheader {
         $lastitem = $thisdisfn;          $lastitem = $thisdisfn;
     }      }
   
     my ($crsauthor,$title);      my $crsauthor;
     if (($env{'request.course.id'}) &&      if (($env{'request.course.id'}) &&
         ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&          ($env{'course.'.$env{'request.course.id'}.'.num'} eq $uname) &&
         ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {          ($env{'course.'.$env{'request.course.id'}.'.domain'} eq $udom)) {
         $crsauthor = 1;          $crsauthor = 1;
         $title = &mt('Course Authoring Space');          if ($title eq '') {
     } else {              $title = &mt('Course Authoring Space');
           }
       } elsif ($title eq '') {
         $title = &mt('Authoring Space');          $title = &mt('Authoring Space');
     }      }
   
Line 6341  sub CSTR_pageheader { Line 6558  sub CSTR_pageheader {
     return $output;      return $output;
 }  }
   
   ##############################################
   =pod
   
   =item * &nocodemirror()
   
   Input: None
   
   Returns: 1 if CodeMirror is deactivated based on
            user's preference, or domain default,
            if user indicated use of default.
   
   =cut
   
   sub nocodemirror {
       my $nocodem = $env{'environment.nocodemirror'};
       unless ($nocodem) {
           my %domdefs = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
           if ($domdefs{'nocodemirror'}) {
               $nocodem = 'yes';
           }
       }
       if ($nocodem eq 'yes') {
           return 1;
       }
       return;
   }
   
   ##############################################
   =pod
   
   =item * &permitted_editors()
   
   Input: $uri (optional)
   
   Returns: %editors hash in which keys are editors
            permitted in current Authoring Space.
            Value for each key is 1. Possible keys
            are: edit, xml, and daxe. If no specific
            set of editors has been set for the Author
            who owns the Authoring Space, then the
            domain default will be used.  If no domain
            default has been set, then the keys will be
            edit and xml.
   
   =cut
   
   sub permitted_editors {
       my ($uri) = @_;
       my ($is_author,$is_coauthor,$auname,$audom,%editors);
       if ($env{'request.role'} =~ m{^au\./}) {
           $is_author = 1;
       } elsif ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)}) {
           ($audom,$auname) = ($1,$2);
           if (($audom ne '') && ($auname ne '')) {
               if (($env{'user.domain'} eq $audom) &&
                   ($env{'user.name'} eq $auname)) {
                   $is_author = 1;
               } else {
                   $is_coauthor = 1;
               }
           }
       } elsif ($env{'request.course.id'}) {
           if ($env{'request.editurl'} =~ m{^/priv/($match_domain)/($match_username)/}) {
               ($audom,$auname) = ($1,$2);
           } elsif ($env{'request.uri'} =~ m{^/priv/($match_domain)/($match_username)/}) {
               ($audom,$auname) = ($1,$2);
           } elsif (($uri eq '/daxesave') &&
                    ($env{'form.path'} =~ m{^/daxeopen/priv/($match_domain)/($match_username)/})) {
               ($audom,$auname) = ($1,$2);
           }
           if (($audom ne '') && ($auname ne '')) {
               if (($env{'user.domain'} eq $audom) &&
                   ($env{'user.name'} eq $auname)) {
                   $is_author = 1;
               } else {
                   $is_coauthor = 1;
               }
           }
       }
       if ($is_author) {
           if (exists($env{'environment.editors'})) {
               map { $editors{$_} = 1; } split(/,/,$env{'environment.editors'});
           } else {
               %editors = ( edit => 1,
                            xml => 1,
                          );
           }
       } elsif ($is_coauthor) {
           if (exists($env{"environment.internal.editors./$audom/$auname"})) {
               map { $editors{$_} = 1; } split(/,/,$env{"environment.internal.editors./$audom/$auname"});
           } else {
               %editors = ( edit => 1,
                            xml => 1,
                          );
           }
       } else {
           %editors = ( edit => 1,
                        xml => 1,
                      );
       }
       return %editors;
   }
   
 ###############################################  ###############################################
 ###############################################  ###############################################
   
Line 6567  sub bodytag { Line 6887  sub bodytag {
         $bodytag .= Apache::lonhtmlcommon::scripttag(          $bodytag .= Apache::lonhtmlcommon::scripttag(
             Apache::lonmenu::utilityfunctions($httphost), 'start');              Apache::lonmenu::utilityfunctions($httphost), 'start');
   
           if ($args->{'collapsible_header'} ne '') {
               my $alttext = &mt('menu state: collapsed');
               my $tooltip = &mt('display standard menus');
               $bodytag .= <<"END";
   <div id="LC_expandingContainer" style="display:inline;">
   <div id="LC_collapsible" class="LC_collapse_trigger" style="position: absolute;top: -5px;left: 0px; z-index:101; display:inline;">
   <a href="#" style="text-decoration:none;"><img class="LC_collapsible_indicator" alt="$alttext" title="$tooltip" src="/res/adm/pages/collapsed.png" style="border:0;margin:0;padding:0;max-width:100%;height:auto" /></a></div>
   <div class="LC_menus_content hidden">
   END
           }
         unless ($args->{'no_primary_menu'}) {          unless ($args->{'no_primary_menu'}) {
             my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref,              my ($left,$right) = Apache::lonmenu::primary_menu($crstype,$ltimenu,$menucoll,$menuref,
                                                               $args->{'links_disabled'},                                                                $args->{'links_disabled'},
                                                               $args->{'links_target'});                                                                $args->{'links_target'},
                                                                 $args->{'collapsible_header'});
   
             if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {              if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
                 if ($dc_info) {                  if ($dc_info) {
Line 6629  sub bodytag { Line 6960  sub bodytag {
             $bodytag .= '<hr style="clear:both" />';              $bodytag .= '<hr style="clear:both" />';
             $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');               $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end'); 
         }          }
           if ($args->{'collapsible_header'} ne '') {
               $bodytag .= $args->{'collapsible_header'}.
                           '<div id="LC_collapsible_separator"></div>'.
                           '</div></div>';
           }
         return $bodytag;          return $bodytag;
 }  }
   
Line 6735  ENDJS Line 7070  ENDJS
         $endbodytag;          $endbodytag;
         }          }
     }      }
       if ((ref($args) eq 'HASH') && ($args->{'dashjs'})) {
           $endbodytag = &Apache::lonhtmlcommon::dash_to_minus_js().$endbodytag;
       }
     return $endbodytag;      return $endbodytag;
 }  }
   
Line 6819  form, .inline { Line 7157  form, .inline {
   display: inline;    display: inline;
 }  }
   
   .LC_menus_content.shown{
     display: inline;
   }
   
   .LC_menus_content.hidden {
     display: none;
   }
   
 .LC_right {  .LC_right {
   text-align:right;    text-align:right;
 }  }
Line 6839  form, .inline { Line 7185  form, .inline {
   width:400px;    width:400px;
 }  }
   
   #LC_collapsible_separator {
       border: 1px solid black;
       width: 99.9%;
       height: 0px;
   }
   
 .LC_iframecontainer {  .LC_iframecontainer {
     width: 98%;      width: 98%;
     margin: 0;      margin: 0;
Line 8051  fieldset { Line 8403  fieldset {
   /* overflow: hidden; */    /* overflow: hidden; */
 }  }
   
   fieldset#LC_selectuser {
       margin: 0;
       padding: 0;
   }
   
 article.geogebraweb div {  article.geogebraweb div {
     margin: 0;      margin: 0;
 }  }
Line 9650  sub symb_from_tinyurl { Line 10007  sub symb_from_tinyurl {
     }      }
 }  }
   
   sub usable_exttools {
       my %tooltypes;
       if ($env{'request.course.id'}) {
           if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'}) {
              if ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'both') {
                  %tooltypes = (
                                crs => 1,
                                dom => 1,
                               );
              } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'crs') {
                  $tooltypes{'crs'} = 1;
              } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.exttool'} eq 'dom') {
                  $tooltypes{'dom'} = 1;
              }
           } else {
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
               my $crstype = lc($env{'course.'.$env{'request.course.id'}.'.type'});
               if ($crstype eq '') {
                   $crstype = 'course';
               }
               if ($crstype eq 'course') {
                   if ($env{'course.'.$env{'request.course.id'}.'internal.coursecode'}) {
                       $crstype = 'official';
                   } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.textbook'}) {
                       $crstype = 'textbook';
                   } elsif ($env{'course.'.$env{'request.course.id'}.'.internal.lti'}) {
                       $crstype = 'lti';
                   } else {
                       $crstype = 'unofficial';
                   }
               }
               my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom);
               if ($domdefaults{$crstype.'domexttool'}) {
                   $tooltypes{'dom'} = 1;
               }
               if ($domdefaults{$crstype.'exttool'}) {
                   $tooltypes{'crs'} = 1;
               }
           }
       }
       return %tooltypes;
   }
   
 sub wishlist_window {  sub wishlist_window {
     return(<<'ENDWISHLIST');      return(<<'ENDWISHLIST');
 <script type="text/javascript">  <script type="text/javascript">
Line 10338  Scalar: 1 if 'Course' to be used, 0 othe Line 10739  Scalar: 1 if 'Course' to be used, 0 othe
   
 ###############################################  ###############################################
 sub show_course {  sub show_course {
       my ($udom,$uname) = @_;
       if (($udom ne '') && ($uname ne '')) {
           if (($udom ne $env{'user.domain'}) || ($uname ne $env{'user.name'})) {
               if (&Apache::lonnet::is_advanced_user($udom,$uname)) {
                   return 0;
               } else {
                   return 1;
               }
           }
       }
     my $course = !$env{'user.adv'};      my $course = !$env{'user.adv'};
     if (!$env{'user.adv'}) {      if (!$env{'user.adv'}) {
         foreach my $env (keys(%env)) {          foreach my $env (keys(%env)) {
Line 16369  sub assign_category_rows { Line 16780  sub assign_category_rows {
   
   
 sub commit_customrole {  sub commit_customrole {
     my ($udom,$uname,$url,$three,$four,$five,$start,$end,$context) = @_;      my ($udom,$uname,$url,$three,$four,$five,$start,$end,$context,$othdomby,$requester) = @_;
     my $result = &Apache::lonnet::assigncustomrole(      my $result = &Apache::lonnet::assigncustomrole(
                      $udom,$uname,$url,$three,$four,$five,$end,$start,undef,undef,$context);                       $udom,$uname,$url,$three,$four,$five,$end,$start,undef,undef,
                        $context,$othdomby,$requester);
     my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.      my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.
                          ($start?', '.&mt('starting').' '.localtime($start):'').                           ($start?', '.&mt('starting').' '.localtime($start):'').
                          ($end?', ending '.localtime($end):'').': <b>'.$result.'</b><br />';                           ($end?', ending '.localtime($end):'').': <b>'.$result.'</b><br />';
Line 16383  sub commit_customrole { Line 16795  sub commit_customrole {
 }  }
   
 sub commit_standardrole {  sub commit_standardrole {
     my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,$credits) = @_;      my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,$credits,
           $othdomby,$requester) = @_;
     my ($output,$logmsg,$linefeed,$result);      my ($output,$logmsg,$linefeed,$result);
     if ($context eq 'auto') {      if ($context eq 'auto') {
         $linefeed = "\n";          $linefeed = "\n";
Line 16392  sub commit_standardrole { Line 16805  sub commit_standardrole {
     }        }  
     if ($three eq 'st') {      if ($three eq 'st') {
         $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,          $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,
                                       $one,$two,$sec,$context,$credits);                                        $one,$two,$sec,$context,$credits,$othdomby,
                                         $requester);
         if (($result =~ /^error/) || ($result eq 'not_in_class') ||           if (($result =~ /^error/) || ($result eq 'not_in_class') || 
             ($result eq 'unknown_course') || ($result eq 'refused')) {              ($result eq 'unknown_course') || ($result eq 'refused')) {
             $output = $logmsg.' '.&mt('Error: ').$result."\n";               $output = $logmsg.' '.&mt('Error: ').$result."\n"; 
Line 16412  sub commit_standardrole { Line 16826  sub commit_standardrole {
         $output = &mt('Assigning').' '.$three.' in '.$url.          $output = &mt('Assigning').' '.$three.' in '.$url.
                ($start?', '.&mt('starting').' '.localtime($start):'').                 ($start?', '.&mt('starting').' '.localtime($start):'').
                ($end?', '.&mt('ending').' '.localtime($end):'').': ';                 ($end?', '.&mt('ending').' '.localtime($end):'').': ';
         $result = &Apache::lonnet::assignrole($udom,$uname,$url,$three,$end,$start,'','',$context);          $result = &Apache::lonnet::assignrole($udom,$uname,$url,$three,$end,$start,
                                                 '','',$context,$othdomby,$requester);
         if ($context eq 'auto') {          if ($context eq 'auto') {
             $output .= $result.$linefeed;              $output .= $result.$linefeed;
         } else {          } else {
Line 16428  sub commit_standardrole { Line 16843  sub commit_standardrole {
   
 sub commit_studentrole {  sub commit_studentrole {
     my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,      my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context,
         $credits) = @_;          $credits,$othdomby,$requester) = @_;
     my ($result,$linefeed,$oldsecurl,$newsecurl);      my ($result,$linefeed,$oldsecurl,$newsecurl);
     if ($context eq 'auto') {      if ($context eq 'auto') {
         $linefeed = "\n";          $linefeed = "\n";
Line 16452  sub commit_studentrole { Line 16867  sub commit_studentrole {
                 }                  }
                 $oldsecurl = $uurl;                  $oldsecurl = $uurl;
                 $expire_role_result =                   $expire_role_result = 
                     &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,'','','',$context);                      &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now,
                 if ($env{'request.course.sec'} ne '') {                                                   '','','',$context,$othdomby,$requester);
                   if ($env{'request.course.sec'} ne '') {
                     if ($expire_role_result eq 'refused') {                      if ($expire_role_result eq 'refused') {
                         my @roles = ('st');                          my @roles = ('st');
                         my @statuses = ('previous');                          my @statuses = ('previous');
Line 16479  sub commit_studentrole { Line 16895  sub commit_studentrole {
                 &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,                  &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,
                                                            undef,undef,undef,$sec,                                                             undef,undef,undef,$sec,
                                                            $end,$start,'','',$cid,                                                             $end,$start,'','',$cid,
                                                            '',$context,$credits);                                                             '',$context,$credits,'',
                                                              $othdomby,$requester);
             if ($modify_section_result =~ /^ok/) {              if ($modify_section_result =~ /^ok/) {
                 if ($secchange == 1) {                  if ($secchange == 1) {
                     if ($sec eq '') {                      if ($sec eq '') {
Line 16872  sub construct_course { Line 17289  sub construct_course {
         $cenv{'internal.defaultcredits'} = $args->{'defaultcredits'};          $cenv{'internal.defaultcredits'} = $args->{'defaultcredits'};
     }      }
     my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.      my @badclasses = (); # Used to accumulate sections/crosslistings that did not pass classlist access check for course owner.
       my @oklcsecs = (); # Used to accumulate LON-CAPA sections for validated institutional sections.
     if ($args->{'crssections'}) {      if ($args->{'crssections'}) {
         $cenv{'internal.sectionnums'} = '';          $cenv{'internal.sectionnums'} = '';
         if ($args->{'crssections'} =~ m/,/) {          if ($args->{'crssections'} =~ m/,/) {
Line 16885  sub construct_course { Line 17303  sub construct_course {
                 my $class = $args->{'crscode'}.$sec;                  my $class = $args->{'crscode'}.$sec;
                 my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});                  my $addcheck = &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$class,$cenv{'internal.courseowner'});
                 $cenv{'internal.sectionnums'} .= $item.',';                  $cenv{'internal.sectionnums'} .= $item.',';
                 unless ($addcheck eq 'ok') {                  if ($addcheck eq 'ok') {
                       unless (grep(/^\Q$gp\E$/,@oklcsecs)) {
                           push(@oklcsecs,$gp);
                       }
                   } else {
                     push(@badclasses,$class);                      push(@badclasses,$class);
                 }                  }
             }              }
Line 16913  sub construct_course { Line 17335  sub construct_course {
                 my ($xl,$gp) = split/:/,$item;                  my ($xl,$gp) = split/:/,$item;
                 my $addcheck =  &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});                  my $addcheck =  &Apache::lonnet::auto_new_course($$crsunum,$$crsudom,$xl,$cenv{'internal.courseowner'});
                 $cenv{'internal.crosslistings'} .= $item.',';                  $cenv{'internal.crosslistings'} .= $item.',';
                 unless ($addcheck eq 'ok') {                  if ($addcheck eq 'ok') {
                       unless (grep(/^\Q$gp\E$/,@oklcsecs)) {
                           push(@oklcsecs,$gp);
                       }
                   } else {
                     push(@badclasses,$xl);                      push(@badclasses,$xl);
                 }                  }
             }              }
Line 16976  sub construct_course { Line 17402  sub construct_course {
     if ($args->{'no_end_date'}) {      if ($args->{'no_end_date'}) {
         $args->{'endaccess'} = 0;          $args->{'endaccess'} = 0;
     }      }
   #  If an official course with institutional sections is created by cloning 
   #  an existing course, section-specific hiding of course totals in student's
   #  view of grades as copied from cloned course, will be checked for valid 
   #  sections.
       if (($can_clone && $cloneid) &&
           ($cenv{'internal.coursecode'} ne '') &&
           ($cenv{'grading'} eq 'standard') &&
           ($cenv{'hidetotals'} ne '') &&
           ($cenv{'hidetotals'} ne 'all')) {
           my @hidesecs;
           my $deletehidetotals;
           if (@oklcsecs) {
               foreach my $sec (split(/,/,$cenv{'hidetotals'})) {
                   if (grep(/^\Q$sec$/,@oklcsecs)) {
                       push(@hidesecs,$sec);
                   }
               }
               if (@hidesecs) {
                   $cenv{'hidetotals'} = join(',',@hidesecs);
               } else {
                   $deletehidetotals = 1;
               }
           } else {
               $deletehidetotals = 1;
           }
           if ($deletehidetotals) {
               delete($cenv{'hidetotals'});
               &Apache::lonnet::del('environment',['hidetotals'],$$crsudom,$$crsunum);
           }
       }
     $cenv{'internal.autostart'}=$args->{'enrollstart'};      $cenv{'internal.autostart'}=$args->{'enrollstart'};
     $cenv{'internal.autoend'}=$args->{'enrollend'};      $cenv{'internal.autoend'}=$args->{'enrollend'};
     $cenv{'default_enrollment_start_date'}=$args->{'startaccess'};      $cenv{'default_enrollment_start_date'}=$args->{'startaccess'};
Line 17336  sub init_user_environment { Line 17792  sub init_user_environment {
   
     my $public=($username eq 'public' && $domain eq 'public');      my $public=($username eq 'public' && $domain eq 'public');
   
     my ($filename,$cookie,$userroles,$firstaccenv,$timerintenv);      my ($filename,$cookie,$userroles,$firstaccenv,$timerintenv,
           $coauthorenv);
     my $now=time;      my $now=time;
   
     if ($public) {      if ($public) {
Line 17402  sub init_user_environment { Line 17859  sub init_user_environment {
           
 # Initialize roles  # Initialize roles
   
  ($userroles,$firstaccenv,$timerintenv) =    ($userroles,$firstaccenv,$timerintenv,$coauthorenv) = 
             &Apache::lonnet::rolesinit($domain,$username,$authhost);              &Apache::lonnet::rolesinit($domain,$username,$authhost);
     }      }
 # ------------------------------------ Check browser type and MathML capability  # ------------------------------------ Check browser type and MathML capability
Line 17480  sub init_user_environment { Line 17937  sub init_user_environment {
             my %is_adv = ( is_adv => $env{'user.adv'} );              my %is_adv = ( is_adv => $env{'user.adv'} );
             my %domdef = &Apache::lonnet::get_domain_defaults($domain);              my %domdef = &Apache::lonnet::get_domain_defaults($domain);
   
             foreach my $tool ('aboutme','blog','webdav','portfolio','timezone') {              foreach my $tool ('aboutme','blog','webdav','portfolio','portaccess','timezone') {
                 $userenv{'availabletools.'.$tool} =                   $userenv{'availabletools.'.$tool} =
                     &Apache::lonnet::usertools_access($username,$domain,$tool,'reload',                      &Apache::lonnet::usertools_access($username,$domain,$tool,'reload',
                                                       undef,\%userenv,\%domdef,\%is_adv);                                                        undef,\%userenv,\%domdef,\%is_adv);
             }              }
Line 17493  sub init_user_environment { Line 17950  sub init_user_environment {
                                                       \%userenv,\%domdef,\%is_adv);                                                        \%userenv,\%domdef,\%is_adv);
             }              }
   
               if ((ref($userroles) eq 'HASH') && ($userroles->{'user.author'}) &&
                   (exists($userroles->{"user.role.au./$domain/"}))) {
                   if ($userenv{'authoreditors'}) {
                       $userenv{'editors'} = $userenv{'authoreditors'};
                   } elsif ($domdef{'editors'} ne '') {
                       $userenv{'editors'} = $domdef{'editors'};
                   } else {
                       $userenv{'editors'} = 'edit,xml';
                   }
               }
   
             $userenv{'canrequest.author'} =              $userenv{'canrequest.author'} =
                 &Apache::lonnet::usertools_access($username,$domain,'requestauthor',                  &Apache::lonnet::usertools_access($username,$domain,'requestauthor',
                                                   'reload','requestauthor',                                                    'reload','requestauthor',
Line 17549  sub init_user_environment { Line 18017  sub init_user_environment {
             if (ref($timerintenv) eq 'HASH') {              if (ref($timerintenv) eq 'HASH') {
                 &_add_to_env(\%disk_env,$timerintenv);                  &_add_to_env(\%disk_env,$timerintenv);
             }              }
               if (ref($coauthorenv) eq 'HASH') {
                   if (keys(%{$coauthorenv})) {
                       &_add_to_env(\%disk_env,$coauthorenv);
                   }
               }
     if (ref($args->{'extra_env'})) {      if (ref($args->{'extra_env'})) {
  &_add_to_env(\%disk_env,$args->{'extra_env'});   &_add_to_env(\%disk_env,$args->{'extra_env'});
     }      }
Line 18500  sub parse_supplemental_title { Line 18973  sub parse_supplemental_title {
         my $name =  &plainname($uname,$udom);          my $name =  &plainname($uname,$udom);
         $name = &HTML::Entities::encode($name,'"<>&\'');          $name = &HTML::Entities::encode($name,'"<>&\'');
         $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');          $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
         $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.          $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.$name;
             $name.': <br />'.$foldertitle;          if ($foldertitle ne '') {
               $title .= ': <br />'.$foldertitle;
           }
     }      }
     if (wantarray) {      if (wantarray) {
         return ($title,$foldertitle,$renametitle);          return ($title,$foldertitle,$renametitle);

Removed from v.1.1399  
changed lines
  Added in v.1.1423


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