--- loncom/interface/spreadsheet/lonspreadsheet.pm 2011/09/26 15:48:06 1.60 +++ loncom/interface/spreadsheet/lonspreadsheet.pm 2013/01/08 16:21:12 1.63 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.60 2011/09/26 15:48:06 raeburn Exp $ +# $Id: lonspreadsheet.pm,v 1.63 2013/01/08 16:21:12 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -276,9 +276,21 @@ sub handler { $symb = $env{'form.usymb'} if (exists($env{'form.usymb'})); my $name = $env{'user.name'}; my $domain = $env{'user.domain'}; + my $warning; if (exists($env{'form.sname'}) && $env{'form.sname'} ne '') { - $name = $env{'form.sname'}; - $domain = $env{'form.sdomain'}; + if (($env{'form.sname'} ne $env{'user.name'}) || + ($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.sdomain'} = $domain; @@ -333,10 +345,10 @@ sub handler { ## my $js; if ($allowed_to_edit) { - my %lt=( + my %lt=&Apache::lonlocal::texthash( 'ce' => 'Cell', - 'ac' => 'Accept', - 'dc' => 'Discard Changes' + 'ac' => 'Save', + 'dc' => 'Cancel' ); my $extra_javascript = &Apache::loncommon::browser_and_searcher_javascript(); @@ -416,6 +428,9 @@ ENDSCRIPT # # Open the form # + if ($warning) { + $r->print('

'.$warning.'

'); + } $r->print('
'); $r->print(&hiddenfield('sname' ,$env{'form.sname'}). &hiddenfield('sdomain',$env{'form.sdomain'}). @@ -520,14 +535,11 @@ ENDSCRIPT ''. ''.$html."\n"); if ($action_message ne '') { - $r->print(< -Last Action: -   - $action_message - - -END + $r->print( + &Apache::loncommon::confirmwrapper( + &mt('Last Action:') + .$action_message) + ); } $r->rflush(); } else { @@ -543,13 +555,13 @@ END if ($allowed_to_view) { $r->print(''. &Apache::loncommon::help_open_topic("Spreadsheet_About", - 'Spreadsheet Help'). + &mt('Spreadsheet Help')). ''); } if ($allowed_to_edit) { $r->print(''. &Apache::loncommon::help_open_topic("Spreadsheet_Editing", - 'Editing Help'). + &mt('Editing Help')). ''); } $r->print('');