[LON-CAPA-cvs] cvs: loncom /interface lonfeedback.pm lonmsg.pm printout.pl /xml lonxml.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 23 Feb 2007 00:39:35 -0000
This is a MIME encoded message
--albertel1172191175
Content-Type: text/plain
albertel Thu Feb 22 19:39:35 2007 EDT
Modified files:
/loncom/interface lonmsg.pm lonfeedback.pm printout.pl
/loncom/xml lonxml.pm
Log:
- making error messages get sent again for print failures (BUG#2231)
- moving decide_receivers to lonmsg for easier inclusion/use by
cgi scripts
--albertel1172191175
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20070222193935.txt"
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.196 loncom/interface/lonmsg.pm:1.197
--- loncom/interface/lonmsg.pm:1.196 Fri Feb 9 10:30:48 2007
+++ loncom/interface/lonmsg.pm Thu Feb 22 19:39:31 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.196 2007/02/09 15:30:48 www Exp $
+# $Id: lonmsg.pm,v 1.197 2007/02/23 00:39:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -665,6 +665,100 @@
return %userfolders;
}
+sub secapply {
+ my $rec=shift;
+ my $defaultflag=shift;
+ $rec=~s/\s+//g;
+ $rec=~s/\@/\:/g;
+ my ($adr,$sections_or_groups)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
+ if ($sections_or_groups) {
+ foreach my $item (split(/\;/,$sections_or_groups)) {
+ if (($item eq $env{'request.course.sec'}) ||
+ ($defaultflag && ($item eq '*'))) {
+ return $adr;
+ } elsif ($env{'request.course.groups'}) {
+ my @usersgroups = split(/:/,$env{'request.course.groups'});
+ if (grep(/^\Q$item\E$/,@usersgroups)) {
+ return $adr;
+ }
+ }
+ }
+ } else {
+ return $rec;
+ }
+ return '';
+}
+
+=pod
+
+=over 4
+
+=item *
+
+decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag);
+
+Arguments
+ $feedurl - /res/ url of resource (only need if $author is true)
+ $author,$question,$course,$policy - all true/false parameters
+ if true will attempt to find the addresses of user that should receive
+ this type of feedback (author - feedback to author of resource $feedurl,
+ $question 'Resource Content Questions', $course 'Course Content Question',
+ $policy 'Course Policy')
+ (Additionally it also checks $env for whether the corresponding form.<name>
+ element exists, for ease of use in a html response context)
+
+ $defaultflag - (internal should be left blank) if true gather addresses
+ that aren't for a section even if I have a section
+ (used for reccursion internally, first we look for
+ addresses for our specific section then we recurse
+ and look for non section addresses)
+
+Returns
+ $typestyle - string of html text, describing what addresses were found
+ %to - a hash, which keys are addresses of users to send messages to
+ the keys will look like name:domain
+
+=cut
+
+sub decide_receiver {
+ my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
+ &Apache::lonenc::check_decrypt(\$feedurl);
+ my $typestyle='';
+ my %to=();
+ if ($env{'form.discuss'} eq 'author' ||$author) {
+ $typestyle.='Submitting as Author Feedback<br />';
+ $feedurl=~ m{^/res/($LONCAPA::domain_re)/($LONCAPA::username_re)/};
+ $to{$2.':'.$1}=1;
+ }
+ my $cid = $env{'request.course.id'};
+ if ($env{'form.discuss'} eq 'question' ||$question) {
+ $typestyle.=&mt('Submitting as Question').'<br />';
+ foreach my $item (split(/\,/,$env{'course.'.$cid.'.question.email'})) {
+ my $rec=&secapply($item,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
+ }
+ }
+ if ($env{'form.discuss'} eq 'course' ||$course) {
+ $typestyle.=&mt('Submitting as Comment').'<br />';
+ foreach my $item (split(/\,/,$env{'course.'.$cid.'.comment.email'})) {
+ my $rec=&secapply($item,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
+ }
+ }
+ if ($env{'form.discuss'} eq 'policy' ||$policy) {
+ $typestyle.=&mt('Submitting as Policy Feedback').'<br />';
+ foreach my $item (split(/\,/,$env{'course.'.$cid.'.policy.email'})) {
+ my $rec=&secapply($item,$defaultflag);
+ if ($rec) { $to{$rec}=1; }
+ }
+ }
+ if ((scalar(%to) eq '0') && (!$defaultflag)) {
+ ($typestyle,%to)=
+ &decide_receiver($feedurl,$author,$question,$course,$policy,1);
+ }
+ return ($typestyle,%to);
+}
+
1;
__END__
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.241 loncom/interface/lonfeedback.pm:1.242
--- loncom/interface/lonfeedback.pm:1.241 Mon Jan 22 20:27:17 2007
+++ loncom/interface/lonfeedback.pm Thu Feb 22 19:39:31 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Feedback
#
-# $Id: lonfeedback.pm,v 1.241 2007/01/23 01:27:17 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.242 2007/02/23 00:39:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2662,108 +2662,11 @@
return ($email,$citations);
}
-sub secapply {
- my $rec=shift;
- my $defaultflag=shift;
- $rec=~s/\s+//g;
- $rec=~s/\@/\:/g;
- my ($adr,$sections_or_groups)=($rec=~/^([^\(]+)\(([^\)]+)\)/);
- if ($sections_or_groups) {
- foreach my $item (split(/\;/,$sections_or_groups)) {
- if (($item eq $env{'request.course.sec'}) ||
- ($defaultflag && ($item eq '*'))) {
- return $adr;
- } elsif ($env{'request.course.groups'}) {
- my @usersgroups = split(/:/,$env{'request.course.groups'});
- if (grep(/^\Q$item\E$/,@usersgroups)) {
- return $adr;
- }
- }
- }
- } else {
- return $rec;
- }
- return '';
-}
-
-=pod
-
-=over 4
-
-=item *
-
-decide_receiver($feedurl,$author,$question,$course,$policy,$defaultflag);
-
-Arguments
- $feedurl - /res/ url of resource (only need if $author is true)
- $author,$question,$course,$policy - all true/false parameters
- if true will attempt to find the addresses of user that should receive
- this type of feedback (author - feedback to author of resource $feedurl,
- $question 'Resource Content Questions', $course 'Course Content Question',
- $policy 'Course Policy')
- (Additionally it also checks $env for whether the corresponding form.<name>
- element exists, for ease of use in a html response context)
-
- $defaultflag - (internal should be left blank) if true gather addresses
- that aren't for a section even if I have a section
- (used for reccursion internally, first we look for
- addresses for our specific section then we recurse
- and look for non section addresses)
-
-Returns
- $typestyle - string of html text, describing what addresses were found
- %to - a hash, which keys are addresses of users to send messages to
- the keys will look like name:domain
-
-=cut
-
-sub decide_receiver {
- my ($feedurl,$author,$question,$course,$policy,$defaultflag) = @_;
- &Apache::lonenc::check_decrypt(\$feedurl);
- my $typestyle='';
- my %to=();
- if ($env{'form.discuss'} eq 'author' ||$author) {
- $typestyle.='Submitting as Author Feedback<br />';
- $feedurl=~ m{^/res/($LONCAPA::domain_re)/($LONCAPA::username_re)/};
- $to{$2.':'.$1}=1;
- }
- if ($env{'form.discuss'} eq 'question' ||$question) {
- $typestyle.=&mt('Submitting as Question').'<br />';
- foreach my $item (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.question.email'})
- ) {
- my $rec=&secapply($item,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ($env{'form.discuss'} eq 'course' ||$course) {
- $typestyle.=&mt('Submitting as Comment').'<br />';
- foreach my $item (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.comment.email'})
- ) {
- my $rec=&secapply($item,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ($env{'form.discuss'} eq 'policy' ||$policy) {
- $typestyle.=&mt('Submitting as Policy Feedback').'<br />';
- foreach my $item (split(/\,/,
- $env{'course.'.$env{'request.course.id'}.'.policy.email'})
- ) {
- my $rec=&secapply($item,$defaultflag);
- if ($rec) { $to{$rec}=1; }
- }
- }
- if ((scalar(%to) eq '0') && (!$defaultflag)) {
- ($typestyle,%to)=
- &decide_receiver($feedurl,$author,$question,$course,$policy,1);
- }
- return ($typestyle,%to);
-}
sub feedback_available {
my ($question,$course,$policy)=@_;
- my ($typestyle,%to)=&decide_receiver('',0,$question,$course,$policy);
+ my ($typestyle,%to)=&Apache::lonmsg::decide_receiver('',0,$question,
+ $course,$policy);
return scalar(%to);
}
@@ -3840,7 +3743,7 @@
$usersaw,$useranswer);
# Who gets this?
- my ($typestyle,%to) = &decide_receiver($feedurl);
+ my ($typestyle,%to) = &Apache::lonmsg::decide_receiver($feedurl);
# Actually send mail
my ($status,$numsent)=&send_msg(&clear_out_html($env{'form.subject'},
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.121 loncom/interface/printout.pl:1.122
--- loncom/interface/printout.pl:1.121 Wed Feb 21 20:00:13 2007
+++ loncom/interface/printout.pl Thu Feb 22 19:39:31 2007
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
#
-# $Id: printout.pl,v 1.121 2007/02/22 01:00:13 albertel Exp $
+# $Id: printout.pl,v 1.122 2007/02/23 00:39:31 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,8 +128,8 @@
foreach my $line (@$texfile) {
$message .= "$line\n";
}
- my (undef, %receivers) = &Apache::lonfeedback::decide_receiver(undef, 0,
- 1,1,1);
+ my (undef, %receivers) = &Apache::lonmsg::decide_receiver(undef, 0,
+ 1,1,1);
# print "<br /> sending...section: $env{'request.course.sec'}";
foreach my $dest (keys %receivers) {
# print "<br /> dest is $dest";
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.439 loncom/xml/lonxml.pm:1.440
--- loncom/xml/lonxml.pm:1.439 Sat Feb 17 21:10:04 2007
+++ loncom/xml/lonxml.pm Thu Feb 22 19:39:35 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# $Id: lonxml.pm,v 1.439 2007/02/18 02:10:04 albertel Exp $
+# $Id: lonxml.pm,v 1.440 2007/02/23 00:39:35 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1567,7 +1567,7 @@
if ( $symb && $env{'request.course.id'} ) {
my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
- my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
+ my (undef,%users)=&Apache::lonmsg::decide_receiver(undef,0,1,1,1);
my $declutter=&Apache::lonnet::declutter($env{'request.filename'});
my $baseurl = &Apache::lonnet::clutter($declutter);
my @userlist;
--albertel1172191175--