--- loncom/interface/spreadsheet/lonspreadsheet.pm 2011/09/26 15:48:06 1.60 +++ loncom/interface/spreadsheet/lonspreadsheet.pm 2011/09/26 18:17:44 1.61 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.60 2011/09/26 15:48:06 raeburn Exp $ +# $Id: lonspreadsheet.pm,v 1.61 2011/09/26 18:17:44 raeburn 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; @@ -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'}).