version 1.2, 2004/11/02 23:11:56
|
version 1.6, 2008/11/10 14:11:01
|
Line 26
|
Line 26
|
# |
# |
# 8/24 Guy Albertelli |
# 8/24 Guy Albertelli |
|
|
|
=pod |
|
|
|
=head1 NAME |
|
|
|
Apache::localstudentphoto |
|
|
|
=head1 SYNOPSIS |
|
|
|
Incoming data: none |
|
Returns '' |
|
|
|
=head1 OVERVIEW |
|
|
|
Prevents errors when undefined subroutines are called in this package. |
|
Will allow new routines added in the future to be called from lond etc. |
|
without the need for customized versions of local*.pm packages to be |
|
modified to include the new subroutines immediately. |
|
|
|
See I<"Programming Perl"> 3rd ed. pp 296-298. |
|
|
|
This is part of the LearningOnline Network with CAPA project |
|
described at http://www.lon-capa.org. |
|
|
|
=cut |
|
|
|
|
package localstudentphoto; |
package localstudentphoto; |
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
|
|
sub fetch { |
sub fetch { |
my ($domain,$user)=@_; |
my ($domain,$user,$pid,$response)=@_; |
|
my $temptxt = ''; |
|
unless (ref($response)) { |
|
$response = \$temptxt; |
|
} |
|
if ($udom eq '' || $uname eq '') { |
|
$$response = 'nouser'; |
|
return ''; |
|
} |
return &main::propath($domain,$user). |
return &main::propath($domain,$user). |
'/userfiles/internal/studentphoto.jpg'; |
'/userfiles/internal/studentphoto.jpg'; |
} |
} |
|
|
|
sub fetch_thumbnail { |
|
my ($udom,$uname) = @_; |
|
if ($udom eq '' || $uname eq '') { |
|
return ''; |
|
} |
|
my $userdir=&main::propath($udom,$uname); |
|
my $filepath = '/userfiles/internal/studentphoto.jpg'; |
|
my $thumbnail = '/userfiles/internal/studentphoto_tn.gif'; |
|
my $source = "$userdir/$filepath"; |
|
my $dest = "$userdir/$thumbnail"; |
|
if (-e $dest) { |
|
return $dest; |
|
} else { |
|
if (!-e $source) { |
|
my $file = &fetch($udom,$uname); |
|
} |
|
if (-e $source) { |
|
my ($fullsize,$thumbsize)=&localstudentphoto::thumbsettings($udom); |
|
if ($fullsize && $thumbsize) { |
|
system("convert -size $fullsize $source -thumbnail $thumbsize $dest"); |
|
} |
|
if (-e $dest) { |
|
return $dest; |
|
} |
|
} |
|
} |
|
return ''; |
|
} |
|
|
|
sub thumbsettings { |
|
my ($dom) = @_; |
|
my $fullsize = '240x240'; |
|
my $thumbsize = '40x40'; |
|
return ($fullsize,$thumbsize); |
|
} |
|
|
|
sub AUTOLOAD { |
|
our $AUTOLOAD; |
|
return ''; |
|
} |
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|
|
|