Diff for /loncom/interface/loncommon.pm between versions 1.537 and 1.554

version 1.537, 2007/06/18 23:19:12 version 1.554, 2007/07/25 23:20:38
Line 240  Inputs: formname, elementname Line 240  Inputs: formname, elementname
   
 formname and elementname specify the name of the html form and the name  formname and elementname specify the name of the html form and the name
 of the element the selection from the search results will be placed in.  of the element the selection from the search results will be placed in.
 =back  
 =cut  =cut
   
 sub browser_and_searcher_javascript {  sub browser_and_searcher_javascript {
Line 378  sub coursebrowser_javascript { Line 378  sub coursebrowser_javascript {
     my ($domainfilter,$sec_element,$formname)=@_;      my ($domainfilter,$sec_element,$formname)=@_;
     my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');      my $crs_or_grp_alert = &mt('Please select the type of LON-CAPA entity - Course or Group - for which you wish to add/modify a user role');
    my $output = '     my $output = '
 <script type="text/javascript" language="Javascript" >  <script type="text/javascript">
     var stdeditbrowser;'."\n";      var stdeditbrowser;'."\n";
    $output .= <<"ENDSTDBRW";     $output .= <<"ENDSTDBRW";
     function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {      function opencrsbrowser(formname,uname,udom,desc,extra_element,multflag,crstype) {
Line 524  function uncheckAll(field) { Line 524  function uncheckAll(field) {
     if (field.length > 0) {      if (field.length > 0) {
         for (i = 0; i < field.length; i++) {          for (i = 0; i < field.length; i++) {
             field[i].checked = false ;              field[i].checked = false ;
         }     } else {          }
       } else {
         field.checked = false ;          field.checked = false ;
     }      }
 }  }
Line 708  sub help_open_topic { Line 709  sub help_open_topic {
     my ($topic, $text, $stayOnPage, $width, $height) = @_;      my ($topic, $text, $stayOnPage, $width, $height) = @_;
     $text = "" if (not defined $text);      $text = "" if (not defined $text);
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     if ($env{'browser.interface'} eq 'textual' ||      if ($env{'browser.interface'} eq 'textual') {
  $env{'environment.remote'} eq 'off' ) {  
  $stayOnPage=1;   $stayOnPage=1;
     }      }
     $width = 350 if (not defined $width);      $width = 350 if (not defined $width);
Line 801  ENDOUTPUT Line 801  ENDOUTPUT
 # now just updates the help link and generates a blue icon  # now just updates the help link and generates a blue icon
 sub help_open_menu {  sub help_open_menu {
     my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text)       my ($topic,$component_help,$faq,$bug,$stayOnPage,$width,$height,$text) 
  = @_;   = @_;    
       
     $stayOnPage = 0 if (not defined $stayOnPage);      $stayOnPage = 0 if (not defined $stayOnPage);
     if ($env{'browser.interface'} eq 'textual' ||      # formerly only used pop-up help (stayOnPage = 0)
  $env{'environment.remote'} eq 'off' ) {      # if environment.remote is on (using remote control UI)
  $stayOnPage=1;      # if ($env{'browser.interface'} eq 'textual' ||
       # $env{'environment.remote'} eq 'off' ) {
       #   $stayOnPage=1;
       #}
       # Now making pop-up help the default even with remote control
       if ($env{'browser.interface'} eq 'textual') {
           $stayOnPage=1;
     }      }
     my $output;      my $output;
     if ($component_help) {      if ($component_help) {
Line 1078  sub changable_area { Line 1083  sub changable_area {
 =pod  =pod
   
 =back  =back
    
 =head1 Excel and CSV file utility routines  =head1 Excel and CSV file utility routines
   
 =over 4  =over 4
Line 1212  sub create_workbook { Line 1217  sub create_workbook {
   
 =item * create_text_file  =item * create_text_file
   
 Create a file to write to and eventually make available to the usre.  Create a file to write to and eventually make available to the user.
 If file creation fails, outputs an error message on the request object and   If file creation fails, outputs an error message on the request object and 
 return undefs.  return undefs.
   
Line 1262  sub domain_select { Line 1267  sub domain_select {
     } &Apache::lonnet::all_domains();      } &Apache::lonnet::all_domains();
     if ($multiple) {      if ($multiple) {
  $domains{''}=&mt('Any domain');   $domains{''}=&mt('Any domain');
    $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
  return &multiple_select_form($name,$value,4,\%domains);   return &multiple_select_form($name,$value,4,\%domains);
     } else {      } else {
    $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))];
  return &select_form($name,$value,%domains);   return &select_form($name,$value,%domains);
     }      }
 }  }
Line 1429  selected"); Line 1436  selected");
 #-------------------------------------------  #-------------------------------------------
 sub select_dom_form {  sub select_dom_form {
     my ($defdom,$name,$includeempty) = @_;      my ($defdom,$name,$includeempty) = @_;
     my @domains = sort(&Apache::lonnet::all_domains());      my @domains = sort {lc($a) cmp lc($b)} (&Apache::lonnet::all_domains());
     if ($includeempty) { @domains=('',@domains); }      if ($includeempty) { @domains=('',@domains); }
     my $selectdomain = "<select name=\"$name\" size=\"1\">\n";      my $selectdomain = "<select name=\"$name\" size=\"1\">\n";
     foreach my $dom (@domains) {      foreach my $dom (@domains) {
Line 2119  sub getnames { Line 2126  sub getnames {
     }      }
 }  }
   
   # -------------------------------------------------------------------- getemails
   =pod
   
   =item * getemails($uname,$udom)
   
   Gets a user's email information and returns it as a hash with keys:
   notification, critnotification, permanentemail
   
   For notification and critnotification, values are comma-separated lists 
   of e-mail address(es); for permanentemail, value is a single e-mail address.
    
   =cut
   
 sub getemails {  sub getemails {
     my ($uname,$udom)=@_;      my ($uname,$udom)=@_;
     if ($udom eq 'public' && $uname eq 'public') {      if ($udom eq 'public' && $uname eq 'public') {
Line 2140  sub getemails { Line 2160  sub getemails {
     }      }
 }  }
   
   sub flush_email_cache {
       my ($uname,$udom)=@_;
       if (!$udom)  { $udom =$env{'user.domain'}; }
       if (!$uname) { $uname=$env{'user.name'};   }
       return if ($udom eq 'public' && $uname eq 'public');
       my $id=$uname.':'.$udom;
       &Apache::lonnet::devalidate_cache_new('emailscache',$id);
   }
   
 # ------------------------------------------------------------------ Screenname  # ------------------------------------------------------------------ Screenname
   
 =pod  =pod
Line 2213  sub track_student_link { Line 2242  sub track_student_link {
         $target = '';          $target = '';
     }      }
     if ($start) { $link.='&amp;start='.$start; }      if ($start) { $link.='&amp;start='.$start; }
           $title = &mt($title);
       $linktext = &mt($linktext);
     return qq{<a href="$link" title="$title" $target>$linktext</a>}.      return qq{<a href="$link" title="$title" $target>$linktext</a>}.
  &help_open_topic('View_recent_activity');   &help_open_topic('View_recent_activity');
 }  }
Line 2666  sub get_student_answers { Line 2696  sub get_student_answers {
   $moreenv{'grade_target'}='answer';    $moreenv{'grade_target'}='answer';
   %moreenv=(%form,%moreenv);    %moreenv=(%form,%moreenv);
   $feedurl = &Apache::lonnet::clutter($feedurl);    $feedurl = &Apache::lonnet::clutter($feedurl);
   &Apache::lonenc::check_encrypt(\$feedurl);  
   my $userview=&Apache::lonnet::ssi($feedurl,%moreenv);    my $userview=&Apache::lonnet::ssi($feedurl,%moreenv);
   return $userview;    return $userview;
 }  }
Line 3253  sub domainlogo { Line 3282  sub domainlogo {
     # See if there is a logo      # See if there is a logo
     if ($designhash{$domain.'.login.domlogo'} ne '') {      if ($designhash{$domain.'.login.domlogo'} ne '') {
         my $imgsrc = $designhash{$domain.'.login.domlogo'};          my $imgsrc = $designhash{$domain.'.login.domlogo'};
         if ($imgsrc =~ /^\/(adm|res)/) {          if ($imgsrc =~ m{^/(adm|res)/}) {
             $imgsrc = &lonhttpdurl($imgsrc);      if ($imgsrc =~ m{^/res/}) {
    my $local_name = &Apache::lonnet::filelocation('',$imgsrc);
    &Apache::lonnet::repcopy($local_name);
       }
      $imgsrc = &lonhttpdurl($imgsrc);
         }           } 
         return '<img src="'.$imgsrc.'" alt="'.$domain.'" />';          return '<img src="'.$imgsrc.'" alt="'.$domain.'" />';
     } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {      } elsif (defined(&Apache::lonnet::domain($domain,'description'))) {
Line 3303  sub designparm { Line 3336  sub designparm {
     }      }
     if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||      if (($which =~ /^(student|coordinator|author|admin)\.img$/) ||
         ($which =~ /login\.(img|logo|domlogo)/)) {          ($which =~ /login\.(img|logo|domlogo)/)) {
         if ($output =~ /^\/(adm|res)\//) {          if ($output =~ m{^/(adm|res)/}) {
       if ($output =~ m{^/res/}) {
    my $local_name = &Apache::lonnet::filelocation('',$output);
    &Apache::lonnet::repcopy($local_name);
       }
             $output = &lonhttpdurl($output);              $output = &lonhttpdurl($output);
         }          }
     }      }
Line 3317  sub designparm { Line 3354  sub designparm {
   
 =back  =back
   
 =head1 HTTP Helpers  =head1 HTML Helpers
   
 =over 4  =over 4
   
Line 3611  sub make_attr_string { Line 3648  sub make_attr_string {
   
 =pod  =pod
   
 =back  
   
 =head1 HTML Helpers  
   
 =over 4  
   
 =item * &endbodytag()  =item * &endbodytag()
   
 Returns a uniform footer for LON-CAPA web pages.  Returns a uniform footer for LON-CAPA web pages.
   
 Inputs: none  Inputs: none
   
 =back  
   
 =cut  =cut
   
 sub endbodytag {  sub endbodytag {
Line 3641  sub endbodytag { Line 3670  sub endbodytag {
   
 =pod  =pod
   
 =over 4  
   
 =item * &standard_css()  =item * &standard_css()
   
 Returns a style sheet  Returns a style sheet
Line 3653  Inputs: (all optional) Line 3680  Inputs: (all optional)
             function       -> force usage of a specific rolish color scheme              function       -> force usage of a specific rolish color scheme
             bgcolor        -> override the default page bgcolor              bgcolor        -> override the default page bgcolor
   
 =back  
   
 =cut  =cut
   
 sub standard_css {  sub standard_css {
Line 3726  form, .inline { display: inline; } Line 3751  form, .inline { display: inline; }
 .LC_diff_added {  .LC_diff_added {
   color: green;    color: green;
 }  }
   .LC_unknown {
     color: yellow;
   }
   
 .LC_icon {  .LC_icon {
   border: 0px;    border: 0px;
 }  }
   .LC_indexer_icon {
     border: 0px;
     height: 22px;
   }
   .LC_docs_spacer {
     width: 25px;
     height: 1px;
     border: 0px;
   }
   
 .LC_internal_info {  .LC_internal_info {
   color: #999;    color: #999;
Line 4398  table.LC_prior_match tr td { Line 4436  table.LC_prior_match tr td {
 }  }
   
 span.LC_nobreak {  span.LC_nobreak {
     white-space: nowrap;    white-space: nowrap;
   }
   
   table.LC_docs_documents {
     background: #BBBBBB;
     border-width: 0px;
     border-collapse: collapse;
   }
   
   table.LC_docs_documents td.LC_docs_document {
     border: 2px solid black;
     padding: 4px;
   }
   
   .LC_docs_course_commands div {
     float: left;
     border: 4px solid #AAAAAA;
     padding: 4px;
     background: #DDDDCC;
   }
   
   .LC_docs_entry_move {
     border: 0px;
     border-collapse: collapse;
   }
   
   .LC_docs_entry_move td {
     border: 2px solid #BBBBBB;
     background: #DDDDDD;
   }
   
   .LC_docs_editor td.LC_docs_entry_commands {
     background: #DDDDDD;
     font-size: x-small;
   }
   .LC_docs_copy {
     color: #000099;
   }
   .LC_docs_cut {
     color: #550044;
   }
   .LC_docs_rename {
     color: #009900;
   }
   .LC_docs_remove {
     color: #990000;
   }
   
   .LC_docs_reinit_warn,
   .LC_docs_ext_edit {
     font-size: x-small;
   }
   
   .LC_docs_editor td.LC_docs_entry_title,
   .LC_docs_editor td.LC_docs_entry_icon {
     background: #FFFFBB;
   }
   .LC_docs_editor td.LC_docs_entry_parameter {
     background: #BBBBFF;
     font-size: x-small;
     white-space: nowrap;
   }
   
   table.LC_docs_adddocs td,
   table.LC_docs_adddocs th {
     border: 1px solid #BBBBBB;
     padding: 4px;
     background: #DDDDDD;
 }  }
   
 END  END
Line 4406  END Line 4511  END
   
 =pod  =pod
   
 =over 4  
   
 =item * &headtag()  =item * &headtag()
   
 Returns a uniform footer for LON-CAPA web pages.  Returns a uniform footer for LON-CAPA web pages.
Line 4431  Inputs: $title - optional title for the Line 4534  Inputs: $title - optional title for the
             no_auto_mt_title              no_auto_mt_title
                            -> prevent &mt()ing the title arg                             -> prevent &mt()ing the title arg
   
 =back  
   
 =cut  =cut
   
 sub headtag {  sub headtag {
Line 4488  ADDMETA Line 4589  ADDMETA
   
 =pod  =pod
   
 =over 4  
   
 =item * &font_settings()  =item * &font_settings()
   
 Returns neccessary <meta> to set the proper encoding  Returns neccessary <meta> to set the proper encoding
   
 Inputs: none  Inputs: none
   
 =back  
   
 =cut  =cut
   
 sub font_settings {  sub font_settings {
Line 4514  sub font_settings { Line 4611  sub font_settings {
   
 =pod  =pod
   
 =over 4  
   
 =item * &xml_begin()  =item * &xml_begin()
   
 Returns the needed doctype and <html>  Returns the needed doctype and <html>
   
 Inputs: none  Inputs: none
   
 =back  
   
 =cut  =cut
   
 sub xml_begin {  sub xml_begin {
Line 4548  sub xml_begin { Line 4641  sub xml_begin {
   
 =pod  =pod
   
 =over 4  
   
 =item * &endheadtag()  =item * &endheadtag()
   
 Returns a uniform </head> for LON-CAPA web pages.  Returns a uniform </head> for LON-CAPA web pages.
   
 Inputs: none  Inputs: none
   
 =back  
   
 =cut  =cut
   
 sub endheadtag {  sub endheadtag {
Line 4566  sub endheadtag { Line 4655  sub endheadtag {
   
 =pod  =pod
   
 =over 4  
   
 =item * &head()  =item * &head()
   
 Returns a uniform complete <head>..</head> section for LON-CAPA web pages.  Returns a uniform complete <head>..</head> section for LON-CAPA web pages.
Line 4575  Returns a uniform complete <head>..</hea Line 4662  Returns a uniform complete <head>..</hea
 Inputs: $title - optional title for the page  Inputs: $title - optional title for the page
         $head_extra - optional extra HTML to put inside the <head>          $head_extra - optional extra HTML to put inside the <head>
   
 =back  
   
 =cut  =cut
   
 sub head {  sub head {
Line 4586  sub head { Line 4671  sub head {
   
 =pod  =pod
   
 =over 4  
   
 =item * &start_page()  =item * &start_page()
   
 Returns a complete <html> .. <body> section for LON-CAPA web pages.  Returns a complete <html> .. <body> section for LON-CAPA web pages.
Line 4626  Inputs: $title - optional title for the Line 4709  Inputs: $title - optional title for the
   
                   no_auto_mt_title -> prevent &mt()ing the title arg                    no_auto_mt_title -> prevent &mt()ing the title arg
   
 =back  
   
 =cut  =cut
   
 sub start_page {  sub start_page {
Line 4679  sub start_page { Line 4760  sub start_page {
   
 =pod  =pod
   
 =over 4  
   
 =item * &head()  =item * &head()
   
 Returns a complete </body></html> section for LON-CAPA web pages.  Returns a complete </body></html> section for LON-CAPA web pages.
Line 4838  sub simple_error_page { Line 4917  sub simple_error_page {
     }      }
 }  }
   
   =pod
   
   =item * &inhibit_menu_check($arg)
   
   Checks for a inhibitmenu state and generates output to preserve it
   
   Inputs:         $arg - can be any of
                        - undef - in which case the return value is a string 
                                  to add  into arguments list of a uri
                        - 'input' - in which case the return value is a HTML
                                    <form> <input> field of type hidden to
                                    preserve the value
                        - a url - in which case the return value is the url with
                                  the neccesary cgi args added to preserve the
                                  inhibitmenu state
                        - a ref to a url - no return value, but the string is
                                           updated to include the neccessary cgi
                                           args to preserve the inhibitmenu state
   
   =cut
   
   sub inhibit_menu_check {
       my ($arg) = @_;
       &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
       if ($arg eq 'input') {
    if ($env{'form.inhibitmenu'}) {
       return '<input type="hidden" name="inhibitmenu" value="'.$env{'form.inhibitmenu'}.'" />';
    } else {
       return
    }
       }
       if ($env{'form.inhibitmenu'}) {
    if (ref($arg)) {
       $$arg .= '?inhibitmenu='.$env{'form.inhibitmenu'};
    } elsif ($arg eq '') {
       $arg .= 'inhibitmenu='.$env{'form.inhibitmenu'};
    } else {
       $arg .= '?inhibitmenu='.$env{'form.inhibitmenu'};
    }
       }
       if (!ref($arg)) {
    return $arg;
       }
   }
   
 ###############################################  ###############################################
   
 =pod  =pod
   
   =back
   
   =head1 User Information Routines
   
   =over 4
   
 =item * &get_users_function()  =item * &get_users_function()
   
 Used by &bodytag to determine the current users primary role.  Used by &bodytag to determine the current users primary role.
Line 4869  sub get_users_function { Line 4999  sub get_users_function {
   
 =pod  =pod
   
 =item * &check_user_status  =item * &check_user_status()
   
 Determines current status of supplied role for a  Determines current status of supplied role for a
 specific user. Roles can be active, previous or future.  specific user. Roles can be active, previous or future.
Line 5404  sub get_secgrprole_info { Line 5534  sub get_secgrprole_info {
   
 =pod  =pod
   
   =back
   
   =head1 HTTP Helpers
   
   =over 4
   
 =item * get_unprocessed_cgi($query,$possible_names)  =item * get_unprocessed_cgi($query,$possible_names)
   
 Modify the %env hash to contain unprocessed CGI form parameters held in  Modify the %env hash to contain unprocessed CGI form parameters held in
Line 6441  sub commit_customrole { Line 6577  sub commit_customrole {
 }  }
   
 sub commit_standardrole {  sub commit_standardrole {
     my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;      my ($udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
     my $output;      my ($output,$logmsg,$linefeed);
     my $logmsg;      if ($context eq 'auto') {
           $linefeed = "\n";
       } else {
           $linefeed = "<br />\n";
       }  
     if ($three eq 'st') {      if ($three eq 'st') {
         my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec);          my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end,
         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {                                           $one,$two,$sec,$context);
           if (($result =~ /^error/) || ($result eq 'not_in_class') || 
               ($result eq 'unknown_course')) {
             $output = "Error: $result\n";               $output = "Error: $result\n"; 
         } else {          } else {
             $output = &mt('Assigning').' '.$three.' in '.$url.              $output = $logmsg.$linefeed.&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):'').': ';
                ': <b>'.$result.'</b><br />'.              if ($context eq 'auto') {
                &mt('Add to classlist').': <b>ok</b><br />';                  $output .= $result.$linefeed.&mt('Add to classlist').': ok';
               } else {
                  $output .= '<b>'.$result.'</b>'.$linefeed.
                  &mt('Add to classlist').': <b>ok</b>';
               }
               $output .= $linefeed;
         }          }
     } else {      } else {
         $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):'').': <b>'.                 ($end?', '.&mt('ending').' '.localtime($end):'').': ';
                &Apache::lonnet::assignrole(          my $result = &Apache::lonnet::assignrole($udom,$uname,$url,$three,$end,$start);
                    $udom,$uname,$url,$three,$end,$start).          if ($context eq 'auto') {
                    '</b><br />';              $output .= $result.$linefeed;
           } else {
               $output .= '<b>'.$result.'</b>'.$linefeed;
           }
     }      }
     return $output;      return $output;
 }  }
   
 sub commit_studentrole {  sub commit_studentrole {
     my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec) = @_;      my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_;
     my $linefeed =  '<br />'."\n";      my ($result,$linefeed);
     my $result;      if ($context eq 'auto') {
           $linefeed = "\n";
       } else {
           $linefeed = '<br />'."\n";
       }
     if (defined($one) && defined($two)) {      if (defined($one) && defined($two)) {
         my $cid=$one.'_'.$two;          my $cid=$one.'_'.$two;
         my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);          my $oldsec=&Apache::lonnet::getsection($udom,$uname,$cid);
Line 6516  sub commit_studentrole { Line 6670  sub commit_studentrole {
 ############################################################  ############################################################
   
 sub construct_course {  sub construct_course {
     my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname) = @_;      my ($args,$logmsg,$courseid,$crsudom,$crsunum,$udom,$uname,$context) = @_;
     my $outcome;      my $outcome;
       my $linefeed =  '<br />'."\n";
       if ($context eq 'auto') {
           $linefeed = "\n";
       }
 #  #
 # Open course  # Open course
 #  #
Line 6538  sub construct_course { Line 6695  sub construct_course {
     # Utils::Course. This needs to at least be output as a comment      # Utils::Course. This needs to at least be output as a comment
     # 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]<br />',$crstype,$$courseid);      $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.'<br>';      $outcome .= &mt('Created on').': '.$crsuhome.$linefeed;
 #  #
 # Are we cloning?  # Are we cloning?
 #  #
     my $cloneid='';      my $cloneid='';
     if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {      if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {
           my $can_clone = 0;
  $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};   $cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};
         my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);          my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);
  my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);   my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
           my $clonemsg;
  if ($clonehome eq 'no_host') {   if ($clonehome eq 'no_host') {
     $outcome .=              $clonemsg = &mt('Attempting to clone non-existing [_1]',$crstype);
     '<br /><font color="red">'.&mt('Attempting to clone non-existing [_1]',$crstype).' '.$cloneid.'</font>';              if ($context eq 'auto') {
                   $outcome .= $clonemsg;
               } else {
           $outcome .= '<font color="red">'.$clonemsg.'</font>';
               }
               $outcome .= $linefeed;
  } else {   } else {
     $outcome .=               my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
     '<br /><font color="green">'.&mt('Cloning [_1] from [_2]',$crstype,$clonehome).'</font>';              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);      my %oldcenv=&Apache::lonnet::dump('environment',$$crsudom,$$crsunum);
 # Copy all files  # Copy all files
     &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid);      &Apache::lonclonecourse::copycoursefiles($cloneid,$$courseid);
Line 6679  sub construct_course { Line 6874  sub construct_course {
                 'dnhr' => 'does not have rights to access enrollment in these classes',                  'dnhr' => 'does not have rights to access enrollment in these classes',
                 'adby' => 'as determined by the policies of your institution on access to official classlists'                  'adby' => 'as determined by the policies of your institution on access to official classlists'
         );          );
         $outcome .= '<font color="red">'.$lt{'tclb'}.' ('.$cenv{'internal.courseowner'}.') - '.$lt{'dnhr'}.' ('.$lt{'adby'}.').<br /><ul>'."\n";          my $badclass_msg = $cenv{'internal.courseowner'}.') - '.$lt{'dnhr'}.
         foreach (@badclasses) {                             ' ('.$lt{'adby'}.')';
             $outcome .= "<li>$_</li>\n";          if ($context eq 'auto') {
         }              $outcome .= $badclass_msg.$linefeed;
         $outcome .= "</ul><br /><br /></font>\n";              $outcome .= '<font color="red">'.$badclass_msg.$linefeed.'<ul>'."\n";
               foreach my $item (@badclasses) {
                   if ($context eq 'auto') {
                       $outcome .= " - $item\n";
                   } else {
                       $outcome .= "<li>$item</li>\n";
                   }
               }
               if ($context eq 'auto') {
                   $outcome .= $linefeed;
               } else {
                   $outcome .= "</ul><br /><br /></font>\n";
               }
           } 
     }      }
     if ($args->{'no_end_date'}) {      if ($args->{'no_end_date'}) {
         $args->{'endaccess'} = 0;          $args->{'endaccess'} = 0;
Line 6699  sub construct_course { Line 6907  sub construct_course {
     $cenv{'internal.autharg'} = $args->{'autharg'};       $cenv{'internal.autharg'} = $args->{'autharg'}; 
     if ( ($cenv{'internal.authtype'} =~ /^krb/) && ($cenv{'internal.autoadds'} == 1)) {      if ( ($cenv{'internal.authtype'} =~ /^krb/) && ($cenv{'internal.autoadds'} == 1)) {
         if (! defined($cenv{'internal.autharg'}) || $cenv{'internal.autharg'}  eq '') {          if (! defined($cenv{'internal.autharg'}) || $cenv{'internal.autharg'}  eq '') {
             $outcome .= '<font color="red" size="+1">'.              my $krb_msg = &mt('As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student'); 
                       &mt('As you did not include the default Kerberos domain to be used for authentication in this class, the institutional data used by the automated enrollment process must include the Kerberos domain for each new student').'</font></p>';              if ($context eq 'auto') {
                   $outcome .= $krb_msg;
               } else {
                   $outcome .= '<font color="red" size="+1">'.$krb_msg.'</font>';
               }
               $outcome .= $linefeed;
         }          }
     }      }
     if (($args->{'ccdomain'}) && ($args->{'ccuname'})) {      if (($args->{'ccdomain'}) && ($args->{'ccuname'})) {
Line 6756  sub construct_course { Line 6969  sub construct_course {
     # By default, use standard grading      # By default, use standard grading
     if (!defined($cenv{'grading'})) { $cenv{'grading'} = 'standard'; }      if (!defined($cenv{'grading'})) { $cenv{'grading'} = 'standard'; }
   
     $outcome .= ('<br />'.&mt('Setting environment').': '.                       $outcome .= $linefeed.&mt('Setting environment').': '.                 
           &Apache::lonnet::put('environment',\%cenv,$$crsudom,$$crsunum).'<br>');            &Apache::lonnet::put('environment',\%cenv,$$crsudom,$$crsunum).$linefeed;
 #  #
 # Open all assignments  # Open all assignments
 #  #
Line 6767  sub construct_course { Line 6980  sub construct_course {
                            $storeunder.'.type' => 'date_start');                             $storeunder.'.type' => 'date_start');
                 
        $outcome .= &mt('Opening all assignments').': '.&Apache::lonnet::cput         $outcome .= &mt('Opening all assignments').': '.&Apache::lonnet::cput
                  ('resourcedata',\%storecontent,$$crsudom,$$crsunum).'<br>';                   ('resourcedata',\%storecontent,$$crsudom,$$crsunum).$linefeed;
    }     }
 #  #
 # Set first page  # Set first page
Line 6794  sub construct_course { Line 7007  sub construct_course {
  (my $outtext,$errtext) = &LONCAPA::map::storemap($map,1);   (my $outtext,$errtext) = &LONCAPA::map::storemap($map,1);
   
  if ($errtext) { $fatal=2; }   if ($errtext) { $fatal=2; }
         $outcome .= ($fatal?$errtext:'write ok').'<br />';          $outcome .= ($fatal?$errtext:'write ok').$linefeed;
     }      }
     return $outcome;      return $outcome;
 }  }

Removed from v.1.537  
changed lines
  Added in v.1.554


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