Annotation of loncom/publisher/lonunauthorized.pm, revision 1.10

1.1       www         1: # The LearningOnline Network
                      2: # Unauthorized to access construction space
                      3: #
1.10    ! www         4: # $Id: lonunauthorized.pm,v 1.9 2009/05/14 15:36:29 bisitz Exp $
1.1       www         5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: package Apache::lonunauthorized;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
                     34: use Apache::lonnet;
                     35: use Apache::loncacc;
1.2       www        36: use Apache::lonlocal;
1.6       albertel   37: use LONCAPA();
1.1       www        38: 
                     39: sub handler {
                     40:     my $r = shift;
1.2       www        41:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        42:     $r->send_http_header;
                     43:     return OK if $r->header_only;
                     44: 
                     45: # ------------------------------------------------------------ Print the screen
                     46: # Figure out who the user is and what they wanted to access
                     47: 
                     48:     my ($ownername,$ownerdomain)=
1.4       albertel   49:      &Apache::loncacc::constructaccess($env{'request.editurl'},$r->dir_config('lonDefDomain'));
1.1       www        50: # print header
1.5       albertel   51:     $r->print(&Apache::loncommon::start_page("Failed Access to Construction Space",
                     52: 					     undef,
                     53: 					     {'domain' => $ownerdomain,}));
1.1       www        54: # figure out what went wrong
                     55: 
                     56:     if ($ownerdomain) {
1.9       bisitz     57: 	$r->print('<p class="LC_error">'
1.8       bisitz     58:                  .&mt('The construction space for this resource is located on another server.')
1.9       bisitz     59:                  .'</p>'
                     60:                  .'<p>'
                     61:                  .&mt('Choose another server.')
1.8       bisitz     62:                  .'</p>');
1.1       www        63:         my $ownerhome=&Apache::lonnet::homeserver($ownername,$ownerdomain);
                     64:         unless ($ownerhome eq 'no_host') {
1.8       bisitz     65: 	    $r->print('<p>'
                     66:                      .&mt('Please log into [_1] to edit.'
                     67:                          ,'<tt>'.&Apache::lonnet::hostname($ownerhome).'</tt>')
                     68:                      .'</p>');
1.1       www        69:         }
1.10    ! www        70:     } elsif (!$env{'request.editurl'}) {
        !            71:         $r->print('<p class="LC_error">'
        !            72:                  .&mt('There may be a problem with the filename, e.g., you may be attempting to edit a versioned file (files in construction may not include a version number in front of the extension).')
        !            73:                  .'</p>');
1.1       www        74:     } else {
1.9       bisitz     75:         $r->print('<p class="LC_error">'
1.8       bisitz     76:                  .&mt('You do not have authoring privileges for this resource')
1.9       bisitz     77:                  .'</p>');
1.6       albertel   78:         my ($realownername)=
                     79: 	    ($env{'request.editurl'}=~m{/(?:~|priv/|home/)($LONCAPA::username_re)});
1.1       www        80:         my $realownerhome=
1.6       albertel   81: 	    &Apache::lonnet::homeserver($realownername,
                     82: 					$r->dir_config('lonDefDomain'));
1.1       www        83:         unless ($realownerhome eq 'no_host') {
1.8       bisitz     84:             my $plainname=&Apache::loncommon::plainname($realownername,$r->dir_config('lonDefDomain'));
1.9       bisitz     85:             my $user=$realownername.':'.$r->dir_config('lonDefDomain');
1.8       bisitz     86:             my $userlink=&Apache::loncommon::aboutmewrapper(
                     87:                              $plainname.' ('.$user.')'
                     88:                             ,$realownername
                     89:                             ,$r->dir_config('lonDefDomain'));
                     90: 	    $r->print('<p>'
                     91:                      .&mt('Contact [_1] for access.',$userlink)
                     92:                      .'</p>');
1.1       www        93:         }
                     94:     }
                     95:     
1.5       albertel   96:     $r->print(&Apache::loncommon::end_page());
1.1       www        97:     return OK;
                     98: } 
                     99: 
                    100: 1;
                    101: __END__

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