Annotation of loncom/interface/lonmodifycourse.pm, revision 1.57.2.2

1.20      albertel    1: # The LearningOnline Network with CAPA
1.28      raeburn     2: # handler for DC-only modifiable course settings
1.20      albertel    3: #
1.57.2.2! raeburn     4: # $Id: lonmodifycourse.pm,v 1.57.2.1 2010/09/11 21:36:00 raeburn Exp $
1.20      albertel    5: #
1.3       raeburn     6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
1.1       raeburn    28: package Apache::lonmodifycourse;
                     29: 
                     30: use strict;
                     31: use Apache::Constants qw(:common :http);
                     32: use Apache::lonnet;
                     33: use Apache::loncommon;
1.28      raeburn    34: use Apache::lonhtmlcommon;
1.1       raeburn    35: use Apache::lonlocal;
1.36      raeburn    36: use Apache::lonuserutils;
1.28      raeburn    37: use Apache::lonpickcourse;
1.1       raeburn    38: use lib '/home/httpd/lib/perl';
1.25      www        39: use LONCAPA;
1.1       raeburn    40: 
1.28      raeburn    41: sub get_dc_settable {
1.48      raeburn    42:     my ($type) = @_;
                     43:     if ($type eq 'Community') {
                     44:         return ('courseowner');
                     45:     } else {
                     46:         return ('courseowner','coursecode','authtype','autharg');
                     47:     }
                     48: }
                     49: 
                     50: sub autoenroll_keys {
                     51:     my $internals = ['coursecode','courseowner','authtype','autharg','autoadds','autodrops',
1.50      raeburn    52:                          'autostart','autoend','sectionnums','crosslistings',
                     53:                          'co-owners'];
1.48      raeburn    54:     my $accessdates = ['default_enrollment_start_date','default_enrollment_end_date'];
                     55:     return ($internals,$accessdates);
1.28      raeburn    56: }
                     57: 
1.38      raeburn    58: sub catalog_settable {
1.49      raeburn    59:     my ($confhash,$type) = @_;
1.38      raeburn    60:     my @settable;
                     61:     if (ref($confhash) eq 'HASH') {
1.49      raeburn    62:         if ($type eq 'Community') {
                     63:             if ($confhash->{'togglecatscomm'} ne 'comm') {
                     64:                 push(@settable,'togglecats');
                     65:             }
                     66:             if ($confhash->{'categorizecomm'} ne 'comm') {
                     67:                 push(@settable,'categorize');
                     68:             }
                     69:         } else {
                     70:             if ($confhash->{'togglecats'} ne 'crs') {
                     71:                 push(@settable,'togglecats');
                     72:             }
                     73:             if ($confhash->{'categorize'} ne 'crs') {
                     74:                 push(@settable,'categorize');
                     75:             }
1.38      raeburn    76:         }
                     77:     } else {
                     78:         push(@settable,('togglecats','categorize'));
                     79:     }
                     80:     return @settable;
                     81: }
                     82: 
1.28      raeburn    83: sub get_enrollment_settings {
                     84:     my ($cdom,$cnum) = @_;
1.48      raeburn    85:     my ($internals,$accessdates) = &autoenroll_keys();
                     86:     my @items;
                     87:     if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) { 
                     88:         @items = map { 'internal.'.$_; } (@{$internals});
                     89:         push(@items,@{$accessdates});
                     90:     }
                     91:     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
1.28      raeburn    92:     my %enrollvar;
                     93:     $enrollvar{'autharg'} = '';
                     94:     $enrollvar{'authtype'} = '';
1.48      raeburn    95:     foreach my $item (keys(%settings)) {
1.28      raeburn    96:         if ($item =~ m/^internal\.(.+)$/) {
                     97:             my $type = $1;
                     98:             if ( ($type eq "autoadds") || ($type eq "autodrops") ) {
                     99:                 if ($settings{$item} == 1) {
                    100:                     $enrollvar{$type} = "ON";
                    101:                 } else {
                    102:                     $enrollvar{$type} = "OFF";
1.10      raeburn   103:                 }
1.28      raeburn   104:             } elsif ( ($type eq "autostart") || ($type eq "autoend") ) {
                    105:                 if ( ($type eq "autoend") && ($settings{$item} == 0) ) {
1.48      raeburn   106:                     $enrollvar{$type} = &mt('No end date');
1.28      raeburn   107:                 } else {
1.48      raeburn   108:                     $enrollvar{$type} = &Apache::lonlocal::locallocaltime($settings{$item});
1.14      raeburn   109:                 }
1.50      raeburn   110:             } elsif (($type eq 'sectionnums') || ($type eq 'co-owners')) {
1.28      raeburn   111:                 $enrollvar{$type} = $settings{$item};
                    112:                 $enrollvar{$type} =~ s/,/, /g;
                    113:             } elsif ($type eq "authtype"
                    114:                      || $type eq "autharg"    || $type eq "coursecode"
                    115:                      || $type eq "crosslistings") {
                    116:                 $enrollvar{$type} = $settings{$item};
                    117:             } elsif ($type eq 'courseowner') {
                    118:                 if ($settings{$item} =~ /^[^:]+:[^:]+$/) {
                    119:                     $enrollvar{$type} = $settings{$item};
                    120:                 } else {
                    121:                     if ($settings{$item} ne '') {
                    122:                         $enrollvar{$type} = $settings{$item}.':'.$cdom;
1.26      raeburn   123:                     }
1.1       raeburn   124:                 }
1.28      raeburn   125:             }
                    126:         } elsif ($item =~ m/^default_enrollment_(start|end)_date$/) {
                    127:             my $type = $1;
                    128:             if ( ($type eq 'end') && ($settings{$item} == 0) ) {
1.48      raeburn   129:                 $enrollvar{$item} = &mt('No end date');
1.28      raeburn   130:             } elsif ( ($type eq 'start') && ($settings{$item} eq '') ) {
                    131:                 $enrollvar{$item} = 'When enrolled';
                    132:             } else {
1.48      raeburn   133:                 $enrollvar{$item} = &Apache::lonlocal::locallocaltime($settings{$item});
1.1       raeburn   134:             }
                    135:         }
                    136:     }
1.28      raeburn   137:     return %enrollvar;
                    138: }
                    139: 
                    140: sub print_course_search_page {
                    141:     my ($r,$dom,$domdesc) = @_;
1.48      raeburn   142:     my $action = '/adm/modifycourse';
                    143:     my $type = $env{'form.type'};
                    144:     if (!defined($env{'form.type'})) {
                    145:         $type = 'Course';
                    146:     }
                    147:     &print_header($r,$type);
1.28      raeburn   148:     my $filterlist = ['descriptfilter',
                    149:                       'instcodefilter','ownerfilter',
1.44      raeburn   150:                       'coursefilter'];
1.28      raeburn   151:     my $filter = {};
1.57.2.1  raeburn   152:     my ($numtitles,$cctitle,$dctitle);
1.48      raeburn   153:     my $ccrole = 'cc';
                    154:     if ($type eq 'Community') {
                    155:         $ccrole = 'co';
1.46      raeburn   156:     }
1.48      raeburn   157:     $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.46      raeburn   158:     $dctitle = &Apache::lonnet::plaintext('dc');
                    159:     $r->print(&Apache::lonpickcourse::js_changer());
1.48      raeburn   160:     if ($type eq 'Community') {
                    161:         $r->print('<h3>'.&mt('Search for a community in the [_1] domain',$domdesc).'</h3>');
                    162:     } else {
                    163:         $r->print('<h3>'.&mt('Search for a course in the [_1] domain',$domdesc).'</h3>');
1.46      raeburn   164:     }   
1.28      raeburn   165:     $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
1.57.2.1  raeburn   166:                              undef,undef,$filter,$action,\$numtitles,'modifycourse'));
1.48      raeburn   167:     if ($type eq 'Community') {
                    168:         $r->print(&mt('Actions available after searching for a community:').'<ul>'.
                    169:                   '<li>'.&mt('Enter the community with the role of [_1]',$cctitle).'</li>'."\n".
                    170:                   '<li>'.&mt('View or modify community settings which only a [_1] may modify.',$dctitle).
                    171:                   '</li>'."\n".'</ul>');
                    172:     } else {
                    173:         $r->print(&mt('Actions available after searching for a course:').'<ul>'.
                    174:                   '<li>'.&mt('Enter the course with the role of [_1]',$cctitle).'</li>'."\n".
                    175:                   '<li>'.&mt('View or modify course settings which only a [_1] may modify.',$dctitle).
                    176:                   '</li>'."\n".'</ul>');
                    177:     }
1.28      raeburn   178: }
                    179: 
                    180: sub print_course_selection_page {
                    181:     my ($r,$dom,$domdesc) = @_;
1.48      raeburn   182:     my $type = $env{'form.type'};
                    183:     if (!defined($type)) {
                    184:         $type = 'Course';
                    185:     }
                    186:     &print_header($r,$type);
1.28      raeburn   187: 
                    188: # Criteria for course search 
                    189:     my $filterlist = ['descriptfilter',
                    190:                       'instcodefilter','ownerfilter',
                    191:                       'ownerdomfilter','coursefilter'];
                    192:     my %filter;
                    193:     my $action = '/adm/modifycourse';
                    194:     my $dctitle = &Apache::lonnet::plaintext('dc');
1.57.2.1  raeburn   195:     my $numtitles;
1.46      raeburn   196:     $r->print(&Apache::lonpickcourse::js_changer());
1.48      raeburn   197:     $r->print(&mt('Revise your search criteria for this domain').' ('.$domdesc.').<br />');
1.28      raeburn   198:     $r->print(&Apache::lonpickcourse::build_filters($filterlist,$type,
1.57.2.1  raeburn   199:                                        undef,undef,\%filter,$action,\$numtitles));
1.28      raeburn   200:     $filter{'domainfilter'} = $dom;
                    201:     my %courses = &Apache::lonpickcourse::search_courses($r,$type,0,
1.57.2.2! raeburn   202:                                                          \%filter,$numtitles);
1.46      raeburn   203:     &Apache::lonpickcourse::display_matched_courses($r,$type,0,$action,undef,undef,undef,
1.28      raeburn   204:                                                     %courses);
1.1       raeburn   205:     return;
                    206: }
                    207: 
1.28      raeburn   208: sub print_modification_menu {
1.48      raeburn   209:     my ($r,$cdesc,$domdesc,$dom,$type) = @_;
                    210:     &print_header($r,$type);
1.54      bisitz    211:     my ($ccrole,$categorytitle,$setquota_text,$setparams_text,$cat_text);
1.48      raeburn   212:     if ($type eq 'Community') {
                    213:         $ccrole = 'co';
                    214:     } else {
                    215:         $ccrole = 'cc';
                    216:     } 
                    217:     if ($type eq 'Community') {
1.54      bisitz    218:         $categorytitle = 'View/Modify Community Settings';
1.48      raeburn   219:         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a community.');
                    220:         $setparams_text = 'View/Modify community owner';
                    221:         $cat_text = 'View/Modify catalog settings for community';
                    222:     } else {
1.54      bisitz    223:         $categorytitle = 'View/Modify Course Settings';
1.48      raeburn   224:         $setquota_text = &mt('Total disk space allocated for storage of portfolio files in all groups in a course.');
                    225:         $setparams_text = 'View/Modify course owner, institutional code, and default authentication';
1.57      raeburn   226:         $cat_text = 'View/Modify catalog settings for course';
1.48      raeburn   227:     }
1.57      raeburn   228:     my $anon_text = 'Responder threshold required to display anonymous survey submissions';
1.54      bisitz    229: 
1.38      raeburn   230:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$dom);
1.49      raeburn   231:     my @additional_params = &catalog_settable($domconf{'coursecategories'},$type);
1.54      bisitz    232: 
                    233:     sub phaseurl {
                    234:         my $phase = shift;
                    235:         return "javascript:changePage(document.menu,'$phase')"
1.38      raeburn   236:     }
1.54      bisitz    237:     my @menu =
                    238:         ({  categorytitle => $categorytitle,
                    239:         items => [
                    240:             {
                    241:                 linktext => $setparams_text,
                    242:                 url => &phaseurl('setparms'),
                    243:                 permission => 1,
                    244:                 #help => '',
1.55      bisitz    245:                 icon => 'crsconf.png',
1.54      bisitz    246:                 linktitle => ''
                    247:             },
                    248:             {
                    249:                 linktext => 'View/Modify quota for group portfolio files',
                    250:                 url => &phaseurl('setquota'),
                    251:                 permission => 1,
                    252:                 #help => '',
1.55      bisitz    253:                 icon => 'groupportfolioquota.png',
1.54      bisitz    254:                 linktitle => ''
                    255:             },
                    256:             {
1.57      raeburn   257:                 linktext => 'View/Modify responders threshold for anonymous survey submissions display',
                    258:                 url => &phaseurl('setanon'),
                    259:                 permission => 1,
                    260:                 #help => '',
                    261:                 icon => 'anonsurveythreshold.png',
                    262:                 linktitle => ''
                    263:             },
                    264:             {
1.54      bisitz    265:                 linktext => $cat_text,
                    266:                 url => &phaseurl('catsettings'),
                    267:                 permission => (@additional_params > 0),
                    268:                 #help => '',
1.55      bisitz    269:                 icon => 'ccatconf.png',
1.54      bisitz    270:                 linktitle => ''
                    271:             },
                    272:             {
                    273:                 linktext => 'Display current settings for automated enrollment',
                    274:                 url => &phaseurl('viewparms'),
                    275:                 permission => ($type ne 'Community'),
                    276:                 #help => '',
1.55      bisitz    277:                 icon => 'roles.png',
1.54      bisitz    278:                 linktitle => ''
                    279:             },
                    280:         ]
                    281:         },
1.48      raeburn   282:         );
1.54      bisitz    283: 
                    284:     my $menu_html =
                    285:         '<h3>'
                    286:        .&mt('View/Modify settings for: [_1]',
                    287:                 '<span class="LC_nobreak">'.$cdesc.'</span>')
                    288:        .'</h3>'."\n".'<p>';
1.48      raeburn   289:     if ($type eq 'Community') {
                    290:         $menu_html .= &mt('Although almost all community settings can be modified by a Coordinator, the following may only be set or modified by a Domain Coordinator:');
                    291:     } else {
                    292:         $menu_html .= &mt('Although almost all course settings can be modified by a Course Coordinator, the following may only be set or modified by a Domain Coordinator:');
                    293:     }
1.54      bisitz    294:     $menu_html .= '</p>'."\n".'<ul>';
1.48      raeburn   295:     if ($type eq 'Community') {
                    296:         $menu_html .= '<li>'.&mt('Community owner (permitted to assign Coordinator roles in the community).').'</li>';
                    297:     } else {
                    298:         $menu_html .=  '<li>'.&mt('Course owner (permitted to assign Course Coordinator roles in the course).').'</li>'.
                    299:                        '<li>'.&mt("Institutional code and default authentication (both required for auto-enrollment of students from institutional datafeeds).").'</li>';
                    300:     }
1.57      raeburn   301:     $menu_html .= '<li>'.$setquota_text.'</li>'.
                    302:                   '<li>'.$anon_text.'</li>'."\n";
1.38      raeburn   303:     foreach my $item (@additional_params) {
1.48      raeburn   304:         if ($type eq 'Community') {
                    305:             if ($item eq 'togglecats') {
1.54      bisitz    306:                 $menu_html .= '  <li>'.&mt('Hiding/unhiding a community from the catalog (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
1.48      raeburn   307:             } elsif ($item eq 'categorize') {
1.54      bisitz    308:                 $menu_html .= '  <li>'.&mt('Manual cataloging of a community (although can be [_1]configured[_2] to be modifiable by a Coordinator in community context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
1.48      raeburn   309:             }
                    310:         } else {
                    311:             if ($item eq 'togglecats') {
1.54      bisitz    312:                 $menu_html .= '  <li>'.&mt('Hiding/unhiding a course from the course catalog (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
1.48      raeburn   313:             } elsif ($item eq 'categorize') {
1.54      bisitz    314:                 $menu_html .= '  <li>'.&mt('Manual cataloging of a course (although can be [_1]configured[_2] to be modifiable by a Course Coordinator in course context).','<a href="/adm/domainprefs?actions=coursecategories&amp;phase=display">','</a>').'</li>'."\n";
1.48      raeburn   315:             }
1.38      raeburn   316:         }
                    317:     }
1.54      bisitz    318:     $menu_html .=
                    319:         ' </ul>'
                    320:        .'<form name="menu" method="post" action="/adm/modifycourse">'
                    321:        ."\n"
                    322:        .&hidden_form_elements();
1.28      raeburn   323:     
                    324:     $r->print($menu_html);
1.54      bisitz    325:     $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
                    326:     $r->print('</form>');
1.28      raeburn   327:     return;
                    328: }
                    329: 
1.37      raeburn   330: sub print_ccrole_selected {
1.48      raeburn   331:     my ($r,$type) = @_;
                    332:     &print_header($r,$type);
1.37      raeburn   333:     my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
                    334:     $r->print('<form name="ccrole" method="post" action="/adm/roles">
                    335: <input type="hidden" name="selectrole" value="1" />
                    336: <input type="hidden" name="newrole" value="cc./'.$cdom.'/'.$cnum.'" />
                    337: </form>');
                    338: }
                    339: 
1.28      raeburn   340: sub print_settings_display {
                    341:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    342:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
1.48      raeburn   343:     my %longtype = &course_settings_descrip($type);
1.28      raeburn   344:     my %lt = &Apache::lonlocal::texthash(
1.48      raeburn   345:             'valu' => 'Current value',
                    346:             'cour' => 'Current settings are:',
                    347:             'cose' => "Settings which control auto-enrollment using classlists from your institution's student information system fall into two groups:",
                    348:             'dcon' => 'Modifiable only by Domain Coordinator',
                    349:             'back' => 'Pick another action',
1.28      raeburn   350:     );
1.48      raeburn   351:     my $ccrole = 'cc';
                    352:     if ($type eq 'Community') {
                    353:        $ccrole = 'co';
                    354:     }
                    355:     my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.28      raeburn   356:     my $dctitle = &Apache::lonnet::plaintext('dc');
1.48      raeburn   357:     my @modifiable_params = &get_dc_settable($type);
                    358:     my ($internals,$accessdates) = &autoenroll_keys();
                    359:     my @items;
                    360:     if ((ref($internals) eq 'ARRAY') && (ref($accessdates) eq 'ARRAY')) {
                    361:         @items =  (@{$internals},@{$accessdates});
                    362:     }
1.28      raeburn   363:     my $disp_table = &Apache::loncommon::start_data_table()."\n".
                    364:                      &Apache::loncommon::start_data_table_header_row()."\n".
1.48      raeburn   365:                      "<th>&nbsp;</th>\n".
1.28      raeburn   366:                      "<th>$lt{'valu'}</th>\n".
                    367:                      "<th>$lt{'dcon'}</th>\n".
                    368:                      &Apache::loncommon::end_data_table_header_row()."\n";
1.48      raeburn   369:     foreach my $item (@items) {
1.28      raeburn   370:         $disp_table .= &Apache::loncommon::start_data_table_row()."\n".
1.48      raeburn   371:                        "<td><b>$longtype{$item}</b></td>\n".
                    372:                        "<td>$enrollvar{$item}</td>\n";
                    373:         if (grep(/^\Q$item\E$/,@modifiable_params)) {
1.50      raeburn   374:             $disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n";
1.28      raeburn   375:         } else {
1.48      raeburn   376:             $disp_table .= '<td align="right">'.&mt('No').'</td>'."\n";
1.28      raeburn   377:         }
                    378:         $disp_table .= &Apache::loncommon::end_data_table_row()."\n";
1.3       raeburn   379:     }
1.28      raeburn   380:     $disp_table .= &Apache::loncommon::end_data_table()."\n";
1.48      raeburn   381:     &print_header($r,$type);
                    382:     my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
                    383:     my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
                    384:                                          '=1&destinationurl=/adm/populate','&<>"'); 
                    385:     $r->print('<h3>'.&mt('Current automated enrollment settings for:').
                    386:               ' <span class="LC_nobreak">'.$cdesc.'</span></h3>'.
                    387:               '<form action="/adm/modifycourse" method="post" name="viewparms">'."\n".
                    388:               '<p>'.$lt{'cose'}.'<ul>'.
                    389:               '<li>'.&mt('Settings modifiable by a [_1] via the [_2]Automated Enrollment Manager[_3] in a course.',$cctitle,'<a href="'.$escuri.'">','</a>').'</li>'.
                    390:               '<li>'.&mt('Settings modifiable by a [_1] via [_2]View/Modify course owner, institutional code, and default authentication[_3].',$dctitle,'<a href="javascript:changePage(document.viewparms,'."'setparms'".');">','</a>')."\n".
                    391:               '</li></ul></p>'.
                    392:               '<p>'.$lt{'cour'}.'</p><p>'.$disp_table.'</p><p>'.
                    393:               '<a href="javascript:changePage(document.viewparms,'."'menu'".')">'.$lt{'back'}.'</a>'."\n".
                    394:               &hidden_form_elements().
                    395:               '</p></form>'
                    396:      );
1.28      raeburn   397: }
1.3       raeburn   398: 
1.28      raeburn   399: sub print_setquota {
                    400:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    401:     my %lt = &Apache::lonlocal::texthash(
1.48      raeburn   402:                 'cquo' => 'Disk space for storage of group portfolio files for:',
1.28      raeburn   403:                 'gpqu' => 'Course portfolio files disk space',
1.42      schafran  404:                 'modi' => 'Save',
1.48      raeburn   405:                 'back' => 'Pick another action',
1.28      raeburn   406:     );
1.48      raeburn   407:     if ($type eq 'Community') {
                    408:         $lt{'gpqu'} = &mt('Community portfolio files disk space');
                    409:     }
1.28      raeburn   410:     my %settings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
                    411:     my $coursequota = $settings{'internal.coursequota'};
                    412:     if ($coursequota eq '') {
                    413:         $coursequota = 20;
1.3       raeburn   414:     }
1.48      raeburn   415:     &print_header($r,$type);
1.28      raeburn   416:     my $hidden_elements = &hidden_form_elements();
1.48      raeburn   417:     my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_Quota');
1.28      raeburn   418:     $r->print(<<ENDDOCUMENT);
1.57      raeburn   419: <form action="/adm/modifycourse" method="post" name="setquota" onsubmit="return verify_quota();">
1.48      raeburn   420: <h3>$lt{'cquo'} <span class="LC_nobreak">$cdesc</span></h3>
1.28      raeburn   421: <p>
1.48      raeburn   422: $helpitem $lt{'gpqu'}: <input type="text" size="4" name="coursequota" value="$coursequota" /> Mb &nbsp;&nbsp;&nbsp;&nbsp;
1.57      raeburn   423: <input type="submit" value="$lt{'modi'}" />
1.28      raeburn   424: </p>
                    425: $hidden_elements
                    426: <a href="javascript:changePage(document.setquota,'menu')">$lt{'back'}</a>
                    427: </form>
                    428: ENDDOCUMENT
                    429:     return;
                    430: }
1.3       raeburn   431: 
1.57      raeburn   432: sub print_set_anonsurvey_threshold {
                    433:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    434:     my %lt = &Apache::lonlocal::texthash(
                    435:                 'resp' => 'Responder threshold for anonymous survey submissions display:',
                    436:                 'sufa' => 'Anonymous survey submissions displayed when responders exceeds',
                    437:                 'modi' => 'Save',
                    438:                 'back' => 'Pick another action',
                    439:     );
                    440:     my %settings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
                    441:     my $threshold = $settings{'internal.anonsurvey_threshold'};
                    442:     if ($threshold eq '') {
                    443:         my %domconfig = 
                    444:             &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
                    445:         if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
                    446:             $threshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
                    447:             if ($threshold eq '') {
                    448:                 $threshold = 10;
                    449:             }
                    450:         } else {
                    451:             $threshold = 10;
                    452:         }
                    453:     }
                    454:     &print_header($r,$type);
                    455:     my $hidden_elements = &hidden_form_elements();
                    456:     my $helpitem = &Apache::loncommon::help_open_topic('Modify_Anonsurvey_Threshold');
                    457:     $r->print(<<ENDDOCUMENT);
                    458: <form action="/adm/modifycourse" method="post" name="setanon" onsubmit="return verify_anon_threshold();">
                    459: <h3>$lt{'resp'} <span class="LC_nobreak">$cdesc</span></h3>
                    460: <p>
                    461: $helpitem $lt{'sufa'}: <input type="text" size="4" name="threshold" value="$threshold" /> &nbsp;&nbsp;&nbsp;&nbsp;
                    462: <input type="submit" value="$lt{'modi'}" />
                    463: </p>
                    464: $hidden_elements
                    465: <a href="javascript:changePage(document.setanon,'menu')">$lt{'back'}</a>
                    466: </form>
                    467: ENDDOCUMENT
                    468:     return;
                    469: }
                    470: 
1.38      raeburn   471: sub print_catsettings {
1.48      raeburn   472:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
                    473:     &print_header($r,$type);
1.38      raeburn   474:     my %lt = &Apache::lonlocal::texthash(
1.48      raeburn   475:                                          'back'    => 'Pick another action',
                    476:                                          'catset'  => 'Catalog Settings for Course',
                    477:                                          'visi'    => 'Visibility in Course/Community Catalog',
                    478:                                          'exclude' => 'Exclude from course catalog:',
                    479:                                          'categ'   => 'Categorize Course',
                    480:                                          'assi'    => 'Assign one or more categories and/or subcategories to this course.'
1.38      raeburn   481:                                         );
1.48      raeburn   482:     if ($type eq 'Community') {
                    483:         $lt{'catset'} = &mt('Catalog Settings for Community');
                    484:         $lt{'exclude'} = &mt('Exclude from course catalog');
                    485:         $lt{'categ'} = &mt('Categorize Community');
1.49      raeburn   486:         $lt{'assi'} = &mt('Assign one or more subcategories to this community.');
1.48      raeburn   487:     }
1.38      raeburn   488:     $r->print('<form action="/adm/modifycourse" method="post" name="catsettings">'.
1.48      raeburn   489:               '<h3>'.$lt{'catset'}.' <span class="LC_nobreak">'.$cdesc.'</span></h3>');
1.38      raeburn   490:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49      raeburn   491:     my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38      raeburn   492:     if (@cat_params > 0) {
                    493:         my %currsettings = 
                    494:             &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
                    495:         if (grep(/^togglecats$/,@cat_params)) {
                    496:             my $excludeon = '';
                    497:             my $excludeoff = ' checked="checked" ';
                    498:             if ($currsettings{'hidefromcat'} eq 'yes') {
                    499:                 $excludeon = $excludeoff;
                    500:                 $excludeoff = ''; 
                    501:             }
1.48      raeburn   502:             $r->print('<br /><h4>'.$lt{'visi'}.'</h4>'.
                    503:                       $lt{'exclude'}.
                    504:                       '&nbsp;<label><input name="hidefromcat" type="radio" value="yes" '.$excludeon.' />'.&mt('Yes').'</label>&nbsp;&nbsp;&nbsp;<label><input name="hidefromcat" type="radio" value="" '.$excludeoff.' />'.&mt('No').'</label><br /><p>');
                    505:             if ($type eq 'Community') {
                    506:                 $r->print(&mt("If a community has been categorized using at least one of the categories defined for communities in the domain, it will be listed in the domain's publicly accessible Course/Community Catalog, unless excluded."));
                    507:             } else {
                    508:                 $r->print(&mt("Unless excluded, a course will be listed in the domain's publicly accessible Course/Community Catalog, if at least one of the following applies").':<ul>'.
                    509:                           '<li>'.&mt('Auto-cataloging is enabled and the course is assigned an institutional code.').'</li>'.
                    510:                           '<li>'.&mt('The course has been categorized using at least one of the course categories defined for the domain.').'</li></ul>');
                    511:             }
                    512:             $r->print('</ul></p>');
1.38      raeburn   513:         }
                    514:         if (grep(/^categorize$/,@cat_params)) {
1.48      raeburn   515:             $r->print('<br /><h4>'.$lt{'categ'}.'</h4>');
1.38      raeburn   516:             if (ref($domconf{'coursecategories'}) eq 'HASH') {
                    517:                 my $cathash = $domconf{'coursecategories'}{'cats'};
                    518:                 if (ref($cathash) eq 'HASH') {
1.48      raeburn   519:                     $r->print($lt{'assi'}.'<br /><br />'.
1.38      raeburn   520:                               &Apache::loncommon::assign_categories_table($cathash,
1.49      raeburn   521:                                                      $currsettings{'categories'},$type));
1.38      raeburn   522:                 } else {
                    523:                     $r->print(&mt('No categories defined for this domain'));
                    524:                 }
                    525:             } else {
                    526:                 $r->print(&mt('No categories defined for this domain'));
                    527:             }
1.48      raeburn   528:             unless ($type eq 'Community') { 
                    529:                 $r->print('<p>'.&mt('If auto-cataloging based on institutional code is enabled in the domain, a course will continue to be listed in the catalog of official courses, in addition to receiving a listing under any manually assigned categor(ies).').'</p>');
                    530:             }
1.38      raeburn   531:         }
1.48      raeburn   532:         $r->print('<p><input type="button" name="chgcatsettings" value="'.
                    533:                   &mt('Save').'" onclick="javascript:changePage(document.catsettings,'."'processcat'".');" /></p>');
1.38      raeburn   534:     } else {
1.48      raeburn   535:         $r->print('<span class="LC_warning">');
                    536:         if ($type eq 'Community') {
                    537:             $r->print(&mt('Catalog settings in this domain are set in community context via "Community Configuration".'));
                    538:         } else {
                    539:             $r->print(&mt('Catalog settings in this domain are set in course context via "Course Configuration".'));
                    540:         }
                    541:         $r->print('</span><br /><br />'."\n".
1.38      raeburn   542:                   '<a href="javascript:changePage(document.catsettings,'."'menu'".');">'.
                    543:                   $lt{'back'}.'</a>');
                    544:     }
                    545:     $r->print(&hidden_form_elements().'</form>'."\n");
                    546:     return;
                    547: }
                    548: 
1.28      raeburn   549: sub print_course_modification_page {
1.48      raeburn   550:     my ($r,$cdom,$cnum,$cdesc,$type) = @_;
1.2       raeburn   551:     my %lt=&Apache::lonlocal::texthash(
                    552:             'actv' => "Active",
                    553:             'inac' => "Inactive",
                    554:             'ownr' => "Owner",
                    555:             'name' => "Name",
1.26      raeburn   556:             'unme' => "Username:Domain",
1.2       raeburn   557:             'stus' => "Status",
1.48      raeburn   558:             'nocc' => 'There is currently no owner set for this course.',
1.32      raeburn   559:             'gobt' => "Save",
1.2       raeburn   560:     );
1.48      raeburn   561:     my ($ownertable,$ccrole,$javascript_validations,$authenitems,$ccname);
                    562:     my %enrollvar = &get_enrollment_settings($cdom,$cnum);
                    563:     if ($type eq 'Community') {
                    564:         $ccrole = 'co';
                    565:         $lt{'nocc'} = &mt('There is currently no owner set for this community.');
                    566:     } else {
                    567:         $ccrole ='cc';
                    568:         ($javascript_validations,$authenitems) = &gather_authenitems($cdom,\%enrollvar);
                    569:     }
                    570:     $ccname = &Apache::lonnet::plaintext($ccrole,$type);
                    571:     my %roleshash = &Apache::lonnet::get_my_roles($cnum,$cdom,'','',[$ccrole]);
                    572:     my (@local_ccs,%cc_status,%pname);
                    573:     foreach my $item (keys(%roleshash)) {
                    574:         my ($uname,$udom) = split(/:/,$item);
                    575:         if (!grep(/^\Q$uname\E:\Q$udom\E$/,@local_ccs)) {
                    576:             push(@local_ccs,$uname.':'.$udom);
                    577:             $pname{$uname.':'.$udom} = &Apache::loncommon::plainname($uname,$udom);
                    578:             $cc_status{$uname.':'.$udom} = $lt{'actv'};
1.1       raeburn   579:         }
                    580:     }
1.48      raeburn   581:     if (($enrollvar{'courseowner'} ne '') && 
                    582:         (!grep(/^$enrollvar{'courseowner'}$/,@local_ccs))) {
                    583:         push(@local_ccs,$enrollvar{'courseowner'});
1.26      raeburn   584:         my ($owneruname,$ownerdom) = split(/:/,$enrollvar{'courseowner'});
                    585:         $pname{$enrollvar{'courseowner'}} = 
                    586:                          &Apache::loncommon::plainname($owneruname,$ownerdom);
1.48      raeburn   587:         my $active_cc = &Apache::loncommon::check_user_status($ownerdom,$owneruname,
                    588:                                                               $cdom,$cnum,$ccrole);
1.19      raeburn   589:         if ($active_cc eq 'active') {
1.2       raeburn   590:             $cc_status{$enrollvar{'courseowner'}} = $lt{'actv'};
1.1       raeburn   591:         } else {
1.2       raeburn   592:             $cc_status{$enrollvar{'courseowner'}} = $lt{'inac'};
1.1       raeburn   593:         }
                    594:     }
1.48      raeburn   595:     @local_ccs = sort(@local_ccs);
                    596:     if (@local_ccs == 0) {
                    597:         $ownertable = $lt{'nocc'};
                    598:     } else {
                    599:         my $numlocalcc = scalar(@local_ccs);
                    600:         $ownertable = '<input type="hidden" name="numlocalcc" value="'.$numlocalcc.'" />'.
                    601:                       &Apache::loncommon::start_data_table()."\n".
                    602:                       &Apache::loncommon::start_data_table_header_row()."\n".
                    603:                       '<th>'.$lt{'ownr'}.'</th>'.
                    604:                       '<th>'.$lt{'name'}.'</th>'.
                    605:                       '<th>'.$lt{'unme'}.'</th>'.
                    606:                       '<th>'.$lt{'stus'}.'</th>'.
                    607:                       &Apache::loncommon::end_data_table_header_row()."\n";
                    608:         foreach my $cc (@local_ccs) {
                    609:             $ownertable .= &Apache::loncommon::start_data_table_row()."\n";
                    610:             if ($cc eq $enrollvar{'courseowner'}) {
                    611:                   $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" checked="checked" /></td>'."\n";
                    612:             } else {
                    613:                 $ownertable .= '<td><input type="radio" name="courseowner" value="'.$cc.'" /></td>'."\n";
                    614:             }
                    615:             $ownertable .= 
                    616:                  '<td>'.$pname{$cc}.'</td>'."\n".
                    617:                  '<td>'.$cc.'</td>'."\n".
                    618:                  '<td>'.$cc_status{$cc}.' '.$ccname.'</td>'."\n".
                    619:                  &Apache::loncommon::end_data_table_row()."\n";
                    620:         }
                    621:         $ownertable .= &Apache::loncommon::end_data_table();
                    622:     }
                    623:     &print_header($r,$type,$javascript_validations);
                    624:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    625:     my $mainheader = &modifiable_only_title($type);
                    626:     my $hidden_elements = &hidden_form_elements();
                    627:     $r->print('<form action="/adm/modifycourse" method="post" name="'.$env{'form.phase'}.'">'."\n".
                    628:               '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3><p>'.
                    629:               &Apache::lonhtmlcommon::start_pick_box());
                    630:     if ($type eq 'Community') {
                    631:         $r->print(&Apache::lonhtmlcommon::row_title(
                    632:                   &Apache::loncommon::help_open_topic('Modify_Community_Owner').
                    633:                   '&nbsp;'.&mt('Community Owner'))."\n");
                    634:     } else {
                    635:         $r->print(&Apache::lonhtmlcommon::row_title(
                    636:                       &Apache::loncommon::help_open_topic('Modify_Course_Instcode').
                    637:                       '&nbsp;'.&mt('Course Code'))."\n".
                    638:                   '<input type="text" size="10" name="coursecode" value="'.$enrollvar{'coursecode'}.'" />'.
                    639:                   &Apache::lonhtmlcommon::row_closure().
                    640:                   &Apache::lonhtmlcommon::row_title(
                    641:                      &Apache::loncommon::help_open_topic('Modify_Course_Defaultauth').
                    642:                      '&nbsp;'.&mt('Default Authentication method'))."\n".
                    643:                   $authenitems."\n".
                    644:                   &Apache::lonhtmlcommon::row_closure().
                    645:                   &Apache::lonhtmlcommon::row_title(
                    646:                       &Apache::loncommon::help_open_topic('Modify_Course_Owner').
                    647:                       '&nbsp;'.&mt('Course Owner'))."\n");
                    648:     }
                    649:     $r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure(1).
                    650:               &Apache::lonhtmlcommon::end_pick_box().'</p><p>'.$hidden_elements.
                    651:               '<input type="button" onclick="javascript:changePage(this.form,'."'processparms'".');');
                    652:     if ($type eq 'Community') {
                    653:         $r->print('this.form.submit();"');
                    654:     } else {
                    655:         $r->print('javascript:verify_message(this.form);"');
                    656:     }
                    657:     $r->print('value="'.$lt{'gobt'}.'" /></p></form>');
                    658:     return;
                    659: }
                    660: 
                    661: sub modifiable_only_title {
                    662:     my ($type) = @_;
                    663:     my $dctitle = &Apache::lonnet::plaintext('dc');
                    664:     if ($type eq 'Community') {
                    665:         return &mt('Community settings modifiable only by [_1] for:',$dctitle);
                    666:     } else {
                    667:         return &mt('Course settings modifiable only by [_1] for:',$dctitle);
                    668:     }
                    669: }
1.24      albertel  670: 
1.48      raeburn   671: sub gather_authenitems {
                    672:     my ($cdom,$enrollvar) = @_;
1.28      raeburn   673:     my ($krbdef,$krbdefdom)=&Apache::loncommon::get_kerberos_defaults($cdom);
1.2       raeburn   674:     my $curr_authtype = '';
                    675:     my $curr_authfield = '';
1.48      raeburn   676:     if (ref($enrollvar) eq 'HASH') {
                    677:         if ($enrollvar->{'authtype'} =~ /^krb/) {
                    678:             $curr_authtype = 'krb';
                    679:         } elsif ($enrollvar->{'authtype'} eq 'internal' ) {
                    680:             $curr_authtype = 'int';
                    681:         } elsif ($enrollvar->{'authtype'} eq 'localauth' ) {
                    682:             $curr_authtype = 'loc';
                    683:         }
1.2       raeburn   684:     }
                    685:     unless ($curr_authtype eq '') {
                    686:         $curr_authfield = $curr_authtype.'arg';
1.33      raeburn   687:     }
1.48      raeburn   688:     my $javascript_validations = 
                    689:         &Apache::lonuserutils::javascript_validations('modifycourse',$krbdefdom,
                    690:                                                       $curr_authtype,$curr_authfield);
1.35      raeburn   691:     my %param = ( formname => 'document.'.$env{'form.phase'},
1.48      raeburn   692:            kerb_def_dom => $krbdefdom,
                    693:            kerb_def_auth => $krbdef,
1.2       raeburn   694:            mode => 'modifycourse',
                    695:            curr_authtype => $curr_authtype,
1.48      raeburn   696:            curr_autharg => $enrollvar->{'autharg'}
                    697:         );
1.32      raeburn   698:     my (%authform,$authenitems);
                    699:     $authform{'krb'} = &Apache::loncommon::authform_kerberos(%param);
                    700:     $authform{'int'} = &Apache::loncommon::authform_internal(%param);
                    701:     $authform{'loc'} = &Apache::loncommon::authform_local(%param);
                    702:     foreach my $item ('krb','int','loc') {
                    703:         if ($authform{$item} ne '') {
                    704:             $authenitems .= $authform{$item}.'<br />';
                    705:         }
1.1       raeburn   706:     }
1.48      raeburn   707:     return($javascript_validations,$authenitems);
1.1       raeburn   708: }
                    709: 
                    710: sub modify_course {
1.30      raeburn   711:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
1.48      raeburn   712:     my %longtype = &course_settings_descrip($type);
1.50      raeburn   713:     my @items = ('internal.courseowner','description','internal.co-owners',
                    714:                  'internal.pendingco-owners');
1.48      raeburn   715:     unless ($type eq 'Community') {
                    716:         push(@items,('internal.coursecode','internal.authtype','internal.autharg',
                    717:                      'internal.sectionnums','internal.crosslistings'));
1.1       raeburn   718:     }
1.48      raeburn   719:     my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum);
                    720:     my $description = $settings{'description'};
                    721:     my ($ccrole,$response,$chgresponse,$nochgresponse,$reply,%currattr,%newattr,%cenv,%changed,
                    722:         @changes,@nochanges,@sections,@xlists,@warnings);
                    723:     my @modifiable_params = &get_dc_settable($type);
1.28      raeburn   724:     foreach my $param (@modifiable_params) {
1.48      raeburn   725:         $currattr{$param} = $settings{'internal.'.$param};
1.1       raeburn   726:     }
1.48      raeburn   727:     if ($type eq 'Community') {
                    728:         %changed = ( owner  => 0 );
                    729:         $ccrole = 'co';
                    730:     } else {
                    731:         %changed = ( code  => 0,
                    732:                      owner => 0,
                    733:                    );
                    734:         $ccrole = 'cc';
                    735:         unless ($settings{'internal.sectionnums'} eq '') {
                    736:             if ($settings{'internal.sectionnums'} =~ m/,/) {
                    737:                 @sections = split/,/,$settings{'internal.sectionnums'};
                    738:             } else {
                    739:                 $sections[0] = $settings{'internal.sectionnums'};
                    740:             }
                    741:         }
                    742:         unless ($settings{'internal.crosslistings'} eq'') {
                    743:             if ($settings{'internal.crosslistings'} =~ m/,/) {
                    744:                 @xlists = split/,/,$settings{'internal.crosslistings'};
                    745:             } else {
                    746:                 $xlists[0] = $settings{'internal.crosslistings'};
                    747:             }
                    748:         }
                    749:         if ($env{'form.login'} eq 'krb') {
                    750:             $newattr{'authtype'} = $env{'form.login'};
                    751:             $newattr{'authtype'} .= $env{'form.krbver'};
                    752:             $newattr{'autharg'} = $env{'form.krbarg'};
                    753:         } elsif ($env{'form.login'} eq 'int') {
                    754:             $newattr{'authtype'} ='internal';
                    755:             if ((defined($env{'form.intarg'})) && ($env{'form.intarg'})) {
                    756:                 $newattr{'autharg'} = $env{'form.intarg'};
                    757:             }
                    758:         } elsif ($env{'form.login'} eq 'loc') {
                    759:             $newattr{'authtype'} = 'localauth';
                    760:             if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) {
                    761:                 $newattr{'autharg'} = $env{'form.locarg'};
                    762:             }
                    763:         }
                    764:         if ( $newattr{'authtype'}=~ /^krb/) {
                    765:             if ($newattr{'autharg'}  eq '') {
                    766:                 push(@warnings,
                    767:                            &mt('As you did not include the default Kerberos domain'
1.45      bisitz    768:                           .' to be used for authentication in this class, the'
                    769:                           .' institutional data used by the automated'
                    770:                           .' enrollment process must include the Kerberos'
1.48      raeburn   771:                           .' domain for each new student.'));
                    772:             }
                    773:         }
                    774: 
                    775:         if ( exists($env{'form.coursecode'}) ) {
                    776:             $newattr{'coursecode'}=$env{'form.coursecode'};
                    777:             unless ( $newattr{'coursecode'} eq $currattr{'coursecode'} ) {
                    778:                 $changed{'code'} = 1;
                    779:             }
1.1       raeburn   780:         }
                    781:     }
                    782: 
1.16      albertel  783:     if ( exists($env{'form.courseowner'}) ) {
                    784:         $newattr{'courseowner'}=$env{'form.courseowner'};
1.14      raeburn   785:         unless ( $newattr{'courseowner'} eq $currattr{'courseowner'} ) {
1.38      raeburn   786:             $changed{'owner'} = 1;
1.1       raeburn   787:         } 
                    788:     }
1.48      raeburn   789: 
1.50      raeburn   790:     if ($changed{'owner'} || $changed{'code'}) {
1.38      raeburn   791:         my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum,
                    792:                                                     undef,undef,'.');
                    793:         if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
1.48      raeburn   794:             if ($changed{'code'}) {
                    795:                 $crsinfo{$env{'form.pickedcourse'}}{'inst_code'} = $env{'form.coursecode'};
                    796:             }
                    797:             if ($changed{'owner'}) {
                    798:                 $crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'};
                    799:             }
1.38      raeburn   800:             my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
                    801:             my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
1.50      raeburn   802:             if ($putres eq 'ok') {
                    803:                 &update_coowners($cdom,$cnum,$chome,\%settings,\%newattr);
                    804:             }
1.38      raeburn   805:         }
1.14      raeburn   806:     }
1.28      raeburn   807:     foreach my $param (@modifiable_params) {
                    808:         if ($currattr{$param} eq $newattr{$param}) {
                    809:             push(@nochanges,$param);
1.1       raeburn   810:         } else {
1.48      raeburn   811:             $cenv{'internal.'.$param} = $newattr{$param};
1.28      raeburn   812:             push(@changes,$param);
1.1       raeburn   813:         }
                    814:     }
                    815:     if (@changes > 0) {
1.48      raeburn   816:         $chgresponse = &mt("The following settings have been changed:<br/><ul>");
1.1       raeburn   817:     }
1.48      raeburn   818:     if (@nochanges > 0) {
                    819:         $nochgresponse = &mt("The following settings remain unchanged:<br/><ul>");
1.1       raeburn   820:     }
1.33      raeburn   821:     if (@changes > 0) {
1.28      raeburn   822:         my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
1.1       raeburn   823:         if ($putreply !~ /^ok$/) {
1.48      raeburn   824:             $response = '<p class="LC_error">'.
                    825:                         &mt('There was a problem processing your requested changes.').'<br />';
                    826:             if ($type eq 'Community') {
                    827:                 $response .= &mt('Settings for this community have been left unchanged.');
                    828:             } else {
                    829:                 $response .= &mt('Settings for this course have been left unchanged.');
                    830:             }
                    831:             $response .= '<br/>'.&mt('Error: ').$putreply.'</p>';
1.1       raeburn   832:         } else {
1.28      raeburn   833:             foreach my $attr (@modifiable_params) {
1.48      raeburn   834:                 if (grep/^\Q$attr\E$/,@changes) {
                    835: 	            $chgresponse .= '<li>'.$longtype{$attr}.' '.&mt('now set to:').' "'.$newattr{$attr}.'".</li>';
1.1       raeburn   836:                 } else {
1.48      raeburn   837: 	            $nochgresponse .= '<li>'.$longtype{$attr}.' '.&mt('still set to:').' "'.$currattr{$attr}.'".</li>';
1.1       raeburn   838:                 }
                    839:             }
1.48      raeburn   840:             if (($type ne 'Community') && ($changed{'code'} || $changed{'owner'})) {
1.1       raeburn   841:                 if ( $newattr{'courseowner'} eq '') {
1.48      raeburn   842: 	            push(@warnings,&mt('There is no owner associated with this LON-CAPA course.').
                    843:                                    '<br />'.&mt('If automated enrollment at your institution requires validation of course owners, automated enrollment will fail.'));
1.1       raeburn   844:                 } else {
                    845: 	            if (@sections > 0) {
1.38      raeburn   846:                         if ($changed{'code'}) {
1.2       raeburn   847: 	                    foreach my $sec (@sections) {
                    848: 		                if ($sec =~ m/^(.+):/) {
1.48      raeburn   849:                                     my $instsec = $1;
1.8       raeburn   850: 		                    my $inst_course_id = $newattr{'coursecode'}.$1;
1.28      raeburn   851:                                     my $course_check = &Apache::lonnet::auto_validate_courseID($cnum,$cdom,$inst_course_id);
1.7       raeburn   852: 			            if ($course_check eq 'ok') {
1.28      raeburn   853:                                         my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.48      raeburn   854: 			                unless ($outcome eq 'ok') {
                    855:                                
1.53      raeburn   856: 				            push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome).'<br/>');
1.1       raeburn   857: 			                }
                    858: 			            } else {
1.53      raeburn   859:                                         push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$course_check));
1.1       raeburn   860: 			            }
                    861: 		                } else {
1.48      raeburn   862: 			            push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.1       raeburn   863: 		                }
                    864: 		            }
1.38      raeburn   865: 	                } elsif ($changed{'owner'}) {
1.4       raeburn   866:                             foreach my $sec (@sections) {
                    867:                                 if ($sec =~ m/^(.+):/) {
1.48      raeburn   868:                                     my $instsec = $1;
                    869:                                     my $inst_course_id = $newattr{'coursecode'}.$instsec;
1.28      raeburn   870:                                     my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$inst_course_id,$newattr{'courseowner'});
1.4       raeburn   871:                                     unless ($outcome eq 'ok') {
1.53      raeburn   872:                                         push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3] for the following reason: "[_4]".',$description,$newattr{'coursecode'},$instsec,$outcome));
1.4       raeburn   873:                                     }
                    874:                                 } else {
1.53      raeburn   875:                                     push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for "[_2]" - section: [_3], because this is not a valid section entry.',$description,$newattr{'coursecode'},$sec));
1.4       raeburn   876:                                 }
                    877:                             }
                    878:                         }
1.1       raeburn   879: 	            } else {
1.53      raeburn   880: 	                push(@warnings,&mt('As no section numbers are currently listed for "[_1]", automated enrollment will not occur for any sections of institutional course code: "[_2]".',$description,$newattr{'coursecode'}));
1.1       raeburn   881: 	            }
1.38      raeburn   882: 	            if ( (@xlists > 0) && ($changed{'owner'}) ) {
1.1       raeburn   883: 	                foreach my $xlist (@xlists) {
                    884: 		            if ($xlist =~ m/^(.+):/) {
1.48      raeburn   885:                                 my $instxlist = $1;
                    886:                                 my $outcome = &Apache::lonnet::auto_new_course($cnum,$cdom,$instxlist,$newattr{'courseowner'});
1.1       raeburn   887: 		                unless ($outcome eq 'ok') {
1.48      raeburn   888: 			            push(@warnings,&mt('If automatic enrollment is enabled for "[_1]", automated enrollment may fail for crosslisted class "[_2]" for the following reason: "[_3]".',$description,$instxlist,$outcome));
1.1       raeburn   889: 		                }
1.28      raeburn   890: 		            }
1.1       raeburn   891: 	                }
                    892: 	            }
                    893:                 }
                    894:             }
                    895:         }
1.2       raeburn   896:     } else {
1.28      raeburn   897:         foreach my $attr (@modifiable_params) {
1.48      raeburn   898:             $nochgresponse .= '<li>'.$longtype{$attr}.' '.&mt('still set to').' "'.$currattr{$attr}.'".</li>';
1.2       raeburn   899:         }
1.1       raeburn   900:     }
                    901: 
                    902:     if (@changes > 0) {
                    903:         $chgresponse .= "</ul><br/><br/>";
                    904:     }
                    905:     if (@nochanges > 0) {
                    906:         $nochgresponse .=  "</ul><br/><br/>";
                    907:     }
1.48      raeburn   908:     my ($warning,$numwarnings);
                    909:     my $numwarnings = scalar(@warnings); 
                    910:     if ($numwarnings) {
                    911:         $warning = &mt('The following [quant,_1,warning was,warnings were] generated when applying your changes to automated enrollment:',$numwarnings).'<p><ul>';
                    912:         foreach my $warn (@warnings) {
                    913:             $warning .= '<li><span class="LC_warning">'.$warn.'</span></li>';
                    914:         }
                    915:         $warning .= '</ul></p>';
1.1       raeburn   916:     }
1.48      raeburn   917:     if ($response) {
                    918:         $reply = $response;
                    919:     } else {
1.1       raeburn   920:         $reply = $chgresponse.$nochgresponse.$warning;
                    921:     }
1.48      raeburn   922:     &print_header($r,$type);
                    923:     my $mainheader = &modifiable_only_title($type);
                    924:     $reply = '<h3>'.$mainheader.' <span class="LC_nobreak">'.$cdesc.'</span></h3>'."\n".
                    925:              '<p>'.$reply.'</p>'."\n".
1.28      raeburn   926:              '<form action="/adm/modifycourse" method="post" name="processparms">'.
                    927:              &hidden_form_elements().
1.48      raeburn   928:              '<a href="javascript:changePage(document.processparms,'."'menu'".')">'.
                    929:              &mt('Pick another action').'</a>';
                    930:     if ($numwarnings) {
                    931:         my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
                    932:         my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
                    933:                                              '=1&destinationurl=/adm/populate','&<>"');
                    934: 
                    935:         $reply .= '<br /><a href="'.$escuri.'">'.
                    936:                   &mt('Go to Automated Enrollment Manager for course').'</a>';
                    937:     }
                    938:     $reply .= '</form>';
1.3       raeburn   939:     $r->print($reply);
1.28      raeburn   940:     return;
                    941: }
                    942: 
1.50      raeburn   943: sub update_coowners {
                    944:     my ($cdom,$cnum,$chome,$settings,$newattr) = @_;
                    945:     return unless ((ref($settings) eq 'HASH') && (ref($newattr) eq 'HASH'));
                    946:     my %designhash = &Apache::loncommon::get_domainconf($cdom);
                    947:     my (%cchash,$autocoowners);
                    948:     if ($designhash{$cdom.'.autoassign.co-owners'}) {
                    949:         $autocoowners = 1;
                    950:         %cchash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,['cc']);
                    951:     }
                    952:     if ($settings->{'internal.courseowner'} ne $newattr->{'courseowner'}) {
                    953:         my $oldowner_to_coowner;
1.51      raeburn   954:         my @types = ('co-owners');
1.50      raeburn   955:         if (($newattr->{'coursecode'}) && ($autocoowners)) {
                    956:             my $oldowner = $settings->{'internal.courseowner'};
                    957:             if ($cchash{$oldowner.':cc'}) {
1.51      raeburn   958:                 my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$oldowner);
                    959:                 if ($result eq 'valid') {
                    960:                     if ($settings->{'internal.co-owner'}) {
                    961:                         my @current = split(',',$settings->{'internal.co-owners'});
                    962:                         unless (grep(/^\Q$oldowner\E$/,@current)) {
                    963:                             $oldowner_to_coowner = 1;
                    964:                         }
                    965:                     } else {
1.50      raeburn   966:                         $oldowner_to_coowner = 1;
                    967:                     }
                    968:                 }
                    969:             }
1.51      raeburn   970:         } else {
                    971:             push(@types,'pendingco-owners');
1.50      raeburn   972:         }
1.51      raeburn   973:         foreach my $type (@types) {
1.50      raeburn   974:             if ($settings->{'internal.'.$type}) {
                    975:                 my @current = split(',',$settings->{'internal.'.$type});
                    976:                 my $newowner = $newattr->{'courseowner'};
                    977:                 my @newvalues = ();
                    978:                 if (($newowner ne '') && (grep(/^\Q$newowner\E$/,@current))) {
                    979:                     foreach my $person (@current) {
                    980:                         unless ($person eq $newowner) {
                    981:                             push(@newvalues,$person);
                    982:                         }
                    983:                     }
                    984:                 } else {
                    985:                     @newvalues = @current;
                    986:                 }
                    987:                 if ($oldowner_to_coowner) {
                    988:                     push(@newvalues,$settings->{'internal.courseowner'});
                    989:                     @newvalues = sort(@newvalues);
                    990:                 }
                    991:                 my $newownstr = join(',',@newvalues);
                    992:                 if ($newownstr ne $settings->{'internal.'.$type}) {
                    993:                     if ($type eq 'co-owners') {
                    994:                         my $deleted = '';
                    995:                         unless (@newvalues) {
                    996:                             $deleted = 1;
                    997:                         }
                    998:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
                    999:                                                         $deleted,@newvalues);
                   1000:                     } else {
                   1001:                         my $pendingcoowners;
                   1002:                         my $cid = $cdom.'_'.$cnum;
                   1003:                         if (@newvalues) {
                   1004:                             $pendingcoowners = join(',',@newvalues);
                   1005:                             my %pendinghash = (
                   1006:                                 'internal.pendingco-owners' => $pendingcoowners,
                   1007:                             );
1.52      raeburn  1008:                             my $putresult = &Apache::lonnet::put('environment',\%pendinghash,$cdom,$cnum);
1.50      raeburn  1009:                             if ($putresult eq 'ok') {
                   1010:                                 if ($env{'course.'.$cid.'.num'} eq $cnum) {
1.52      raeburn  1011:                                     &Apache::lonnet::appenv({'course.'.$cid.'.internal.pendingco-owners' => $pendingcoowners});
1.50      raeburn  1012:                                 }
                   1013:                             }
                   1014:                         } else {
                   1015:                             my $delresult = &Apache::lonnet::del('environment',['internal.pendingco-owners'],$cdom,$cnum);
                   1016:                             if ($delresult eq 'ok') {
                   1017:                                 if ($env{'course.'.$cid.'.internal.pendingco-owners'}) {
                   1018:                                     &Apache::lonnet::delenv('course.'.$cid.'.internal.pendingco-owners');
                   1019:                                 }
                   1020:                             }
                   1021:                         }
                   1022:                     }
                   1023:                 } elsif ($oldowner_to_coowner) {
                   1024:                     &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
                   1025:                                          $settings->{'internal.courseowner'});
                   1026: 
                   1027:                 }
                   1028:             } elsif ($oldowner_to_coowner) {
                   1029:                 &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
                   1030:                                      $settings->{'internal.courseowner'});
                   1031:             }
                   1032:         }
                   1033:     }
                   1034:     if ($settings->{'internal.coursecode'} ne $newattr->{'coursecode'}) {
                   1035:         if ($newattr->{'coursecode'} ne '') {
                   1036:             my %designhash = &Apache::loncommon::get_domainconf($cdom);
                   1037:             if ($designhash{$cdom.'.autoassign.co-owners'}) {
                   1038:                 my @newcoowners = ();
                   1039:                 if ($settings->{'internal.co-owners'}) {
                   1040:                     my @currcoown = split(',',$settings->{'internal.coowners'});
                   1041:                     my ($updatecoowners,$delcoowners);
                   1042:                     foreach my $person (@currcoown) {
1.51      raeburn  1043:                         my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$person);
1.50      raeburn  1044:                         if ($result eq 'valid') {
                   1045:                             push(@newcoowners,$person);
                   1046:                         }
                   1047:                     }
                   1048:                     foreach my $item (sort(keys(%cchash))) {
                   1049:                         my ($uname,$udom,$urole) = split(':',$item);
1.51      raeburn  1050:                         next if ($uname.':'.$udom eq $newattr->{'courseowner'});
1.50      raeburn  1051:                         unless (grep(/^\Q$uname\E:\Q$udom\E$/,@newcoowners)) {
1.51      raeburn  1052:                             my ($result,$desc) = &Apache::lonnet::auto_validate_instcode($cnum,$cdom,$newattr->{'coursecode'},$uname.':'.$udom);
                   1053:                             if ($result eq 'valid') {
                   1054:                                 push(@newcoowners,$uname.':'.$udom);
                   1055:                             }
1.50      raeburn  1056:                         }
                   1057:                     }
                   1058:                     if (@newcoowners) {
                   1059:                         my $coowners = join(',',sort(@newcoowners));
                   1060:                         unless ($coowners eq $settings->{'internal.co-owners'}) {
                   1061:                             $updatecoowners = 1;
                   1062:                         }
                   1063:                     } else {
                   1064:                         $delcoowners = 1;
                   1065:                     }
                   1066:                     if ($updatecoowners || $delcoowners) {
                   1067:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,
                   1068:                                                         $delcoowners,@newcoowners);
                   1069:                     }
                   1070:                 } else {
                   1071:                     foreach my $item (sort(keys(%cchash))) {
                   1072:                         my ($uname,$udom,$urole) = split(':',$item);
                   1073:                         push(@newcoowners,$uname.':'.$udom);
                   1074:                     }
                   1075:                     if (@newcoowners) {
                   1076:                         &Apache::lonnet::store_coowners($cdom,$cnum,$chome,'',
                   1077:                                                         @newcoowners);
                   1078:                     }
                   1079:                 }
                   1080:             }
                   1081:         }
                   1082:     }
                   1083:     return;
                   1084: }
                   1085: 
1.28      raeburn  1086: sub modify_quota {
1.48      raeburn  1087:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
                   1088:     &print_header($r,$type);
                   1089:     $r->print('<form action="/adm/modifycourse" method="post" name="processquota">'."\n".
                   1090:               '<h3>'.&mt('Disk space for storage of group portfolio files for:').
                   1091:               ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
1.28      raeburn  1092:     my %oldsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
                   1093:     my $defaultquota = 20;
                   1094:     if ($env{'form.coursequota'} ne '') {
                   1095:         my $newquota = $env{'form.coursequota'};
                   1096:         if ($newquota =~ /^\s*(\d+\.?\d*|\.\d+)\s*$/) {
                   1097:             $newquota = $1;
                   1098:             if ($oldsettings{'internal.coursequota'} eq $env{'form.coursequota'}) {
1.48      raeburn  1099:                 $r->print(&mt('The disk space allocated for group portfolio files remains unchanged as [_1] Mb.',$env{'form.coursequota'}));
1.28      raeburn  1100:             } else {
                   1101:                 my %cenv = (
                   1102:                            'internal.coursequota' => $env{'form.coursequota'},
                   1103:                            );
                   1104:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
                   1105:                                                     $cnum);
                   1106:                 if (($oldsettings{'internal.coursequota'} eq '') && 
                   1107:                     ($env{'form.coursequota'} == $defaultquota)) {
1.48      raeburn  1108:                     if ($type eq 'Community') {
                   1109:                          $r->print(&mt('The disk space allocated for group portfolio files in this community is the default quota for this domain: [_1] Mb.',$defaultquota));
                   1110:                     } else {
                   1111:                          $r->print(&mt('The disk space allocated for group portfolio files in this course is the default quota for this domain: [_1] Mb.',$defaultquota));
                   1112:                     }
1.28      raeburn  1113:                 } else {
                   1114:                     if ($putreply eq 'ok') {
                   1115:                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.coursequota'],$cdom,$cnum);
1.57      raeburn  1116:                         $r->print(&mt('The disk space allocated for group portfolio files is now: [_1] Mb.','<b>'.$updatedsettings{'internal.coursequota'}.'</b>'));
1.28      raeburn  1117:                         my $usage = &Apache::longroup::sum_quotas($cdom.'_'.$cnum);
                   1118:                         if ($usage >= $updatedsettings{'internal.coursequota'}) {
                   1119:                             my $newoverquota;
                   1120:                             if ($usage < $oldsettings{'internal.coursequota'}) {
                   1121:                                 $newoverquota = 'now';
                   1122:                             }
1.48      raeburn  1123:                             $r->print('<p>');
                   1124:                             if ($type eq 'Community') {
                   1125:                                 $r->print(&mt('Disk usage [_1] exceeds the quota for this community.',$newoverquota).' '.
                   1126:                                           &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the community will not be possible until some files have been deleted, and total usage is below community quota.'));
                   1127:                             } else {
                   1128:                                 $r->print(&mt('Disk usage [_1] exceeds the quota for this course.',$newoverquota).' '.
                   1129:                                           &mt('Upload of new portfolio files and assignment of a non-zero Mb quota to new groups in the course will not be possible until some files have been deleted, and total usage is below course quota.'));
                   1130:                             }
                   1131:                             $r->print('</p>');
1.28      raeburn  1132:                         }
                   1133:                     } else {
1.48      raeburn  1134:                         $r->print(&mt('An error occurred storing the quota for group portfolio files: ').
                   1135:                                   $putreply);
1.28      raeburn  1136:                     }
                   1137:                 }
                   1138:             }
                   1139:         } else {
                   1140:             $r->print(&mt('The new quota requested contained invalid characters, so the quota is unchanged.'));
                   1141:         }
                   1142:     }
1.48      raeburn  1143:     $r->print('<p>'.
                   1144:               '<a href="javascript:changePage(document.processquota,'."'menu'".')">'.
                   1145:               &mt('Pick another action').'</a>');
1.28      raeburn  1146:     $r->print(&hidden_form_elements().'</form>');
                   1147:     return;
1.1       raeburn  1148: }
                   1149: 
1.57      raeburn  1150: sub modify_anonsurvey_threshold {
                   1151:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
                   1152:     &print_header($r,$type);
                   1153:     $r->print('<form action="/adm/modifycourse" method="post" name="processthreshold">'."\n".
                   1154:               '<h3>'.&mt('Responder threshold required for display of anonymous survey submissions:').
                   1155:               ' <span class="LC_nobreak">'.$cdesc.'</span></h3><br />');
                   1156:     my %oldsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
                   1157:     my %domconfig =
                   1158:         &Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom);
                   1159:     my $defaultthreshold; 
                   1160:     if (ref($domconfig{'coursedefaults'}) eq 'HASH') {
                   1161:         $defaultthreshold = $domconfig{'coursedefaults'}{'anonsurvey_threshold'};
                   1162:         if ($defaultthreshold eq '') {
                   1163:             $defaultthreshold = 10;
                   1164:         }
                   1165:     } else {
                   1166:         $defaultthreshold = 10;
                   1167:     }
                   1168:     if ($env{'form.threshold'} eq '') {
                   1169:         $r->print(&mt('The proposed responder threshold for display of anonymous survey submissions was blank, so the threshold is unchanged.'));
                   1170:     } else {
                   1171:         my $newthreshold = $env{'form.threshold'};
                   1172:         if ($newthreshold =~ /^\s*(\d+)\s*$/) {
                   1173:             $newthreshold = $1;
                   1174:             if ($oldsettings{'internal.anonsurvey_threshold'} eq $env{'form.threshold'}) {
                   1175:                 $r->print(&mt('Responder threshold for anonymous survey submissions display remains unchanged: [_1].',$env{'form.threshold'}));
                   1176:             } else {
                   1177:                 my %cenv = (
                   1178:                            'internal.anonsurvey_threshold' => $env{'form.threshold'},
                   1179:                            );
                   1180:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,
                   1181:                                                     $cnum);
                   1182:                 if (($oldsettings{'internal.anonsurvey_threshold'} eq '') &&
                   1183:                     ($env{'form.threshold'} == $defaultthreshold)) {
                   1184:                     $r->print(&mt('The responder threshold for display of anonymous survey submissions is the default for this domain: [_1].',$defaultthreshold));
                   1185:                 } else {
                   1186:                     if ($putreply eq 'ok') {
                   1187:                         my %updatedsettings = &Apache::lonnet::get('environment',['internal.anonsurvey_threshold'],$cdom,$cnum);
                   1188:                         $r->print(&mt('The responder threshold for display of anonymous survey submissions is now: [_1].','<b>'.$updatedsettings{'internal.anonsurvey_threshold'}.'</b>'));
                   1189:                     } else {
                   1190:                         $r->print(&mt('An error occurred storing the responder threshold for anonymous submissions display: ').
                   1191:                                   $putreply);
                   1192:                     }
                   1193:                 }
                   1194:             }
                   1195:         } else {
                   1196:             $r->print(&mt('The proposed responder threshold for display of anonymous submissions contained invalid characters, so the threshold is unchanged.'));
                   1197:         }
                   1198:     }
                   1199:     $r->print('<p>'.
                   1200:               '<a href="javascript:changePage(document.processthreshold,'."'menu'".')">'.
                   1201:               &mt('Pick another action').'</a>');
                   1202:     $r->print(&hidden_form_elements().'</form>');
                   1203:     return;
                   1204: }
                   1205: 
1.38      raeburn  1206: sub modify_catsettings {
1.48      raeburn  1207:     my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_;
                   1208:     &print_header($r,$type);
                   1209:     my ($ccrole,%desc);
                   1210:     if ($type eq 'Community') {
                   1211:         $desc{'hidefromcat'} = &mt('Excluded from community catalog');
                   1212:         $desc{'categories'} = &mt('Assigned categories for this community');
                   1213:         $ccrole = 'co';
                   1214:     } else {
                   1215:         $desc{'hidefromcat'} = &mt('Excluded from course catalog');
                   1216:         $desc{'categories'} = &mt('Assigned categories for this course');
                   1217:         $ccrole = 'cc';
                   1218:     }
1.38      raeburn  1219:     $r->print('
                   1220: <form action="/adm/modifycourse" method="post" name="processcat">
                   1221: <h3>'.&mt('Category settings').'</h3>');
                   1222:     my %domconf = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
1.49      raeburn  1223:     my @cat_params = &catalog_settable($domconf{'coursecategories'},$type);
1.38      raeburn  1224:     if (@cat_params > 0) {
                   1225:         my (%cenv,@changes,@nochanges);
                   1226:         my %currsettings =
                   1227:             &Apache::lonnet::get('environment',['hidefromcat','categories'],$cdom,$cnum);
                   1228:         my (@newcategories,%showitem); 
                   1229:         if (grep(/^togglecats$/,@cat_params)) {
                   1230:             if ($currsettings{'hidefromcat'} ne $env{'form.hidefromcat'}) {
                   1231:                 push(@changes,'hidefromcat');
                   1232:                 $cenv{'hidefromcat'} = $env{'form.hidefromcat'};
                   1233:             } else {
                   1234:                 push(@nochanges,'hidefromcat');
                   1235:             }
                   1236:             if ($env{'form.hidefromcat'} eq 'yes') {
                   1237:                 $showitem{'hidefromcat'} = '"'.&mt('Yes')."'";
                   1238:             } else {
                   1239:                 $showitem{'hidefromcat'} = '"'.&mt('No').'"';
                   1240:             }
                   1241:         }
                   1242:         if (grep(/^categorize$/,@cat_params)) {
                   1243:             my (@cats,@trails,%allitems,%idx,@jsarray);
                   1244:             if (ref($domconf{'coursecategories'}) eq 'HASH') {
                   1245:                 my $cathash = $domconf{'coursecategories'}{'cats'};
                   1246:                 if (ref($cathash) eq 'HASH') {
                   1247:                     &Apache::loncommon::extract_categories($cathash,\@cats,\@trails,
                   1248:                                                            \%allitems,\%idx,\@jsarray);
                   1249:                 }
                   1250:             }
                   1251:             @newcategories =  &Apache::loncommon::get_env_multiple('form.usecategory');
                   1252:             if (@newcategories == 0) {
                   1253:                 $showitem{'categories'} = '"'.&mt('None').'"';
                   1254:             } else {
                   1255:                 $showitem{'categories'} = '<ul>';
                   1256:                 foreach my $item (@newcategories) {
                   1257:                     $showitem{'categories'} .= '<li>'.$trails[$allitems{$item}].'</li>';
                   1258:                 }
                   1259:                 $showitem{'categories'} .= '</ul>';
                   1260:             }
                   1261:             my $catchg = 0;
                   1262:             if ($currsettings{'categories'} ne '') {
                   1263:                 my @currcategories = split('&',$currsettings{'categories'});
                   1264:                 foreach my $cat (@currcategories) {
                   1265:                     if (!grep(/^\Q$cat\E$/,@newcategories)) {
                   1266:                         $catchg = 1;
                   1267:                         last;
                   1268:                     }
                   1269:                 }
                   1270:                 if (!$catchg) {
                   1271:                     foreach my $cat (@newcategories) {
                   1272:                         if (!grep(/^\Q$cat\E$/,@currcategories)) {
                   1273:                             $catchg = 1;
                   1274:                             last;                     
                   1275:                         } 
                   1276:                     } 
                   1277:                 }
                   1278:             } else {
                   1279:                 if (@newcategories > 0) {
                   1280:                     $catchg = 1;
                   1281:                 }
                   1282:             }
                   1283:             if ($catchg) {
                   1284:                 $cenv{'categories'} = join('&',@newcategories);
                   1285:                 push(@changes,'categories');
                   1286:             } else {
                   1287:                 push(@nochanges,'categories');
                   1288:             }
                   1289:             if (@changes > 0) {
                   1290:                 my $putreply = &Apache::lonnet::put('environment',\%cenv,$cdom,$cnum);
                   1291:                 if ($putreply eq 'ok') {
                   1292:                     my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
                   1293:                                                                 $cnum,undef,undef,'.');
                   1294:                     if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') {
                   1295:                         if (grep(/^hidefromcat$/,@changes)) {
                   1296:                             $crsinfo{$env{'form.pickedcourse'}}{'hidefromcat'} = $env{'form.hidefromcat'};
                   1297:                         }
                   1298:                         if (grep(/^categories$/,@changes)) {
                   1299:                             $crsinfo{$env{'form.pickedcourse'}}{'categories'} = $cenv{'categories'};
                   1300:                         }
                   1301:                         my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
                   1302:                         my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime');
                   1303:                     }
1.48      raeburn  1304:                     $r->print(&mt('The following changes occurred:').'<ul>');
1.38      raeburn  1305:                     foreach my $item (@changes) {
1.48      raeburn  1306:                         $r->print('<li>'.&mt('[_1] now set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38      raeburn  1307:                     }
                   1308:                     $r->print('</ul><br />');
                   1309:                 }
                   1310:             }
                   1311:             if (@nochanges > 0) {
1.48      raeburn  1312:                 $r->print(&mt('The following were unchanged:').'<ul>');
1.38      raeburn  1313:                 foreach my $item (@nochanges) {
1.48      raeburn  1314:                     $r->print('<li>'.&mt('[_1] still set to: [_2]',$desc{$item},$showitem{$item}).'</li>');
1.38      raeburn  1315:                 }
                   1316:                 $r->print('</ul>');
                   1317:             }
                   1318:         }
                   1319:     } else {
1.48      raeburn  1320:         my $newrole = $ccrole.'./'.$cdom.'/'.$cnum;
                   1321:         my $escuri = &HTML::Entities::encode('/adm/roles?selectrole=1&'.$newrole.
                   1322:                                              '=1&destinationurl=/adm/courseprefs','&<>"');
                   1323:         if ($type eq 'Community') {
                   1324:             $r->print(&mt('Category settings for communities in this domain should be modified in community context (via "[_1]Community Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
                   1325:         } else {
                   1326:             $r->print(&mt('Category settings for courses in this domain should be modified in course context (via "[_1]Course Configuration[_2]").','<a href="$escuri">','</a>').'<br />');
                   1327:         }
1.38      raeburn  1328:     }
                   1329:     $r->print('<br />'."\n".
                   1330:               '<a href="javascript:changePage(document.processcat,'."'menu'".')">'.
1.48      raeburn  1331:               &mt('Pick another action').'</a>');
1.38      raeburn  1332:     $r->print(&hidden_form_elements().'</form>');
                   1333:     return;
                   1334: }
                   1335: 
1.1       raeburn  1336: sub print_header {
1.48      raeburn  1337:     my ($r,$type,$javascript_validations) = @_;
1.28      raeburn  1338:     my $phase = "start";
                   1339:     if ( exists($env{'form.phase'}) ) {
                   1340:         $phase = $env{'form.phase'};
                   1341:     }
                   1342:     my $js = qq|
                   1343: <script type="text/javascript">
                   1344: function changePage(formname,newphase) {
                   1345:     formname.phase.value = newphase;
                   1346:     if (newphase == 'processparms') {
                   1347:         return;
1.1       raeburn  1348:     }
1.28      raeburn  1349:     formname.submit();
                   1350: }
                   1351: </script>
                   1352: |;
                   1353:     if ($phase eq 'setparms') {
                   1354: 	$js .= qq|
                   1355: <script  type="text/javascript">
                   1356: $javascript_validations
                   1357: </script>
                   1358: |;
                   1359:     } elsif ($phase eq 'courselist') {
                   1360:         $js .= qq|
                   1361: <script type="text/javascript">
                   1362: function gochoose(cname,cdom,cdesc) {
                   1363:     document.courselist.pickedcourse.value = cdom+'_'+cname;
                   1364:     document.courselist.submit();
                   1365: }
                   1366: </script>
                   1367: |;
                   1368:     } elsif ($phase eq 'setquota') {
1.57      raeburn  1369:         my $invalid = &mt('The quota you entered contained invalid characters.');
                   1370:         my $alert = &mt('You must enter a number');
                   1371:         my $regexp = '/^\s*(\d+\.?\d*|\.\d+)\s*$/';
                   1372:         $js .= <<"ENDSCRIPT";
1.28      raeburn  1373: <script type="text/javascript">
1.57      raeburn  1374: function verify_quota() {
                   1375:     var newquota = document.setquota.coursequota.value; 
                   1376:     var num_reg = $regexp;
1.28      raeburn  1377:     if (num_reg.test(newquota)) {
1.57      raeburn  1378:         changePage(document.setquota,'processquota');
1.1       raeburn  1379:     } else {
1.57      raeburn  1380:         alert("$invalid\\n$alert");
                   1381:         return false;
1.1       raeburn  1382:     }
1.57      raeburn  1383:     return true;
                   1384: }
                   1385: </script>
                   1386: ENDSCRIPT
                   1387:     } elsif ($phase eq 'setanon') {
                   1388:         my $invalid = &mt('The responder threshold you entered is invalid.');
                   1389:         my $alert = &mt('You must enter a positive integer.');
                   1390:         my $regexp = ' /^\s*\d+\s*$/';
                   1391:         $js .= <<"ENDSCRIPT";
                   1392: <script type="text/javascript">
                   1393: function verify_anon_threshold() {
                   1394:     var newthreshold = document.setanon.threshold.value;
                   1395:     var num_reg = $regexp;
                   1396:     if (num_reg.test(newthreshold)) {
                   1397:         if (newthreshold > 0) {
                   1398:             changePage(document.setanon,'processthreshold');
                   1399:         } else {
                   1400:             alert("$invalid\\n$alert");
                   1401:             return false;
                   1402:         }
                   1403:     } else {
                   1404:         alert("$invalid\\n$alert");
                   1405:         return false;
                   1406:     }
                   1407:     return true;
1.28      raeburn  1408: }
                   1409: </script>
                   1410: ENDSCRIPT
1.1       raeburn  1411:     }
1.37      raeburn  1412:     my $starthash;
                   1413:     if ($env{'form.phase'} eq 'ccrole') {
                   1414:         $starthash = {
                   1415:            add_entries => {'onload' => "javascript:document.ccrole.submit();"},
                   1416:                      };
                   1417:     }
1.48      raeburn  1418:     $r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings',
1.37      raeburn  1419: 					     $js,$starthash));
1.48      raeburn  1420:     my $bread_text = "View/Modify Courses/Communities";
                   1421:     if ($type eq 'Community') {
                   1422:         $bread_text = 'Community Settings';
1.41      raeburn  1423:     } else {
1.48      raeburn  1424:         $bread_text = 'Course Settings';
1.41      raeburn  1425:     }
1.48      raeburn  1426:     $r->print(&Apache::lonhtmlcommon::breadcrumbs($bread_text));
1.5       raeburn  1427:     return;
1.1       raeburn  1428: }
                   1429: 
                   1430: sub print_footer {
1.23      albertel 1431:     my ($r) = @_;
                   1432:     $r->print('<br />'.&Apache::loncommon::end_page());
1.5       raeburn  1433:     return;
1.3       raeburn  1434: }
                   1435: 
                   1436: sub check_course {
1.28      raeburn  1437:     my ($r,$dom,$domdesc) = @_;
                   1438:     my ($ok_course,$description,$instcode,$owner);
1.35      raeburn  1439:     my %args = (
                   1440:                  one_time => 1,
                   1441:                );
                   1442:     my %coursehash = 
                   1443:         &Apache::lonnet::coursedescription($env{'form.pickedcourse'},\%args);
                   1444:     my $cnum = $coursehash{'num'};
                   1445:     my $cdom = $coursehash{'domain'};
                   1446:     if ($cdom eq $dom) {
                   1447:         my $description;
                   1448:         my %courseIDs = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',
1.38      raeburn  1449:                                                       $cnum,undef,undef,'.');
1.35      raeburn  1450:         if (keys(%courseIDs) > 0) {
                   1451:             $ok_course = 'ok';
                   1452:             my ($instcode,$owner);
                   1453:             if (ref($courseIDs{$cdom.'_'.$cnum}) eq 'HASH') {
                   1454:                 $description = $courseIDs{$cdom.'_'.$cnum}{'description'};
                   1455:                 $instcode = $courseIDs{$cdom.'_'.$cnum}{'inst_code'};
                   1456:                 $owner = $courseIDs{$cdom.'_'.$cnum}{'owner'};          
                   1457:             } else {
                   1458:                 ($description,$instcode,$owner) = 
                   1459:                                    split(/:/,$courseIDs{$cdom.'_'.$cnum});
                   1460:             }
                   1461:             $description = &unescape($description);
                   1462:             $instcode = &unescape($instcode);
                   1463:             if ($instcode) {
                   1464:                 $description .= " ($instcode)";
1.5       raeburn  1465:             }
1.35      raeburn  1466:             return ($ok_course,$description);
1.3       raeburn  1467:         }
                   1468:     }
1.1       raeburn  1469: }
                   1470: 
1.28      raeburn  1471: sub course_settings_descrip {
1.48      raeburn  1472:     my ($type) = @_;
                   1473:     my %longtype;
                   1474:     if ($type eq 'Community') {
                   1475:          %longtype = &Apache::lonlocal::texthash(
                   1476:                       'courseowner' => "Username:domain of community owner",
1.50      raeburn  1477:                       'co-owners'   => "Username:domain of each co-owner",
1.48      raeburn  1478:          );
                   1479:     } else {
                   1480:          %longtype = &Apache::lonlocal::texthash(
1.28      raeburn  1481:                       'authtype' => 'Default authentication method',
                   1482:                       'autharg'  => 'Default authentication parameter',
                   1483:                       'autoadds' => 'Automated adds',
                   1484:                       'autodrops' => 'Automated drops',
                   1485:                       'autostart' => 'Date of first automated enrollment',
                   1486:                       'autoend' => 'Date of last automated enrollment',
                   1487:                       'default_enrollment_start_date' => 'Date of first student access',
                   1488:                       'default_enrollment_end_date' => 'Date of last student access',
                   1489:                       'coursecode' => 'Official course code',
                   1490:                       'courseowner' => "Username:domain of course owner",
1.50      raeburn  1491:                       'co-owners'   => "Username:domain of each co-owner",
1.28      raeburn  1492:                       'notifylist' => 'Course Coordinators to be notified of enrollment changes',
1.48      raeburn  1493:                       'sectionnums' => 'Course section number:LON-CAPA section',
                   1494:                       'crosslistings' => 'Crosslisted class:LON-CAPA section',
                   1495:          );
                   1496:     }
1.28      raeburn  1497:     return %longtype;
                   1498: }
                   1499: 
                   1500: sub hidden_form_elements {
                   1501:     my $hidden_elements = 
1.46      raeburn  1502:       &Apache::lonhtmlcommon::echo_form_input(['gosearch','updater','coursecode',
1.37      raeburn  1503:           'prevphase','numlocalcc','courseowner','login','coursequota','intarg',
1.57      raeburn  1504:           'locarg','krbarg','krbver','counter','hidefromcat','usecategory',
                   1505:           'threshold'])."\n".
1.37      raeburn  1506:           '<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />';
1.28      raeburn  1507:     return $hidden_elements;
                   1508: }
1.1       raeburn  1509: 
                   1510: sub handler {
                   1511:     my $r = shift;
                   1512:     if ($r->header_only) {
                   1513:         &Apache::loncommon::content_type($r,'text/html');
                   1514:         $r->send_http_header;
                   1515:         return OK;
                   1516:     }
1.28      raeburn  1517:     my $dom = $env{'request.role.domain'};
1.31      albertel 1518:     my $domdesc = &Apache::lonnet::domain($dom,'description');
1.28      raeburn  1519:     if (&Apache::lonnet::allowed('ccc',$dom)) {
1.1       raeburn  1520:         &Apache::loncommon::content_type($r,'text/html');
                   1521:         $r->send_http_header;
                   1522: 
1.28      raeburn  1523:         &Apache::lonhtmlcommon::clear_breadcrumbs();
                   1524: 
                   1525:         my $phase = $env{'form.phase'};
1.46      raeburn  1526:         if ($env{'form.updater'}) {
                   1527:             $phase = '';
                   1528:         }
1.37      raeburn  1529:         if ($phase eq '') {
                   1530:             &Apache::lonhtmlcommon::add_breadcrumb
1.28      raeburn  1531:             ({href=>"/adm/modifycourse",
1.48      raeburn  1532:               text=>"Course/Community search"});
1.28      raeburn  1533:             &print_course_search_page($r,$dom,$domdesc);
1.1       raeburn  1534:         } else {
1.37      raeburn  1535:             my $firstform = $phase;
                   1536:             if ($phase eq 'courselist') {
                   1537:                 $firstform = 'filterpicker';
1.48      raeburn  1538:             }
                   1539:             my $choose_text;
                   1540:             my $type = $env{'form.type'};
                   1541:             if ($type eq '') {
                   1542:                 $type = 'Course';
                   1543:             }
                   1544:             if ($type eq 'Community') {
                   1545:                 $choose_text = "Choose a community";
                   1546:             } else {
                   1547:                 $choose_text = "Choose a course";
1.37      raeburn  1548:             } 
1.28      raeburn  1549:             &Apache::lonhtmlcommon::add_breadcrumb
1.37      raeburn  1550:             ({href=>"javascript:changePage(document.$firstform,'')",
1.48      raeburn  1551:               text=>"Course/Community search"},
1.37      raeburn  1552:               {href=>"javascript:changePage(document.$phase,'courselist')",
1.48      raeburn  1553:               text=>$choose_text});
1.28      raeburn  1554:             if ($phase eq 'courselist') {
                   1555:                 &print_course_selection_page($r,$dom,$domdesc);
                   1556:             } else {
                   1557:                 my ($checked,$cdesc) = &check_course($r,$dom,$domdesc);
                   1558:                 if ($checked eq 'ok') {
1.48      raeburn  1559:                     my $enter_text;
                   1560:                     if ($type eq 'Community') {
                   1561:                         $enter_text = 'Enter community';
                   1562:                     } else {
                   1563:                         $enter_text = 'Enter course';
                   1564:                     }
1.28      raeburn  1565:                     if ($phase eq 'menu') {
1.37      raeburn  1566:                         &Apache::lonhtmlcommon::add_breadcrumb
                   1567:                         ({href=>"javascript:changePage(document.$phase,'menu')",
                   1568:                           text=>"Pick action"});
1.48      raeburn  1569:                         &print_modification_menu($r,$cdesc,$domdesc,$dom,$type);
1.37      raeburn  1570:                     } elsif ($phase eq 'ccrole') {
                   1571:                         &Apache::lonhtmlcommon::add_breadcrumb
                   1572:                          ({href=>"javascript:changePage(document.$phase,'ccrole')",
1.48      raeburn  1573:                            text=>$enter_text});
                   1574:                         &print_ccrole_selected($r,$type);
1.28      raeburn  1575:                     } else {
1.37      raeburn  1576:                         &Apache::lonhtmlcommon::add_breadcrumb
                   1577:                         ({href=>"javascript:changePage(document.$phase,'menu')",
                   1578:                           text=>"Pick action"});
1.28      raeburn  1579:                         my ($cdom,$cnum) = split(/_/,$env{'form.pickedcourse'});
                   1580:                         if ($phase eq 'setquota') {
                   1581:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1582:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1583:                               text=>"Set quota"});
1.38      raeburn  1584:                             &print_setquota($r,$cdom,$cnum,$cdesc,$type);
1.28      raeburn  1585:                         } elsif ($phase eq 'processquota') { 
                   1586:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1587:                             ({href=>"javascript:changePage(document.$phase,'setquota')",
                   1588:                               text=>"Set quota"});
                   1589:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1590:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1591:                               text=>"Result"});
1.48      raeburn  1592:                             &modify_quota($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.57      raeburn  1593:                         } elsif ($phase eq 'setanon') {
                   1594:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1595:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1596:                               text=>"Threshold for anonymous submissions display"});
                   1597:                             &print_set_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$type);
                   1598: 
                   1599:                         } elsif ($phase eq 'processthreshold') {
                   1600:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1601:                             ({href=>"javascript:changePage(document.$phase,'setanon')",
                   1602:                               text=>"Threshold for anonymous submissions display"});
                   1603:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1604:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1605:                               text=>"Result"});
                   1606:                             &modify_anonsurvey_threshold($r,$cdom,$cnum,$cdesc,$domdesc,$type);
                   1607:                         } elsif ($phase eq 'viewparms') {
1.28      raeburn  1608:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1609:                             ({href=>"javascript:changePage(document.$phase,'viewparms')",
                   1610:                               text=>"Display settings"});
                   1611:                             &print_settings_display($r,$cdom,$cnum,$cdesc,$type);
                   1612:                         } elsif ($phase eq 'setparms') {
                   1613:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1614:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1615:                               text=>"Change settings"});
1.48      raeburn  1616:                             &print_course_modification_page($r,$cdom,$cnum,$cdesc,$type);
1.28      raeburn  1617:                         } elsif ($phase eq 'processparms') {
                   1618:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1619:                             ({href=>"javascript:changePage(document.$phase,'setparms')",
                   1620:                               text=>"Change settings"});
                   1621:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1622:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1623:                               text=>"Result"});
1.30      raeburn  1624:                             &modify_course($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.38      raeburn  1625:                         } elsif ($phase eq 'catsettings') {
                   1626:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1627:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1628:                               text=>"Catalog settings"});
                   1629:                             &print_catsettings($r,$cdom,$cnum,$cdesc,$type);
                   1630:                         } elsif ($phase eq 'processcat') {
                   1631:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1632:                             ({href=>"javascript:changePage(document.$phase,'catsettings')",
                   1633:                               text=>"Catalog settings"});
                   1634:                             &Apache::lonhtmlcommon::add_breadcrumb
                   1635:                             ({href=>"javascript:changePage(document.$phase,'$phase')",
                   1636:                               text=>"Result"});
1.48      raeburn  1637:                             &modify_catsettings($r,$cdom,$cnum,$cdesc,$domdesc,$type);
1.28      raeburn  1638:                         }
                   1639:                     }
                   1640:                 } else {
1.48      raeburn  1641:                     $r->print('<span class="LC_error">');
                   1642:                     if ($type eq 'Community') {
                   1643:                         $r->print(&mt('The course you selected is not a valid course in this domain'));
                   1644:                     } else {
                   1645:                         $r->print(&mt('The community you selected is not a valid community in this domain'));
                   1646:                     }
                   1647:                     $r->print(" ($domdesc)</span>");
1.28      raeburn  1648:                 }
                   1649:             }
1.1       raeburn  1650:         }
1.28      raeburn  1651:         &print_footer($r);
1.1       raeburn  1652:     } else {
1.16      albertel 1653:         $env{'user.error.msg'}=
1.48      raeburn  1654:         "/adm/modifycourse:ccc:0:0:Cannot modify course/community settings";
1.1       raeburn  1655:         return HTTP_NOT_ACCEPTABLE;
                   1656:     }
                   1657:     return OK;
                   1658: }
                   1659: 
                   1660: 1;
                   1661: __END__

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