--- loncom/interface/loncommon.pm 2004/07/26 21:57:27 1.203
+++ loncom/interface/loncommon.pm 2004/10/06 18:54:32 1.216
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.203 2004/07/26 21:57:27 albertel Exp $
+# $Id: loncommon.pm,v 1.216 2004/10/06 18:54:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -611,8 +611,9 @@ sub help_open_topic {
# Add the graphic
my $title = &mt('Online Help');
+ my $helpicon=&lonhttpdurl("/adm/help/gif/smallHelp.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.='' };
return $template;
@@ -667,9 +668,10 @@ sub help_open_menu {
my $template;
if ($text ne "") {
$template .=
- "
".
- "$text";
+ "".
+ "$text";
}
+ my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($component_help) {
if (!$text) {
@@ -743,8 +745,9 @@ sub help_open_bug {
# Add the graphic
my $title = &mt('Report a Bug');
+ my $bugicon=&lonhttpdurl("/adm/lonMisc/smallBug.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.=' | ' };
return $template;
@@ -787,8 +790,9 @@ sub help_open_faq {
# Add the graphic
my $title = &mt('View the FAQ');
+ my $faqicon=&lonhttpdurl("/adm/lonMisc/smallFAQ.gif");
$template .= <<"ENDTEMPLATE";
-
+
ENDTEMPLATE
if ($text ne '') { $template.=' |
' };
return $template;
@@ -812,7 +816,7 @@ format.
sub csv_translate {
my $text = shift;
$text =~ s/\"/\"\"/g;
- $text =~ s/\n//g;
+ $text =~ s/\n/ /g;
return $text;
}
@@ -863,7 +867,7 @@ sub define_excel_formats {
$format->{'h2'} = $workbook->add_format(bold=>1, size=>16);
$format->{'h3'} = $workbook->add_format(bold=>1, size=>14);
$format->{'date'} = $workbook->add_format(num_format=>
- 'mmm d yyyy hh:mm AM/PM');
+ 'mm/dd/yyyy hh:mm:ss');
return $format;
}
@@ -1765,8 +1769,19 @@ if the user does not
sub nickname {
my ($uname,$udom)=@_;
- my %names=&Apache::lonnet::get('environment',
- ['nickname','firstname','middlename','lastname','generation'],$udom,$uname);
+ my %names;
+ if ($uname eq $ENV{'user.name'} &&
+ $udom eq $ENV{'user.domain'}) {
+ %names=('nickname' => $ENV{'environment.nickname'} ,
+ 'firstname' => $ENV{'environment.firstname'} ,
+ 'middlename' => $ENV{'environment.middlename'},
+ 'lastname' => $ENV{'environment.lastname'} ,
+ 'generation' => $ENV{'environment.generation'});
+ } else {
+ %names=&Apache::lonnet::get('environment',
+ ['nickname','firstname','middlename',
+ 'lastname','generation'],$udom,$uname);
+ }
my $name=$names{'nickname'};
if ($name) {
$name='"'.$name.'"';
@@ -1792,11 +1807,13 @@ Gets a users screenname and returns it a
sub screenname {
my ($uname,$udom)=@_;
- my %names=
- &Apache::lonnet::get('environment',['screenname'],$udom,$uname);
+ if ($uname eq $ENV{'user.name'} &&
+ $udom eq $ENV{'user.domain'}) {return $ENV{'environment.screenname'};}
+ my %names=&Apache::lonnet::get('environment',['screenname'],$udom,$uname);
return $names{'screenname'};
}
+
# ------------------------------------------------------------- Message Wrapper
sub messagewrapper {
@@ -1817,7 +1834,7 @@ sub noteswrapper {
sub aboutmewrapper {
my ($link,$username,$domain,$target)=@_;
- return ''.$link.'';
}
@@ -1829,9 +1846,28 @@ sub syllabuswrapper {
if ($fontcolor) {
$linktext=''.$linktext.'';
}
- return "$linktext";
+ return qq{$linktext};
+}
+
+sub track_student_link {
+ my ($linktext,$sname,$sdom,$target) = @_;
+ my $link ="/adm/trackstudent";
+ my $title = 'View recent activity';
+ if (defined($sname) && $sname !~ /^\s*$/ &&
+ defined($sdom) && $sdom !~ /^\s*$/) {
+ $link .= "?selected_student=$sname:$sdom";
+ $title .= ' of this student';
+ }
+ if (defined($target) && $target !~ /^\s*$/) {
+ $target = qq{target="$target"};
+ } else {
+ $target = '';
+ }
+ return qq{$linktext};
}
+
+
=pod
=back
@@ -2312,7 +2348,7 @@ sub maketime {
my %th=@_;
return POSIX::mktime(
($th{'seconds'},$th{'minutes'},$th{'hours'},
- $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,$th{'dlsav'}));
+ $th{'day'},$th{'month'}-1,$th{'year'}-1900,0,0,-1));
}
#########################################
@@ -2383,10 +2419,8 @@ sub domainlogo {
my $domain = &determinedomain(shift);
# See if there is a logo
if (-e '/home/httpd/html/adm/lonDomLogos/'.$domain.'.gif') {
- my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
- if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
- return '';
+ my $logo=&lonhttpdurl("/adm/lonDomLogos/$domain.gif");
+ return '';
} elsif(exists($Apache::lonnet::domaindescription{$domain})) {
return $Apache::lonnet::domaindescription{$domain};
} else {
@@ -2523,10 +2557,26 @@ END
'LON-CAPA: '.$title.'
';
} elsif ($ENV{'environment.remote'} eq 'off') {
# No Remote
+ my $roleinfo=(<
+
+
+ $ENV{'environment.firstname'}
+ $ENV{'environment.middlename'}
+ $ENV{'environment.lastname'}
+ $ENV{'environment.generation'}
+
+
+$role
+
+$realm
+
+
+ENDROLE
return $bodytag.&Apache::lonmenu::menubuttons($forcereg,'web',
$forcereg).
- '';
+ ''.$title.
+' | '.$roleinfo.'
';
}
#
@@ -2697,12 +2747,12 @@ returns cache-controlling header code
=cut
sub cacheheader {
- unless ($ENV{'request.method'} eq 'GET') { return ''; }
- my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime);
- my $output .='
+ unless ($ENV{'request.method'} eq 'GET') { return ''; }
+ my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime);
+ my $output .='
';
- return $output;
+ return $output;
}
=pod
@@ -2714,12 +2764,13 @@ specifies header code to not have cache
=cut
sub no_cache {
- my ($r) = @_;
- unless ($ENV{'request.method'} eq 'GET') { return ''; }
- #my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime);
- $r->no_cache(1);
- $r->header_out("Pragma" => "no-cache");
- #$r->header_out("Expires" => $date);
+ my ($r) = @_;
+ if ($ENV{'REQUEST_METHOD'} ne 'GET' &&
+ $ENV{'request.method'} ne 'GET') { return ''; }
+ my $date=strftime("%a, %d %b %Y %H:%M:%S GMT",gmtime(time));
+ $r->no_cache(1);
+ $r->header_out("Expires" => $date);
+ $r->header_out("Pragma" => "no-cache");
}
sub content_type {
@@ -3651,6 +3702,20 @@ sub icon {
return $iconname;
}
+sub lonhttpdurl {
+ my ($url)=@_;
+ my $lonhttpd_port=$Apache::lonnet::perlvar{'lonhttpdPort'};
+ if (!defined($lonhttpd_port)) { $lonhttpd_port='8080'; }
+ return 'http://'.$ENV{'SERVER_NAME'}.':'.$lonhttpd_port.$url;
+}
+
+sub connection_aborted {
+ my ($r)=@_;
+ $r->print(" ");$r->rflush();
+ my $c = $r->connection;
+ return $c->aborted();
+}
+
=pod
=back