Annotation of loncom/auth/localstudentphoto.pm, revision 1.6

1.1       albertel    1: # The LON-CAPA dummy student photo fetch mechnism
                      2: #
1.6     ! jms         3: # $Id: localstudentphoto.pm,v 1.5 2008/11/10 13:20:24 jms Exp $
1.1       albertel    4: #
                      5: # Copyright Michigan State University Board of Trustees
                      6: #
                      7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      8: #
                      9: # LON-CAPA is free software; you can redistribute it and/or modify
                     10: # it under the terms of the GNU General Public License as published by
                     11: # the Free Software Foundation; either version 2 of the License, or
                     12: # (at your option) any later version.
                     13: #
                     14: # LON-CAPA is distributed in the hope that it will be useful,
                     15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     17: # GNU General Public License for more details.
                     18: #
                     19: # You should have received a copy of the GNU General Public License
                     20: # along with LON-CAPA; if not, write to the Free Software
                     21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     22: #
                     23: # /home/httpd/html/adm/gpl.txt
                     24: #
                     25: # http://www.lon-capa.org/
                     26: #
                     27: # 8/24 Guy Albertelli
                     28: 
1.6     ! jms        29: =pod
        !            30: 
        !            31: =head1 NAME
        !            32: 
        !            33: Apache::localstudentphoto
        !            34: 
        !            35: =head1 SYNOPSIS
        !            36: 
        !            37: Incoming data: none
        !            38: Returns ''
        !            39: 
        !            40: =head1 OVERVIEW
        !            41: 
        !            42: Prevents errors when undefined subroutines are called in this package. 
        !            43: Will allow new routines added in the future to be called from lond etc.
        !            44: without the need for customized versions of local*.pm packages to be
        !            45: modified to include the new subroutines immediately.
        !            46: 
        !            47: See I<"Programming Perl"> 3rd ed. pp 296-298.
1.1       albertel   48: 
1.6     ! jms        49: This is part of the LearningOnline Network with CAPA project
        !            50: described at http://www.lon-capa.org.
        !            51: 
        !            52: =cut
1.5       jms        53: 
                     54: 
1.1       albertel   55: package localstudentphoto;
                     56: use lib '/home/httpd/lib/perl/';
                     57: use LONCAPA::Configuration;
                     58: 
                     59: sub fetch {
1.3       raeburn    60:     my ($domain,$user,$pid,$response)=@_;
                     61:     my $temptxt = '';
                     62:     unless (ref($response)) {
                     63:         $response = \$temptxt;
                     64:     }
                     65:     if ($udom eq '' || $uname eq '') {
                     66:         $$response = 'nouser';
                     67:         return '';
                     68:     }
1.2       albertel   69:     return &main::propath($domain,$user).
1.1       albertel   70: 	'/userfiles/internal/studentphoto.jpg';
                     71: }
                     72: 
1.3       raeburn    73: sub fetch_thumbnail {
                     74:     my ($udom,$uname) = @_;
                     75:     if ($udom eq '' || $uname eq '') {
                     76:         return '';
                     77:     }
                     78:     my $userdir=&main::propath($udom,$uname);
                     79:     my $filepath = '/userfiles/internal/studentphoto.jpg';
                     80:     my $thumbnail = '/userfiles/internal/studentphoto_tn.gif';
                     81:     my $source =  "$userdir/$filepath";
                     82:     my $dest = "$userdir/$thumbnail";
                     83:     if (-e $dest) {
                     84:         return $dest;
                     85:     } else {
                     86:         if (!-e $source) {
                     87:             my $file = &fetch($udom,$uname);
                     88:         }
                     89:         if (-e $source) {
                     90:             my ($fullsize,$thumbsize)=&localstudentphoto::thumbsettings($udom);
                     91:             if ($fullsize && $thumbsize) {
                     92:                 system("convert -size $fullsize $source -thumbnail $thumbsize $dest");
                     93:             }
                     94:             if (-e $dest) {
                     95:                 return $dest;
                     96:             }
                     97:         }
                     98:     }
                     99:     return '';
                    100: }   
                    101: 
                    102: sub thumbsettings {
                    103:     my ($dom) = @_;
                    104:     my $fullsize = '240x240';
                    105:     my $thumbsize = '40x40';
                    106:     return ($fullsize,$thumbsize);
                    107: }
1.4       raeburn   108:                                                                                 
                    109: sub AUTOLOAD {
                    110:     our $AUTOLOAD;
                    111:     return '';
                    112: }
1.3       raeburn   113: 
1.1       albertel  114: 1;
                    115: __END__
1.5       jms       116: 
                    117: 
                    118: 

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