Diff for /loncom/interface/lonconfigsettings.pm between versions 1.3 and 1.9

version 1.3, 2009/04/26 00:09:53 version 1.9, 2010/01/07 18:21:25
Line 38  use Apache::lonlocal; Line 38  use Apache::lonlocal;
   
 sub print_header {  sub print_header {
     my ($r,$phase,$context,$jscript) = @_;      my ($r,$phase,$context,$jscript) = @_;
     my ($pagetitle,$brcrumtitle,$action);      my ($pagetitle,$brcrumtitle,$action,$call_category_check);
     if ($context eq 'domain') {      if ($context eq 'domain') {
         ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','Domain Settings');          ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','Domain Settings');
         $action = '/adm/domainprefs';          $action = '/adm/domainprefs';
           if ($phase eq 'display') {
               my @actions = &Apache::loncommon::get_env_multiple('form.actions');
               if (grep(/^coursecategories$/,@actions)) {
                   $call_category_check = qq|
       if (formname == document.display) {
           if (!categoryCheck(formname)) {
               return;
           }
       }
   |;
               }
           }
     } else {      } else {
         ($pagetitle, $brcrumtitle) = ('Course Configuration','Course Configuration');          if (&Apache::loncommon::course_type() eq 'Community') {
               ($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
           } else {
               ($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
           }
         $action = '/adm/courseprefs';          $action = '/adm/courseprefs';
     }      }
     my $alert = &mt('You must select at least one functionality type to display.');      my $alert = &mt('You must select at least one functionality type to display.');
     my $js = '      my $js = '
 <script type="text/javascript">  <script type="text/javascript">
   // <![CDATA[
   
 function changePage(formname,newphase) {  function changePage(formname,newphase) {
     formname.phase.value = newphase;      formname.phase.value = newphase;
     numchecked = 0;      numchecked = 0;
Line 71  function changePage(formname,newphase) { Line 89  function changePage(formname,newphase) {
             return;              return;
         }          }
     }      }
       '.$call_category_check.'
     formname.submit();      formname.submit();
 }'."\n";  }'."\n";
     if ($phase eq 'pickactions') {      if ($phase eq 'pickactions') {
Line 81  function changePage(formname,newphase) { Line 100  function changePage(formname,newphase) {
         $js .= &color_pick_js()."\n";          $js .= &color_pick_js()."\n";
     }      }
     $js .= &Apache::loncommon::viewport_size_js().'      $js .= &Apache::loncommon::viewport_size_js().'
   
   // ]]>
 </script>  </script>
 ';  ';
     if ($jscript) {      if ($jscript) {
Line 124  sub print_footer { Line 145  sub print_footer {
               $env{'form.width'}.'" />'.                $env{'form.width'}.'" />'.
               '<input type="hidden" name="height" value="'.                '<input type="hidden" name="height" value="'.
               $env{'form.height'}.'" />');                $env{'form.height'}.'" />');
       if (defined($env{'form.origin'})) {
           $r->print('<input type="hidden" name="origin" value="'.$env{'form.origin'}.'" />'."\n");
       }
     if (($phase eq 'display') || ($phase eq 'process')) {      if (($phase eq 'display') || ($phase eq 'process')) {
         if (ref($actions) eq 'ARRAY') {          if (ref($actions) eq 'ARRAY') {
             foreach my $item (@{$actions}) {              foreach my $item (@{$actions}) {
Line 152  sub print_footer { Line 176  sub print_footer {
 }  }
   
 sub make_changes {  sub make_changes {
     my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles) = @_;      my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,$allitems) = @_;
     my %brcrumtext = &get_crumb_text();      my %brcrumtext = &get_crumb_text();
     my @actions = &Apache::loncommon::get_env_multiple('form.actions');      my @actions = &Apache::loncommon::get_env_multiple('form.actions');
       my ($numchanged,%changes,%disallowed);
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
       ({href=>"javascript:changePage(document.$phase,'display')",        ({href=>"javascript:changePage(document.$phase,'display')",
         text=>$brcrumtext{$context}},          text=>$brcrumtext{$context}},
        {href=>"javascript:changePage(document.$phase,'$phase')",         {href=>"javascript:changePage(document.$phase,'$phase')",
         text=>"Updated"});          text=>"Updated"});
     &print_header($r,$phase,$context);      &print_header($r,$phase,$context);
       my $crstype;
       if ($context eq 'course') {
           $crstype = &Apache::loncommon::course_type();
       }
     if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') &&       if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && 
         (ref($prefs) eq 'HASH')) {          (ref($prefs) eq 'HASH')) {
         foreach my $item (@{$prefs_order}) {          foreach my $item (@{$prefs_order}) {
             if (grep(/^\Q$item\E$/,@actions)) {              if (grep(/^\Q$item\E$/,@actions)) {
                 $r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>');  
                 if ($context eq 'domain') {                  if ($context eq 'domain') {
                     $r->print(&Apache::domainprefs::process_changes($r,$dom,$confname,$item,$roles,$values));                      $r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>'.
                                 &Apache::domainprefs::process_changes($r,$dom,
                                             $confname,$item,$roles,$values));
                 } else {                  } else {
                     $r->print(&Apache::courseprefs::process_changes($r,$dom,$item,$values));                      $changes{$item} = {};
                       &Apache::courseprefs::process_changes($dom,$item,$values,
                                                             $prefs->{$item},$changes{$item},
                                                             $allitems,\%disallowed,$crstype);
                       if (keys(%{$changes{$item}}) > 0) {
                           $numchanged ++;
                       }
                   }
               }
           }
       }
       if ($context eq 'course') {
           if ($numchanged) {
               $r->print(&Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
                                                             $prefs,$values,\%changes,$crstype));
           } else {
               if ($crstype eq 'Community') {
                   $r->print(&mt("No changes made to community configuration."));
               } else {
                   $r->print(&mt("No changes made to course configuration."));
               }
           }
           if (keys(%disallowed) > 0) {
               $r->print('<p>');
               foreach my $item ('cloners','rolenames','feedback','discussion','localization') {
                   if (ref($disallowed{$item}) eq 'HASH') {
                       if (keys(%{$disallowed{$item}}) > 0) {
                           $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item},
                                                                              $prefs,$crstype));
                       }
                 }                  }
             }              }
               $r->print('</p>');
         }          }
     }      }
     $r->print('<p>');      $r->print('<p>');
     &print_footer($r,$phase,'display','Back to configuration display',\@actions);      my $footer_text = 'Back to configuration display';
       if ($context eq 'course') {
           $footer_text = 'Back to display/edit settings'; 
       }
       &print_footer($r,$phase,'display',$footer_text,\@actions);
     $r->print('</p>');      $r->print('</p>');
 }  }
   
 sub display_settings {  sub display_settings {
     my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,      my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,
         $allitems) = @_;          $allitems,$crstype) = @_;
     my %brcrumtext = &get_crumb_text();      my %brcrumtext = &get_crumb_text();
     my @actions = &Apache::loncommon::get_env_multiple('form.actions');      my @actions = &Apache::loncommon::get_env_multiple('form.actions');
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
         ({href=>"javascript:changePage(document.$phase,'display')",          ({href=>"javascript:changePage(document.$phase,'display')",
           text=>"Course Settings"});            text=>"Display/Edit Settings"});
     &print_header($r,$phase,$context,$jscript);      &print_header($r,$phase,$context,$jscript);
     if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) {       if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) { 
         if (@actions > 0) {          if (@actions > 0) {
Line 203  sub display_settings { Line 267  sub display_settings {
                     } else {                      } else {
                         ($output{$item},$rowtotal{$item}) =                          ($output{$item},$rowtotal{$item}) =
                             &Apache::courseprefs::print_config_box($r,$dom,$phase,                              &Apache::courseprefs::print_config_box($r,$dom,$phase,
                                 $item,$prefs->{$item},$values,$allitems);                                  $item,$prefs->{$item},$values,$allitems,$crstype);
                     }                      }
                     $rowsum += $rowtotal{$item};                      $rowsum += $rowtotal{$item};
                 }                  }
Line 237  sub display_settings { Line 301  sub display_settings {
             } else {              } else {
                 $colend = @items;                  $colend = @items;
             }              }
             $r->print('<p><table class="LC_double_column"><tr><td class="LC_left_col">');            for (my $i=0; $i<$colend; $i++) {              if ($context ne 'course') {
               $r->print('<p><table class="LC_double_column"><tr><td class="LC_left_col">');            
               }
               else {
               $r->print('<div id="prefs" style="max-width:900px;margin: 10px auto 10px auto;">');
               }
               for (my $i=0; $i<$colend; $i++) {
                 $r->print($output{$items[$i]});                  $r->print($output{$items[$i]});
             }              }
             $r->print('</td><td></td><td class="LC_right_col">');              if ($context ne 'course') {
               $r->print('</td><td></td><td class="LC_right_col">');
               }
             if ($colend < @items) {              if ($colend < @items) {
                 for (my $i=$colend; $i<@items; $i++) {                  for (my $i=$colend; $i<@items; $i++) {
                     $r->print($output{$items[$i]});                      $r->print($output{$items[$i]});
                 }                  }
             }              }
             $r->print('</td></tr></table></p>');              if ($context ne 'course') {
             $r->print(&print_footer($r,$phase,'process','Save',\@actions));              $r->print('</td></tr></table></p>');
               }
               else {
               $r->print('</div>');
               }
               $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions));
         } else {          } else {
             $r->print('<input type="hidden" name="phase" value="" />'.              $r->print('<input type="hidden" name="phase" value="" />'.
                   '<input type="hidden" name="numcols" value="'.                    '<input type="hidden" name="numcols" value="'.
Line 257  sub display_settings { Line 334  sub display_settings {
         }          }
         $r->print('</form>');          $r->print('</form>');
     }      }
       if ($context eq 'course') {
       $r->print('
   <script type="text/javascript">
    $(document).ready(function(){
    $("#prefs").accordion({
    autoHeight: false
    });
    $("#prefs td.LC_left_item").css("text-align", "right");
    $("#prefs td.LC_left_item").css("width", "40%");
    $("#prefs td.LC_left_item").css("padding-right", "10px");
    $("#prefs td.LC_right_item").css("text-align", "left");
    $("#prefs td.LC_right_item").css("width", "60%");
    });
   </script>
   ');
       }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return;      return;
 }  }
Line 268  sub display_choices { Line 361  sub display_choices {
     }      }
     my %helphash;      my %helphash;
     &print_header($r,$phase,$context);      &print_header($r,$phase,$context);
     $r->print('<h3>'.&mt('Functionality to display/modify').'</h3>');      $r->print('<h3>'.&mt('Settings to display/modify').'</h3>');
     $r->print('<script type="text/javascript">'."\n".      $r->print('<script type="text/javascript">'."\n".
                 '// <![CDATA['."\n".
               &Apache::loncommon::check_uncheck_jscript()."\n".                &Apache::loncommon::check_uncheck_jscript()."\n".
                 '// ]]>'."\n".
               '</script>'."\n".'<p><input type="button" value="'.&mt('check all').'" '.                '</script>'."\n".'<p><input type="button" value="'.&mt('check all').'" '.
               'onclick="javascript:checkAll(document.pickactions.actions)"'.                'onclick="javascript:checkAll(document.pickactions.actions)"'.
               ' />'.('&nbsp;'x2).                ' />'.('&nbsp;'x2).
Line 373  ENDCOL Line 468  ENDCOL
 sub get_crumb_text {  sub get_crumb_text {
     my %brcrumbtext = (      my %brcrumbtext = (
                        domain => 'Domain Settings',                         domain => 'Domain Settings',
                        course => 'Course Settings',                         course => 'Display/Edit Settings',
                      );                       );
     return %brcrumbtext;      return %brcrumbtext;
 }  }

Removed from v.1.3  
changed lines
  Added in v.1.9


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