Diff for /loncom/interface/loncommon.pm between versions 1.564.2.11 and 1.565

version 1.564.2.11, 2007/10/12 00:16:40 version 1.565, 2007/08/18 00:01:37
Line 870  sub help_menu_js { Line 870  sub help_menu_js {
  'js_ready'    => 1,   'js_ready'    => 1,
  'add_entries' => {   'add_entries' => {
     'border' => '0',      'border' => '0',
     'rows'   => "110,*",},});      'rows'   => "105,*",},});
     my $end_page =      my $end_page =
         &Apache::loncommon::end_page({'frameset' => 1,          &Apache::loncommon::end_page({'frameset' => 1,
       'js_ready' => 1,});        'js_ready' => 1,});
Line 1084  sub changable_area { Line 1084  sub changable_area {
   
 =pod  =pod
   
   =item * resize_textarea_js
   
   emits the needed javascript to resize a textarea to be as big as possible
   
   creates a function resize_textrea that takes two IDs first should be
   the id of the element to resize, second should be the id of a div that
   surrounds everything that comes after the textarea, this routine needs
   to be attached to the <body> for the onload and onresize events.
   
   
   =cut
   
   sub resize_textarea_js {
       return <<"RESIZE";
       <script type="text/javascript">
   var Geometry = {};
   function init_geometry() {
       if (Geometry.init) { return };
       Geometry.init=1;
       if (window.innerHeight) {
    Geometry.getViewportHeight = function() { return window.innerHeight; };
       }
       else if (document.documentElement && document.documentElement.clientHeight) {
    Geometry.getViewportHeight = 
       function() { return document.documentElement.clientHeight; };
       }
       else if (document.body.clientHeight) {
    Geometry.getViewportHeight = 
       function() { return document.body.clientHeight; };
       }
   }
   
   function resize_textarea(textarea_id,bottom_id) {
       init_geometry();
       var textarea        = document.getElementById(textarea_id);
       //alert(textarea);
   
       var textarea_top    = textarea.offsetTop;
       var textarea_height = textarea.offsetHeight;
       var bottom          = document.getElementById(bottom_id);
       var bottom_top      = bottom.offsetTop;
       var bottom_height   = bottom.offsetHeight;
       var window_height   = Geometry.getViewportHeight();
       var fudge           = 23; 
       var new_height      = window_height-fudge-textarea_top-bottom_height;
       if (new_height < 300) {
    new_height = 300;
       }
       textarea.style.height=new_height+'px';
   }
   </script>
   RESIZE
   
   }
   
   =pod
   
 =back  =back
     
 =head1 Excel and CSV file utility routines  =head1 Excel and CSV file utility routines
Line 3458  sub bodytag { Line 3515  sub bodytag {
     if (!$realm) { $realm='&nbsp;'; }      if (!$realm) { $realm='&nbsp;'; }
 # Set messages  # Set messages
     my $messages=&domainlogo($domain);      my $messages=&domainlogo($domain);
   # Port for miniserver
       my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
       if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
   
     my $extra_body_attr = &make_attr_string($forcereg,\%design);      my $extra_body_attr = &make_attr_string($forcereg,\%design);
   
Line 3575  ENDROLE Line 3635  ENDROLE
   
     my $imgsrc = $img;      my $imgsrc = $img;
     if ($img =~ /^\/adm/) {      if ($img =~ /^\/adm/) {
         $imgsrc = &lonhttpdurl($img);          $imgsrc = 'http://'.$ENV{'HTTP_HOST'}.':'.$lonhttpdPort.$img;
     }      }
     my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';      my $upperleft='<img src="'.$imgsrc.'" alt="'.$function.'" />';
   
Line 4283  table#LC_helpmenu_links a:hover { Line 4343  table#LC_helpmenu_links a:hover {
   border: 1px solid #8888FF;    border: 1px solid #8888FF;
   background: #CCCCFF;    background: #CCCCFF;
 }  }
   
 table.LC_pick_box {  table.LC_pick_box {
     width: 100%;
   border-collapse: separate;    border-collapse: separate;
   background: white;    background: white;
   border: 1px solid black;    border: 1px solid black;
Line 4296  table.LC_pick_box td.LC_pick_box_title { Line 4358  table.LC_pick_box td.LC_pick_box_title {
   width: 184px;    width: 184px;
   padding: 8px;    padding: 8px;
 }  }
 table.LC_pick_box td.LC_pick_box_value {  
   text-align: left;  
   padding: 8px;  
 }  
 table.LC_pick_box td.LC_pick_box_select {  
   text-align: left;  
   padding: 8px;  
 }  
 table.LC_pick_box td.LC_pick_box_separator {  table.LC_pick_box td.LC_pick_box_separator {
   padding: 0px;    padding: 0px;
   height: 1px;    height: 1px;
Line 4312  table.LC_pick_box td.LC_pick_box_separat Line 4366  table.LC_pick_box td.LC_pick_box_separat
 table.LC_pick_box td.LC_pick_box_submit {  table.LC_pick_box td.LC_pick_box_submit {
   text-align: right;    text-align: right;
 }  }
 table.LC_pick_box td.LC_evenrow_value {  
   text-align: left;  
   padding: 8px;  
   background-color: $data_table_light;  
 }  
 table.LC_pick_box td.LC_oddrow_value {  
   text-align: left;  
   padding: 8px;  
   background-color: $data_table_light;  
 }  
 table.LC_helpform_receipt {  
   width: 620px;  
   border-collapse: separate;  
   background: white;  
   border: 1px solid black;  
   border-spacing: 1px;  
 }  
 table.LC_helpform_receipt td.LC_pick_box_title {  
   background: $tabbg;  
   font-weight: bold;  
   text-align: right;  
   width: 184px;  
   padding: 8px;  
 }  
 table.LC_helpform_receipt td.LC_evenrow_value {  
   text-align: left;  
   padding: 8px;  
   background-color: $data_table_light;  
 }  
 table.LC_helpform_receipt td.LC_oddrow_value {  
   text-align: left;  
   padding: 8px;  
   background-color: $data_table_light;  
 }  
 table.LC_helpform_receipt td.LC_pick_box_separator {  
   padding: 0px;  
   height: 1px;  
   background: black;  
 }  
 span.LC_helpform_receipt_cat {  
   font-weight: bold;  
 }  
 table.LC_group_priv_box {  table.LC_group_priv_box {
   background: white;    background: white;
   border: 1px solid black;    border: 1px solid black;
Line 4498  span.LC_nobreak { Line 4511  span.LC_nobreak {
   white-space: nowrap;    white-space: nowrap;
 }  }
   
 span.LC_cusr_emph {  
   font-style: italic;  
 }  
   
 table.LC_docs_documents {  table.LC_docs_documents {
   background: #BBBBBB;    background: #BBBBBB;
   border-width: 0px;    border-width: 0px;
Line 4685  Inputs: none Line 4694  Inputs: none
 sub xml_begin {  sub xml_begin {
     my $output='';      my $output='';
   
     if ($env{'internal.start_page'}==1) {      &Apache::lonhtmlcommon::init_htmlareafields();
  &Apache::lonhtmlcommon::init_htmlareafields();  
     }  
   
     if ($env{'browser.mathml'}) {      if ($env{'browser.mathml'}) {
  $output='<?xml version="1.0"?>'   $output='<?xml version="1.0"?>'
Line 5602  sub get_secgrprole_info { Line 5609  sub get_secgrprole_info {
 }  }
   
 sub user_picker {  sub user_picker {
     my ($dom,$srch,$forcenewuser,$caller) = @_;      my ($dom,$srch,$forcenewuser) = @_;
     my $currdom = $dom;      my $currdom = $dom;
     my %curr_selected = (      my %curr_selected = (
                         srchin => 'dom',                          srchin => 'dom',
                         srchby => 'lastname',                          srchby => 'uname',
                       );                        );
     my $srchterm;      my $srchterm;
     if (ref($srch) eq 'HASH') {      if (ref($srch) eq 'HASH') {
Line 5625  sub user_picker { Line 5632  sub user_picker {
         $srchterm = $srch->{'srchterm'};          $srchterm = $srch->{'srchterm'};
     }      }
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                     'usr'       => 'Search criteria',  
                     'doma'      => 'Domain/institution to search',                      'doma'      => 'Domain/institution to search',
                     'uname'     => 'username',                      'uname'     => 'username',
                     'lastname'  => 'last name',                      'lastname'  => 'last name',
                     'lastfirst' => 'last name, first name',                      'lastfirst' => 'last name, first name',
                     'crs'       => 'in this course',                      'crs'       => 'in this course',
                     'dom'       => 'in selected LON-CAPA domain',                       'dom'       => 'in this domain', 
                     'alc'       => 'all LON-CAPA',                      'alc'       => 'all LON-CAPA',
                     'instd'     => 'in institutional directory for selected domain',                      'instd'     => 'in institutional directory',
                     'exact'     => 'is',                      'exact'     => 'is',
                     'contains'  => 'contains',                      'contains'  => 'contains',
                     'begins'    => 'begins with',  
                     'youm'      => "You must include some text to search for.",  
                     'thte'      => "The text you are searching for must contain at least two characters when using a 'begins' type search.",  
                     'thet'      => "The text you are searching for must contain at least three characters when using a 'contains' type search.",  
                     'yomc'      => "You must choose a domain when using an institutional directory search.",  
                     'ymcd'      => "You must choose a domain when using a domain search.",  
                     'whus'      => "When using searching by last,first you must include a comma as separator between last name and first name.",  
                     'whse'      => "When searching by last,first you must include at least one character in the first name.",  
                      'thfo'     => "The following need to be corrected before the search can be run:",  
                                        );                                         );
     my $domform = &select_dom_form($currdom,'srchdomain',1,1);      my $domform = &select_dom_form($currdom,'srchdomain',1,1);
     my $srchinsel = ' <select name="srchin">';      my $srchinsel = ' <select name="srchin">';
Line 5668  sub user_picker { Line 5665  sub user_picker {
     $srchinsel .= "\n  </select>\n";      $srchinsel .= "\n  </select>\n";
   
     my $srchbysel =  ' <select name="srchby">';      my $srchbysel =  ' <select name="srchby">';
     foreach my $option ('lastname','lastfirst','uname') {      foreach my $option ('uname','lastname','lastfirst') {
         if ($curr_selected{'srchby'} eq $option) {          if ($curr_selected{'srchby'} eq $option) {
             $srchbysel .= '              $srchbysel .= '
    <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';     <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
Line 5680  sub user_picker { Line 5677  sub user_picker {
     $srchbysel .= "\n  </select>\n";      $srchbysel .= "\n  </select>\n";
   
     my $srchtypesel = ' <select name="srchtype">';      my $srchtypesel = ' <select name="srchtype">';
     foreach my $option ('begins','contains','exact') {      foreach my $option ('exact','contains') {
         if ($curr_selected{'srchtype'} eq $option) {          if ($curr_selected{'srchtype'} eq $option) {
             $srchtypesel .= '              $srchtypesel .= '
    <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';     <option value="'.$option.'" selected="selected">'.$lt{$option}.'</option>';
Line 5694  sub user_picker { Line 5691  sub user_picker {
     my ($newuserscript,$new_user_create);      my ($newuserscript,$new_user_create);
   
     if ($forcenewuser) {      if ($forcenewuser) {
         if (ref($srch) eq 'HASH') {   $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\');" /> </p>';
             if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) {  
         $new_user_create = '<p> <input type="submit" name="forcenew" value="'.&HTML::Entities::encode(&mt('Make new user "[_1]"',$srchterm),'<>&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" /> </p>';  
             }  
         }  
   
         $newuserscript = <<"ENDSCRIPT";          $newuserscript = <<"ENDSCRIPT";
   
 function setSearch(createnew,callingForm) {  function setSearch(createnew) {
     if (createnew == 1) {      if (createnew == 1) {
         for (var i=0; i<callingForm.srchby.length; i++) {          for (var i=0; i<document.crtuser.srchby.length; i++) {
             if (callingForm.srchby.options[i].value == 'uname') {              if (document.crtuser.srchby.options[i].value == 'uname') {
                 callingForm.srchby.selectedIndex = i;                  document.crtuser.srchby.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<callingForm.srchin.length; i++) {          for (var i=0; i<document.crtuser.srchin.length; i++) {
             if ( callingForm.srchin.options[i].value == 'dom') {              if ( document.crtuser.srchin.options[i].value == 'dom') {
  callingForm.srchin.selectedIndex = i;   document.crtuser.srchin.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<callingForm.srchtype.length; i++) {          for (var i=0; i<document.crtuser.srchtype.length; i++) {
             if (callingForm.srchtype.options[i].value == 'exact') {              if (document.crtuser.srchtype.options[i].value == 'exact') {
                 callingForm.srchtype.selectedIndex = i;                  document.crtuser.srchtype.selectedIndex = i;
             }              }
         }          }
         for (var i=0; i<callingForm.srchdomain.length; i++) {          for (var i=0; i<document.crtuser.srchdomain.length; i++) {
             if (callingForm.srchdomain.options[i].value == '$env{'request.role.domain'}') {              if (document.crtuser.srchdomain.options[i].value == '$env{'request.role.domain'}') {
                 callingForm.srchdomain.selectedIndex = i;                  document.crtuser.srchdomain.selectedIndex = i;
             }              }
         }          }
     }      }
Line 5732  ENDSCRIPT Line 5724  ENDSCRIPT
   
     my $output = <<"END_BLOCK";      my $output = <<"END_BLOCK";
 <script type="text/javascript">  <script type="text/javascript">
 function validateEntry(callingForm) {  function validateEntry() {
   
     var checkok = 1;      var checkok = 1;
     var srchin;      var srchin;
     for (var i=0; i<callingForm.srchin.length; i++) {      for (var i=0; i<document.crtuser.srchin.length; i++) {
  if ( callingForm.srchin[i].checked ) {   if ( document.crtuser.srchin[i].checked ) {
     srchin = callingForm.srchin[i].value;      srchin = document.crtuser.srchin[i].value;
  }   }
     }      }
   
     var srchtype = callingForm.srchtype.options[callingForm.srchtype.selectedIndex].value;      var srchtype = document.crtuser.srchtype.options[document.crtuser.srchtype.selectedIndex].value;
     var srchby = callingForm.srchby.options[callingForm.srchby.selectedIndex].value;      var srchby = document.crtuser.srchby.options[document.crtuser.srchby.selectedIndex].value;
     var srchdomain = callingForm.srchdomain.options[callingForm.srchdomain.selectedIndex].value;      var srchdomain = document.crtuser.srchdomain.options[document.crtuser.srchdomain.selectedIndex].value;
     var srchterm =  callingForm.srchterm.value;      var srchterm =  document.crtuser.srchterm.value;
     var srchin = callingForm.srchin.options[callingForm.srchin.selectedIndex].value;      var srchin = document.crtuser.srchin.options[document.crtuser.srchin.selectedIndex].value;
     var msg = "";      var msg = "";
   
     if (srchterm == "") {      if (srchterm == "") {
         checkok = 0;          checkok = 0;
         msg += "$lt{'youm'}\\n";          msg += "You must include some text to search for.\\n";
     }  
   
     if (srchtype== 'begins') {  
         if (srchterm.length < 2) {  
             checkok = 0;  
             msg += "$lt{'thte'}\\n";  
         }  
     }      }
   
     if (srchtype== 'contains') {      if (srchtype== 'contains') {
         if (srchterm.length < 3) {          if (srchterm.length < 3) {
             checkok = 0;              checkok = 0;
             msg += "$lt{'thet'}\\n";              msg += "The text you are searching for must contain at least three characters when using a 'contains' type search.\\n";
         }          }
     }      }
     if (srchin == 'instd') {      if (srchin == 'instd') {
         if (srchdomain == '') {          if (srchdomain == '') {
             checkok = 0;              checkok = 0;
             msg += "$lt{'yomc'}\\n";              msg += "You must choose a domain when using an institutional directory search.\\n";
         }          }
     }      }
     if (srchin == 'dom') {      if (srchin == 'dom') {
         if (srchdomain == '') {          if (srchdomain == '') {
             checkok = 0;              checkok = 0;
             msg += "$lt{'ymcd'}\\n";              msg += "You must choose a domain when using a domain search.\\n";
         }          }
     }      }
     if (srchby == 'lastfirst') {      if (srchby == 'lastfirst') {
         if (srchterm.indexOf(",") == -1) {          if (srchterm.indexOf(",") == -1) {
             checkok = 0;              checkok = 0;
             msg += "$lt{'whus'}\\n";              msg += "When using searching by last,first you must include a comma as separator between last name and first name.\\n";
         }          }
         if (srchterm.indexOf(",") == srchterm.length -1) {          if (srchterm.indexOf(",") == srchterm.length -1) {
             checkok = 0;              checkok = 0;
             msg += "$lt{'whse'}\\n";              msg += "When searching by last,first you must include at least one character in the first name.\\n";
         }          }
     }      }
     if (checkok == 0) {      if (checkok == 0) {
         alert("$lt{'thfo'}\\n"+msg);          alert("The following need to be corrected before the search can be run:\\n"+msg);
         return;          return;
     }      }
     if (checkok == 1) {      if (checkok == 1) {
         callingForm.submit();          document.crtuser.submit();
     }      }
 }  }
   
Line 5806  $new_user_create Line 5791  $new_user_create
   
 <table>  <table>
  <tr>   <tr>
   <td>$lt{'doma'}:</td>  
   <td>$domform</td>  
   </td>  
  </tr>  
  <tr>  
   <td>$lt{'usr'}:</td>  
   <td>$srchbysel    <td>$srchbysel
       $srchtypesel         $srchtypesel 
       <input type="text" size="15" name="srchterm" value="$srchterm" />        <input type="text" size="15" name="srchterm" value="$srchterm" />
       $srchinsel         $srchinsel 
   </td>    </td>
  </tr>   </tr>
    <tr>
     <td>$lt{'doma'}: $domform</td>
     </td>
    </tr>
 </table>  </table>
 <br />  <br />
 END_BLOCK  END_BLOCK
Line 5825  END_BLOCK Line 5808  END_BLOCK
     return $output;      return $output;
 }  }
   
   
   
 =pod  =pod
   
 =back  =back
Line 6984  sub commit_studentrole { Line 6969  sub commit_studentrole {
 ############################################################  ############################################################
 ############################################################  ############################################################
   
 sub check_clone {  
     my ($args,$linefeed) = @_;  
     my $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};  
     my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);  
     my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);  
     my $clonemsg;  
     my $can_clone = 0;  
   
     if ($clonehome eq 'no_host') {  
         $clonemsg = &mt('No new course created.').$linefeed.&mt('A new course could not be cloned from the specified original - [_1] - because it is a non-existent course.',$args->{'clonecourse'}.':'.$args->{'clonedomain'});       
     } else {  
  my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});  
  if ($env{'request.role.domain'} eq $args->{'clonedomain'}) {  
     $can_clone = 1;  
  } else {  
     my %clonehash = &Apache::lonnet::get('environment',['cloners'],  
  $args->{'clonedomain'},$args->{'clonecourse'});  
     my @cloners = split(/,/,$clonehash{'cloners'});  
             if (grep(/^\*$/,@cloners)) {  
                 $can_clone = 1;  
             } elsif (grep(/^\*\:\Q$args->{'ccdomain'}\E$/,@cloners)) {  
                 $can_clone = 1;  
             } else {  
         my %roleshash =  
     &Apache::lonnet::get_my_roles($args->{'ccuname'},  
  $args->{'ccdomain'},  
                                          'userroles',['active'],['cc'],  
  [$args->{'clonedomain'}]);  
         if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':cc'}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {  
     $can_clone = 1;  
         } else {  
                     $clonemsg = &mt('No new course created.').$linefeed.&mt('The new course could not be cloned from the existing course because the new course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});  
         }  
     }  
         }  
     }  
     return ($can_clone, $clonemsg, $cloneid, $clonehome);  
 }  
   
 sub construct_course {  sub construct_course {
     my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;      my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;
     my $outcome;      my $outcome;
Line 7030  sub construct_course { Line 6976  sub construct_course {
     if ($context eq 'auto') {      if ($context eq 'auto') {
         $linefeed = "\n";          $linefeed = "\n";
     }      }
   
 #  
 # Are we cloning?  
 #  
     my ($can_clone, $clonemsg, $cloneid, $clonehome);  
     if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {  
  ($can_clone, $clonemsg, $cloneid, $clonehome) = &check_clone($args,$linefeed);  
  if ($context ne 'auto') {  
             if ($clonemsg ne '') {  
         $clonemsg = '<span class="LC_error">'.$clonemsg.'</span>';  
             }  
  }  
  $outcome .= $clonemsg.$linefeed;  
   
         if (!$can_clone) {  
     return (0,$outcome);  
  }  
     }  
   
 #  #
 # Open course  # Open course
 #  #
Line 7069  sub construct_course { Line 6996  sub construct_course {
     # if anyone ever decides to not show this, and Utils::Course::new      # if anyone ever decides to not show this, and Utils::Course::new
     # will need to be suitably modified.      # will need to be suitably modified.
     $outcome .= &mt('New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;      $outcome .= &mt('New LON-CAPA [_1] ID: [_2]',$crstype,$$courseid).$linefeed;
   
 #  #
 # Check if created correctly  # Check if created correctly
 #  #
     ($$crsudom,$$crsunum)= &LONCAPA::split_courseid($$courseid);      ($$crsudom,$$crsunum)= &LONCAPA::split_courseid($$courseid);
     my $crsuhome=&Apache::lonnet::homeserver($$crsunum,$$crsudom);      my $crsuhome=&Apache::lonnet::homeserver($$crsunum,$$crsudom);
     $outcome .= &mt('Created on').': '.$crsuhome.$linefeed;      $outcome .= &mt('Created on').': '.$crsuhome.$linefeed;
   
 #  #
 # Do the cloning  # Are we cloning?
 #     #
     if ($can_clone && $cloneid) {      my $cloneid='';
  $clonemsg = &mt('Cloning [_1] from [_2]',$crstype,$clonehome);      if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {
  if ($context ne 'auto') {          my $can_clone = 0;
     $clonemsg = '<span class="LC_success">'.$clonemsg.'</span>';   $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};
  }          my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);
  $outcome .= $clonemsg.$linefeed;   my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
  my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);          my $clonemsg;
    if ($clonehome eq 'no_host') {
               $clonemsg = &mt('Attempting to clone non-existing [_1]',$crstype);
               if ($context eq 'auto') {
                   $outcome .= $clonemsg;
               } else {
           $outcome .= '<font color="red">'.$clonemsg.'</font>';
               }
               $outcome .= $linefeed;
    } else {
               my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
               if ($env{'request.role.domain'} eq $args->{'form.clonedomain'}) {
                   $can_clone = 1;
               } else {
                   my %clonehash = &Apache::lonnet::get('environment',['cloners'],
                               $args->{'clonedomain'},$args->{'clonecourse'});
                   my @cloners = split(/,/,$clonehash{'cloners'});
                   my %roleshash =
                       &Apache::lonnet::get_my_roles($args->{'ccuname'},
                           $args->{'ccdomain'},'userroles',['active'],['cc'],
                           [$args->{'clonedomain'}]);
                   if (($roleshash{$args->{'clonecourse'}.':'.$args->{'clonedomain'}.':cc'}) || (grep(/^\Q$args->{'ccuname'}\E:\Q$args->{'ccdomain'}\E$/,@cloners))) {
                       $can_clone = 1;
                   } else {
                       $clonemsg = &mt('The new course was not cloned from an existing course because the course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$args->{'ccuname'}.':'.$args->{'ccdomain'},$clonedesc{'description'});
                       if ($context eq 'auto') {
                           $outcome .= $clonemsg;
                       } else {
                           $outcome .= '<font color="red">'.$clonemsg.'</font>';
                       }
                       $outcome .= $linefeed;
                   }
               }
           }
           if ($can_clone) {
       $clonemsg = &mt('Cloning [_1] from [_2]',$crstype,$clonehome);
               if ($context eq 'auto') {
                   $outcome = $clonemsg;
               } else { 
                   $outcome .= '<font color="green">'.$clonemsg.'</font>';
               }
               $outcome .= $linefeed;
       my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);
 # Copy all files  # Copy all files
  &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid);      &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid);
 # Restore URL  # Restore URL
  $cenv{'url'}=$oldcenv{'url'};      $cenv{'url'}=$oldcenv{'url'};
 # Restore title  # Restore title
  $cenv{'description'}=$oldcenv{'description'};      $cenv{'description'}=$oldcenv{'description'};
 # restore grading mode  # restore grading mode
  if (defined($oldcenv{'grading'})) {      if (defined($oldcenv{'grading'})) {
     $cenv{'grading'}=$oldcenv{'grading'};   $cenv{'grading'}=$oldcenv{'grading'};
  }      }
 # Mark as cloned  # Mark as cloned
  $cenv{'clonedfrom'}=$cloneid;      $cenv{'clonedfrom'}=$cloneid;
  delete($cenv{'default_enrollment_start_date'});      delete($cenv{'default_enrollment_start_date'});
  delete($cenv{'default_enrollment_end_date'});      delete($cenv{'default_enrollment_end_date'});
    }
     }      }
   
 #  #
 # Set environment (will override cloned, if existing)  # Set environment (will override cloned, if existing)
 #  #
Line 7209  sub construct_course { Line 7178  sub construct_course {
                            ' ('.$lt{'adby'}.')';                             ' ('.$lt{'adby'}.')';
         if ($context eq 'auto') {          if ($context eq 'auto') {
             $outcome .= $badclass_msg.$linefeed;              $outcome .= $badclass_msg.$linefeed;
             $outcome .= '<div class="LC_warning">'.$badclass_msg.$linefeed.'<ul>'."\n";              $outcome .= '<font color="red">'.$badclass_msg.$linefeed.'<ul>'."\n";
             foreach my $item (@badclasses) {              foreach my $item (@badclasses) {
                 if ($context eq 'auto') {                  if ($context eq 'auto') {
                     $outcome .= " - $item\n";                      $outcome .= " - $item\n";
Line 7220  sub construct_course { Line 7189  sub construct_course {
             if ($context eq 'auto') {              if ($context eq 'auto') {
                 $outcome .= $linefeed;                  $outcome .= $linefeed;
             } else {              } else {
                 $outcome .= "</ul><br /><br /></div>\n";                  $outcome .= "</ul><br /><br /></font>\n";
             }              }
         }           } 
     }      }
Line 7242  sub construct_course { Line 7211  sub construct_course {
             if ($context eq 'auto') {              if ($context eq 'auto') {
                 $outcome .= $krb_msg;                  $outcome .= $krb_msg;
             } else {              } else {
                 $outcome .= '<span class="LC_error">'.$krb_msg.'</span>';                  $outcome .= '<font color="red" size="+1">'.$krb_msg.'</font>';
             }              }
             $outcome .= $linefeed;              $outcome .= $linefeed;
         }          }
Line 7340  sub construct_course { Line 7309  sub construct_course {
  if ($errtext) { $fatal=2; }   if ($errtext) { $fatal=2; }
         $outcome .= ($fatal?$errtext:'write ok').$linefeed;          $outcome .= ($fatal?$errtext:'write ok').$linefeed;
     }      }
       return $outcome;
     return (1,$outcome);  
 }  }
   
 ############################################################  ############################################################
Line 7384  sub icon { Line 7352  sub icon {
     return &lonhttpdurl($iconname);      return &lonhttpdurl($iconname);
 }   } 
   
 sub lonhttpd_port {  
     my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};  
     if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }  
     # IE doesn't like a secure page getting images from a non-secure  
     # port (when logging we haven't parsed the browser type so default  
     # back to secure  
     if ((!exists($env{'browser.type'}) || $env{'browser.type'} eq 'explorer')  
  && $ENV{'SERVER_PORT'} == 443) {  
  return 443;  
     }  
     return $lonhttpd_port;  
   
 }  
   
 sub lonhttpdurl {  sub lonhttpdurl {
     my ($url)=@_;      my ($url)=@_;
       my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};
     my $lonhttpd_port = &lonhttpd_port();      if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }
     if ($lonhttpd_port == 443) {  
  return 'https://'.$ENV{'SERVER_NAME'}.$url;  
     }  
     return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;      return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;
 }  }
   

Removed from v.1.564.2.11  
changed lines
  Added in v.1.565


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