Diff for /loncom/interface/lonblockingmenu.pm between versions 1.13 and 1.20

version 1.13, 2014/06/12 00:33:41 version 1.20, 2016/10/22 01:49:10
Line 105  block (including deletion), or when a ne Line 105  block (including deletion), or when a ne
   
 =over  =over
   
   =item &get_permission()
   
   Returns information about permission user has to set/modify exam
   blocking events.
   
   Inputs: None
   
   Outputs: 2
       $readonly - true if modification of blocking events is prohibited.
   
       $allowed  - true if blocking events information can be shown.
    
   
 =item &get_timed_items()  =item &get_timed_items()
   
 Provides perl data structure with information about timed interval  Provides perl data structure with information about timed interval
Line 222  Side Effects: &update_released_required( Line 235  Side Effects: &update_released_required(
 Generates web form elements used to display, cancel, or modify   Generates web form elements used to display, cancel, or modify 
 existing blocking events.   existing blocking events. 
   
 Inputs: 7   Inputs: 8 
       - $r - Apache request object        - $r - Apache request object
   
       - $records - Reference to hash of current blocks        - $records - Reference to hash of current blocks
Line 238  Inputs: 7 Line 251  Inputs: 7
   
       - $blockcount - number of existing blocking events in course        - $blockcount - number of existing blocking events in course
   
         - $readonly - if true, modification not allowed.
    
   
 Output: None  Output: None
   
 Side Effects: prints web form elements (in a table) for current blocks.   Side Effects: prints web form elements (in a table) for current blocks. 
Line 422  sub handler { Line 438  sub handler {
   
 # ----------------------------------------------------------- Permissions check  # ----------------------------------------------------------- Permissions check
   
     unless ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||      my ($readonly,$allowed) = &get_permission();
             (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.      unless ($allowed) {
                                       '/'.$env{'request.course.sec'}))) {  
         $env{'user.error.msg'}=          $env{'user.error.msg'}=
      "/adm/setblock:dcm:0:0:Cannot set blocking of communications in a course";       "/adm/setblock:dcm:0:0:Cannot view/set blocking of communications in a course";
         return HTTP_NOT_ACCEPTABLE;          return HTTP_NOT_ACCEPTABLE;
     }      }
   
Line 471  sub handler { Line 486  sub handler {
             $r->print(&Apache::loncourserespicker::create_picker($navmap,              $r->print(&Apache::loncourserespicker::create_picker($navmap,
                                      'examblock','resourceblocks',$crstype,                                       'examblock','resourceblocks',$crstype,
                                      \%blockedmaps,\%blockedresources,                                       \%blockedmaps,\%blockedresources,
                                      $env{'form.block'}));                                       $env{'form.block'},'','',undef,$readonly));
         } else {          } else {
             $r->print($errormsg);              $r->print($errormsg);
         }          }
Line 480  sub handler { Line 495  sub handler {
   
 # -------------------------- Store changes and retrieve latest block information  # -------------------------- Store changes and retrieve latest block information
     my $storeresult;      my $storeresult;
     if ($env{'form.action'} eq 'store') {      unless ($readonly) {
         (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);          if ($env{'form.action'} eq 'store') {
         if ($numchanges > 0) {              (my $numchanges,$storeresult) = &blockstore($r,$crstype,$blockcount,\%records);
             $blockcount = &get_blockdates(\%records);              if ($numchanges > 0) {
                   $blockcount = &get_blockdates(\%records);
               }
         }          }
     }      }
   
Line 561  sub handler { Line 578  sub handler {
             '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".              '<li>'.&mt('accessing content in LON-CAPA portfolios or blogs').'</li>'."\n".
             '<li>'.&mt("generating printouts of $lctype content").'</li>'.              '<li>'.&mt("generating printouts of $lctype content").'</li>'.
             '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.              '<li>'.&mt("accessing $lctype content in specified folders or resources").'</li>'.
               '<li>'.&mt("changing user's own password").'</li>'.
             '</ul>'.              '</ul>'.
             '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'              '<p class="LC_warning">'.$lt{'blca'}.'<br />'.$lt{'pobl'}.'</p>'
         );          );
Line 568  sub handler { Line 586  sub handler {
   
 # ------------------------ Choose between modifying existing block or adding new  # ------------------------ Choose between modifying existing block or adding new
     $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');      $r->print('<form name="blockform" method="post" action="/adm/setblock?action=store">');
     if ($blockcount > 0) {      
          $r->print(<<"END");      unless ($readonly) { 
           if ($blockcount > 0) {
               $r->print(<<"END");
 <div class="LC_left_float">  <div class="LC_left_float">
 <fieldset><legend>$lt{'actt'}</legend>  <fieldset><legend>$lt{'actt'}</legend>
 <span class="LC_nobreak">  <span class="LC_nobreak">
Line 586  onclick="toggleAddModify();" />$lt{'addn Line 606  onclick="toggleAddModify();" />$lt{'addn
 <br clear="all" />  <br clear="all" />
 <div id="showadd" style="display:none">  <div id="showadd" style="display:none">
 END  END
     } else {          } else {
         $r->print($lt{'ncbc'}.'<br /><br />'.              $r->print($lt{'ncbc'}.'<br /><br />'.
                   '<h4>'.$lt{'addn'}.'</h4>'.                        '<h4>'.$lt{'addn'}.'</h4>'.
                   '<input type="hidden" name="blockaction" value="add" />');                        '<input type="hidden" name="blockaction" value="add" />');
           }
     }      }
     my ($navmap,$errormsg) =      my ($navmap,$errormsg) =
         &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');          &Apache::loncourserespicker::get_navmap_object($crstype,'examblock');
   
 # --------------------------------------------- Interface for adding a new block  # --------------------------------------------- Interface for adding a new block
     &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,      if ($readonly) {
                               $navmap,$errormsg);          if (!$blockcount) {
               $r->print($lt{'ncbc'}.'<br />');
           }
       } else {
           &display_addblocker_table($r,$blockcount,\%ltext,\%intervals,
                                     $navmap,$errormsg);
           if ($blockcount > 0) {
               $r->print('</div>');
           }
       }
   
 # ------------------------------------------------- Interface for existig blocks  # ------------------------------------------------ Interface for existing blocks
     if ($blockcount > 0) {      if ($blockcount > 0) {
         $r->print('</div>');  
         &display_blocker_status($r,\%records,\%ltext,\%intervals,          &display_blocker_status($r,\%records,\%ltext,\%intervals,
                                 $navmap,$errormsg,$blockcount);                                  $navmap,$errormsg,$blockcount,$readonly);
     }      }
     $r->print(<<"END");      unless ($readonly) {
           $r->print(<<"END");
 <br />  <br />
 <input type ="submit" value="$lt{'stor'}" />  <input type ="submit" value="$lt{'stor'}" />
 </form>  
 END  END
     $r->print(&Apache::loncommon::end_page());      }
       $r->print('</form>'.
                 &Apache::loncommon::end_page());
     return OK;      return OK;
 }  }
   
   sub get_permission {
       my %permission;
       my $allowed = 0;
       my $readonly = 0;
       return ($readonly,$allowed) unless ($env{'request.course.id'});
       if ((&Apache::lonnet::allowed('dcm',$env{'request.course.id'})) ||
           (&Apache::lonnet::allowed('dcm',$env{'request.course.id'}.'/'.
                     $env{'request.course.sec'}))) {
           $allowed = 1;
       } elsif ((&Apache::lonnet::allowed('vcb',$env{'request.course.id'})) ||
                (&Apache::lonnet::allowed('vcb',$env{'request.course.id'}.'/'.
                     $env{'request.course.sec'}))) {
           $readonly = 1;
           $allowed = 1;
       }
       return ($readonly,$allowed);
   }
   
 sub get_timed_items {  sub get_timed_items {
     my ($cdom,$cnum) = @_;      my ($cdom,$cnum) = @_;
     my ($cid,%intervals);      my ($cid,%intervals);
Line 629  sub get_timed_items { Line 678  sub get_timed_items {
     my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);      my $resourcedata=&Apache::lonparmset::readdata($cnum,$cdom);
     if (ref($resourcedata) eq 'HASH') {      if (ref($resourcedata) eq 'HASH') {
         foreach my $key (keys(%{$resourcedata})) {          foreach my $key (keys(%{$resourcedata})) {
             if ($key =~ /^\Q$cid\E(.+)\.0\.interval$/) {              if ($key =~ /^\Q$cid\E(.*)\.0\.interval$/) {
                 my $middle = $1;                  my $middle = $1;
                 if ($middle eq '') {                  if ($middle eq '') {
                     $intervals{'course'}{'all'} = $resourcedata->{$key};                      $intervals{'course'}{'all'} = $resourcedata->{$key};
Line 913  sub get_block_choices { Line 962  sub get_block_choices {
                     if (ref($symb_ref) eq 'HASH') {                      if (ref($symb_ref) eq 'HASH') {
                         my %resources = map { $symb_ref->{$_} => 1; }                           my %resources = map { $symb_ref->{$_} => 1; } 
                                             (split(/,/,$env{'form.docs_resources_'.$item}));                                              (split(/,/,$env{'form.docs_resources_'.$item}));
                           if (exists($resources{''})) {
                               delete($resources{''});
                           }
                         $blocklist->{$type}->{resources} = \%resources;                          $blocklist->{$type}->{resources} = \%resources;
                         if (keys(%resources) > 0) {                          if (keys(%resources) > 0) {
                             $blockdocs = 1;                              $blockdocs = 1;
Line 924  sub get_block_choices { Line 976  sub get_block_choices {
                     if (ref($map_ref) eq 'HASH') {                      if (ref($map_ref) eq 'HASH') {
                         my %maps = map { $map_ref->{$_} => 1; }                                                       my %maps = map { $map_ref->{$_} => 1; }                             
                                        (split(/,/,$env{'form.docs_maps_'.$item}));                                         (split(/,/,$env{'form.docs_maps_'.$item}));
                           if (exists($maps{''})) {
                               delete($maps{''});
                           }
                         $blocklist->{$type}->{maps} = \%maps;                          $blocklist->{$type}->{maps} = \%maps;
                         if (keys(%maps) > 0) {                          if (keys(%maps) > 0) {
                             $blockdocs = 1;                              $blockdocs = 1;
Line 968  sub check_release_required { Line 1023  sub check_release_required {
 }  }
   
 sub display_blocker_status {  sub display_blocker_status {
     my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount) = @_;      my ($r,$records,$ltext,$intervals,$navmap,$errormsg,$blockcount,$readonly) = @_;
     my $parmcount = 0;      my $parmcount = 0;
     my (%map_url,%resource_symb,%titles,%lookups);      my (%map_url,%resource_symb,%titles,%lookups,$disabled);
     &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');      &Apache::loncourserespicker::enumerate_course_contents($navmap,\%map_url,\%resource_symb,\%titles,'examblock');
     %{$lookups{'maps'}} = reverse(%map_url);      %{$lookups{'maps'}} = reverse(%map_url);
     %{$lookups{'resources'}} = reverse(%resource_symb);      %{$lookups{'resources'}} = reverse(%resource_symb);
Line 980  sub display_blocker_status { Line 1035  sub display_blocker_status {
         'noch' => 'No change',          'noch' => 'No change',
     );      );
     $r->print('<div id="showmodify" style="display:block">'.      $r->print('<div id="showmodify" style="display:block">'.
               &Apache::loncommon::start_data_table());                &Apache::loncommon::start_data_table().'<tr>');
       if ($readonly) {
           $disabled = ' disabled="disabled"';
       } else {
           $r->print('<th></th>');
       }
     $r->print(<<"END");      $r->print(<<"END");
   <tr>  
     <th></th>  
     <th>$ltext->{'type'}</th>      <th>$ltext->{'type'}</th>
     <th>$ltext->{'even'}</th>      <th>$ltext->{'even'}</th>
     <th>$ltext->{'blck'}</th>      <th>$ltext->{'blck'}</th>
Line 1002  END Line 1060  END
            &Apache::loncommon::aboutmewrapper(             &Apache::loncommon::aboutmewrapper(
                            &Apache::loncommon::plainname($setuname,$setudom),                             &Apache::loncommon::plainname($setuname,$setudom),
                            $setuname,$setudom);                             $setuname,$setudom);
           my $state = '';
         $r->print(&Apache::loncommon::start_data_table_row());          $r->print(&Apache::loncommon::start_data_table_row());
         $r->print(<<"ACT");          if ($readonly) {
               $state = 'disabled';
           } else {
               $r->print(<<"ACT");
   
         <td valign="middle"><span class="LC_nobreak"><label>          <td valign="middle"><span class="LC_nobreak"><label>
         <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}          <input type="radio" name="action_$parmcount" value="modify" />$lt{'modi'}
Line 1017  END Line 1079  END
         </label></span>          </label></span>
         </td>          </td>
 ACT  ACT
           }
         my ($start,$end,$startform,$endform);           my ($start,$end,$startform,$endform); 
         if ($record =~ /^(\d+)____(\d+)$/) {          if ($record =~ /^(\d+)____(\d+)$/) {
             ($start,$end) = split(/____/,$record);              ($start,$end) = split(/____/,$record);
             $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.              $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.
                                                              $parmcount,$start,$onchange);                                                               $parmcount,$start,$onchange,
                                                                undef,$state);
             $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.              $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.
                                                            $parmcount,$end,$onchange);                                                             $parmcount,$end,$onchange,
                                                              undef,$state);
             $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.              $r->print('<td><fieldset><legend>'.$ltext->{'defs'}.'</legend>'.
                       $ltext->{'star'}.':&nbsp;'.$startform.'<br />'.                        $ltext->{'star'}.':&nbsp;'.$startform.'<br />'.
                       $ltext->{'endd'}.':&nbsp;&nbsp;'.$endform.'</fieldset></td>');                        $ltext->{'endd'}.':&nbsp;&nbsp;'.$endform.'</fieldset></td>');
Line 1153  ACT Line 1218  ACT
                 }                  }
             }              }
             $r->print(&create_interval_form($intervals,$parmcount,$navmap,$item,$jschg,              $r->print(&create_interval_form($intervals,$parmcount,$navmap,$item,$jschg,
                                             $itemname,$iteminfo).'</fieldset></td>');                                              $itemname,$iteminfo,$disabled).'</fieldset></td>');
         }          }
         $r->print(<<"END");          $r->print(<<"END");
         <td>          <td>
          <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" />           <input type="text" name="title_$parmcount" size="15" value="$title" onfocus="$jschg" $disabled />
          <input type="hidden" name="key_$parmcount" value="$blockid" />           <input type="hidden" name="key_$parmcount" value="$blockid" />
          <br />           <br />
          <br />           <br />
          $ltext->{'setb'}: $settername           $ltext->{'setb'}: $settername
         </td>          </td>
 END  END
         $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups).'</td>'.          $r->print('<td>'.&blocker_checkboxes($parmcount,$blocks,$jschg,\%lookups,$disabled).'</td>'.
                   &Apache::loncommon::end_data_table_row());                    &Apache::loncommon::end_data_table_row());
         $parmcount++;          $parmcount++;
     }      }
Line 1254  END Line 1319  END
 }  }
   
 sub blocker_checkboxes {  sub blocker_checkboxes {
     my ($parmcount,$blocks,$jschg,$lookups) = @_;      my ($parmcount,$blocks,$jschg,$lookups,$disabled) = @_;
     my ($typeorder,$types) = &blocktype_text();      my ($typeorder,$types) = &blocktype_text();
     my $numinrow = 2;      my $numinrow = 2;
     my %currdocs;      my %currdocs;
Line 1321  sub blocker_checkboxes { Line 1386  sub blocker_checkboxes {
         }           } 
         $output .= '<span class="LC_nobreak"><label>'."\n".          $output .= '<span class="LC_nobreak"><label>'."\n".
                    '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.                     '<input type="checkbox" id="'.$item.'" name="'.$item.'"'.
                    $blockstatus.$clickaction.' value="1" />'.                     $blockstatus.$clickaction.' value="1"'.$disabled.' />'.
                    $types->{$block}.'</label></span>'."\n";                     $types->{$block}.'</label></span>'."\n";
         if ($block eq 'docs') {          if ($block eq 'docs') {
             if ($blockstatus ne '') {              if ($blockstatus ne '') {
Line 1340  sub blocker_checkboxes { Line 1405  sub blocker_checkboxes {
 }  }
   
 sub create_interval_form {  sub create_interval_form {
     my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo) = @_;      my ($intervals,$parmcount,$navmap,$currkey,$jschg,$itemname,$iteminfo,$disabled) = @_;
     return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));      return unless ((ref($intervals) eq 'HASH') && (ref($navmap)));
     my $intervalform;      my $intervalform;
     if (keys(%{$intervals}) > 0) {      if (keys(%{$intervals}) > 0) {
Line 1353  sub create_interval_form { Line 1418  sub create_interval_form {
                     $clickaction = ' onclick="'.$jschg.'"';                      $clickaction = ' onclick="'.$jschg.'"';
                 }                  }
                 $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                  $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                  '" value="course"'.$checked.$clickaction.' />';                                   '" value="course"'.$checked.$clickaction.$disabled.' />';
                 if ($currkey eq 'course') {                  if ($currkey eq 'course') {
                     $intervalform .= $itemname;                      $intervalform .= $itemname;
                 } else {                  } else {
Line 1378  sub create_interval_form { Line 1443  sub create_interval_form {
                             }                              }
                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                              $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                              '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.                                               '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
                                              $checked.$clickaction.' />';                                               $checked.$clickaction.$disabled.' />';
                             if ($currkey eq $map) {                              if ($currkey eq $map) {
                                 $intervalform .= $itemname.'</label>'.$iteminfo;                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
Line 1419  sub create_interval_form { Line 1484  sub create_interval_form {
                             }                              }
                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.                              $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                              '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.                                               '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
                                              $checked.$clickaction.' />';                                               $checked.$clickaction.$disabled.' />';
                             if ($currkey eq $resource) {                              if ($currkey eq $resource) {
                                 $intervalform .= $itemname.'</label>'.$iteminfo;                                  $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {                              } else {
Line 1449  sub create_interval_form { Line 1514  sub create_interval_form {
         if ($currkey ne '') {          if ($currkey ne '') {
             $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.              $intervalform = '<input type="radio" name="firstaccess_'.$parmcount.
                             '" checked="checked" value="'.                              '" checked="checked" value="'.
                             &HTML::Entities::encode($currkey,'"<>&').' />'.                              &HTML::Entities::encode($currkey,'"<>&').'"'.$disabled.' />'.
                             $itemname.'<br />';                              $itemname.'<br />';
         } else {          } else {
             $intervalform = &mt('No timed items defined.').' '.              $intervalform = &mt('No timed items defined.').' '.
Line 1495  sub blocktype_text { Line 1560  sub blocktype_text {
         'blogs' => 'Blogs',          'blogs' => 'Blogs',
         'docs' => 'Content',          'docs' => 'Content',
         'printout' => 'Printouts',          'printout' => 'Printouts',
           'passwd' => 'Change Password',
     );      );
     my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs'];      my $typeorder = ['com','chat','boards','port','groups','blogs','printout','docs','passwd'];
     return ($typeorder,\%types);      return ($typeorder,\%types);
 }  }
   

Removed from v.1.13  
changed lines
  Added in v.1.20


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