--- loncom/interface/loncommon.pm 2004/07/03 18:49:42 1.193 +++ loncom/interface/loncommon.pm 2004/09/24 22:07:34 1.214 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.193 2004/07/03 18:49:42 raeburn Exp $ +# $Id: loncommon.pm,v 1.214 2004/09/24 22:07:34 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -250,6 +250,8 @@ of the element the selection from the se =cut sub browser_and_searcher_javascript { + my ($mode)=@_; + if (!defined($mode)) { $mode='edit'; } my $resurl=&lastresurl(); return <$ENV{'request.course.fn'}.formdata"); - &get_unprocessed_cgi($ENV{'QUERY_STRING'},undef); - foreach (keys %ENV) { - if ($_ =~ m/^form\.(.+)$/) { - if (ref($ENV{$_}) eq 'ARRAY') { - my $valstr = join(",",@{$ENV{$_}}); - print FILE "$1 = $valstr\n"; - } else { - print FILE "$1 = $ENV{$_}\n"; - } - } - } - close(FILE); - } foreach (\$color,\$function,\$topic,\$component_help,\$faq,\$bug,\$origurl) { $$_ = &Apache::lonnet::escape($$_); } - if (!$stayOnPage) - { + if (!$stayOnPage) { $link = "javascript:helpMenu('open')"; - } - else - { + } else { $link = "javascript:helpMenu('display')"; } - my $banner_link = "/adm/helpmenu?page=banner&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp"; + my $banner_link = "/adm/helpmenu?page=banner&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp&stayonpage=$stayOnPage"; my $details_link = "/adm/helpmenu?page=body&color=$color&function=$function&topic=$topic&component_help=$component_help&faq=$faq&bug=$bug&origurl=$origurl&stamp=$timestamp"; - my $template .= <<"ENDTEMPLATE"; + my $template; + if ($text ne "") { + $template .= + "". + "
$text"; + } + $template .= <<"ENDTEMPLATE"; - (Help Menu) + (Help Menu) ENDTEMPLATE + if ($component_help) { + if (!$text) { + $template=&help_open_topic($component_help,undef,$stayOnPage, + $width,$height).' '.$template; + } else { + my $help_text; + $help_text=&Apache::lonnet::unescape($topic); + $template='
'. + &help_open_topic($component_help,$help_text,$stayOnPage, + $width,$height).''.$template. + '
'; + } + } + if ($text ne '') { $template.='
' }; return $template; } @@ -809,7 +812,7 @@ format. sub csv_translate { my $text = shift; $text =~ s/\"/\"\"/g; - $text =~ s/\n//g; + $text =~ s/\n/ /g; return $text; } @@ -860,7 +863,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; } @@ -1762,8 +1765,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.'"'; @@ -1789,17 +1803,21 @@ 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 { - my ($link,$un,$do)=@_; + my ($link,$username,$domain)=@_; return -"$link"; + ''.$link.''; } # --------------------------------------------------------------- Notes Wrapper @@ -1812,8 +1830,8 @@ sub noteswrapper { sub aboutmewrapper { my ($link,$username,$domain,$target)=@_; - return "$link"; + return ''.$link.''; } # ------------------------------------------------------------ Syllabus Wrapper @@ -1824,9 +1842,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 @@ -1893,6 +1930,9 @@ returns description of a specified copyr sub copyrightdescription { return &mt($cprtag{shift(@_)}); } + +=pod + =item * source_copyrightids() returns list of all source copyrights @@ -2304,7 +2344,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)); } ######################################### @@ -2515,10 +2555,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.'
'.$title. +'
'; } # @@ -2548,7 +2604,7 @@ $upperleft $realm  -
+
ENDBODY } @@ -3643,6 +3699,13 @@ sub icon { return $iconname; } +sub connection_aborted { + my ($r)=@_; + $r->print(" ");$r->rflush(); + my $c = $r->connection; + return $c->aborted(); +} + =pod =back