Annotation of loncom/interface/lonblockingmenu.pm, revision 1.5

1.1       raeburn     1: # The LearningOnline Network with CAPA
1.4       raeburn     2: # Routines for configuring blocking of access to collaborative functions, 
                      3: # and specific resources during an exam
1.1       raeburn     4: #
1.5     ! raeburn     5: # $Id: lonblockingmenu.pm,v 1.4 2012/03/31 14:15:24 raeburn Exp $
1.1       raeburn     6: #
                      7: # Copyright Michigan State University Board of Trustees
                      8: #
                      9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                     10: #
                     11: # LON-CAPA is free software; you can redistribute it and/or modify
                     12: # it under the terms of the GNU General Public License as published by
                     13: # the Free Software Foundation; either version 2 of the License, or
                     14: # (at your option) any later version.
                     15: #
                     16: # LON-CAPA is distributed in the hope that it will be useful,
                     17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     19: # GNU General Public License for more details.
                     20: #
                     21: # You should have received a copy of the GNU General Public License
                     22: # along with LON-CAPA; if not, write to the Free Software
                     23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     24: #
                     25: # /home/httpd/html/adm/gpl.txt
                     26: #
                     27: # http://www.lon-capa.org/
                     28: #
1.4       raeburn    29: ##############################################################
1.1       raeburn    30: ##############################################################
                     31: 
                     32: =pod
                     33: 
                     34: =head1 NAME
                     35: 
                     36: lonblockingmenu - Handler to set/modify exam blocks in a course.
                     37: 
                     38: =head1 SYNOPSIS
                     39: 
                     40: lonblockingmenu provides an interface for setting exam blocks in a course.  
                     41: 
                     42: =head1 DESCRIPTION
                     43: 
                     44: This module is used to configure blocking of access to collaborative tools
                     45: and/or resources during an exam.
                     46: 
1.4       raeburn    47: =head1 OVERVIEW
                     48: 
                     49: To support high-stakes testing, LON-CAPA provides Coordinators with the
                     50: ability to disable communication and collaborative features within the
                     51: system for the duration of an exam.
                     52: 
                     53: Features which can be disabled include:
                     54: (a) those which a student could use to communicate with another student.
                     55: Messaging, discussion, chat, blogs, and some functionality in groups fall 
                     56: into this category.
                     57: (b) those which a student could use to access materials prepared by the
                     58: student in advance of an exam, (e.g., for use during an online exam, to
                     59: gain an unfair advantage). Blogs and portfolio fall into this category.
                     60: 
                     61: For communication blocking to be truly effective in preventing unwanted
                     62: communication, or access to online materials, online testing needs to
                     63: take place in a lab setting where use of tools outside LON-CAPA, and use
                     64: of web sites beyond LON-CAPA are unavailable.
                     65: 
                     66: Access to specified folder(s) and/or resources in the course contents 
                     67: can also be restricted for the duration of an exam.
                     68: 
                     69: Exam blocks are of two types:
                     70: (a) Blocks with a defined start and end date.
                     71: (b) Blocks associated with a timed interval set for a specific folder,
                     72: or resource.
                     73: 
                     74: When a student attempts to use a collaboration or communication feature
                     75: which is currently blocked, information will be available about the
                     76: duration of the block, and the identity of the Course Coordinator who
                     77: set the block.
                     78: 
                     79: Although LON-CAPA communication can be blocked during an exam, course
                     80: personnel with the 'evb' (evade blocking) privilege will continue to
                     81: receive LON-CAPA messages sent from students in a course with an active
                     82: block on messaging. Students will not be able to view messages sent by
                     83: other students in the same course for the duration of the blocking event.
                     84: 
                     85: Because students may be enrolled in more than one LON-CAPA course at a time
                     86: it is important to use reasonable time windows for blocking events, or, in
                     87: the case of blocks triggered by clicking a button to start a timed quiz, 
                     88: quiz durations that are of limited duration. This is especially important
                     89: when blocking prtfolio access, as other courses may require students to use
                     90: the portfolio as a mechanism for submitting assigments.
                     91: 
                     92: Information about blocks in a course will be cached for 10 minutes, so,
                     93: as with parameters set for resources, it can take up to 10 minutes for
                     94: new blocks, or changes to existing blocks, to propagate to other servers.
                     95: 
                     96: Changes to existing blocks on the server hosting your current session
                     97: are available immediately, as cached data on blocks is devalidated
                     98: automatically on the current server whenever a change is made to a 
                     99: block (including deletion), or when a new block is added. 
                    100: 
1.1       raeburn   101: =head1 INTERNAL SUBROUTINES
                    102: 
                    103: =over
                    104: 
1.4       raeburn   105: =item &get_timed_items()
                    106: 
                    107: Provides perl data structure with information about timed interval
                    108: parameters set in a course.
                    109: 
                    110: Inputs: 2 (optional)
                    111:        $cdom - course's domain
                    112: 
                    113:        $cnum - course's ID
                    114: 
                    115: Output: 1 Hash 
                    116:        nested hashes containing information about timed interval
                    117:        parameters in course). Top level keys are type: course,
                    118:        map, resource. Next inner keys are map or symb. Next
                    119:        inner keys are scope (all, section, group, users).
                    120:        Values are interval (in seconds).
                    121: 
1.1       raeburn   122: =item &blockstore()
                    123: 
1.4       raeburn   124: Stores changes to exam blocks in comm_block.db file for course.
                    125: Processes deletions, modifications and additions.
                    126: 
                    127: Inputs: 2
                    128:       $crstype - Container type: Course or Community.
                    129: 
                    130:       $blockcount - Total number of blocking events in course.
                    131: 
                    132: Outputs: 2
                    133:       $changestotal - Total number of changes made.
                    134: 
                    135:       $output - Information about changes made.
                    136: 
                    137: 
                    138: =item &enumerate_course_contents()
                    139: 
                    140: Create hashes of maps (for folders/pages) and symbs (for resources) in
                    141: a course, where keys are numbers (starting with 1) and values are
                    142: map url, or symb, for an iteration through the course, as seen by
                    143: a Course Coordinator. Used to generate numerical IDs to facilitate
                    144: storage of lists of maps or resources to be blocked during an exam.   
                    145: 
                    146: Inputs: 3
                    147:       $navmap - navmaps object
                    148: 
                    149:       $map_url - reference to hash to contain URLs of maps in course
                    150: 
                    151:       $resource_symb - reference to hash to contain symbs for
                    152:                        resources in course
                    153: 
                    154: Outputs: None
                    155: 
                    156: Side Effects: $map_url and $resource_symb hashrefs are populated.
                    157: 
                    158: 
1.1       raeburn   159: =item &get_dates_from_form()
                    160: 
1.4       raeburn   161: Extract start and end dates from web form input for blocks with
                    162: defined start/end time.
                    163: 
                    164: Inputs: 1 - $item - numeric ID of current block.
                    165: 
                    166: Outputs: 2 - $startdate, $enddate (UNIX times for start and end times
                    167:              for blocks with defined start/end   
                    168: 
                    169: 
1.1       raeburn   170: =item &get_blockdates()
                    171: 
1.4       raeburn   172: Retrieves contents of comm_block.db file for a course.
                    173: 
                    174: Inputs: 1 - $records - reference to hash to contain blocks 
                    175: 
                    176: Outputs: 1 - $blockcount - number of blocks
                    177: 
                    178: Side Effects: populates records hashref.
                    179: 
                    180: 
1.1       raeburn   181: =item &get_block_choices()
                    182: 
1.4       raeburn   183: Extract information from web form about which communication/
                    184: collaboration features are to be blocked, for a partilcuar event,
                    185: and also which content areas will have access blocked for the
                    186: duration of the block.
                    187: 
                    188: Inputs: 3 
                    189:     - $item - numeric ID of current block 
                    190: 
                    191:     - $map_ref - reference to hash mapping numeric IDs to map urls 
                    192: 
                    193:     - $symb_ref - reference to hash mapping numeric IDs to symbs
                    194: 
                    195: Outputs: 2
                    196:     - $blocktypes - reference to hash of features to be blocked
                    197: 
                    198:     - $blockdocs - boolean - 0 if no blocking of content, 1 if blocking 
                    199:                              of content access 
                    200: 
                    201: 
                    202: =item &check_release_required()
                    203: 
                    204: Update LON-CAPA version requirements for course if blocked items
                    205: (content) or blocking type (triggered by student starting timer)
                    206: require specific LON-CAPA version (i.e., 2.11).
                    207: 
                    208: Inputs: 1 - type of constraint (currently: 'docs' or 'timer'). 
                    209: 
                    210: Outputs: None
                    211: 
                    212: Side Effects: &update_released_required() called in lonnet, if
                    213:               needed to update version requirements for course.   
                    214: 
                    215: 
1.1       raeburn   216: =item &display_blocker_status()
                    217: 
1.4       raeburn   218: Generates web form elements used to display, cancel, or modify 
                    219: existing blocking events. 
                    220: 
                    221: Inputs: 7 
                    222:       - $r - Apache request object
                    223: 
                    224:       - $records - Reference to hash of current blocks
                    225: 
                    226:       - $ltext - Reference to hash of phrases (localized)
                    227: 
                    228:       - $intervals - Reference to hash of parameters for timed intervals
                    229: 
                    230:       - $navmap - navmaps object.
                    231: 
                    232:       - $errormsg - error message for display, if navmaps object
                    233:                     could not be instantiated
                    234: 
                    235:       - $blockcount - number of existing blocking events in course
                    236: 
                    237: Output: None
                    238: 
                    239: Side Effects: prints web form elements (in a table) for current blocks. 
                    240: 
                    241: =item &path_to_trigger()
                    242: 
                    243: Provides hierarchy of names of folders/sub-folders containing the current
                    244: item identified as an item with an interval timer set, to be used as a 
                    245: trigger. 
                    246: 
                    247: Inputs: 3 
                    248:      - $navmap - navmaps object
                    249: 
                    250:      - $map - url for map (either the trigger itself, or map containing
                    251:                            the resource, which is the trigger). 
                    252: 
                    253:      - $type - type of trigger: map or resource.
                    254: 
                    255: Outputs: 1 @pathitems - array of folder/subfolder names.  
                    256: 
                    257: 
                    258: =item &convlim()
                    259: 
                    260: Convert a time interval used for a timed quiz (in seconds) to
                    261: days, hours. minutes and seconds.
                    262: 
                    263: Inputs: 1 - $timelimit  - time interval in seconds
                    264: 
                    265: Outputs: 1 - $output - time in format: DD days, HH hours, MM minutes, SS seconds  
                    266: 
                    267: 
1.1       raeburn   268: =item &display_addblocker_table()
                    269: 
1.4       raeburn   270: Generate web form elements used to define a new blocking event. 
                    271: 
                    272: Inputs: 6
                    273:     - $r - Apache resource object
                    274: 
                    275:     - $parmcount - current ID for block (same as number of current blocks,
                    276:                    block IDs in web form have zero-based index)
                    277: 
                    278:     - $ltext - reference to hash of phrases (localized)
                    279: 
                    280:     - $intervals - Reference to hash of parameters for timed intervals
                    281: 
                    282:     - $navmap - navmaps object
                    283: 
                    284:     - $errormsg - error message for display, if navmaps object
                    285:                   could not be instantiated
                    286: 
                    287: Outputs: None
                    288:  
                    289: Side Effects: prints web form elements (in a table) for adding a new block.
                    290: 
                    291: 
                    292: =item &blocker_checkboxes()
                    293: 
                    294: Generates web form elements in a table for checkboxes used to indicate
                    295: which types of communication/collaboration and/or content should be blocked.
                    296: 
                    297: Inputs: 4 
                    298:     - $parmcount - numeric ID of current block
                    299: 
                    300:     - $blocks - reference to hash of functionalities to block 
                    301: 
                    302:     - $jschg - text of javascript call to execute when checkbox clicked  
                    303:                use within a box via 'onclick="$jchg"'
                    304:  
                    305:     - $lookups - reference to hash to map urls or symbs to numeric IDs
                    306:                  used to populate hodden form elements containing list
                    307:                  of resources and folders with access blocking currently set.
                    308: 
                    309: Output: 1 - HTML for table of checkboxes for current block  
                    310: 
                    311: 
                    312: =item &create_interval_form()
                    313: 
                    314: Creates web form elements used to select one of the defined timed interval 
                    315: items in the course for use in an exam block of type: "Triggered by 
                    316: Activating Timer".
                    317: 
                    318: Inputs: 7 (three required, last four optional)
                    319:    - $intervals - Reference to hash of parameters for timed intervals
                    320: 
                    321:    - $parmcount - numeric ID of current block
                    322: 
                    323:    - $navmap - navmaps object
                    324: 
                    325:    - $currkey - current interval (where this is a block already using
                    326:                 an interval-based trigger).  
                    327: 
                    328:    - $jschg - text of javascript call to execute when radiobutton clicked
                    329:               use within a box via 'onclick="$jchg"'
                    330: 
                    331:    - $itemname - name/scope of current interval used for this block 
                    332: 
                    333:    - $iteminfo - Expandable/collapsible block showing which users are
                    334:                  able to activate the timer using the current trigger item.
                    335: 
                    336: Outputs: 1 - $intervalform - web form elements used to select a time interval
                    337: 
                    338: 
                    339: =item &trigger_details_toggle()
                    340:  
                    341: Creates link used to expand item showing information about timer for current
                    342: trigger for exam block. 
                    343: 
                    344: Inputs: 1 - $parmcount - numericID of exam block in web form. 
                    345: 
                    346: Outputs: 1 - returns HTML for link to display contents of information item 
                    347: 
                    348: =item &show_timer_path()
                    349: 
                    350: Display hierarchy of names of folders/sub-folders containing the current
                    351: item identified as an item with an interval timer set.
                    352: 
                    353: Inputs: 3
                    354:     - $type - map or resource
                    355: 
                    356:     - $item - map URL or resource symb
                    357: 
                    358:     - $navmap - navmaps object
                    359: 
                    360: Outputs: 1 - HTML containing hierarchy of folders/subfolders (raquo entity separated).  
                    361: 
                    362: 
1.1       raeburn   363: =item &blocktype_text()
                    364: 
1.4       raeburn   365: Inputs: None
                    366: 
                    367: Output: 2 
                    368:      - $typeorder - reference to array of blockable communication/collaboration/content
                    369: 
                    370:      - $types -reference to hash of descriptions (localized) of blockable types.
                    371:  
                    372: 
                    373: =item &blockingmenu_javascript()
                    374: 
                    375: Create Javascript used to launch pop-up used for content selection, and to
                    376: toggle visibility of a number of expandable/collapsible divs.
                    377: 
                    378: Inputs: 1 - $blockcount - 
                    379: 
                    380: Output: 1 - Javascript (with <script></script> tags) for functions used to:
                    381:             (a) launch pop-up window for selection of course content to which
                    382:             access could be blocked. 
                    383:             (b) toggle visibility of a number of divs:
                    384: 
                    385: =over 
                    386: 
                    387: =item *  for block type - defined dates or timer activated
                    388: 
                    389: =item *  for action to take -- add or modify block
                    390: 
                    391: =item *  for display of detailed information about intervals 
                    392: 
                    393: =back
                    394: 
                    395: 
1.1       raeburn   396: =back  
                    397: 
1.2       raeburn   398: =cut
1.1       raeburn   399: 
                    400: package Apache::lonblockingmenu;
                    401: 
                    402: use strict;
                    403: use Apache::lonnet;
                    404: use Apache::Constants qw(:common :http);
                    405: use Apache::loncommon();
                    406: use Apache::lonhtmlcommon();
1.4       raeburn   407: use Apache::lonparmset();
1.1       raeburn   408: use HTML::Entities();
                    409: use Apache::lonlocal;
                    410: use lib '/home/httpd/lib/perl/';
                    411: use LONCAPA qw(:DEFAULT :match);
                    412: 
                    413: sub handler {
                    414:     my $r=shift;
                    415: 
                    416: # ----------------------------------------------------------- Set document type
                    417: 
                    418:     &Apache::loncommon::content_type($r,'text/html');
                    419:     $r->send_http_header;
                    420: 
                    421:     return OK if $r->header_only;
                    422: 
                    423:     #  Needs to be in a course
                    424:     if (! ($env{'request.course.fn'})) {
                    425:         # Not in a course
                    426:         $env{'user.error.msg'}=
                    427:      "/adm/setblock:dcm:0:0:Cannot set blocking of communications in a course";
                    428:         return HTTP_NOT_ACCEPTABLE;
                    429:     }
                    430: 
                    431: # ----------------------------------------------------------- Permissions check
                    432: 
1.3       raeburn   433:     unless ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
                    434:             (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
1.1       raeburn   435:                                       '/'.$env{'request.course.sec'}))) {
1.3       raeburn   436:         $env{'user.error.msg'}=
                    437:      "/adm/setblock:dcm:0:0:Cannot set blocking of communications in a course";
1.1       raeburn   438:         return HTTP_NOT_ACCEPTABLE;
                    439:     }
                    440: 
                    441: # -----------------------------Get action and calling context from query string
                    442: 
1.4       raeburn   443:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    444:                                             ['action','caller','block']);
1.1       raeburn   445: 
1.4       raeburn   446:     my $crstype = &Apache::loncommon::course_type();
                    447:     my $action = $env{'form.action'};
                    448:     my %records = ();
                    449:     my $blockcount = 0;
                    450: 
                    451: # ------------------------------------------------------ Retrieve current blocks
                    452:     $blockcount = &get_blockdates(\%records);
                    453: 
                    454: # -------------------- Generate display for pop-up of Maps and Resources blocked   
                    455:     if ($action eq 'showdocs') {
                    456:         my ($navmap,$errormsg) = 
                    457:             &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
                    458:         if (ref($navmap)) {
                    459:             my (%blockedmaps,%blockedresources);
                    460:             if ($env{'form.block'} =~ /^\d+$/) {
                    461:                 my @currblocks = sort(keys(%records));
                    462:                 my $block = $currblocks[$env{'form.block'}];
                    463:                 if (($block ne '') && (ref($records{$block}) eq 'HASH')) {
                    464:                     if (ref($records{$block}{'blocks'}) eq 'HASH') {
                    465:                         if (ref($records{$block}{'blocks'}{'docs'}) eq 'HASH') {
                    466:                             if (ref($records{$block}{'blocks'}{'docs'}{'maps'}) eq 'HASH') {
                    467:                                 %blockedmaps = %{$records{$block}{'blocks'}{'docs'}{'maps'}};
                    468:                             }
                    469:                             if (ref($records{$block}{'blocks'}{'docs'}{'resources'}) eq 'HASH') {
                    470:                                 %blockedresources = %{$records{$block}{'blocks'}{'docs'}{'resources'}};
                    471:                             }
                    472:                         }
                    473:                     }
                    474:                 }
                    475:             }
                    476:             $r->print(&Apache::loncourserespicker::create_picker($navmap,
                    477:                                      'examblock','resourceblocks',$crstype,
                    478:                                      \%blockedmaps,\%blockedresources,
                    479:                                      $env{'form.block'}));
                    480:         } else {
                    481:             $r->print($errormsg);
                    482:         }
                    483:         return OK;
                    484:     }
1.1       raeburn   485: 
1.4       raeburn   486: # -------------------------- Store changes and retrieve latest block information
                    487:     my $storeresult;
                    488:     if ($env{'form.action'} eq 'store') {
                    489:         (my $numchanges,$storeresult) = &blockstore($crstype,$blockcount);
                    490:         if ($numchanges > 0) {
                    491:             $blockcount = &get_blockdates(\%records);
                    492:         }
                    493:     }
                    494: 
                    495: # ------------------------------------------------------------------ Breadcrumbs
1.1       raeburn   496:     &Apache::lonhtmlcommon::clear_breadcrumbs();
                    497:     if ($env{'form.caller'} eq 'email') {  
                    498:         &Apache::lonhtmlcommon::add_breadcrumb
                    499:             ({href=>'/adm/communicate',
                    500:               text=>'Communication/Messages',
                    501:               faq=>12,bug=>'Communication Tools',});
                    502:     } else {
                    503:         &Apache::lonhtmlcommon::add_breadcrumb
                    504:             ({href=>'/adm/parmset',
                    505:               text=>'Content and Problem Settings'});
                    506:     }
                    507:     &Apache::lonhtmlcommon::add_breadcrumb
                    508:         ({href=>'/adm/setblock',
                    509:           text=>'Blocking communication/resource access'});
                    510: 
1.4       raeburn   511:     my $js = &blockingmenu_javascript($blockcount);
1.1       raeburn   512: 
1.4       raeburn   513:     $r->print(
                    514:         &Apache::loncommon::start_page('Blocking communication/content access',$js).
                    515:         &Apache::lonhtmlcommon::breadcrumbs('Blocking communication/content access'));
1.1       raeburn   516: 
                    517:     my $usertype;
                    518:     my $crstype = &Apache::loncommon::course_type();
                    519:     if ($crstype eq 'Community') {
                    520:         $usertype = 'members';
                    521:     } else {
                    522:         $usertype = 'students';
                    523:     }
                    524:     my $lctype = lc($crstype);
1.4       raeburn   525:     my %lt=&Apache::lonlocal::texthash (
                    526:             'cbds' => 'Blocking communication and/or content access during exams',
                    527:             'prev' => "For the duration of an exam, or a timed quiz, students in this course can be prevented from:",
                    528:             'blca' => "Blocks can potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA $lctype.",
                    529:             'pobl' => "Portfolio blocking can impact a student's ability to complete assigments in courses besides your own. Please use this feature wisely.",
                    530:             'actt' => "Action to take:",
                    531:             'addn' => 'Add new blocking event',
                    532:             'mexb' => 'Modify existing blocking event(s)', 
                    533:             'ncbc' => 'There are no blocking events currently saved.',
                    534:             'stor' => 'Save',
1.1       raeburn   535:     );
                    536: 
                    537:     my %ltext = &Apache::lonlocal::texthash(
1.4       raeburn   538:             'type' => 'Type',
                    539:             'defs' => 'Defined Start/End',
                    540:             'trig' => 'Triggered by Activating Timer', 
1.1       raeburn   541:             'setb' => 'Set by',
                    542:             'even' => 'Event',
                    543:             'blck' => 'Blocked?',
                    544:             'star' => 'Start',
1.4       raeburn   545:             'endd' => 'End',
                    546:             'chda' => 'Choose dates',
                    547:             'chtr' => 'Choose trigger',
                    548:             'when' => 'When using defined start/end times for an event, please set dates carefully.',
                    549:             'yes'  => 'Yes',
                    550:             'no'   => 'No',
1.1       raeburn   551:     );
                    552: 
                    553:     $r->print('<h3>'.$lt{'cbds'}.'</h3>');
                    554: 
1.4       raeburn   555: # ---------------------------------------------------- Get Time Limit parameters
                    556:     my %intervals = &get_timed_items();
                    557: 
                    558: # -------------------------------------------- Display information about changes 
1.1       raeburn   559:     if ($env{'form.action'} eq 'store') {
1.4       raeburn   560:         $r->print($storeresult);
                    561:     } else {
                    562:         $r->print(
                    563:             $lt{'prev'}.
                    564:             '<ul>'."\n".
                    565:             '<li>'.&mt("displaying LON-CAPA messages sent by other $usertype in the $lctype").'</li>'."\n".
                    566:             '<li>'.&mt("displaying or posting to LON-CAPA discussion boards or live chat in the $lctype").'</li>'."\n".
                    567:             '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".
                    568:             '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.
                    569:             '</ul>'.
                    570:             '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
                    571:         );
1.1       raeburn   572:     }
                    573: 
1.4       raeburn   574: # ------------------------ Choose between modifying existing block or adding new
                    575:     $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');
                    576:     if ($blockcount > 0) {
                    577:          $r->print(<<"END");
                    578: <div class="LC_left_float">
                    579: <fieldset><legend>$lt{'actt'}</legend>
                    580: <span class="LC_nobreak">
                    581: <label><input type="radio" name="blockaction" value="modify" id="modifyaction" 
                    582: onclick="toggleAddModify();" checked="checked" />$lt{'mexb'}</label>
                    583: </span>
                    584: <br />
                    585: <span class="LC_nobreak">
                    586: <label><input type="radio" name="blockaction" value="add" id="addaction" 
                    587: onclick="toggleAddModify();" />$lt{'addn'}</label>
                    588: </span>
                    589: </fieldset>
                    590: </div>
                    591: <br clear="all" />
                    592: <div id="showadd" style="display:none">
                    593: END
                    594:     } else {
                    595:         $r->print($lt{'ncbc'}.'<br /><br />'.
                    596:                   '<h4>'.$lt{'addn'}.'</h4>'.
                    597:                   '<input type="hidden" name="blockaction" value="add" />');
                    598:     }
                    599:     my ($navmap,$errormsg) =
                    600:         &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
1.1       raeburn   601: 
1.4       raeburn   602: # --------------------------------------------- Interface for adding a new block
                    603:     &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,
                    604:                               $navmap,$errormsg);
                    605: 
                    606: # ------------------------------------------------- Interface for existig blocks
1.1       raeburn   607:     if ($blockcount > 0) {
1.4       raeburn   608:         $r->print('</div>');
                    609:         &display_blocker_status($r,\%records,\%ltext,\%intervals,
                    610:                                 $navmap,$errormsg,$blockcount);
1.1       raeburn   611:     }
                    612:     $r->print(<<"END");
                    613: <br />
                    614: <input type ="submit" value="$lt{'stor'}" />
                    615: </form>
                    616: END
                    617:     $r->print(&Apache::loncommon::end_page());
                    618:     return OK;
                    619: }
                    620: 
1.4       raeburn   621: sub get_timed_items {
                    622:     my ($cdom,$cnum) = @_;
                    623:     my ($cid,%intervals);
                    624:     if ($cdom eq '' || $cnum eq '') {
                    625:         $cid = $env{'request.course.id'};
                    626:         $cdom = $env{'course.'.$cid.'.domain'};
                    627:         $cnum = $env{'course.'.$cid.'.num'};
                    628:     } else {
                    629:         $cid = $cdom.'_'.$cnum;
                    630:     }
                    631:     if ($cid eq '') {
                    632:         return %intervals;
                    633:     }
                    634:     my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);
                    635:     if (ref($resourcedata) eq 'HASH') {
                    636:         foreach my $key (keys(%{$resourcedata})) {
                    637:             if ($key =~ /^\Q$cid\E(.+)\.0\.interval$/) {
                    638:                 my $middle = $1;
                    639:                 if ($middle eq '') {
                    640:                     $intervals{'course'}{'all'} = $resourcedata->{$key};
                    641:                 } elsif ($middle =~ /^\.\[(\w+)\]$/) {
                    642:                     $intervals{'course'}{'secgrp'}{$1} = $resourcedata->{$key};
                    643:                 } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]$/) {
                    644:                     $intervals{'course'}{'users'}{$1} = $resourcedata->{$key};
                    645:                 } elsif ($middle =~ /^\.(.+)\Q___(all)\E$/) {
                    646:                     my $inner = $1;
                    647:                     if ($inner =~ /^\[(\w+)\]\.([^\]]+)$/) {
                    648:                         $intervals{'map'}{$2}{'secgrp'}{$1} = $resourcedata->{$key};
                    649:                     } elsif ($inner =~ /^\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
                    650:                         $intervals{'map'}{$2}{'users'}{$1} = $resourcedata->{$key};
                    651:                     } else {
                    652:                         $intervals{'map'}{$inner}{'all'} = $resourcedata->{$key};
                    653:                     }
                    654:                 } elsif ($middle =~ /^\.\[(\w+)\]\.([^\]]+)$/) {
                    655:                     $intervals{'resource'}{$2}{'secgrp'}{$1} = $resourcedata->{$key}; 
                    656:                 } elsif ($middle =~ /^\.\[useropt\:($match_username\:$match_domain)\]\.([^\]]+)$/) {
                    657:                     $intervals{'resource'}{$2}{'users'}{$1} = $resourcedata->{$key};
                    658:                 } else {
                    659:                     my ($symb) = ($middle =~ /^\.(.+)$/);
                    660:                     $intervals{'resource'}{$symb}{'all'} = $resourcedata->{$key};
                    661:                 }
                    662:             }
                    663:         }
                    664:     }
                    665:     return %intervals;
                    666: }
                    667: 
1.1       raeburn   668: sub blockstore {
1.4       raeburn   669:     my ($crstype,$blockcount) = @_;
1.1       raeburn   670:     my %lt=&Apache::lonlocal::texthash(
                    671:             'tfcm' => 'The following changes were made',
1.4       raeburn   672:             'ncwm' => 'No changes were made.',
                    673:             'unna' => 'Unable to retrieve contents of course.', 
1.1       raeburn   674:     );
                    675:     my %adds = ();
                    676:     my %removals = ();
                    677:     my %cancels = ();
                    678:     my $modtotal = 0;
                    679:     my $canceltotal = 0;
                    680:     my $addtotal = 0;
1.4       raeburn   681:     my $changestotal = 0;
                    682:     my $addtimer = 0;
1.1       raeburn   683:     my %blocking = ();
1.4       raeburn   684:     my (%map_url,%resource_symb,$output);
                    685:     $output = '<h3>'.$lt{'head'}.'</h3>';
                    686:     if ($env{'form.blockaction'} eq 'modify') {
                    687:         foreach my $envkey (keys(%env)) {
                    688:             if ($envkey =~ m/^form\.action_(\d+)$/) {
                    689:                 if ($env{$envkey} eq 'modify') {
                    690:                     $adds{$1} = 1;
                    691:                     $removals{$1} = 1;
                    692:                 } elsif ($env{$envkey} eq 'cancel') {
                    693:                     $cancels{$1} = $1;
                    694:                     unless ( defined($removals{$1}) ) {
                    695:                         $removals{$1} = 1;
                    696:                         $canceltotal ++;
                    697:                     }
                    698:                 }
                    699:             }
1.1       raeburn   700:         }
1.4       raeburn   701:     } elsif ($env{'form.blockaction'} eq 'add') {
                    702:         $adds{$blockcount} = 1;
1.1       raeburn   703:     }
1.4       raeburn   704:     my ($navmap,$errormsg) =
                    705:         &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
                    706:     unless (ref($navmap)) {
                    707:         $output = $lt{'unna'}.' '.$lt{'ncwm'}.'</br>';
                    708:         return ($changestotal,$output);
                    709:     }
                    710:     &enumerate_course_contents($navmap,\%map_url,\%resource_symb);
1.1       raeburn   711:     foreach my $key (keys(%removals)) {
                    712:         my $hashkey = $env{'form.key_'.$key};
                    713:         &Apache::lonnet::del('comm_block',["$hashkey"],
                    714:                          $env{'course.'.$env{'request.course.id'}.'.domain'},
                    715:                          $env{'course.'.$env{'request.course.id'}.'.num'}
                    716:                          );
                    717:     }
                    718:     foreach my $key (keys(%adds)) {
                    719:         unless ( defined($cancels{$key}) ) {
1.4       raeburn   720:             my $newkey;
                    721:             if ($env{'form.firstaccess_'.$key}) {
                    722:                 my $interval = 
                    723:                     &HTML::Entities::decode($env{'form.firstaccess_'.$key});
                    724:                 if ($interval ne '') {
                    725:                     if ($interval eq 'course') {
                    726:                         $newkey = 'firstaccess____'.$interval;
                    727:                     } elsif ($interval =~ /___\d+___/) {
                    728:                         my ($map,$resid,$url) = 
                    729:                             &Apache::lonnet::decode_symb($interval);
                    730:                         if (&Apache::lonnet::is_on_map($url)) {
                    731:                             $newkey = 'firstaccess____'.$interval;
                    732:                         }
                    733:                     } elsif (&Apache::lonnet::is_on_map($interval)) {
                    734:                         $newkey = 'firstaccess____'.$interval;
                    735:                     }
                    736:                     if ($newkey ne '') {
                    737:                         unless (defined($removals{$key})) {
                    738:                             $addtimer ++;
                    739:                         }
                    740:                     }
                    741:                 }
                    742:             } else {
                    743:                 my ($newstart,$newend) = &get_dates_from_form($key);
                    744:                 $newkey = $newstart.'____'.$newend;
                    745:             }
                    746:             if ($newkey ne '') {
                    747:                 my ($blocktypes,$blockdocs) = 
                    748:                     &get_block_choices($key,\%map_url,\%resource_symb);
                    749:                 $blocking{$newkey} = {
1.1       raeburn   750:                           setter => $env{'user.name'}.':'.$env{'user.domain'},
                    751:                           event  => &escape($env{'form.title_'.$key}),
                    752:                           blocks => $blocktypes,
                    753:                         };
1.4       raeburn   754:                 if ($blockdocs) {
                    755:                     &check_release_required('docs');
                    756:                 }
1.5     ! raeburn   757:                 if (ref($blocktypes) eq 'HASH') {
        !           758:                     if ($blocktypes->{'printout'} eq 'on') {
        !           759:                         &check_release_required('printout');
        !           760:                     }
        !           761:                 }
1.4       raeburn   762:                 if (exists($removals{$key})) {
                    763:                     $modtotal ++;
                    764:                 } else {
                    765:                     $addtotal ++;
                    766:                 }
                    767:             } else {
                    768:                 if ($env{'form.toggle_'.$key} eq 'timer') {
                    769:                     $output .= '<p class="LC_warning">'.
                    770:                                &mt('Invalid trigger for new blocking event').
                    771:                                '</p>';
                    772:                 } else {
                    773:                     $output .= '<p class="LC_warning">'.
                    774:                                &mt('No date range found for new blocking event').
                    775:                                '</p>';
                    776:                 }
                    777:             }
1.1       raeburn   778:         }
                    779:     }
                    780:     if ($addtotal + $modtotal > 0) {
                    781:         &Apache::lonnet::put('comm_block',\%blocking,
                    782:                      $env{'course.'.$env{'request.course.id'}.'.domain'},
                    783:                      $env{'course.'.$env{'request.course.id'}.'.num'}
                    784:                      );
1.4       raeburn   785:         if ($addtimer) {
                    786:             &check_release_required('timer');
                    787:         }
1.1       raeburn   788:     }
1.4       raeburn   789:     $changestotal = $canceltotal + $modtotal + $addtotal;
                    790:     if ($changestotal > 0) {
                    791:         &Apache::lonnet::devalidate_cache_new('comm_block',
                    792:                                               $env{'request.course.id'});
                    793:         $output .= $lt{'tfcm'}.'<ul>';
1.1       raeburn   794:         if ($canceltotal > 0) {
1.4       raeburn   795:             $output .= '<li>'.
                    796:                        &mt('[quant,_1,blocking event was,blocking events were] removed.',
                    797:                            $canceltotal).
                    798:                        '</li>';
1.1       raeburn   799:         }
                    800:         if ($modtotal > 0) {
1.4       raeburn   801:             $output .= '<li>'.
                    802:                        &mt('[quant,_1,blocking event was,blocking events were] modified.',
                    803:                            $modtotal).
                    804:                        '</li>';
1.1       raeburn   805:         }
                    806:         if ($addtotal > 0) {
1.4       raeburn   807:             $output .= '<li>'.
                    808:                        &mt('[quant,_1,blocking event was,blocking events were] added.',
                    809:                            $addtotal).
                    810:                        '</li>';
1.1       raeburn   811:         }
1.4       raeburn   812:         $output .= '</ul>';
1.1       raeburn   813:     } else {
1.4       raeburn   814:         $output .= $lt{'ncwm'};
                    815:     }
                    816:     $output .= '<br />';
                    817:     return ($changestotal,$output);
                    818: }
                    819: 
                    820: sub enumerate_course_contents {
                    821:     my ($navmap,$map_url,$resource_symb) = @_;
                    822:     if ((ref($navmap)) && (ref($map_url) eq 'HASH') && 
                    823:         (ref($resource_symb) eq 'HASH')) {
                    824:         my $it = $navmap->getIterator(undef,undef,undef,1,undef,undef);
                    825:         my $count = 0;
                    826:         while (my $curRes = $it->next()) {
                    827:             if (ref($curRes)) {
                    828:                 $count ++;
                    829:                 my $symb = $curRes->symb();
                    830:                 my $ressymb = $symb;
                    831:                 if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
                    832:                     unless ($ressymb =~ m|adm/wrapper/adm|) {
                    833:                         $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.
                    834:                                    '/bulletinboard';
                    835:                     }
                    836:                 }
                    837:                 if (($curRes->is_sequence()) || ($curRes->is_page())) {
                    838:                     $map_url->{$count} = (&Apache::lonnet::decode_symb($symb))[2];
                    839:                 } else {
                    840:                     $resource_symb->{$count} = $ressymb;
                    841:                 }
                    842:             }
                    843:         }
1.1       raeburn   844:     }
                    845:     return;
                    846: }
                    847: 
                    848: sub get_dates_from_form {
                    849:     my $item = shift;
                    850:     my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
                    851:     my $enddate   = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
                    852:     return ($startdate,$enddate);
                    853: }
                    854: 
                    855: sub get_blockdates {
1.4       raeburn   856:     my ($records) = @_;
                    857:     my $blockcount = 0;
1.1       raeburn   858:     %{$records} = &Apache::lonnet::dump('comm_block',
                    859:                          $env{'course.'.$env{'request.course.id'}.'.domain'},
                    860:                          $env{'course.'.$env{'request.course.id'}.'.num'}
                    861:                          );
1.4       raeburn   862:     $blockcount = keys(%{$records});
1.1       raeburn   863: 
                    864:     if ((keys(%{$records}))[0] =~ /^error: 2 /) {
1.4       raeburn   865:         $blockcount = 0;
1.1       raeburn   866:     }
1.4       raeburn   867:     return $blockcount;
1.1       raeburn   868: }
                    869: 
                    870: sub get_block_choices {
1.4       raeburn   871:     my ($item,$map_ref,$symb_ref) = @_;
1.1       raeburn   872:     my $blocklist;
1.4       raeburn   873:     my $blockdocs;
1.1       raeburn   874:     my ($typeorder,$types) = &blocktype_text();
                    875:     foreach my $type (@{$typeorder}) {
1.4       raeburn   876:         if ($type eq 'docs') {
                    877:             if ($env{'form.'.$type.'_'.$item}) {
                    878:                 $blocklist->{$type} = {};
                    879:                 if ($env{'form.docs_resources_'.$item}) {
                    880:                     $env{'form.docs_resources_'.$item} =~ s/,$//;
                    881:                     if (ref($symb_ref) eq 'HASH') {
                    882:                         my %resources = map { $symb_ref->{$_} => 1; } 
                    883:                                             (split(/,/,$env{'form.docs_resources_'.$item}));
                    884:                         $blocklist->{$type}->{resources} = \%resources;
                    885:                         if (keys(%resources) > 0) {
                    886:                             $blockdocs = 1;
                    887:                         }
                    888:                     }
                    889:                 }
                    890:                 if ($env{'form.docs_maps_'.$item}) {
                    891:                     $env{'form.docs_maps_'.$item} =~ s/,$//;
                    892:                     if (ref($map_ref) eq 'HASH') {
                    893:                         my %maps = map { $map_ref->{$_} => 1; }                             
                    894:                                        (split(/,/,$env{'form.docs_maps_'.$item}));
                    895:                         $blocklist->{$type}->{maps} = \%maps;
                    896:                         if (keys(%maps) > 0) {
                    897:                             $blockdocs = 1;
                    898:                         }
                    899:                     }
                    900:                 }
                    901:             }
                    902:         } else {
                    903:             if ($env{'form.'.$type.'_'.$item}) {
                    904:                 $blocklist->{$type} = 'on';
                    905:             } else {
                    906:                 $blocklist->{$type} = 'off';
                    907:             }
                    908:         }
                    909:     }
                    910:     return ($blocklist,$blockdocs);
                    911: }
                    912: 
                    913: sub check_release_required {
                    914:     my ($value) = @_; 
                    915:     my $needsrelease = $Apache::lonnet::needsrelease{'course:commblock:'.$value};
                    916:     if ($needsrelease) {
                    917:         my $curr_required = 
                    918:             $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
                    919:         if ($curr_required eq '') {
                    920:             &Apache::lonnet::update_released_required($needsrelease);
1.1       raeburn   921:         } else {
1.4       raeburn   922:             my ($currmajor,$currminor) = split(/\./,$curr_required);
                    923:             my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
                    924:             if (($currmajor < $needsmajor) || 
                    925:                 ($currmajor == $needsmajor && $currminor < $needsminor)) {
                    926:                 &Apache::lonnet::update_released_required($needsrelease);
                    927:             }
1.1       raeburn   928:         }
                    929:     }
1.4       raeburn   930:     return;
1.1       raeburn   931: }
                    932: 
                    933: sub display_blocker_status {
1.4       raeburn   934:     my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_;
1.1       raeburn   935:     my $parmcount = 0;
1.4       raeburn   936:     my (%map_url,%resource_symb,%lookups);
                    937:     &enumerate_course_contents($navmap,\%map_url,\%resource_symb);
                    938:     %{$lookups{'maps'}} = reverse(%map_url);
                    939:     %{$lookups{'resources'}} = reverse(%resource_symb);
1.1       raeburn   940:     my %lt = &Apache::lonlocal::texthash(
                    941:         'modi' => 'Modify',
1.4       raeburn   942:         'dele' => 'Delete',
                    943:         'noch' => 'No change',
1.1       raeburn   944:     );
1.4       raeburn   945:     $r->print('<div id="showmodify" style="display:block">'.
                    946:               &Apache::loncommon::start_data_table());
1.1       raeburn   947:     $r->print(<<"END");
                    948:   <tr>
1.4       raeburn   949:     <th></th>
                    950:     <th>$ltext->{'type'}</th>
1.1       raeburn   951:     <th>$ltext->{'even'}</th>
                    952:     <th>$ltext->{'blck'}</th>
                    953:   </tr>
                    954: END
                    955:     foreach my $record (sort(keys(%{$records}))) {
1.4       raeburn   956:         my $jschg = 
                    957:             'javascript:window.document.forms['. "'blockform'".']'.
                    958:             '.elements['."'action_$parmcount'".'][0].checked=true;';
                    959:         my $onchange = 'onfocus="'.$jschg.'"';
1.1       raeburn   960:         my ($setuname,$setudom,$title,$blocks) =
                    961:             &Apache::loncommon::parse_block_record($$records{$record});
                    962:         $title = &HTML::Entities::encode($title,'"<>&');
1.4       raeburn   963:         my $blockid = &HTML::Entities::encode($record,'"<>&');
1.1       raeburn   964:         my $settername =
                    965:            &Apache::loncommon::aboutmewrapper(
                    966:                            &Apache::loncommon::plainname($setuname,$setudom),
                    967:                            $setuname,$setudom);
                    968:         $r->print(&Apache::loncommon::start_data_table_row());
1.4       raeburn   969:         $r->print(<<"ACT");
                    970: 
                    971:         <td valign="middle"><span class="LC_nobreak"><label>
                    972:         <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}
                    973:         </label></span><br />
                    974:         <span class="LC_nobreak"><label>
                    975:         <input type="radio" name="action_$parmcount" value="cancel" />$lt{'dele'}
                    976:         </label></span><br />
                    977:         <span class="LC_nobreak"><label>
                    978:         <input type="radio" name="action_$parmcount" id="nochange_$parmcount" 
                    979:          value="nochange" checked="checked" />$lt{'noch'}
                    980:         </label></span>
                    981:         </td>
                    982: ACT
                    983:         my ($start,$end,$startform,$endform); 
                    984:         if ($record =~ /^(\d+)____(\d+)$/) {
                    985:             ($start,$end) = split(/____/,$record);
                    986:             $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
                    987:                                                              $parmcount,$start,$onchange);
                    988:             $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
                    989:                                                            $parmcount,$end,$onchange);
                    990:             $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.
                    991:                       $ltext->{'star'}.':&nbsp;'.$startform.'<br />'.
                    992:                       $ltext->{'endd'}.':&nbsp;&nbsp;'.$endform.'</fieldset></td>');
                    993:         } elsif ($record =~ /^firstaccess____(.+)$/) {
                    994:             my $item = $1;
                    995:             my ($itemname,$iteminfo,$skipdetails);
                    996:             my $type = 'map';
                    997:             my $url;
                    998:             if ($item eq 'course') {
                    999:                 $type = 'course';
                   1000:             } elsif ($item =~ /___\d+___/) {
                   1001:                 $type = 'resource';
                   1002:                 (my $map, my $resid, $url) = &Apache::lonnet::decode_symb($item);  
                   1003:             } else {
                   1004:                 $url = $item;
                   1005:             }
                   1006:             $r->print('<td><fieldset><legend>'.$ltext->{'trig'}.'</legend>');
                   1007:             if ($type eq 'course') {
                   1008:                 $itemname = &mt('Timer for all items in course.');
                   1009:             } else {
                   1010:                 if (&Apache::lonnet::is_on_map($url)) { 
                   1011:                     if ($type eq 'map') {
                   1012:                         if (ref($navmap)) {
                   1013:                             my $res = $navmap->getResourceByUrl($item);
                   1014:                             my $title = $res->compTitle();
                   1015:                             $itemname = &mt('Timer for all items in folder: [_1]',
                   1016:                                             '<span style="font-style:italic">'.
                   1017:                                             $title.'</span>');
                   1018:                         }
                   1019:                     } else {
                   1020:                         if (ref($navmap)) {
                   1021:                             my $res = $navmap->getBySymb($item);
                   1022:                             my $title = $res->compTitle();
                   1023:                             $itemname = &mt('Timer for resource: [_1]',
                   1024:                                              '<span style="font-style:italic">'.
                   1025:                                              $title.'</span>');
                   1026:                         }
                   1027:                     }
                   1028:                     if (ref($navmap)) {
                   1029:                         my $path = &show_timer_path($type,$item);
                   1030:                         if ($path) {
                   1031:                             $iteminfo  = ' <span style="font-size:90%;">'.
                   1032:                                          &mt('(in: [_1])',$path).
                   1033:                                          '</span>';
                   1034:                         }
                   1035:                     }
                   1036:                 } else {
                   1037:                     $skipdetails = 1;
                   1038:                     $itemname = '<span style="LC_warning">'.
                   1039:                                 &mt('Timer folder/resource not in course').
                   1040:                                 '</span>';  
                   1041:                 }
                   1042:             }
                   1043:             if ((!$skipdetails) && (ref($intervals) eq 'HASH')) {
                   1044:                 if (ref($intervals->{$type}) eq 'HASH') {
                   1045:                     $iteminfo .= &trigger_details_toggle($parmcount).
                   1046:                                 '<ul id="trigdetails_'.$parmcount.'" style="display:none">';
                   1047:                     if ($type eq 'course') {
                   1048:                         foreach my $scope (keys(%{$intervals->{$type}})) {
                   1049:                             if ($scope eq 'all') {
                   1050:                                 $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
                   1051:                                          &convlim($intervals->{$type}->{$scope})).'</li>';
                   1052:                             } elsif ($scope eq 'secgrp') {
                   1053:                                 if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
                   1054:                                     $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
                   1055:                                     foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
                   1056:                                         $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$item,
                   1057:                                                      &convlim($intervals->{$type}->{$scope}->{$item})).
                   1058:                                                      '</li>';
                   1059:                                     }
                   1060:                                     $iteminfo .= '</ul></li>';
                   1061:                                 }
                   1062:                             } elsif ($scope eq 'users') {
                   1063:                                 if (ref($intervals->{$type}->{$scope}) eq 'HASH') {
                   1064:                                     $iteminfo .= '<li>'.&mt('Users').'<ul>'; 
                   1065:                                     foreach my $item (sort(keys(%{$intervals->{$type}->{$scope}}))) {
                   1066:                                         $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',
                   1067:                                                      &convlim($item,$intervals->{$type}->{$scope}->{$item})).
                   1068:                                                      '</li>';
                   1069:                                     }
                   1070:                                     $iteminfo .= '</ul></li>';
                   1071:                                 }
                   1072:                             }
                   1073:                         }
                   1074:                     } elsif (($type eq 'map') || ($type eq 'resource')) {
                   1075:                         if (ref($intervals->{$type}->{$item}) eq 'HASH') { 
                   1076:                             foreach my $scope (keys(%{$intervals->{$type}->{$item}})) {
                   1077:                                 if ($scope eq 'all') {
                   1078:                                     $iteminfo .= '<li>'.&mt('All users -- time limit: [_1]',
                   1079:                                                   &convlim($intervals->{$type}->{$item}->{$scope})).
                   1080:                                                   '</li>';
                   1081:                                 } elsif ($scope eq 'secgrp') {
                   1082:                                     if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
                   1083:                                         $iteminfo .= '<li>'.&mt('Sections/groups').'<ul>';
                   1084:                                         foreach my $sec (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
                   1085:                                             $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$sec,
                   1086:                                                          &convlim($intervals->{$type}->{$item}->{$scope}->{$sec})).
                   1087:                                                          '</li>';
                   1088:                                         }
                   1089:                                         $iteminfo .= '</ul></li>'; 
                   1090:                                     }
                   1091:                                 } elsif ($scope eq 'users') {
                   1092:                                     if (ref($intervals->{$type}->{$item}->{$scope}) eq 'HASH') {
                   1093:                                         $iteminfo .= '<li>'.&mt('Users').'<ul>';
                   1094:                                         foreach my $user (sort(keys(%{$intervals->{$type}->{$item}->{$scope}}))) {
                   1095:                                             $iteminfo .= '<li>'.&mt('[_1] -- time limit: [_2]',$user,
                   1096:                                                          &convlim($intervals->{$type}->{$item}->{$scope}->{$user})).
                   1097:                                                          '</li>';
                   1098:                                         }
                   1099:                                         $iteminfo .= '</ul></li>';
                   1100:                                     }
                   1101:                                 }
                   1102:                             }
                   1103:                         }
                   1104:                     }
                   1105:                     $iteminfo .= '</ul>';
                   1106:                 }
1.1       raeburn  1107:             }
1.4       raeburn  1108:             $r->print(&create_interval_form($intervals,$parmcount,$navmap,$item,$jschg,
                   1109:                                             $itemname,$iteminfo).'</fieldset></td>');
1.1       raeburn  1110:         }
                   1111:         $r->print(<<"END");
1.4       raeburn  1112:         <td>
                   1113:          <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" />
                   1114:          <input type="hidden" name="key_$parmcount" value="$blockid" />
                   1115:          <br />
                   1116:          <br />
                   1117:          $ltext->{'setb'}: $settername
                   1118:         </td>
1.1       raeburn  1119: END
1.4       raeburn  1120:         $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups).'</td>'.
                   1121:                   &Apache::loncommon::end_data_table_row());
1.1       raeburn  1122:         $parmcount++;
                   1123:     }
                   1124:     $r->print(<<"END");
                   1125: </table>
1.4       raeburn  1126: </div>
1.1       raeburn  1127: END
1.4       raeburn  1128:     return;
                   1129: }
                   1130: 
                   1131: sub path_to_trigger {
                   1132:     my ($navmap,$map,$type) = @_;
                   1133:     my @pathitems;
                   1134:     if (ref($navmap)) {
                   1135:         my $mapres = $navmap->getResourceByUrl($map);
                   1136:         if (ref($mapres)) {
                   1137:             my $pcslist = $mapres->map_hierarchy();
                   1138:             if ($pcslist ne '') {
                   1139:                 my @pcs = split(/,/,$pcslist);
                   1140:                 foreach my $pc (@pcs) {    
                   1141:                     if ($pc == 1) {
                   1142:                         push(@pathitems,&mt('Main Course Documents'));
                   1143:                     } else {
                   1144:                         my $res = $navmap->getByMapPc($pc);
                   1145:                         if (ref($res)) {
                   1146:                             my $title = $res->compTitle();
                   1147:                             $title =~ s/\W+/_/g;
                   1148:                             if ($title ne '') {
                   1149:                                 push(@pathitems,$title);
                   1150:                             }
                   1151:                         }
                   1152:                     }
                   1153:                 }
                   1154:             }
                   1155:         }
                   1156:         if ($type eq 'resource') {
                   1157:             if ($mapres->{ID} eq '0.0') {
                   1158:                 push(@pathitems,&mt('Main Course Documents'));
                   1159:             } else {
                   1160:                 my $maptitle = $mapres->compTitle();
                   1161:                 $maptitle =~ s/\W+/_/g;
                   1162:                 if ($maptitle ne '') {
                   1163:                     push(@pathitems,$maptitle);
                   1164:                 }
                   1165:             }
                   1166:         }
                   1167:     }
                   1168:     return @pathitems;
                   1169: }
                   1170: 
                   1171: sub convlim {
                   1172:     my ($timelimit) = @_;
                   1173:     my $output;
                   1174:     my @order = ('days','hours','minutes','seconds');
                   1175:     my %catlimits = ( 
                   1176:                       days    => 86400,
                   1177:                       hours   => 3600,
                   1178:                       minutes => 60,
                   1179:                     );
                   1180:     my @toshow;
                   1181:     foreach my $cat (@order) {
                   1182:         if ($cat eq 'seconds') {
                   1183:             last if ($timelimit <= 0);
                   1184:         } elsif ($timelimit >= $catlimits{$cat}) {
                   1185:             my $val = int($timelimit/$catlimits{$cat});
                   1186:             if ($val > 0) {
                   1187:                 push(@toshow,&mt("[_1] $cat",$val));
                   1188:             }
                   1189:             $timelimit =- $val*$catlimits{$cat};
                   1190:         }
                   1191:     }
                   1192:     my $output = join(', ',@toshow);
                   1193:     return $output;
1.1       raeburn  1194: }
                   1195: 
                   1196: sub display_addblocker_table {
1.4       raeburn  1197:     my ($r,$parmcount,$ltext,$intervals,$navmap,$errormsg) = @_;
                   1198:     return unless ((ref($ltext) eq 'HASH') && (ref($intervals) eq 'HASH'));
1.1       raeburn  1199:     my $start = time;
                   1200:     my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
1.4       raeburn  1201:     my $onchange = 'onfocus="javascript:window.document.forms['.
                   1202:                    "'blockform'].elements['addaction'].".
1.1       raeburn  1203:                    'checked=true;"';
1.4       raeburn  1204:     my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
                   1205:                                                         $parmcount,$start,$onchange);
                   1206:     my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
                   1207:                                                       $parmcount,$end,$onchange);
1.1       raeburn  1208:     my %lt = &Apache::lonlocal::texthash(
                   1209:         'exam' => 'e.g., Exam 1',
                   1210:     );
1.4       raeburn  1211:     my $intervalform = &create_interval_form($intervals,$parmcount,$navmap);
                   1212:     if ($intervalform ne '') {
                   1213:         $intervalform = '<fieldset>'.
                   1214:                         '<legend>'.$ltext->{'chtr'}.'</legend>'.
                   1215:                         $intervalform.
                   1216:                         '</fieldset>';
                   1217:     }
1.1       raeburn  1218:     $r->print(&Apache::loncommon::start_data_table());
                   1219:     $r->print(<<"END");
                   1220:    <tr>
1.4       raeburn  1221:      <th>$ltext->{'type'}</th>
1.1       raeburn  1222:      <th>$ltext->{'even'} $lt{'exam'}</th>
                   1223:      <th>$ltext->{'blck'}</th>
                   1224:    </tr>
                   1225: END
1.4       raeburn  1226:     $r->print(&Apache::loncommon::start_data_table_row().'<td>');
1.1       raeburn  1227:     $r->print(<<"END");
1.4       raeburn  1228:      <span class="LC_nobreak"><label><input type="radio" id="toggle_startstop" 
                   1229:      name="toggle_$parmcount" value="startstop" onclick="showBlockType();" checked="checked" />
                   1230:      $ltext->{'defs'}</label></span>&nbsp;&nbsp; 
                   1231:      <span class="LC_nobreak"><label><input type="radio" id="toggle_timer" name="toggle_$parmcount" 
                   1232:      value="timer" onclick="showBlockType();" />$ltext->{'trig'}</label></span><br />
                   1233:      <div id="show_startstop" style="display:block">
                   1234:      <fieldset><legend>$ltext->{'chda'}</legend>
                   1235:      $ltext->{'star'}:&nbsp;$startform<br />$ltext->{'endd'}:&nbsp;&nbsp;$endform</fieldset>
                   1236:      <span class="LC_warning">$ltext->{'when'}</span></div>
                   1237:      <div id="show_timer" style="display:none">$intervalform</div>
                   1238:      </td>
1.1       raeburn  1239:      <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
                   1240: END
1.4       raeburn  1241:     $r->print('<td>'.&blocker_checkboxes($parmcount).'</td>'.
                   1242:               &Apache::loncommon::end_data_table_row().
                   1243:               &Apache::loncommon::end_data_table()."\n".
                   1244:               '<br />');
                   1245:     return;
                   1246: }
                   1247: 
                   1248: sub blocker_checkboxes {
                   1249:     my ($parmcount,$blocks,$jschg,$lookups) = @_;
                   1250:     my ($typeorder,$types) = &blocktype_text();
                   1251:     my $numinrow = 2;
                   1252:     my %currdocs;
                   1253:     my $output = '<table>';
                   1254:     for (my $i=0; $i<@{$typeorder}; $i++) {
                   1255:         my $block = $typeorder->[$i];
                   1256:         my ($clickaction,$blockstatus);
                   1257:         if ($jschg) {
                   1258:             $clickaction = $jschg;
                   1259:         } 
                   1260:         if ($block eq 'docs') {
                   1261:             if ((ref($blocks) eq 'HASH') && (ref($lookups) eq 'HASH')) {
                   1262:                 if (ref($blocks->{$block}) eq 'HASH') {
                   1263:                     if (keys(%{$blocks->{$block}}) > 0) {
                   1264:                         $blockstatus = 'checked="checked"';
                   1265:                         foreach my $key (sort(keys(%{$blocks->{$block}}))) {
                   1266:                             if (ref($blocks->{$block}{$key}) eq 'HASH') {
                   1267:                                 my @current = ();
                   1268:                                 foreach my $item (keys(%{$blocks->{$block}{$key}})) {
                   1269:                                     if ($lookups->{$key}{$item}) {
                   1270:                                         push(@current,$lookups->{$key}{$item});
                   1271:                                     }
                   1272:                                 }
                   1273:                                 if (@current > 0) {
                   1274:                                     @current=sort { $a <=> $b } (@current);
                   1275:                                     $currdocs{$key} = join(',',@current);
                   1276:                                 }
                   1277:                             }
                   1278:                         }
                   1279:                     }
                   1280:                 }
                   1281:             }
                   1282:             $clickaction .= 'javascript:resblockinfo('."'$parmcount'".');';
                   1283:         } else {
                   1284:             if (ref($blocks) eq 'HASH') { 
                   1285:                 if ($blocks->{$block} eq 'on') {
                   1286:                     $blockstatus = 'checked="checked"';
                   1287:                 }
                   1288:             }
                   1289:         }
                   1290:         my $rem = $i%($numinrow);
                   1291:         if ($rem == 0) {
                   1292:             if ($i > 0) {
                   1293:                 $output .= '</tr>';
                   1294:             }
                   1295:             $output .= '<tr>';
                   1296:         }
                   1297:         if ($i == scalar(@{$typeorder})-1) {
                   1298:             my $colsleft = $numinrow-$rem;
                   1299:             if ($colsleft > 1) {
                   1300:                 $output .= '<td colspan="'.$colsleft.'">';
                   1301:             } else {
                   1302:                 $output .= '<td>';
                   1303:             }
                   1304:         } else {
                   1305:             $output .= '<td>';
                   1306:         }
                   1307:         my $item = $block.'_'.$parmcount;
                   1308:         if ($clickaction) {
                   1309:             $clickaction = ' onclick="'.$clickaction.'"';
                   1310:         }
                   1311:         if ($blockstatus) {
                   1312:             $blockstatus = ' '.$blockstatus;
                   1313:         } 
                   1314:         $output .= '<span class="LC_nobreak"><label>'."\n".
                   1315:                    '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.
                   1316:                    $blockstatus.$clickaction.' value="1" />'.
                   1317:                    $types->{$block}.'</label></span>'."\n";
                   1318:         if ($block eq 'docs') {
                   1319:             if ($blockstatus ne '') {
                   1320:                 $output .= '&nbsp;<a href="javascript:resblockinfo('."'$parmcount'".')">'.
                   1321:                             &mt('Details').'</a>';
                   1322:             }
                   1323:         }
                   1324:         $output .= '<br /></td>';
                   1325:     }
                   1326:     $output .= '</tr></table>'.
                   1327:                '<input type="hidden" name="docs_maps_'.$parmcount.'"'.
                   1328:                ' id="docs_maps_'.$parmcount.'" value="'.$currdocs{'maps'}.'" />'.
                   1329:                '<input type="hidden" name="docs_resources_'.$parmcount.'"'.
                   1330:                ' id="docs_resources_'.$parmcount.'" value="'.$currdocs{'resources'}.'" />';
                   1331:     return $output;
                   1332: }
                   1333: 
                   1334: sub create_interval_form {
                   1335:     my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo) = @_;
                   1336:     return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));
                   1337:     my $intervalform;
                   1338:     if (keys(%{$intervals}) > 0) {
                   1339:         foreach my $type (sort(keys(%{$intervals}))) {
                   1340:             if ($type eq 'course') {
                   1341:                 my ($checked,$clickaction);
                   1342:                 if ($currkey eq 'course') {
                   1343:                     $checked = ' checked="checked"';
                   1344:                 } elsif ($jschg) {
                   1345:                     $clickaction = ' onclick="'.$jschg.'"';
                   1346:                 }
                   1347:                 $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                   1348:                                  '" value="course"'.$checked.$clickaction.' />';
                   1349:                 if ($currkey eq 'course') {
                   1350:                     $intervalform .= $itemname;
                   1351:                 } else {
                   1352:                     $intervalform .= &mt('Timer for all items in course');
                   1353:                 }
                   1354:                 $intervalform .= '</label>';
                   1355:                 if ($currkey eq 'course') {
                   1356:                     $intervalform .= $iteminfo;
                   1357:                 }
                   1358:                 $intervalform .= '<br />';
                   1359:             } elsif ($type eq 'map') {
                   1360:                 if (ref($intervals->{$type}) eq 'HASH') {
                   1361:                     if (ref($navmap)) {
                   1362:                         foreach my $map (sort(keys(%{$intervals->{$type}}))) {
                   1363:                             my ($checked,$clickaction);
                   1364:                             if ($currkey eq $map) {
                   1365:                                 $checked = ' checked="checked"';
                   1366:                             } elsif ($jschg) {
                   1367:                                 $clickaction = ' onclick="'.$jschg.'"';
                   1368:                             }
                   1369:                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                   1370:                                              '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
                   1371:                                              $checked.$clickaction.' />';
                   1372:                             if ($currkey eq $map) {
                   1373:                                 $intervalform .= $itemname.'</label>';
                   1374:                             } else {
                   1375:                                 my $res = $navmap->getResourceByUrl($map);
                   1376:                                 my $title = $res->compTitle();
                   1377:                                 my $path;
                   1378:                                 my $hierarchy = &show_timer_path($type,$map,$navmap);
                   1379:                                 if ($hierarchy) {
                   1380:                                     $path = ' <span style="font-size:90%;">'.
                   1381:                                             &mt('(in: [_1])',$hierarchy).
                   1382:                                             '</span>';
                   1383:                                 }
                   1384:                                 $intervalform .= &mt('Timer for all items in folder: [_1]',
                   1385:                                                      '<i>'.$title.'</i>').
                   1386:                                                  '</label>'.$path;
                   1387:                             }
                   1388:                             if ($currkey eq $map) {
                   1389:                                 $intervalform .= $iteminfo;
                   1390:                             }
                   1391:                             $intervalform .= '<br />';
                   1392:                         }
                   1393:                     }
                   1394:                 }
                   1395:             } elsif ($type eq 'resource') {
                   1396:                 if (ref($intervals->{$type}) eq 'HASH') {
                   1397:                     if (ref($navmap)) {
                   1398:                         foreach my $resource (sort(keys(%{$intervals->{$type}}))) {
                   1399:                             my ($checked,$clickaction);
                   1400:                             if ($currkey eq $resource) {
                   1401:                                 $checked = ' checked="checked"';
                   1402:                             } elsif ($jschg) {
                   1403:                                 $clickaction = ' onclick="'.$jschg.'"';
                   1404:                             }
                   1405:                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                   1406:                                              '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
                   1407:                                              $checked.$clickaction.' />';
                   1408:                             if ($currkey eq $resource) {
                   1409:                                 $intervalform .= $itemname.'</label>';
                   1410:                             } else {
                   1411:                                 my $res = $navmap->getBySymb($resource);
                   1412:                                 my $title = $res->compTitle();
                   1413:                                 my $path;
                   1414:                                 my $hierarchy = &show_timer_path($type,$resource,$navmap);
                   1415:                                 if ($hierarchy) {
                   1416:                                     $path = ' <span style="font-size:90%;">'.
                   1417:                                             &mt('(in: [_1])',$hierarchy).
                   1418:                                             '</span>';
                   1419:                                 }
                   1420:                                 $intervalform .= &mt('Timer for resource: [_1]','<i>'.$title.'</i>').
                   1421:                                                  '</label>'.
                   1422:                                                  $path;
                   1423:                             }
                   1424:                             if ($currkey eq $resource) {
                   1425:                                 $intervalform .= $iteminfo;
                   1426:                             }
                   1427:                             $intervalform .= '<br />';
                   1428:                         }
                   1429:                     }
                   1430:                 }
                   1431:             }
                   1432:         }
                   1433:     } else {
                   1434:         if ($currkey ne '') {
                   1435:             $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.
                   1436:                             '" checked="checked" value="'.
                   1437:                             &HTML::Entities::encode($currkey,'"<>&').' />'.
                   1438:                             $itemname.'<br />';
                   1439:         } else {
                   1440:             $intervalform = &mt('No timed items defined.').' '.
                   1441:                             &mt('Use [_1]Settings[_2] to assign a timer, then return here.',
                   1442:                                 '<a href="/adm/parmset">','</a>');
                   1443:         }
                   1444:     }
                   1445:     return $intervalform;
                   1446: }
                   1447: 
                   1448: sub trigger_details_toggle {
                   1449:     my ($parmcount) = @_;
                   1450:     return ' <span id="toggletext_'.$parmcount.'" class="LC_cusr_subheading LC_nobreak">'.
                   1451:            '<a href="javascript:showTriggerDetails('."'$parmcount'".');" '.
                   1452:            'style="text-decoration: none;"><b>'.&mt('(More ...)').'</b></a></span>';
                   1453: }
                   1454: 
                   1455: sub show_timer_path {
                   1456:     my ($type,$item,$navmap) = @_;
                   1457:     return unless(ref($navmap));
                   1458:     my @pathitems;
                   1459:     if ($type eq 'map') {
                   1460:         @pathitems = &path_to_trigger($navmap,$item,$type);
                   1461:     } elsif ($type eq 'resource') {
                   1462:         my ($map,$id,$resource) = &Apache::lonnet::decode_symb($item);
                   1463:         @pathitems = &path_to_trigger($navmap,$map,$type);
                   1464:     }
                   1465:     if (@pathitems) {
                   1466:         return join(' &raquo; ',@pathitems);
                   1467:     }
1.1       raeburn  1468:     return;
                   1469: }
                   1470: 
                   1471: sub blocktype_text {
                   1472:     my %types = &Apache::lonlocal::texthash(
                   1473:         'com' => 'Messaging',
                   1474:         'chat' => 'Chat Room',
                   1475:         'boards' => 'Discussion',
                   1476:         'port' => 'Portfolio',
                   1477:         'groups' => 'Groups',
                   1478:         'blogs' => 'Blogs',
1.5     ! raeburn  1479:         'docs' => 'Content',
        !          1480:         'printout' => 'Printouts',
1.1       raeburn  1481:     );
1.5     ! raeburn  1482:     my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs'];
1.1       raeburn  1483:     return ($typeorder,\%types);
                   1484: }
                   1485: 
1.4       raeburn  1486: sub blockingmenu_javascript {
                   1487:     my ($blockcount) = @_;
                   1488:     my %lt = &Apache::lonlocal::texthash (
                   1489:                                            more => 'More ...',
                   1490:                                            less => 'Less ...',
                   1491:                                          );
                   1492:     return <<ENDSCRIPT;
                   1493: <script type="text/javascript">
                   1494: // <![CDATA[
                   1495: function resblockinfo(blockid) {
                   1496:     if (document.getElementById('docs_'+blockid).checked) {
                   1497:         var resblockwin = null;
                   1498:         var url = '/adm/setblock?action=showdocs&block='+blockid;
                   1499:         if (!resblockwin || resblockwin.closed) {
                   1500:             resblockwin=window.open(url,'blockingwin','height=480,width=600,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
                   1501:         }
                   1502:         resblockwin.focus();
                   1503:     } else {
                   1504:         document.getElementById('docs_resources_'+blockid).value = '';
                   1505:         document.getElementById('docs_maps_'+blockid).value = '';
                   1506:     }
                   1507:     return;
                   1508: }
                   1509: 
                   1510: function showBlockType() {
                   1511:     if (document.getElementById('toggle_startstop').checked == true) {
                   1512:         document.getElementById('show_startstop').style.display='block';
                   1513:     } else {
                   1514:         document.getElementById('show_startstop').style.display='none';
                   1515:     }
                   1516:     if (document.getElementById('toggle_timer').checked == true) {
                   1517:         document.getElementById('show_timer').style.display='block';
                   1518:     } else {
                   1519:         document.getElementById('show_timer').style.display='none';
                   1520:     }
                   1521:     return;
                   1522: }
                   1523: 
                   1524: function toggleAddModify() {
                   1525:     for (var i=0; i<document.blockform.blockaction.length; i++) {
                   1526:         if (document.blockform.blockaction[i].checked) {
                   1527:             if (document.blockform.blockaction[i].value == 'add') {
                   1528:                document.getElementById('showadd').style.display='block';
                   1529:                document.getElementById('showmodify').style.display='none';
                   1530:                var blocktotal = $blockcount;
                   1531:                if (blocktotal > 0) {
                   1532:                    for (var i=0; i<blocktotal; i++) {
                   1533:                        document.getElementById('nochange_'+i).checked = true;
                   1534:                    }
                   1535:                }
                   1536:                document.getElementById('showmodify').style.display='none';
                   1537:                document.getElementById('showadd').style.display='block';
                   1538:             } else {
                   1539:                document.getElementById('showadd').style.display='none';
                   1540:                document.getElementById('showmodify').style.display='block';
                   1541:             }
                   1542:         }
                   1543:     }
                   1544:     return;
                   1545: }
                   1546: 
                   1547: function showTriggerDetails(item) {
                   1548:     document.getElementById('trigdetails_'+item).style.display='block';
                   1549:     document.getElementById('trigdetails_'+item).style.textAlign='left';
                   1550:     document.getElementById('trigdetails_'+item).style.textFace='normal';
                   1551:     document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:hideTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'less'})</b></a>';
                   1552:     return;
                   1553: }
                   1554: 
                   1555: function hideTriggerDetails(item) {
                   1556:     document.getElementById('trigdetails_'+item).style.display='none';
                   1557:     document.getElementById('toggletext_'+item).innerHTML = '<a href="javascript:showTriggerDetails('+item+');" style="text-decoration: none;"><b>($lt{'more'})</b></a>';
                   1558:     return;
                   1559: }
                   1560: 
                   1561: // ]]>
                   1562: </script>
                   1563: ENDSCRIPT
                   1564: 
                   1565: }
                   1566: 
1.1       raeburn  1567: 1;
                   1568: 
                   1569: __END__

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