Diff for /loncom/interface/domainprefs.pm between versions 1.160.6.30 and 1.212

version 1.160.6.30, 2013/12/27 16:40:08 version 1.212, 2013/10/06 21:25:59
Line 103  $datatable  - HTML containing form eleme Line 103  $datatable  - HTML containing form eleme
   
 In the case of course requests, radio buttons are displayed for each institutional  In the case of course requests, radio buttons are displayed for each institutional
 affiliate type (and also default, and _LC_adv) for each of the course types   affiliate type (and also default, and _LC_adv) for each of the course types 
 (official, unofficial, community, and textbook).  In each case the radio buttons   (official, unofficial and community).  In each case the radio buttons allow the 
 allow the selection of one of four values:  selection of one of four values:
   
 0, approval, validate, autolimit=N (where N is blank, or a positive integer).  0, approval, validate, autolimit=N (where N is blank, or a positive integer).
 which have the following effects:  which have the following effects:
Line 211  sub handler { Line 211  sub handler {
                 'quotas','autoenroll','autoupdate','autocreate',                  'quotas','autoenroll','autoupdate','autocreate',
                 'directorysrch','usercreation','usermodification',                  'directorysrch','usercreation','usermodification',
                 'contacts','defaults','scantron','coursecategories',                  'contacts','defaults','scantron','coursecategories',
                 'serverstatuses','requestcourses','coursedefaults',                  'serverstatuses','requestcourses','helpsettings',
                 'usersessions','loadbalancing','requestauthor'],$dom);                  'coursedefaults','usersessions','loadbalancing',
                   'requestauthor'],$dom);
     my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',      my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
                        'autoupdate','autocreate','directorysrch','contacts',                         'autoupdate','autocreate','directorysrch','contacts',
                        'usercreation','usermodification','scantron',                         'usercreation','usermodification','scantron',
                        'requestcourses','requestauthor','coursecategories',                         'requestcourses','requestauthor','coursecategories',
                        'serverstatuses','coursedefaults','usersessions');                         'serverstatuses','helpsettings',
                          'coursedefaults','usersessions');
     my %existing;      my %existing;
     if (ref($domconfig{'loadbalancing'}) eq 'HASH') {      if (ref($domconfig{'loadbalancing'}) eq 'HASH') {
         %existing = %{$domconfig{'loadbalancing'}};          %existing = %{$domconfig{'loadbalancing'}};
Line 257  sub handler { Line 259  sub handler {
                       help => 'Domain_Configuration_Quotas',                        help => 'Domain_Configuration_Quotas',
                       header => [{col1 => 'User affiliation',                        header => [{col1 => 'User affiliation',
                                   col2 => 'Available tools',                                    col2 => 'Available tools',
                                   col3 => 'Quotas, MB; (Authoring requires role)',}],                                    col3 => 'Quotas, Mb; (Authoring requires role)',}],
                     },                      },
         'autoenroll' =>          'autoenroll' =>
                    { text => 'Auto-enrollment settings',                     { text => 'Auto-enrollment settings',
Line 327  sub handler { Line 329  sub handler {
                   header => [{col1 => 'User affiliation',                    header => [{col1 => 'User affiliation',
                               col2 => 'Availability/Processing of requests',},                                col2 => 'Availability/Processing of requests',},
                              {col1 => 'Setting',                               {col1 => 'Setting',
                               col2 => 'Value'},                                col2 => 'Value'}],
                              {col1 => 'Available textbooks',  
                               col2 => ''}],  
                  },                   },
         'requestauthor' =>          'requestauthor' =>
                  {text => 'Request authoring space',                   {text => 'Request authoring space',
Line 356  sub handler { Line 356  sub handler {
                               col3 => 'Specific IPs',                                col3 => 'Specific IPs',
                             }],                              }],
                  },                   },
         'coursedefaults' =>          'helpsettings' =>
                    {text   => 'Help page settings',
                     help   => 'Domain_Configuration_Help_Settings',
                     header => [{col1 => 'Help Settings (logged-in users)',
                                 col2 => 'Value'}],
                    },
           'coursedefaults' => 
                  {text => 'Course/Community defaults',                   {text => 'Course/Community defaults',
                   help => 'Domain_Configuration_Course_Defaults',                    help => 'Domain_Configuration_Course_Defaults',
                   header => [{col1 => 'Defaults which can be overridden for each course by a DC',                    header => [{col1 => 'Defaults which can be overridden in each course by a CC',
                                 col2 => 'Value',},
                                {col1 => 'Defaults which can be overridden for each course by a DC',
                               col2 => 'Value',},],                                col2 => 'Value',},],
                  },                   },
           'privacy' => 
                    {text   => 'User Privacy',
                     help   => 'Domain_Configuration_User_Privacy',
                     header => [{col1 => 'Setting',
                                 col2 => 'Value',}],
                    },
         'usersessions' =>          'usersessions' =>
                  {text  => 'User session hosting/offloading',                   {text  => 'User session hosting/offloading',
                   help  => 'Domain_Configuration_User_Sessions',                    help  => 'Domain_Configuration_User_Sessions',
Line 420  sub handler { Line 434  sub handler {
                    &common_domprefs_js().                     &common_domprefs_js().
                    &Apache::loncommon::javascript_array_indexof();                     &Apache::loncommon::javascript_array_indexof();
         }          }
         if (grep(/^requestcourses$/,@actions)) {  
             my $javascript_validations;  
             my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'});   
             $js .= <<END;  
 <script type="text/javascript">  
 $javascript_validations  
 </script>  
 $coursebrowserjs  
 END  
         }  
         &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);          &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js);
     } else {      } else {
 # check if domconfig user exists for the domain.  # check if domconfig user exists for the domain.
Line 511  sub process_changes { Line 515  sub process_changes {
         $output = &modify_rolecolors($r,$dom,$confname,$roles,          $output = &modify_rolecolors($r,$dom,$confname,$roles,
                                      $lastactref,%domconfig);                                       $lastactref,%domconfig);
     } elsif ($action eq 'quotas') {      } elsif ($action eq 'quotas') {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'autoenroll') {      } elsif ($action eq 'autoenroll') {
         $output = &modify_autoenroll($dom,$lastactref,%domconfig);          $output = &modify_autoenroll($dom,$lastactref,%domconfig);
     } elsif ($action eq 'autoupdate') {      } elsif ($action eq 'autoupdate') {
Line 535  sub process_changes { Line 539  sub process_changes {
     } elsif ($action eq 'serverstatuses') {      } elsif ($action eq 'serverstatuses') {
         $output = &modify_serverstatuses($dom,%domconfig);          $output = &modify_serverstatuses($dom,%domconfig);
     } elsif ($action eq 'requestcourses') {      } elsif ($action eq 'requestcourses') {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
     } elsif ($action eq 'requestauthor') {      } elsif ($action eq 'requestauthor') {
         $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig);          $output = &modify_quotas($dom,$action,$lastactref,%domconfig);
       } elsif ($action eq 'helpsettings') {
           $output = &modify_helpsettings($r,$dom,$confname,%domconfig);
     } elsif ($action eq 'coursedefaults') {      } elsif ($action eq 'coursedefaults') {
         $output = &modify_coursedefaults($dom,$lastactref,%domconfig);          $output = &modify_coursedefaults($dom,$lastactref,%domconfig);
     } elsif ($action eq 'usersessions') {      } elsif ($action eq 'usersessions') {
Line 609  sub print_config_box { Line 615  sub print_config_box {
             $output .= &print_usersessions('top',$dom,$settings,\$rowtotal);               $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); 
         } elsif ($action eq 'rolecolors') {          } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);              $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal);
           } elsif ($action eq 'coursedefaults') {
               $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal);
         }          }
         $output .= '          $output .= '
            </table>             </table>
Line 659  sub print_config_box { Line 667  sub print_config_box {
             <table class="LC_nested">              <table class="LC_nested">
              <tr class="LC_info_row">               <tr class="LC_info_row">
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>                <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td></tr>'.                <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
                        &print_usermodification('bottom',$dom,$settings,\$rowtotal);                         &print_usermodification('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;              $rowtotal ++;
         } elsif ($action eq 'coursecategories') {          } elsif ($action eq 'coursecategories') {
Line 675  sub print_config_box { Line 683  sub print_config_box {
             <table class="LC_nested">              <table class="LC_nested">
              <tr class="LC_info_row">               <tr class="LC_info_row">
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>                <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>
               <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col2'}).'</td></tr>'.                <td class="LC_right_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
                        &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);                         &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
                 $rowtotal ++;                  $rowtotal ++;
             } else {              } else {
                 $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);                  $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal);
             }              }
         } elsif ($action eq 'requestcourses') {          } elsif ($action eq 'requestcourses') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal).              $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
                        &print_studentcode($settings,\$rowtotal).'  
            </table>  
           </td>  
          </tr>  
          <tr>  
            <td>  
             <table class="LC_nested">  
              <tr class="LC_info_row">  
               <td class="LC_left_item"'.$colspan.'>'.&mt($item->{'header'}->[2]->{'col1'}).'</td>  
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td> </tr>'.  
                        &print_textbookcourses($dom,$settings,\$rowtotal);  
         } elsif ($action eq 'requestauthor') {          } elsif ($action eq 'requestauthor') {
             $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);              $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
         } elsif ($action eq 'usersessions') {          } elsif ($action eq 'usersessions') {
Line 709  sub print_config_box { Line 706  sub print_config_box {
               <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.                <td class="LC_right_item">'.&mt($item->{'header'}->[2]->{'col2'}).'</td>      </tr>'.
                        &print_usersessions('bottom',$dom,$settings,\$rowtotal);                         &print_usersessions('bottom',$dom,$settings,\$rowtotal);
             $rowtotal ++;              $rowtotal ++;
           } elsif ($action eq 'coursedefaults') {
               $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);
         } elsif ($action eq 'rolecolors') {          } elsif ($action eq 'rolecolors') {
             $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'              $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
            </table>             </table>
Line 805  sub print_config_box { Line 804  sub print_config_box {
             $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);              $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal);
         } elsif ($action eq 'loadbalancing') {          } elsif ($action eq 'loadbalancing') {
             $output .= &print_loadbalancing($dom,$settings,\$rowtotal);              $output .= &print_loadbalancing($dom,$settings,\$rowtotal);
         } elsif ($action eq 'coursedefaults') {  
             $output .= &print_coursedefaults('bottom',$dom,$settings,\$rowtotal);  
         }          }
     }      }
     $output .= '      $output .= '
Line 1553  sub print_quotas { Line 1550  sub print_quotas {
     my $typecount = 0;      my $typecount = 0;
     my ($css_class,%titles);      my ($css_class,%titles);
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community','textbook');          @usertools = ('official','unofficial','community');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approval','validate','autolimit');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
Line 1999  sub print_requestmail { Line 1996  sub print_requestmail {
     return $datatable;      return $datatable;
 }  }
   
 sub print_studentcode {  
     my ($settings,$rowtotal) = @_;  
     my $rownum = 0;   
     my ($output,%current);  
     my @crstypes = ('official','unofficial','community','textbook');  
     if (ref($settings->{'uniquecode'}) eq 'HASH') {  
         foreach my $type (@crstypes) {  
             $current{$type} = $settings->{'uniquecode'}{$type};  
         }  
     }  
     $output .= '<tr>'.  
                '<td class="LC_left_item">'.&mt('Generate unique six character code as course identifier?').'</td>'.  
                '<td class="LC_left_item">';  
     foreach my $type (@crstypes) {  
         my $check = ' ';  
         if ($current{$type}) {  
             $check = ' checked="checked" ';  
         }  
         $output .= '<span class="LC_nobreak"><label>'.  
                    '<input type="checkbox" name="uniquecode" value="'.$type.'"'.$check.'/>'.  
                    &mt($type).'</label></span>'.('&nbsp;'x2).' ';  
     }  
     $output .= '</td></tr>';  
     $$rowtotal ++;  
     return $output;  
 }  
   
 sub print_textbookcourses {  
     my ($dom,$settings,$rowtotal) = @_;  
     my $rownum = 0;  
     my $css_class;  
     my $itemcount = 1;  
     my $maxnum = 0;  
     my $bookshash;  
     if (ref($settings) eq 'HASH') {  
         $bookshash = $settings->{'textbooks'};  
     }  
     my %ordered;  
     if (ref($bookshash) eq 'HASH') {  
         foreach my $item (keys(%{$bookshash})) {  
             if (ref($bookshash->{$item}) eq 'HASH') {  
                 my $num = $bookshash->{$item}{'order'};  
                 $ordered{$num} = $item;  
             }  
         }  
     }  
     my $confname = $dom.'-domainconfig';  
     my $switchserver = &check_switchserver($dom,$confname);  
     my $maxnum = scalar(keys(%ordered));  
     my $datatable = &textbookcourses_javascript(\%ordered);  
     if (keys(%ordered)) {  
         my @items = sort { $a <=> $b } keys(%ordered);  
         for (my $i=0; $i<@items; $i++) {  
             $css_class = $itemcount%2?' class="LC_odd_row"':'';  
             my $key = $ordered{$items[$i]};  
             my %coursehash=&Apache::lonnet::coursedescription($key);  
             my $coursetitle = $coursehash{'description'};  
             my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum);  
             if (ref($bookshash->{$key}) eq 'HASH') {  
                 $subject = $bookshash->{$key}->{'subject'};  
                 $title = $bookshash->{$key}->{'title'};  
                 $author = $bookshash->{$key}->{'author'};  
                 $image = $bookshash->{$key}->{'image'};  
                 if ($image ne '') {  
                     my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$});  
                     my $imagethumb = "$path/tn-".$imagefile;  
                     $imgsrc = '<img src="'.$imagethumb.'" alt="'.&mt('Textbook image').'" />';  
                 }  
             }  
             my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"';  
             $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'  
                          .'<select name="'.$key.'"'.$chgstr.'>';  
             for (my $k=0; $k<=$maxnum; $k++) {  
                 my $vpos = $k+1;  
                 my $selstr;  
                 if ($k == $i) {  
                     $selstr = ' selected="selected" ';  
                 }  
                 $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';  
             }  
             $datatable .= '</select>'.('&nbsp;'x2).  
                 '<label><input type="checkbox" name="book_del" value="'.$key.'" />'.  
                 &mt('Delete?').'</label></span></td>'.  
                 '<td colspan="2">'.  
                 '<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="book_subject_'.$i.'" value="'.$subject.'" /></span> '.  
                 ('&nbsp;'x2).  
                 '<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="book_title_'.$i.'" value="'.$title.'" /></span> '.  
                 ('&nbsp;'x2).  
                 '<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="book_author_'.$i.'" value="'.$author.'" /></span> '.  
                 ('&nbsp;'x2).  
                 '<span class="LC_nobreak">'.&mt('Thumbnail:');  
             if ($image) {  
                 $datatable .= '<span class="LC_nobreak">'.  
                               $imgsrc.  
                               '<label><input type="checkbox" name="book_image_del"'.  
                               ' value="'.$key.'" />'.&mt('Delete?').'</label></span> '.  
                               '<span class="LC_nobreak">&nbsp;'.&mt('Replace:').'&nbsp;';  
             }  
             if ($switchserver) {  
                 $datatable .= &mt('Upload to library server: [_1]',$switchserver);  
             } else {  
                 $datatable .= '<input type="file" name="book_image_'.$i.'" value="" />';  
             }  
             $datatable .= '<input type="hidden" name="book_id_'.$i.'" value="'.$key.'" /></span> '.  
                           '<span class="LC_nobreak">'.&mt('LON-CAPA course:').'&nbsp;'.  
                           $coursetitle.'</span></td></tr>'."\n";  
             $itemcount ++;  
         }  
     }  
     $css_class = $itemcount%2?' class="LC_odd_row"':'';  
     my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"';  
     $datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n".  
                   '<input type="hidden" name="book_maxnum" value="'.$maxnum.'" />'."\n".  
                   '<select name="addbook_pos"'.$chgstr.'>';  
     for (my $k=0; $k<$maxnum+1; $k++) {  
         my $vpos = $k+1;  
         my $selstr;  
         if ($k == $maxnum) {  
             $selstr = ' selected="selected" ';  
         }  
         $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';  
     }  
     $datatable .= '</select>&nbsp;'."\n".  
                   '<input type="checkbox" name="addbook" value="1" />'.&mt('Add').'</td>'."\n".  
                   '<td colspan="2">'.  
                   '<span class="LC_nobreak">'.&mt('Subject:').'<input type="text" size="15" name="addbook_subject" value="" /></span> '."\n".  
                   ('&nbsp;'x2).  
                   '<span class="LC_nobreak">'.&mt('Title:').'<input type="text" size="30" name="addbook_title" value="" /></span> '."\n".  
                   ('&nbsp;'x2).  
                   '<span class="LC_nobreak">'.&mt('Author(s):').'<input type="text" size="25" name="addbook_author" value="" /></span> '."\n".  
                   ('&nbsp;'x2).  
                   '<span class="LC_nobreak">'.&mt('Image:').'&nbsp;';  
     if ($switchserver) {  
         $datatable .= &mt('Upload to library server: [_1]',$switchserver);  
     } else {  
         $datatable .= '<input type="file" name="addbook_image" value="" />';  
     }  
     $datatable .= '</span>'."\n".  
                   '<span class="LC_nobreak">'.&mt('LON-CAPA course:').'&nbsp;'.  
                   &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom').  
                   '<input type="text" size="25" name="addbook_cnum" value="" />'.  
                   &Apache::loncommon::selectcourse_link  
                       ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course');  
                   '</span></td>'."\n".  
                   '</tr>'."\n";  
     $itemcount ++;  
     return $datatable;  
 }  
   
 sub textbookcourses_javascript {  
     my ($textbooks) = @_;  
     return unless(ref($textbooks) eq 'HASH');  
     my $num = scalar(keys(%{$textbooks}));  
     my @jsarray;  
     foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) {  
         push(@jsarray,$textbooks->{$item});  
     }  
     my $jstext = '    var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n";  
     return <<"ENDSCRIPT";  
 <script type="text/javascript">  
 // <![CDATA[  
 function reorderBooks(form,item) {  
     var changedVal;  
 $jstext   
     var newpos = 'addbook_pos';  
     var current = new Array;  
     var maxh = 1 + $num;  
     var current = new Array;  
     var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value;  
     if (item == newpos) {  
         changedVal = newitemVal;  
     } else {  
         changedVal = form.elements[item].options[form.elements[item].selectedIndex].value;  
         current[newitemVal] = newpos;  
     }  
     for (var i=0; i<textbooks.length; i++) {  
         var elementName = textbooks[i];  
         if (elementName != item) {  
             if (form.elements[elementName]) {  
                 var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value;  
                 current[currVal] = elementName;  
             }  
         }  
     }  
     var oldVal;  
     for (var j=0; j<maxh; j++) {  
         if (current[j] == undefined) {  
             oldVal = j;  
         }  
     }  
     if (oldVal < changedVal) {  
         for (var k=oldVal+1; k<=changedVal ; k++) {  
            var elementName = current[k];  
            form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex - 1;  
         }  
     } else {  
         for (var k=changedVal; k<oldVal; k++) {  
             var elementName = current[k];  
             form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex + 1;  
         }  
     }  
     return;  
 }  
   
 // ]]>  
 </script>  
   
 ENDSCRIPT  
 }  
   
 sub print_autoenroll {  sub print_autoenroll {
     my ($dom,$settings,$rowtotal) = @_;      my ($dom,$settings,$rowtotal) = @_;
     my $autorun = &Apache::lonnet::auto_run(undef,$dom),      my $autorun = &Apache::lonnet::auto_run(undef,$dom),
Line 2707  sub print_coursedefaults { Line 2494  sub print_coursedefaults {
                                                  \%choices,$itemcount);                                                   \%choices,$itemcount);
     } else {      } else {
         $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';          $css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
         my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits,          my ($currdefresponder,$def_official_credits,$def_unofficial_credits,%curruploadquota);
             %curruploadquota);  
         my $currusecredits = 0;          my $currusecredits = 0;
         my @types = ('official','unofficial','community','textbook');          my @types = ('official','unofficial','community');
         if (ref($settings) eq 'HASH') {          if (ref($settings) eq 'HASH') {
             $currdefresponder = $settings->{'anonsurvey_threshold'};              $currdefresponder = $settings->{'anonsurvey_threshold'};
             if (ref($settings->{'uploadquota'}) eq 'HASH') {              if (ref($settings->{'uploadquota'}) eq 'HASH') {
Line 2721  sub print_coursedefaults { Line 2507  sub print_coursedefaults {
             if (ref($settings->{'coursecredits'}) eq 'HASH') {              if (ref($settings->{'coursecredits'}) eq 'HASH') {
                 $def_official_credits = $settings->{'coursecredits'}->{'official'};                  $def_official_credits = $settings->{'coursecredits'}->{'official'};
                 $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};                  $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'};
                 $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'};                  if (($def_official_credits ne '') || ($def_unofficial_credits ne '')) {
                 if (($def_official_credits ne '') || ($def_unofficial_credits ne '') ||  
                     ($def_textbook_credits ne '')) {  
                     $currusecredits = 1;                      $currusecredits = 1;
                 }                  }
             }              }
Line 2773  sub print_coursedefaults { Line 2557  sub print_coursedefaults {
                          &mt('Default credits for unofficial courses [_1]',                           &mt('Default credits for unofficial courses [_1]',
                          '<input type="text" name="unofficial_credits" value="'.                           '<input type="text" name="unofficial_credits" value="'.
                          $def_unofficial_credits.'" size="3" />').                           $def_unofficial_credits.'" size="3" />').
                          '</span><br />'.  
                          '<span class="LC_nobreak">'.  
                          &mt('Default credits for textbook courses [_1]',  
                          '<input type="text" name="textbook_credits" value="'.  
                          $def_textbook_credits.'" size="3" />').  
                          '</span></div>'."\n";                           '</span></div>'."\n";
         %defaultchecked = ('coursecredits' => 'off');          %defaultchecked = ('coursecredits' => 'off');
         @toggles = ('coursecredits');          @toggles = ('coursecredits');
Line 3568  sub tool_titles { Line 3347  sub tool_titles {
                      official   => 'Official courses (with institutional codes)',                       official   => 'Official courses (with institutional codes)',
                      unofficial => 'Unofficial courses',                       unofficial => 'Unofficial courses',
                      community  => 'Communities',                       community  => 'Communities',
                      textbook   => 'Textbook courses',  
                  );                   );
     return %titles;      return %titles;
 }  }
Line 3578  sub courserequest_titles { Line 3356  sub courserequest_titles {
                                    official   => 'Official',                                     official   => 'Official',
                                    unofficial => 'Unofficial',                                     unofficial => 'Unofficial',
                                    community  => 'Communities',                                     community  => 'Communities',
                                    textbook   => 'Textbook',  
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
Line 3988  sub print_defaults { Line 3765  sub print_defaults {
                  'datelocale_def','portal_def');                   'datelocale_def','portal_def');
     my %defaults;      my %defaults;
     if (ref($settings) eq 'HASH') {      if (ref($settings) eq 'HASH') {
         %defaults = %{$settings};          %defaults = %{$settings};    
     } else {      } else {
         my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);          my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
         foreach my $item (@items) {          foreach my $item (@items) {
Line 4380  sub print_coursecategories { Line 4157  sub print_coursecategories {
                             }                              }
                             $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';                              $datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>';
                         }                          }
                         $datatable .= '</select></span></td><td>';                          $datatable .= '</select></td><td>';
                         if ($parent eq 'instcode' || $parent eq 'communities') {                          if ($parent eq 'instcode' || $parent eq 'communities') {
                             $datatable .=  '<span class="LC_nobreak">'                              $datatable .=  '<span class="LC_nobreak">'
                                            .$default_names{$parent}.'</span>';                                             .$default_names{$parent}.'</span>';
Line 4410  sub print_coursecategories { Line 4187  sub print_coursecategories {
                             $datatable .= '</td>';                              $datatable .= '</td>';
                         } else {                          } else {
                             $datatable .= $parent                              $datatable .= $parent
                                           .'&nbsp;<span class="LC_nobreak"><label>'                                            .'&nbsp;<label><input type="checkbox" name="deletecategory" '
                                           .'<input type="checkbox" name="deletecategory" '  
                                           .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';                                            .'value="'.$item.'" />'.&mt('Delete').'</label></span></td>';
                         }                          }
                         my $depth = 1;                          my $depth = 1;
Line 6046  sub check_switchserver { Line 5822  sub check_switchserver {
 }  }
   
 sub modify_quotas {  sub modify_quotas {
     my ($r,$dom,$action,$lastactref,%domconfig) = @_;      my ($dom,$action,$lastactref,%domconfig) = @_;
     my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,      my ($context,@usertools,@options,%validations,%titles,%confhash,%toolshash,
         %limithash,$toolregexp,%conditions,$resulttext,%changes,$confname,$configuserok,          %limithash,$toolregexp,%conditions,$resulttext,%changes);
         $author_ok,$switchserver,$errors);  
     if ($action eq 'quotas') {      if ($action eq 'quotas') {
         $context = 'tools';           $context = 'tools'; 
     } else {      } else {
         $context = $action;          $context = $action;
     }      }
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         @usertools = ('official','unofficial','community','textbook');          @usertools = ('official','unofficial','community');
         @options =('norequest','approval','validate','autolimit');          @options =('norequest','approval','validate','autolimit');
         %validations = &Apache::lonnet::auto_courserequest_checks($dom);          %validations = &Apache::lonnet::auto_courserequest_checks($dom);
         %titles = &courserequest_titles();          %titles = &courserequest_titles();
         $toolregexp = join('|',@usertools);          $toolregexp = join('|',@usertools);
         %conditions = &courserequest_conditions();          %conditions = &courserequest_conditions();
         $confname = $dom.'-domainconfig';  
         my $servadm = $r->dir_config('lonAdmEMail');  
         ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm);  
     } elsif ($context eq 'requestauthor') {      } elsif ($context eq 'requestauthor') {
         @usertools = ('author');          @usertools = ('author');
         %titles = &authorrequest_titles();          %titles = &authorrequest_titles();
Line 6103  sub modify_quotas { Line 5875  sub modify_quotas {
         my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');          my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
         @approvalnotify = sort(@approvalnotify);          @approvalnotify = sort(@approvalnotify);
         $confhash{'notify'}{'approval'} = join(',',@approvalnotify);          $confhash{'notify'}{'approval'} = join(',',@approvalnotify);
         my @crstypes = ('official','unofficial','community','textbook');  
         my @hasuniquecode = &Apache::loncommon::get_env_multiple('form.uniquecode');  
         foreach my $type (@hasuniquecode) {  
             if (grep(/^\Q$type\E$/,@crstypes)) {  
                 $confhash{'uniquecode'}{$type} = 1;  
             }  
         }  
         my ($newbook,@allpos);  
         if ($context eq 'requestcourses') {  
             if ($env{'form.addbook'}) {  
                 if (($env{'form.addbook_cnum'} =~ /^$match_courseid$/) &&  
                     ($env{'form.addbook_cdom'} =~ /^$match_domain$/)) {  
                     if (&Apache::lonnet::homeserver($env{'form.addbook_cnum'},  
                                                     $env{'form.addbook_cdom'}) eq 'no_host') {  
                         $errors .= '<li><span class="LC_error">'.&mt('Invalid LON-CAPA course for textbook').  
                                    '</span></li>';  
                     } else {  
                         $newbook = $env{'form.addbook_cdom'}.'_'.$env{'form.addbook_cnum'};  
                         my $position = $env{'form.addbook_pos'};  
                         $position =~ s/\D+//g;  
                         if ($position ne '') {  
                             $allpos[$position] = $newbook;  
                         }  
                     }  
                 } else {  
                     $errors .= '<li><span class="LC_error">'.&mt('Invalid LON-CAPA course for textbook').  
                                '</span></li>';  
                 }  
             }  
         }  
         if (ref($domconfig{$action}) eq 'HASH') {          if (ref($domconfig{$action}) eq 'HASH') {
             if (ref($domconfig{$action}{'notify'}) eq 'HASH') {              if (ref($domconfig{$action}{'notify'}) eq 'HASH') {
                 if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {                  if ($domconfig{$action}{'notify'}{'approval'} ne $confhash{'notify'}{'approval'}) {
Line 6143  sub modify_quotas { Line 5885  sub modify_quotas {
                     $changes{'notify'}{'approval'} = 1;                      $changes{'notify'}{'approval'} = 1;
                 }                  }
             }              }
             if (ref($domconfig{$action}{'uniquecode'}) eq 'HASH') {  
                 if (ref($confhash{'uniquecode'}) eq 'HASH') {  
                     foreach my $crstype (keys(%{$domconfig{$action}{'uniquecode'}})) {  
                         unless ($confhash{'uniquecode'}{$crstype}) {  
                             $changes{'uniquecode'} = 1;  
                         }  
                     }  
                     unless ($changes{'uniquecode'}) {  
                         foreach my $crstype (keys(%{$confhash{'uniquecode'}})) {  
                             unless ($domconfig{$action}{'uniquecode'}{$crstype}) {  
                                 $changes{'uniquecode'} = 1;  
                             }  
                         }  
                     }  
                } else {  
                    $changes{'uniquecode'} = 1;  
                }  
             } elsif (ref($confhash{'uniquecode'}) eq 'HASH') {  
                 $changes{'uniquecode'} = 1;  
             }  
             if ($context eq 'requestcourses') {  
                 if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') {  
                     my %deletions;  
                     my @todelete = &Apache::loncommon::get_env_multiple('form.book_del');  
                     if (@todelete) {  
                         map { $deletions{$_} = 1; } @todelete;  
                     }  
                     my %imgdeletions;  
                     my @todeleteimages = &Apache::loncommon::get_env_multiple('form.book_image_del');  
                     if (@todeleteimages) {  
                         map { $imgdeletions{$_} = 1; } @todeleteimages;  
                     }  
                     my $maxnum = $env{'form.book_maxnum'};  
                     for (my $i=0; $i<=$maxnum; $i++) {  
                         my $key = $env{'form.book_id_'.$i};  
                         if (ref($domconfig{$action}{'textbooks'}{$key}) eq 'HASH') {  
                             if ($deletions{$key}) {  
                                 if ($domconfig{$action}{'textbooks'}{$key}{'image'}) {  
                                     #FIXME need to obsolete item in RES space  
                                 }  
                                 next;  
                             } else {  
                                 my $newpos = $env{'form.'.$key};  
                                 $newpos =~ s/\D+//g;  
                                 foreach my $item ('subject','title','author') {  
                                     $confhash{'textbooks'}{$key}{$item} = $env{'form.book_'.$item.'_'.$i};  
                                     if ($domconfig{$action}{'textbooks'}{$key}{$item} ne $confhash{'textbooks'}{$key}{$item}) {  
                                         $changes{'textbooks'}{$key} = 1;  
                                     }  
                                 }  
                                 $allpos[$newpos] = $key;  
                             }  
                             if ($imgdeletions{$key}) {  
                                 $changes{'textbooks'}{$key} = 1;  
                                 #FIXME need to obsolete item in RES space  
                             } elsif ($env{'form.book_image_'.$i.'.filename'}) {  
                                 my ($cdom,$cnum) = split(/_/,$key);  
                                 my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,'book_image_'.$i,  
                                                                               $cdom,$cnum,$configuserok,  
                                                                               $switchserver,$author_ok);  
                                 if ($imgurl) {  
                                     $confhash{'textbooks'}{$key}{'image'} = $imgurl;  
                                     $changes{'textbooks'}{$key} = 1;   
                                 }  
                                 if ($error) {  
                                     &Apache::lonnet::logthis($error);  
                                     $errors .= '<li><span class="LC_error">'.$error.'</span></li>';  
                                 }   
                             } elsif ($domconfig{$action}{'textbooks'}{$key}{'image'}) {  
                                 $confhash{'textbooks'}{$key}{'image'} =   
                                     $domconfig{$action}{'textbooks'}{$key}{'image'};  
                             }  
                         }  
                     }  
                 }  
             }  
         } else {          } else {
             if ($confhash{'notify'}{'approval'}) {              if ($confhash{'notify'}{'approval'}) {
                 $changes{'notify'}{'approval'} = 1;                  $changes{'notify'}{'approval'} = 1;
             }              }
             if (ref($confhash{'uniquecode'} eq 'HASH')) {  
                 $changes{'uniquecode'} = 1;  
             }  
         }  
         if ($context eq 'requestcourses') {  
             if ($newbook) {  
                 $changes{'textbooks'}{$newbook} = 1;  
                 foreach my $item ('subject','title','author') {  
                     $env{'form.addbook_'.$item} =~ s/(`)/'/g;  
                     if ($env{'form.addbook_'.$item}) {  
                         $confhash{'textbooks'}{$newbook}{$item} = $env{'form.addbook_'.$item};  
                     }  
                 }  
                 if ($env{'form.addbook_image.filename'} ne '') {  
                     my ($cdom,$cnum) = split(/_/,$newbook);  
                     my ($imageurl,$error) =   
                         &process_textbook_image($r,$dom,$confname,'addbook_image',$cdom,$cnum,$configuserok,  
                                                 $switchserver,$author_ok);  
                     if ($imageurl) {  
                         $confhash{'textbooks'}{$newbook}{'image'} = $imageurl;  
                     }  
                     if ($error) {  
                         &Apache::lonnet::logthis($error);  
                         $errors .= '<li><span class="LC_error">'.$error.'</span></li>';  
                     }  
                 }  
             }  
             if (@allpos > 0) {  
                 my $idx = 0;  
                 foreach my $item (@allpos) {  
                     if ($item ne '') {  
                         $confhash{'textbooks'}{$item}{'order'} = $idx;  
                         if (ref($domconfig{$action}) eq 'HASH') {  
                             if (ref($domconfig{$action}{'textbooks'}) eq 'HASH') {  
                                 if (ref($domconfig{$action}{'textbooks'}{$item}) eq 'HASH') {  
                                     if ($domconfig{$action}{'textbooks'}{$item}{'order'} ne $idx) {  
                                         $changes{'textbooks'}{$item} = 1;  
                                     }  
                                 }  
                             }  
                         }  
                         $idx ++;  
                     }  
                 }  
             }  
         }          }
     } else {      } else {
         $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};          $confhash{'defaultquota'}{'default'} = $env{'form.defaultquota'};
Line 6409  sub modify_quotas { Line 6030  sub modify_quotas {
         $domdefaults{'requestauthor'} = \%confhash;          $domdefaults{'requestauthor'} = \%confhash;
     } else {      } else {
         foreach my $key (keys(%confhash)) {          foreach my $key (keys(%confhash)) {
             unless (($context eq 'requestcourses') && ($key eq 'textbooks')) {              $domdefaults{$key} = $confhash{$key};
                 $domdefaults{$key} = $confhash{$key};  
             }  
         }          }
     }      }
   
Line 6438  sub modify_quotas { Line 6057  sub modify_quotas {
                             if ($type eq 'default') {                              if ($type eq 'default') {
                                 $typetitle = $othertitle;                                  $typetitle = $othertitle;
                             }                              }
                             $resulttext .= '<li>'.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';                              $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'defaultquota'}{$type}).'</li>';
                         }                          }
                     }                      }
                     $resulttext .= '</ul></li>';                      $resulttext .= '</ul></li>';
Line 6451  sub modify_quotas { Line 6070  sub modify_quotas {
                             if ($type eq 'default') {                              if ($type eq 'default') {
                                 $typetitle = $othertitle;                                  $typetitle = $othertitle;
                             }                              }
                             $resulttext .= '<li>'.&mt('[_1] set to [_2] MB',$typetitle,$confhash{'authorquota'}{$type}).'</li>';                              $resulttext .= '<li>'.&mt('[_1] set to [_2] Mb',$typetitle,$confhash{'authorquota'}{$type}).'</li>';
                         }                          }
                     }                      }
                     $resulttext .= '</ul></li>';                      $resulttext .= '</ul></li>';
Line 6548  sub modify_quotas { Line 6167  sub modify_quotas {
                     }                      }
                 }                  }
             }              }
             if ($action eq 'requestcourses') {  
                 my @offon = ('off','on');  
                 if ($changes{'uniquecode'}) {  
                     if (ref($confhash{'uniquecode'}) eq 'HASH') {  
                         my $codestr = join(' ',map{ &mt($_); } sort(keys(%{$confhash{'uniquecode'}})));  
                         $resulttext .= '<li>'.  
                                        &mt('Generation of six character code as course identifier for distribution to students set to on for: [_1].','<b>'.$codestr.'</b>').  
                                        '</li>';  
                     } else {  
                         $resulttext .= '<li>'.&mt('Generation of six character code as course identifier for distribution to students set to off.').  
                                        '</li>';  
                     }  
                 }  
                 if (ref($changes{'textbooks'}) eq 'HASH') {  
                     $resulttext .= '<li>'.&mt('Available textbooks updated').'<ul>';  
                     foreach my $key (sort(keys(%{$changes{'textbooks'}}))) {  
                         my %coursehash = &Apache::lonnet::coursedescription($key);  
                         my $coursetitle = $coursehash{'description'};  
                         my $position = $confhash{'textbooks'}{$key}{'order'} + 1;  
                         $resulttext .= '<li>';  
                         foreach my $item ('subject','title','author') {  
                             my $name = $item.':';  
                             $name =~ s/^(\w)/\U$1/;  
                             $resulttext .= &mt($name).' '.$confhash{'textbooks'}{$key}{$item}.'<br />';  
                         }  
                         $resulttext .= ' '.&mt('Order: [_1]',$position).'<br />';  
                         if ($confhash{'textbooks'}{$key}{'image'}) {  
                             $resulttext .= ' '.&mt('Image: [_1]',  
                                                '<img src="'.$confhash{'textbooks'}{$key}{'image'}.'"'.  
                                                ' alt="Textbook cover" />').'<br />';  
                         }  
                         $resulttext .= ' '.&mt('LON-CAPA Course: [_1]',$coursetitle).'</li>';  
                     }  
                     $resulttext .= '</ul></li>';  
                 }  
             }  
             $resulttext .= '</ul>';              $resulttext .= '</ul>';
             if (keys(%newenv)) {              if (keys(%newenv)) {
                 &Apache::lonnet::appenv(\%newenv);                  &Apache::lonnet::appenv(\%newenv);
Line 6601  sub modify_quotas { Line 6184  sub modify_quotas {
         $resulttext = '<span class="LC_error">'.          $resulttext = '<span class="LC_error">'.
     &mt('An error occurred: [_1]',$putresult).'</span>';      &mt('An error occurred: [_1]',$putresult).'</span>';
     }      }
     if ($errors) {  
         $resulttext .= '<p>'.&mt('The following errors occurred when modifying Textbook settings.').  
                        '<ul>'.$errors.'</ul></p>';  
     }  
     return $resulttext;      return $resulttext;
 }  }
   
 sub process_textbook_image {  
     my ($r,$dom,$confname,$caller,$cdom,$cnum,$configuserok,$switchserver,$author_ok) = @_;  
     my $filename = $env{'form.'.$caller.'.filename'};  
     my ($error,$url);  
     my ($width,$height) = (50,50);  
     if ($configuserok eq 'ok') {  
         if ($switchserver) {  
             $error = &mt('Upload of textbook image is not permitted to this server: [_1]',  
                          $switchserver);  
         } elsif ($author_ok eq 'ok') {  
             my ($result,$imageurl) =  
                 &publishlogo($r,'upload',$caller,$dom,$confname,  
                              "textbooks/$dom/$cnum/cover",$width,$height);  
             if ($result eq 'ok') {  
                 $url = $imageurl;  
             } else {  
                 $error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result);  
             }  
         } else {  
             $error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3].  Error was: [_4].",$filename,$confname,$dom,$author_ok);  
         }  
     } else {  
         $error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3].  Error was: [_4].",$filename,$confname,$dom,$configuserok);  
     }  
     return ($url,$error);  
 }  
   
 sub modify_autoenroll {  sub modify_autoenroll {
     my ($dom,$lastactref,%domconfig) = @_;      my ($dom,$lastactref,%domconfig) = @_;
     my ($resulttext,%changes);      my ($resulttext,%changes);
Line 8519  sub modify_coursedefaults { Line 8071  sub modify_coursedefaults {
     my %defaultchecked = ('canuse_pdfforms' => 'off');      my %defaultchecked = ('canuse_pdfforms' => 'off');
     my @toggles = ('canuse_pdfforms');      my @toggles = ('canuse_pdfforms');
     my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',      my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial',
                    'uploadquota_community','uploadquota_textbook');                     'uploadquota_community');
     my @types = ('official','unofficial','community','textbook');      my @types = ('official','unofficial','community');
     my %staticdefaults = (      my %staticdefaults = (
                            anonsurvey_threshold => 10,                             anonsurvey_threshold => 10,
                            uploadquota          => 500,                             uploadquota          => 500,
Line 8585  sub modify_coursedefaults { Line 8137  sub modify_coursedefaults {
             }              }
         }          }
         my $officialcreds = $env{'form.official_credits'};          my $officialcreds = $env{'form.official_credits'};
         $officialcreds =~ s/[^\d.]+//g;          $officialcreds =~ s/^[^\d\.]//g;
         my $unofficialcreds = $env{'form.unofficial_credits'};          my $unofficialcreds = $env{'form.unofficial_credits'};
         $unofficialcreds =~ s/[^\d.]+//g;          $unofficialcreds =~ s/^[^\d\.]//g;
         my $textbookcreds = $env{'form.textbook_credits'};  
         $textbookcreds =~ s/[^\d.]+//g;  
         if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&          if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') &&
                 ($env{'form.coursecredits'} eq '1')) {                  ($env{'form.coursecredits'} eq '1')) {
                 $changes{'coursecredits'} = 1;                  $changes{'coursecredits'} = 1;
         } else {          } else {
             if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds)  ||              if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds)  ||
                 ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) ||                  ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds)) {
                 ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) {  
                 $changes{'coursecredits'} = 1;                  $changes{'coursecredits'} = 1;
             }              }
         }          }
         $defaultshash{'coursedefaults'}{'coursecredits'} = {          $defaultshash{'coursedefaults'}{'coursecredits'} = {
             official   => $officialcreds,              official   => $officialcreds,
             unofficial => $unofficialcreds,              unofficial => $unofficialcreds,
             textbook   => $textbookcreds,  
         }          }
     }      }
     my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,      my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash,
                                              $dom);                                               $dom);
     if ($putresult eq 'ok') {      if ($putresult eq 'ok') {
         if (keys(%changes) > 0) {          if (keys(%changes) > 0) {
             my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);              my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); 
             if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {              if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || ($changes{'uploadquota'})) {
                 if ($changes{'canuse_pdfforms'}) {                  if ($changes{'canuse_pdfforms'}) {
                     $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};                      $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'};
Line 8621  sub modify_coursedefaults { Line 8169  sub modify_coursedefaults {
                             $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};                              $defaultshash{'coursedefaults'}{'coursecredits'}{'official'};
                         $domdefaults{'unofficialcredits'} =                          $domdefaults{'unofficialcredits'} =
                             $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};                              $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'};
                         $domdefaults{'textbookcredits'} =  
                             $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'};  
                     }                      }
                 }                  }
                 if ($changes{'uploadquota'}) {                  if ($changes{'uploadquota'}) {
Line 8653  sub modify_coursedefaults { Line 8199  sub modify_coursedefaults {
                         $resulttext .= '<li>'.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').'<ul>'.                          $resulttext .= '<li>'.&mt('Default quota for content uploaded to a course/community via Course Editor set as follows:').'<ul>'.
                                        '<li>'.&mt('Official courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'</b>').'</li>'.                                         '<li>'.&mt('Official courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'official'}.'</b>').'</li>'.
                                        '<li>'.&mt('Unofficial courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'</b>').'</li>'.                                         '<li>'.&mt('Unofficial courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'unofficial'}.'</b>').'</li>'.
                                        '<li>'.&mt('Textbook courses: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'textbook'}.'</b>').'</li>'.  
   
                                        '<li>'.&mt('Communities: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'</b>').'</li>'.                                         '<li>'.&mt('Communities: [_1] MB','<b>'.$defaultshash{'coursedefaults'}{'uploadquota'}{'community'}.'</b>').'</li>'.
                                        '</ul>'.                                         '</ul>'.
                                        '</li>';                                         '</li>';
Line 8664  sub modify_coursedefaults { Line 8208  sub modify_coursedefaults {
                 } elsif ($item eq 'coursecredits') {                  } elsif ($item eq 'coursecredits') {
                     if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {                      if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') {
                         if (($domdefaults{'officialcredits'} eq '') &&                          if (($domdefaults{'officialcredits'} eq '') &&
                             ($domdefaults{'unofficialcredits'} eq '') &&                              ($domdefaults{'unofficialcredits'} eq '')) {
                             ($domdefaults{'textbookcredits'} eq '')) {  
                             $resulttext .= '<li>'.&mt('Student credits not in use for courses in this domain').'</li>';                              $resulttext .= '<li>'.&mt('Student credits not in use for courses in this domain').'</li>';
                         } else {                          } else {
                             $resulttext .= '<li>'.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').'<ul>'.                              $resulttext .= '<li>'.&mt('Student credits can be set per course by a Domain Coordinator, with the following defaults applying:').'<ul>'.
                                            '<li>'.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).'</li>'.                                             '<li>'.&mt('Official courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'official'}).'</li>'.
                                            '<li>'.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).'</li>'.                                             '<li>'.&mt('Unofficial courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}).'</li>'.
                                            '<li>'.&mt('Textbook courses: [_1]',$defaultshash{'coursedefaults'}{'coursecredits'}{'textbook'}).'</li>'.  
                                            '</ul>'.                                             '</ul>'.
                                            '</li>';                                             '</li>';
                         }                          }
Line 9144  sub modify_loadbalancing { Line 8686  sub modify_loadbalancing {
                                 }                                  }
                             }                              }
                         }                          }
                         my $cachekey = &escape('loadbalancing').':'.&escape($dom);                          my $cachekey = &scape('loadbalancing').':'.&escape($dom);
                         &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);                          &Apache::lonnet::remote_devalidate_cache($balancer,[$cachekey]);
                     }                      }
                 }                  }

Removed from v.1.160.6.30  
changed lines
  Added in v.1.212


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