File:  [LON-CAPA] / loncom / interface / lonconfigsettings.pm
Revision 1.46: download - view: text, annotated - select for diffs
Thu Jul 18 18:28:52 2019 UTC (4 years, 10 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Bug 6754. LON-CAPA as LTI Provider.
  Domain configuration to support session expiration in LON-CAPA,
  after user logs out of LTI Consumer which originally launched session,
  (if Consumer supports logoutServiceUrl; e.g. custom_logout_url in Canvas).

    1: # The LearningOnline Network with CAPA
    2: # Handler to set domain-wide configuration settings
    3: #
    4: # $Id: lonconfigsettings.pm,v 1.46 2019/07/18 18:28:52 raeburn Exp $
    5: #
    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: # /home/httpd/html/adm/gpl.txt
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: #
   28: ###############################################################
   29: ##############################################################
   30: 
   31: package Apache::lonconfigsettings;
   32: 
   33: use strict;
   34: use Apache::lonnet;
   35: use Apache::loncommon();
   36: use Apache::lonhtmlcommon();
   37: use Apache::lonlocal;
   38: use Apache::lonparmset();
   39: use Apache::courseclassifier();
   40: use LONCAPA qw(:DEFAULT :match); 
   41: 
   42: sub print_header {
   43:     my ($r,$phase,$context,$jscript,$container,$instcode,$dom,$values) = @_;
   44:     my ($pagetitle,$brcrumtitle,$action,$call_category_check,$instcode_check,
   45:         $crstype,@actions,@code_order);
   46:     if ($phase eq 'display') {
   47:         @actions = &Apache::loncommon::get_env_multiple('form.actions');
   48:     }
   49:     if ($context eq 'domain') {
   50:         ($pagetitle, $brcrumtitle) = ('View/Modify Domain Settings','View/Modify Domain Settings');
   51:         $action = '/adm/domainprefs';
   52:         if ($phase eq 'display') {
   53:             if (grep(/^coursecategories$/,@actions)) {
   54:                 $call_category_check = qq|
   55:     if (formname == document.display) {
   56:         if (!categoryCheck(formname)) {
   57:             return;
   58:         }
   59:     }
   60: |;
   61:             }
   62:         }
   63:     } else {
   64:         $crstype = &Apache::loncommon::course_type();
   65:         if ($crstype eq 'Community') {
   66:             ($pagetitle,$brcrumtitle) = ('Community Configuration','Community Configuration');
   67:         } else {
   68:             ($pagetitle,$brcrumtitle) = ('Course Configuration','Course Configuration');
   69:         }
   70:         $action = '/adm/courseprefs';
   71:         if ($phase eq 'display') {
   72:             if (grep(/^courseinfo$/,@actions)) {
   73:                 my %codedefaults;
   74:                 &Apache::lonnet::auto_instcode_defaults($env{'request.role.domain'},\%codedefaults,
   75:                                                         \@code_order);
   76:                 if (@code_order) {
   77:                    my $noinstcodestr = &mt('You indicated cloning based on category, but did not select any categories.');
   78:                    &js_escape(\$noinstcodestr);
   79:                    $instcode_check = <<"ENDSCRIPT";
   80:     if (formname == document.display) {
   81:         if (formname.cloners_instcode.length) {
   82:             for (var j=0; j<formname.cloners_instcode.length; j++) {
   83:                 if (formname.cloners_instcode[j].checked) {
   84:                     if (formname.cloners_instcode[j].value == 1) {
   85:                         var codes;
   86:                         if (document.getElementsByClassName) {
   87:                             codes = document.getElementsByClassName('LC_cloners_instcodes');
   88:                         } else {
   89:                             codes = getElementsByClassName(document.body,'LC_cloners_instcodes');
   90:                         }
   91:                         if (codes.length) {
   92:                             var gotcode = 0;
   93:                             for (var i=0; i<codes.length; i++) {
   94:                                 if (codes[i].selectedIndex != 0) {
   95:                                      gotcode = 1; 
   96:                                      break;
   97:                                 }
   98:                             }
   99:                             if (!gotcode) {
  100:                                 for (var k=0; k<formname.cloners_instcode.length; k++) {
  101:                                     if (formname.cloners_instcode[k].value == 0) {
  102:                                         formname.cloners_instcode[k].checked = true;
  103:                                     }
  104:                                 }
  105:                                 toggleCloners(document.display.cloners_instcode);
  106:                                 alert('$noinstcodestr');
  107:                                 return false;
  108:                             }
  109:                         }
  110:                     }
  111:                 }
  112:             }
  113:         }
  114:     }
  115: 
  116: ENDSCRIPT
  117:                 }
  118:             }
  119:         }
  120:     }
  121:     my $alert = &mt('You must select at least one functionality type to display.');
  122:     &js_escape(\$alert);
  123:     my $js = '
  124: <script type="text/javascript">
  125: // <![CDATA[
  126: 
  127: function changePage(formname,newphase) {
  128:     formname.phase.value = newphase;
  129:     numchecked = 0;
  130:     if (formname == document.pickactions) {
  131:         if (formname.actions.length > 0) {
  132:             for (var i = 0; i<formname.actions.length; i++) {
  133:                 if (formname.actions[i].checked) {
  134:                     numchecked ++;
  135:                 }
  136:             }
  137:         } else {
  138:             if (formname.actions.checked) {
  139:                 numchecked ++;
  140:             }
  141:         }
  142:         if (numchecked > 0) {
  143:             formname.submit();
  144:         } else {
  145:             alert("'.$alert.'");
  146:             return;
  147:         }
  148:     }
  149:     '.$instcode_check.$call_category_check.'
  150:     formname.submit();
  151: }'."\n";
  152:     if ($phase eq 'pickactions') {
  153: 	$js .= &Apache::lonhtmlcommon::color_picker();
  154:         $js .=
  155:             &Apache::lonhtmlcommon::set_form_elements({actions => 'checkbox'})."\n";
  156:     } elsif ($phase eq 'display') {
  157: 	$js .= &Apache::lonhtmlcommon::color_picker();
  158:         $js .= &color_pick_js()."\n";
  159:     }
  160:     $js .= &Apache::loncommon::viewport_size_js().'
  161: 
  162: // ]]>
  163: </script>
  164: ';
  165:     if ($jscript) {
  166:         $js .= "
  167: 
  168: $jscript
  169: 
  170: ";
  171:     }
  172:     my $additem;
  173:     if ($phase eq 'pickactions') {
  174:         my %loaditems = (
  175:                     'onload' => "setFormElements(document.pickactions);",
  176:                         );
  177:         $additem = {'add_entries' => \%loaditems,};
  178:     } elsif ($phase eq 'display') {
  179:         if ($context eq 'domain') {
  180:             my $onload;
  181:             if (grep(/^coursedefaults$/,@actions)) {
  182:                 $onload = "toggleDisplay(document.display,'cloneinstcode');".
  183:                           "toggleDisplay(document.display,'credits');".
  184:                           "toggleDisplay(document.display,'studentsubmission');";
  185:             }
  186:             if (grep(/^selfcreation$/,@actions)) {
  187:                 my $prefix = 'cancreate_emailverified';
  188:                 my $customclass = 'LC_selfcreate_email';
  189:                 my $classprefix = 'LC_canmodify_emailusername_';
  190:                 my $optionsprefix = 'LC_options_emailusername_';
  191:                 $onload .= "toggleRows(document.display,'cancreate_email','selfassign','$customclass','$classprefix','$optionsprefix');";
  192:                 my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
  193:                 my $hascustom;
  194:                 my ($emailrules,$emailruleorder) = &Apache::lonnet::inst_userrules($dom,'email');
  195:                 if (ref($emailrules) eq 'HASH') {
  196:                     if (keys(%{$emailrules}) > 0) {
  197:                         $hascustom = 'cancreate_emailrule';
  198:                     }
  199:                 }
  200:                 my @posstypes;
  201:                 if (ref($types) eq 'ARRAY') {
  202:                     @posstypes = @{$types};
  203:                     push(@posstypes,'default');
  204:                     foreach my $type (@posstypes) {
  205:                         $onload .= "toggleEmailOptions(document.display,'cancreate_emailoptions','$hascustom',".
  206:                                                                "'cancreate_emaildomain','$type');";
  207:                     }
  208:                 } else {
  209:                     $onload .= "toggleEmailOptions(document.display,'cancreate_emailoptions','$hascustom',".
  210:                                                        "'cancreate_emaildomain','default');";
  211:                 }
  212:             } 
  213:             if (grep(/^contacts$/,@actions)) {
  214:                 my $customclass = 'LC_helpdesk_override';
  215:                 my $optionsprefix = 'LC_options_helpdesk_';
  216:                 $onload .= "toggleHelpdeskRow(document.display,'overrides','$customclass','$optionsprefix');";
  217:             }
  218:             if (grep(/^lti$/,@actions)) {
  219:                 $onload .= "toggleLTI(document.display,'user','add');".
  220:                            "toggleLTI(document.display,'crs','add');".
  221:                            "toggleLTI(document.display,'sec','add');".
  222:                            "toggleLTI(document.display,'lcauth','add');".
  223:                            "toggleLTI(document.display,'lcmenu','add');".
  224:                            "toggleLTI(document.display,'passback','add');".
  225:                            "toggleLTI(document.display,'callback','add');";
  226:                 if (ref($values) eq 'HASH') {
  227:                     if (ref($values->{'lti'}) eq 'HASH') {
  228:                         my $numlti = scalar(keys(%{$values->{'lti'}}));
  229:                         for (my $i=0; $i<$numlti; $i++) {
  230:                             $onload .= "toggleLTI(document.display,'user','$i');".
  231:                                        "toggleLTI(document.display,'crs','$i');".
  232:                                        "toggleLTI(document.display,'sec','$i');".
  233:                                        "toggleLTI(document.display,'lcauth','$i');".
  234:                                        "toggleLTI(document.display,'lcmenu','$i');".
  235:                                        "toggleLTI(document.display,'passback','$i');".
  236:                                        "toggleLTI(document.display,'callback','$i');";
  237:                         }
  238:                     }
  239:                 }
  240:             }
  241:             if (grep(/^ltitools$/,@actions)) {
  242:                 $onload .= "toggleLTITools(document.display,'passback','add');".
  243:                            "toggleLTITools(document.display,'roster','add');".
  244:                            "toggleLTITools(document.display,'user','add');";
  245:                 if (ref($values) eq 'HASH') {
  246:                     if (ref($values->{'ltitools'}) eq 'HASH') {
  247:                         my $numltitools = scalar(keys(%{$values->{'ltitools'}}));
  248:                         for (my $i=0; $i<$numltitools; $i++) {
  249:                             $onload .= "toggleLTITools(document.display,'passback','$i');".
  250:                                        "toggleLTITools(document.display,'roster','$i');".
  251:                                        "toggleLTITools(document.display,'user','$i');";
  252:                         }
  253:                     }
  254:                 }
  255:             }
  256:             if (grep(/^scantron$/,@actions)) {
  257:                 $onload .= "toggleScantron('document.display');";
  258:             }
  259:             if ($onload) {
  260:                 my %loaditems = (
  261:                                   'onload' => $onload,
  262:                                 );
  263:                 $additem = {'add_entries' => \%loaditems,};
  264:             }
  265:         } elsif ($context eq 'course') {
  266:             if (grep(/^courseinfo$/,@actions)) {
  267:                 if (@code_order) { 
  268:                     $additem = {
  269:                                    add_entries => {'onload' => "courseSet('','load');toggleCloners(document.display.cloners_instcode);"},
  270:                                };
  271:                 }
  272:             }
  273:         }
  274:     }
  275:     $r->print(&Apache::loncommon::start_page($pagetitle,$js,$additem));
  276:     $r->print(&Apache::lonhtmlcommon::breadcrumbs($brcrumtitle));
  277:     $r->print('
  278: <form name="parmform" action="">
  279: <input type="hidden" name="pres_marker" />
  280: <input type="hidden" name="pres_type" />
  281: <input type="hidden" name="pres_value" />
  282: </form>
  283: ');
  284:     if ($container) {
  285:        &Apache::lonparmset::startSettingsScreen($r,$container,$crstype);
  286:     }
  287:     $r->print('<form method="post" name="'.$phase.'" action="'.$action.'"'.
  288:               ' enctype="multipart/form-data">');
  289:     return;
  290: }
  291: 
  292: sub print_footer {
  293:     my ($r,$phase,$newphase,$button_text,$actions,$container,$parm_permission) = @_;
  294:     $button_text = &mt($button_text);
  295:     $r->print('<input type="hidden" name="phase" value="" />');
  296:     if (defined($env{'form.origin'})) {
  297:         $r->print('<input type="hidden" name="origin" value="'.$env{'form.origin'}.'" />'."\n");
  298:     }
  299:     if (($phase eq 'display') || ($phase eq 'process')) {
  300:         if (ref($actions) eq 'ARRAY') {
  301:             foreach my $item (@{$actions}) {
  302:                 $r->print('<input type="hidden" name="actions" value="'.$item.'" />'."\n");
  303:             }
  304:         }
  305:     }
  306:     my $dest='"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
  307:     if ($phase eq 'process') {
  308:         $r->print(
  309:             &Apache::lonhtmlcommon::actionbox(
  310:                 ['<a href='.$dest.'>'.$button_text.'</a>']));
  311:     } else {
  312:         my $onclick;
  313:         if ($phase eq 'display') {
  314:             $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
  315:         } else {
  316:             $onclick = '"javascript:changePage(document.'.$phase.','."'$newphase'".')"';
  317:         }
  318:         my $showbutton = 1;
  319:         if (ref($parm_permission) eq 'HASH') {
  320:             unless (($parm_permission->{'process'}) || ($newphase eq 'display')) {
  321:                 $showbutton = 0;
  322:             }
  323:         }
  324:         if ($showbutton) {
  325:             $r->print('<p><input type="button" name="store" value="'.
  326:                       $button_text.'" onclick='.$onclick.' /></p>');
  327:         } 
  328:     }
  329:     if ($phase eq 'process') {
  330:         $r->print('</form>');
  331:         if ($container) {
  332:            &Apache::lonparmset::endSettingsScreen($r);
  333:         }
  334:         $r->print(&Apache::loncommon::end_page());
  335:     }
  336:     return;
  337: }
  338: 
  339: sub make_changes {
  340:     my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$roles,
  341:         $allitems,$container,$parm_permission) = @_;
  342:     my %brcrumtext = &get_crumb_text();
  343:     my @actions = &Apache::loncommon::get_env_multiple('form.actions');
  344:     my ($numchanged,%changes,%disallowed);
  345:     &Apache::lonhtmlcommon::add_breadcrumb
  346:       ({href=>"javascript:changePage(document.$phase,'display')",
  347:         text=>$brcrumtext{$context}},
  348:        {href=>"javascript:changePage(document.$phase,'$phase')",
  349:         text=>"Updated"});
  350:     &print_header($r,$phase,$context,undef,$container);
  351:     my ($crstype,%lastact);
  352:     if ($context eq 'course') {
  353:         $crstype = &Apache::loncommon::course_type();
  354:     }
  355:     if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && 
  356:         (ref($prefs) eq 'HASH')) {
  357:         foreach my $item (@{$prefs_order}) {
  358:             if (grep(/^\Q$item\E$/,@actions)) {
  359:                 if ($context eq 'domain') {
  360:                     $r->print('<h3>'.&mt($prefs->{$item}{'text'}).'</h3>'.
  361:                               &Apache::domainprefs::process_changes($r,$dom,
  362:                                           $confname,$item,$roles,$values,\%lastact));
  363:                 } else {
  364:                     $changes{$item} = {};
  365:                     &Apache::courseprefs::process_changes($dom,$item,$values,
  366:                                                           $prefs->{$item},$changes{$item},
  367:                                                           $allitems,\%disallowed,$crstype);
  368:                     if (keys(%{$changes{$item}}) > 0) {
  369:                         $numchanged ++;
  370:                     }
  371:                 }
  372:             }
  373:         }
  374:     }
  375:     if ($context eq 'course') {
  376:         if ($numchanged) {
  377:             my $message = &Apache::courseprefs::store_changes($dom,$confname,$prefs_order,\@actions,
  378:                                                           $prefs,$values,\%changes,$crstype);
  379:             $r->print(&Apache::loncommon::confirmwrapper($message));
  380:         } else {
  381:             if ($crstype eq 'Community') {
  382:                 $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to community configuration.")));
  383:             } else {
  384:                 $r->print(&Apache::loncommon::confirmwrapper(&mt("No changes made to course configuration.")));
  385:             }
  386:         }
  387:         if (keys(%disallowed) > 0) {
  388:             $r->print('<p>');
  389:             foreach my $item ('cloners','rolenames','feedback','discussion','localization') {
  390:                 if (ref($disallowed{$item}) eq 'HASH') {
  391:                     if (keys(%{$disallowed{$item}}) > 0) {
  392:                         $r->print(&Apache::courseprefs::display_disallowed($item,$disallowed{$item},
  393:                                                                            $prefs,$crstype));
  394:                     }
  395:                 }
  396:             }
  397:             $r->print('</p>');
  398:         }
  399:     }
  400:     $r->print('<p>');
  401:     my $footer_text = 'Back to configuration display';
  402:     if ($context eq 'course') {
  403:         $footer_text = 'Back to display/edit settings'; 
  404:     }
  405:     &print_footer($r,$phase,'display',$footer_text,\@actions,$container,$parm_permission);
  406:     $r->print('</p>');
  407:     return \%lastact;
  408: }
  409: 
  410: sub display_settings {
  411:     my ($r,$dom,$phase,$context,$prefs_order,$prefs,$values,$confname,$jscript,
  412:         $allitems,$crstype,$container,$parm_permission) = @_;
  413:     my %brcrumtext = &get_crumb_text();
  414:     my @actions = &Apache::loncommon::get_env_multiple('form.actions');
  415:     &Apache::lonhtmlcommon::add_breadcrumb
  416:         ({href=>"javascript:changePage(document.$phase,'display')",
  417:           text=>"Display/Edit Settings"});
  418:     my $instcode;
  419:     if (ref($values) eq 'HASH') {
  420:         $instcode = $values->{'internal.coursecode'};
  421:     }
  422:     &print_header($r,$phase,$context,$jscript,$container,$instcode,$dom,$values);
  423:     my $divwidth = 900;
  424:     if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH') && (ref($values) eq 'HASH')) { 
  425:         if (@actions > 0) {
  426:             my $rowsum = 0;
  427:             my (%output,%rowtotal,@items,$got_check_uncheck);
  428:             foreach my $item (@{$prefs_order}) {
  429:                 if (grep(/^\Q$item\E$/,@actions)) {
  430:                     push(@items,$item);
  431:                     if ($context eq 'domain') {
  432:                         my $settings;
  433:                         if (ref($values) eq 'HASH') { 
  434:                             $settings = $values->{$item};
  435:                         }
  436:                         if (($item eq 'usersessions') || ($item eq 'ssl')) {
  437:                             unless ($got_check_uncheck) {
  438:                                 $r->print('<script type="text/javascript">'."\n".
  439:                                           '// <![CDATA['."\n".
  440:                                           &Apache::loncommon::check_uncheck_jscript()."\n".
  441:                                           '// ]]>'."\n".
  442:                                           '</script>'."\n");
  443:                                 $got_check_uncheck = 1;
  444:                             }
  445:                         } elsif ($item eq 'selfcreation') {
  446:                             if (ref($values) eq 'HASH') {
  447:                                 $settings = $values->{'usercreation'};
  448:                             }
  449:                         } elsif ($item eq 'defaults') {
  450:                             if (ref($values->{'inststatus'}) eq 'HASH') {
  451:                                 if (ref($values->{'defaults'}) eq 'HASH') {
  452:                                     $settings = {%{$values->{'inststatus'}},%{$values->{'defaults'}}};
  453:                                 } else {
  454:                                     $settings = $values->{'inststatus'};
  455:                                 }
  456:                             } else {
  457:                                 my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
  458:                                 my $inststatus = {
  459:                                                    inststatustypes => $usertypes,
  460:                                                    inststatusorder => $types,
  461:                                                    inststatusguest => [], 
  462:                                                  };
  463:                                 if (ref($values->{defaults}) eq 'HASH') {
  464:                                     $settings = {%{$inststatus},%{$values->{'defaults'}}};
  465:                                 } else {
  466:                                     $settings = $inststatus;
  467:                                 }
  468:                             }
  469:                         }
  470:                         ($output{$item},$rowtotal{$item}) =
  471:                             &Apache::domainprefs::print_config_box($r,$dom,$confname,
  472:                                 $phase,$item,$prefs->{$item},$settings);
  473:                     } else {
  474:                         ($output{$item},$rowtotal{$item}) =
  475:                             &Apache::courseprefs::print_config_box($r,$dom,$phase,
  476:                                 $item,$prefs->{$item},$values,$allitems,$crstype,$parm_permission);
  477:                     }
  478:                     $rowsum += $rowtotal{$item};
  479:                 }
  480:             }
  481:             $r->print('<div id="prefs" style="max-width:'.$divwidth.'px;margin: 10px auto 10px auto;">');
  482:             for (my $i=0; $i<@items; $i++) {
  483:                 $r->print($output{$items[$i]});
  484:             }
  485:             $r->print('</div>');
  486:             $r->print(&print_footer($r,$phase,'process','Save Changes',\@actions,$container,$parm_permission));
  487:         } else {
  488:             $r->print('<input type="hidden" name="phase" value="" />'.
  489:                       '<span class="LC_error">'.&mt('No settings chosen').
  490:                       '</span>');
  491:         }
  492:         $r->print('</form>');
  493:     }
  494:     if ($container) {
  495:         &Apache::lonparmset::endSettingsScreen($r);
  496:     }
  497:     $r->print(&Apache::loncommon::end_page());
  498:     return;
  499: }
  500: 
  501: sub display_choices {
  502:     my ($r,$phase,$context,$prefs_order,$prefs,$container,$parm_permission) = @_;
  503:     if ($phase eq '') {
  504:         $phase = 'pickactions';
  505:     }
  506:     my %helphash;
  507:     &print_header($r,$phase,$context,undef,$container);
  508:     $r->print('<script type="text/javascript">'."\n".
  509:               '// <![CDATA['."\n".
  510:               &Apache::loncommon::check_uncheck_jscript()."\n".
  511:               '// ]]>'."\n".
  512:               '</script>'."\n");
  513:     my $heading = &mt('Settings to display/modify');
  514:     if (ref($parm_permission) eq 'HASH') {
  515:         unless ($parm_permission->{'process'}) {
  516:             $heading = &mt('Settings to display');
  517:         }
  518:     }
  519:     $r->print('<h3>'.$heading.'</h3>'.
  520:               '<div><input type="button" value="'.&mt('check all').'" '.
  521:               'onclick="javascript:checkAll(document.pickactions.actions)"'.
  522:               ' />'.('&nbsp;'x2).
  523:               '<input type="button" value="'.&mt('uncheck all').'" '.
  524:               'onclick="javascript:uncheckAll(document.pickactions.actions)" />'.
  525:               "\n".
  526:               '</div><div class="LC_left_float">');
  527:     my ($numitems,$maxincol,$firstthird,$secondthird,$seconddiv,$thirddiv,$count);
  528:     if (ref($prefs_order) eq 'ARRAY') {
  529:         $numitems = @{$prefs_order};
  530:     }
  531:     my $numcols = 3;
  532:     $maxincol = int($numitems/$numcols);
  533:     if ($numitems%$numcols) {
  534:         $maxincol ++;
  535:     }
  536:     $firstthird = $maxincol;
  537:     $secondthird = $firstthird + $maxincol;
  538:     $count = 0;
  539:     if ((ref($prefs_order) eq 'ARRAY') && (ref($prefs) eq 'HASH')) {
  540:         foreach my $item (@{$prefs_order}) {
  541:             $r->print('<h4>'.
  542:                       &Apache::loncommon::help_open_topic($prefs->{$item}->{'help'}).
  543:                       '<label><input type="checkbox" name="actions" value="'.$item.
  544:                       '" />&nbsp;'.&mt($prefs->{$item}->{'text'}).'</label></h4>');
  545:             $count ++;
  546:             if ((!$seconddiv) && ($count >= $firstthird)) {
  547:                 $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
  548:                 $seconddiv = 1;
  549:             }
  550:             if ((!$thirddiv) && ($count >= $secondthird)) {
  551:                 $r->print('</div>'."\n".'<div class="LC_left_float">'."\n");
  552:                 $thirddiv = 1;
  553:             }
  554:         }
  555:         $r->print('</div><br clear="all" />');
  556:     }
  557:     $r->print(&print_footer($r,$phase,'display','Display',undef,$container,$parm_permission));
  558:     $r->print('</form>');
  559:     if ($container) {
  560:         &Apache::lonparmset::endSettingsScreen($r);
  561:     }
  562:     $r->print(&Apache::loncommon::end_page());
  563:     return;
  564: }
  565: 
  566: sub color_pick_js {
  567:     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
  568:     my $output = <<"ENDCOL";
  569: 
  570:     $pjump_def
  571: 
  572:     function psub() {
  573:         modalWindow.close();
  574:         if (document.parmform.pres_marker.value!='') {
  575:             if (document.parmform.pres_type.value!='') {
  576:                 eval('document.display.'+
  577:                      document.parmform.pres_marker.value+
  578:                      '.value=document.parmform.pres_value.value;');
  579:             }
  580:         } else {
  581:             document.parmform.pres_value.value='';
  582:             document.parmform.pres_marker.value='';
  583:         }
  584:     }
  585: 
  586:     function get_id (span_id) {
  587:         if (document.getElementById) {
  588:             return document.getElementById(span_id);
  589:         }
  590:         if (document.all) {
  591:             return document.all[span_id];
  592:         }
  593:         return false;
  594:     }
  595: 
  596:     function colchg_span (span_id_str,new_color_item) {
  597:         var span_ref = get_id(span_id_str);
  598:         if (span_ref.style) { span_ref = span_ref.style; }
  599:         span_ref.background = new_color_item.value;
  600:         span_ref.backgroundColor = new_color_item.value;
  601:         span_ref.bgColor = new_color_item.value;
  602:     }
  603: 
  604: ENDCOL
  605:     return $output;
  606: }
  607: 
  608: sub get_crumb_text {
  609:     my %brcrumbtext = (
  610:                        domain => 'Domain Settings',
  611:                        course => 'Display/Edit Settings',
  612:                      );
  613:     return %brcrumbtext;
  614: }
  615: 
  616: 1;

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