--- loncom/interface/loncommon.pm 2012/08/07 10:52:17 1.1090 +++ loncom/interface/loncommon.pm 2012/08/14 15:45:06 1.1092 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1090 2012/08/07 10:52:17 foxr Exp $ +# $Id: loncommon.pm,v 1.1092 2012/08/14 15:45:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -70,6 +70,7 @@ use Apache::lonclonecourse(); use LONCAPA qw(:DEFAULT :match); use DateTime::TimeZone; use DateTime::Locale::Catalog; +use Text::Aspell; # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -3063,41 +3064,27 @@ Note: This sub assumes that aspell is in sub check_spelling { my ($wordlist, $language) = @_; + my @misspellings; + + # Generate the speller and set the langauge. + # if explicitly selected: - # Format the command. If $language is null then - # don't request a language - Note that's dangerous - # because there's no assurance the server is running the intended default - # language. - - my $langswitch = ''; + my $speller = Text::Aspell->new; if ($language) { - $langswitch = "--lang=$language"; + $speller->set_option('lang', $language); } - my $aspell_command = "aspell -a $language"; - my $full_command = "echo $wordlist | $aspell_command"; - - my $ispell_result = `$full_command`; + # Turn the word list into an array of words by splittingon whitespace - # The result is several lines of text. - # the first line will start with @(#). Other wise - # There's an error. With an error our fallback is to declare - # all the words are correctly spelled (return empty string). + my @words = split(/\s+/, $wordlist); - my @misspellings; - my @lines = split(/\n/, $ispell_result); - my $heading = shift(@lines); # header - if ($heading =~ /^\@\(#\) /) { - foreach my $word (split(/\s+/, $wordlist)) { - my $spellok = pop(@lines); - if (!($spellok =~ /^\*/)) { - push(@misspellings, $word); - } + foreach my $word (@words) { + if(! $speller->check($word)) { + push(@misspellings, $word); } - return join(' ', (@misspellings)); # empty if all words ok. - } else { - return ""; } + return join(' ', @misspellings); + } # -------------------------------------------------------------- Plaintext name @@ -13885,6 +13872,20 @@ sub init_user_environment { \%userenv,\%domdef,\%is_adv); } + $userenv{'canrequest.author'} = + &Apache::lonnet::usertools_access($username,$domain,'requestauthor', + 'reload','requestauthor', + \%userenv,\%domdef,\%is_adv); + my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], + $domain,$username); + my $reqstatus = $reqauthor{'author_status'}; + if ($reqstatus eq 'approval' || $reqstatus eq 'approved') { + if (ref($reqauthor{'author'}) eq 'HASH') { + $userenv{'requestauthorqueued'} = $reqstatus.':'. + $reqauthor{'author'}{'timestamp'}; + } + } + $env{'user.environment'} = "$lonids/$cookie.id"; if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",