Diff for /loncom/interface/spreadsheet/lonspreadsheet.pm between versions 1.55 and 1.55.6.1

version 1.55, 2009/07/08 17:55:10 version 1.55.6.1, 2011/10/09 00:28:03
Line 106  sub file_dialogs { Line 106  sub file_dialogs {
         $spreadsheet->filename($env{'form.savefilename'});          $spreadsheet->filename($env{'form.savefilename'});
         my $save_status = $spreadsheet->save();          my $save_status = $spreadsheet->save();
         if ($save_status ne 'ok') {          if ($save_status ne 'ok') {
             $message .= "An error occurred while saving the spreadsheet".              $message .= '<span class="LC_error">'.
                 "There error is:".$save_status;                  &mt('An error occurred while saving the spreadsheet. The error is: [_1].',
                       $save_status).'</span>';
         } else {          } else {
             $message .= "Spreadsheet saved as ".$spreadsheet->filename();              $message .= '<span class="LC_info">'.&mt('Spreadsheet saved as: [_1] .',
                           '<span class="LC_filename">'.$spreadsheet->filename().'</span>').
                           '</span>';
         }          }
     } elsif (exists($env{'form.newformula'}) &&       } elsif (exists($env{'form.newformula'}) && 
              exists($env{'form.cell'})       &&                exists($env{'form.cell'})       && 
Line 227  sub handler { Line 230  sub handler {
             $r->uri.":opa:0:0:Cannot modify spreadsheet";              $r->uri.":opa:0:0:Cannot modify spreadsheet";
         return HTTP_NOT_ACCEPTABLE;           return HTTP_NOT_ACCEPTABLE; 
     }      }
       my ($sheettype) = ($r->uri=~/\/(\w+)$/);
     my $courseid = $env{'request.course.id'};      my $courseid = $env{'request.course.id'};
   
       ##
       ## Check permissions
       my $allowed_to_edit = &Apache::lonnet::allowed('mgr',
                                                   $env{'request.course.id'});
       # Only those instructors/tas/whatevers with complete access
       # (not section restricted) are able to modify spreadsheets.
       my $allowed_to_view =  &Apache::lonnet::allowed('vgr',
                                                   $env{'request.course.id'});
       if (! $allowed_to_view) {
           $allowed_to_view = &Apache::lonnet::allowed('vgr',
                       $env{'request.course.id'}.'/'.$env{'request.course.sec'});
           # Those who are restricted by section are allowed to view.
           # The routines in lonstatistics which decide which students'
           # will be shown take care of the restriction by section.
       }
   
     #      #
     # Do not allow students to continue if standard or external grading is in      # Do not allow users without vgr or mgr priv to continue unless 
     # effect.      # grading type is set to spreadsheet.
     #      #
     if ($env{'request.role'} =~ /^st\./) {  
         if ($env{'course.'.$courseid.'.grading'} eq 'standard' ||      if ((!$allowed_to_view) && (!$allowed_to_edit)) {
     $env{'course.'.$courseid.'.grading'} eq 'external' ) {          if ($env{'course.'.$courseid.'.grading'} eq 'spreadsheet') {
             return HTTP_NOT_ACCEPTABLE;              if ($sheettype ne 'studentcalc') {
                   $r->internal_redirect('/adm/studentcalc');
                   return OK;
               }
           } else {
               $r->internal_redirect('/adm/quickgrades');
               return OK;
         }          }
     }      }
     #      #
Line 253  sub handler { Line 280  sub handler {
     }      }
     #      #
     # Determine basic information about the spreadsheet      # Determine basic information about the spreadsheet
     my ($sheettype) = ($r->uri=~/\/(\w+)$/);  
     #      #
     my $symb   = undef;      my $symb   = undef;
     $symb = $env{'form.usymb'} if (exists($env{'form.usymb'}));      $symb = $env{'form.usymb'} if (exists($env{'form.usymb'}));
     my $name   = $env{'user.name'};      my $name   = $env{'user.name'};
     my $domain = $env{'user.domain'};      my $domain = $env{'user.domain'};
       my $warning;
     if (exists($env{'form.sname'}) && $env{'form.sname'} ne '') {      if (exists($env{'form.sname'}) && $env{'form.sname'} ne '') {
         $name   = $env{'form.sname'};          if (($env{'form.sname'} ne $env{'user.name'}) ||
         $domain = $env{'form.sdomain'};              ($env{'form.sdomain'} ne $env{'user.domain'})) {
               if (($allowed_to_view) || ($allowed_to_edit)) {
                   if (&Apache::lonnet::homeserver($env{'form.sname'},$env{'form.sdomain'}) ne 'no_host') {
                       $name   = $env{'form.sname'};
                       $domain = $env{'form.sdomain'};
                   } else {
                       $warning = &mt('Requested user: "[_1]" does not exist; your own sheet is displayed instead.',$env{'form.sname'}.':'.$env{'form.sdomain'});
                   }
               } else {
                   $warning = &mt('Your current role is not permitted to display this sheet for the requested user: "[_1]"; your own sheet is displayed instead.',$env{'form.sname'}.':'.$env{'form.sdomain'});
               }
           }
     }      }
     $env{'form.sname'} = $name;      $env{'form.sname'} = $name;
     $env{'form.sdomain'} = $domain;      $env{'form.sdomain'} = $domain;
Line 276  sub handler { Line 314  sub handler {
                                                     $env{'request.course.id'});                                                      $env{'request.course.id'});
     }      }
   
     ##  
     ## Check permissions  
     my $allowed_to_edit = &Apache::lonnet::allowed('mgr',  
                                                 $env{'request.course.id'});  
     # Only those instructors/tas/whatevers with complete access  
     # (not section restricted) are able to modify spreadsheets.  
     my $allowed_to_view =  &Apache::lonnet::allowed('vgr',  
                                                 $env{'request.course.id'});  
     if (! $allowed_to_view) {  
         $allowed_to_view = &Apache::lonnet::allowed('vgr',  
                     $env{'request.course.id'}.'/'.$env{'request.course.sec'});  
         # Those who are restricted by section are allowed to view.  
         # The routines in lonstatistics which decide which students'   
         # will be shown take care of the restriction by section.  
     }  
     #      #
     # Only those able to view others grades will be allowed to continue       # Only those able to view others grades will be allowed to continue 
     # if they are not requesting their own.      # if they are not requesting their own.
     if ($sheettype eq 'classcalc') {      if ($sheettype eq 'classcalc') {
         if (! $allowed_to_view) {          if (!$allowed_to_view) {
     $env{'user.error.msg'}=              $r->internal_redirect('/adm/studentcalc');
  $r->uri.":vgr:0:0:Access Permission Denied";              return OK;
     return HTTP_NOT_ACCEPTABLE;   
  }   }
     }      }
     if ((($name   ne $env{'user.name'} ) ||      if ((($name   ne $env{'user.name'} ) ||
Line 403  ENDSCRIPT Line 425  ENDSCRIPT
           text  => 'Spreadsheet',            text  => 'Spreadsheet',
           faq   => 134,            faq   => 134,
           bug   => 'Spreadsheet'});            bug   => 'Spreadsheet'});
       my $settingslink = &Apache::lonhtmlcommon::coursepreflink(&mt('Grade display settings'),
                                                                 'grading');
       &Apache::lonhtmlcommon::add_breadcrumb_tool('advtools',$settingslink);
     $r->print(&Apache::loncommon::start_page('Grades Spreadsheet',$js).      $r->print(&Apache::loncommon::start_page('Grades Spreadsheet',$js).
               &Apache::lonhtmlcommon::breadcrumbs('Spreadsheet',                &Apache::lonhtmlcommon::breadcrumbs('Spreadsheet',
   'Spreadsheet_About').    'Spreadsheet_About'));
               '<form action="'.$r->uri.'" name="sheet" method="post">');      #
       # Open the form
       #
       if ($warning) {
           $r->print('<p class="LC_info">'.$warning.'</p>');
       }
       $r->print('<form action="'.$r->uri.'" name="sheet" method="post">');
     $r->print(&hiddenfield('sname'  ,$env{'form.sname'}).      $r->print(&hiddenfield('sname'  ,$env{'form.sname'}).
               &hiddenfield('sdomain',$env{'form.sdomain'}).                &hiddenfield('sdomain',$env{'form.sdomain'}).
               &hiddenfield('usymb'  ,$env{'form.usymb'}));                &hiddenfield('usymb'  ,$env{'form.usymb'}));

Removed from v.1.55  
changed lines
  Added in v.1.55.6.1


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