Diff for /loncom/interface/lonmsgdisplay.pm between versions 1.181.2.9.2.3 and 1.191

version 1.181.2.9.2.3, 2023/10/07 01:47:21 version 1.191, 2020/01/10 05:08:39
Line 111  use Apache::loncommunicate; Line 111  use Apache::loncommunicate;
 use Apache::lonfeedback;  use Apache::lonfeedback;
 use Apache::lonrss();  use Apache::lonrss();
 use Apache::lonselstudent();  use Apache::lonselstudent();
 use Apache::lonenc();  
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
Line 783  sub groupmail_header { Line 782  sub groupmail_header {
     if ($grouppagelink) {      if ($grouppagelink) {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
             ({href=>$grouppagelink,              ({href=>$grouppagelink,
               text=>&mt('Group').": $description",                text=>"Group: $description",
               title=>&mt("Go to group's home page"),                title=>"Go to group's home page"},);
               no_mt=>1,  
              },);  
     } else {      } else {
         &Apache::lonhtmlcommon::add_breadcrumb          &Apache::lonhtmlcommon::add_breadcrumb
             ({text=>&mt('Group').": $description",              ({text=>"Group: $description",});
               no_mt=>1,});  
     }      }
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb   
          ({href=>"/adm/email?compose=group&group=".            ({href=>"/adm/email?compose=group&group=".
                  "$env{'form.group'}&$refarg",                       "$env{'form.group'}&$refarg",
            text=>"Send a Message in a Group",                 text=>"Send a Message in a Group",
            title=>"Compose Group Message"},);                 title=>"Compose Group Message"},);
     if ($action eq 'sending') {      if ($action eq 'sending') {
             &Apache::lonhtmlcommon::add_breadcrumb              &Apache::lonhtmlcommon::add_breadcrumb
                          ({text=>"Messages being sent.",                           ({text=>"Messages being sent.",
                            title=>"E-mails sent"},);                             title=>"E-mails sent"},);
     }      }
     my $groupheader = &Apache::loncommon::start_page('Group Message');      my $groupheader = &Apache::loncommon::start_page('Group Message');
     $groupheader .= &Apache::lonhtmlcommon::breadcrumbs(      $groupheader .= &Apache::lonhtmlcommon::breadcrumbs
                                     &mt('Group messages - [_1]',$description),                  ('Group - '.$env{'form.group'}.' Email');
                                                         undef,undef,undef,undef,1);  
     return $groupheader;      return $groupheader;
 }  }
   
Line 913  sub discrit { Line 908  sub discrit {
 }  }
   
 sub sortedmessages {  sub sortedmessages {
     my ($blocked,$startblock,$endblock,$by_ip,$numblocked,$folder,$msgstatus) = @_;      my ($blocked,$startblock,$endblock,$numblocked,$folder,$msgstatus) = @_;
     my $suffix=&Apache::lonmsg::foldersuffix($folder);      my $suffix=&Apache::lonmsg::foldersuffix($folder);
     my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);      my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
     #unpack the varibles and repack into temp for sorting      #unpack the varibles and repack into temp for sorting
Line 945  sub sortedmessages { Line 940  sub sortedmessages {
     push(@temp1,$content{'recuser'},$content{'recdomain'});      push(@temp1,$content{'recuser'},$content{'recdomain'});
  }   }
         # Check whether message was sent during blocking period.          # Check whether message was sent during blocking period.
         if (($by_ip) ||          if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
             (($sendtime >= $startblock) && ($sendtime <= $endblock && $endblock > 0))) {  
             $$blocked{$msgid} = 'ON';              $$blocked{$msgid} = 'ON';
             $$numblocked ++;              $$numblocked ++;
         } else {           } else { 
Line 1073  sub disfolder { Line 1067  sub disfolder {
     my %blocked = ();      my %blocked = ();
     my %setters = ();      my %setters = ();
     my $numblocked = 0;      my $numblocked = 0;
     my $clientip = &Apache::lonnet::get_requestor_ip($r);      my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =  
         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);  
     my %js_lt = &Apache::lonlocal::texthash(      my %js_lt = &Apache::lonlocal::texthash(
                       sede => 'Select a destination folder to which the messages will be moved.',                        sede => 'Select a destination folder to which the messages will be moved.',
                       nome => 'No messages have been selected to apply this action to.',                        nome => 'No messages have been selected to apply this action to.',
Line 1119  sub disfolder { Line 1111  sub disfolder {
 ENDDISHEADER  ENDDISHEADER
   
     my $fsqs='&amp;folder='.$folder;      my $fsqs='&amp;folder='.$folder;
     my @temp=&sortedmessages(\%blocked,$startblock,$endblock,$by_ip,\$numblocked,$folder,$msgstatus);      my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
     my $totalnumber=$#temp+1;      my $totalnumber=$#temp+1;
     if ($totalnumber < 1) {      if ($totalnumber < 1) {
         $r->print('<p class="LC_info">');          $r->print('<p class="LC_info">');
Line 1132  ENDDISHEADER Line 1124  ENDDISHEADER
         }          }
         $r->print('</p>');          $r->print('</p>');
         if ($numblocked > 0) {          if ($numblocked > 0) {
             $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,$by_ip,$clientip,$blockdom,              $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
                                          \%setters));                                           \%setters));
         }          }
         return;          return;
Line 1322  ENDDISHEADER Line 1314  ENDDISHEADER
     $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /><input type="hidden" name="msgstatus" value="'.$msgstatus.'" /><input type="hidden" name="markedaction" value="" /></form>');      $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /><input type="hidden" name="msgstatus" value="'.$msgstatus.'" /><input type="hidden" name="markedaction" value="" /></form>');
     if ($numblocked > 0) {      if ($numblocked > 0) {
         $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,          $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
                                      $by_ip,$clientip,$blockdom,\%setters));                                       \%setters));
     }      }
 }  }
   
 sub blocked_in_folder {  sub blocked_in_folder {
     my ($numblocked,$startblock,$endblock,$by_ip,$clientip,$blockdom,$setters) = @_;      my ($numblocked,$startblock,$endblock,$setters) = @_;
     my $output;      my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
     if ($by_ip) {      my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
         $output = '<br /><br />'.      my $output = '<br /><br />'.
                   &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages is blocked for your current IP address: [_2].',$numblocked,$clientip).'<br />'.  
                   &mt('Note: communication is being blocked for certain IP address(es).');  
     } else {  
         my $beginblock = &Apache::lonlocal::locallocaltime($startblock);  
         my $finishblock = &Apache::lonlocal::locallocaltime($endblock);  
         $output = '<br /><br />'.  
                   &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock);                    &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock);
     }  
     #$output .= &Apache::loncommon::build_block_table($startblock,$endblock,      #$output .= &Apache::loncommon::build_block_table($startblock,$endblock,
     #                                                 $setters);      #                                                 $setters);
     my ($blocked, $blocktext) = &Apache::loncommon::blocking_status("com",$clientip);      
       my ($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
     $output .="<br /><br />".$blocktext;      $output .="<br /><br />".$blocktext;
   
     return $output;      return $output;
Line 1352  sub blocked_in_folder { Line 1338  sub blocked_in_folder {
 sub compout {  sub compout {
     my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode,      my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode,
         $multiforward)=@_;          $multiforward)=@_;
     my $clientip = &Apache::lonnet::get_requestor_ip($r);  
     my %setters;  
     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =  
         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);  
     if ($by_ip) {  
         my $showdom = &Apache::lonnet::domain($blockdom);  
         if ($showdom eq '') {  
             $showdom = $blockdom;  
         }  
         $r->print(&Apache::loncommon::start_page('Messages'));  
         $r->print(&Apache::lonhtmlcommon::breadcrumbs('Send and display messages'));  
         $r->print('<p class="LC_warning">'.  
                  &mt('Sending of LON-CAPA messages is blocked for your current IP address: [_1].',$clientip).'</p>'.  
                  '<ul><li>'.  
                  &mt('Note: communication is being blocked for certain IP address(es).').  
                  '</li><li>'.  
                  &mt('This restriction was set by an administrator in the [_1] LON-CAPA domain.',$showdom).  
                  '</li></ul>');  
         return;  
     }  
     my $suffix=&Apache::lonmsg::foldersuffix($folder);      my $suffix=&Apache::lonmsg::foldersuffix($folder);
     my ($cdom,$cnum,$group,$refarg);      my ($cdom,$cnum,$group,$refarg);
     if (exists($env{'form.group'})) {      if (exists($env{'form.group'})) {
Line 1451  sub compout { Line 1417  sub compout {
                     );                      );
     if (!$forwarding && !$multiforward) {      if (!$forwarding && !$multiforward) {
         $attachrow = '<tr><td colspan="3"><b>'.$lt{'atta'}.'</b> '.$attachmax{'text'}          $attachrow = '<tr><td colspan="3"><b>'.$lt{'atta'}.'</b> '.$attachmax{'text'}
             .': <input type="file" name="attachment" class="LC_flUpload" />'              .': <input type="file" name="attachment" class="LC_flUpload" multiple />'
             .'<input type="hidden" id="LC_free_space" value="'.$attachmax{'num'}.'" />'              .'<input type="hidden" id="LC_free_space" value="'.$attachmax{'num'}.'" />'
             .'</td></tr>';              .'</td></tr>';
     }      }
Line 2136  sub displaymessage { Line 2102  sub displaymessage {
     my %setters = ();      my %setters = ();
     my $numblocked = 0;      my $numblocked = 0;
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
     my $clientip = &Apache::lonnet::get_requestor_ip($r);  
   
 # info to generate "next" and "previous" buttons and check if message is blocked  # info to generate "next" and "previous" buttons and check if message is blocked
     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =       my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);      my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
     my @messages=&sortedmessages(\%blocked,$startblock,$endblock,$by_ip,\$numblocked,$folder,$msgstatus);  
     if ( $blocked{$msgid} eq 'ON' ) {      if ( $blocked{$msgid} eq 'ON' ) {
         &printheader($r,'/adm/email',&mt('Display a Message'));          &printheader($r,'/adm/email',&mt('Display a Message'));
         #$r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));          #$r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
         my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com",$clientip);          my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
         $r->print("<br />".$blocktext);          $r->print("<br />".$blocktext);
         return;          return;
     }      }
Line 2179  sub displaymessage { Line 2143  sub displaymessage {
   
   
     my $number_of_messages = scalar(@messages); #subtract 1 for last index      my $number_of_messages = scalar(@messages); #subtract 1 for last index
     my $head_extra;  
   
 # if student's view of resource will be included  
 # get <link> tag(s) for css file(s) in use, and pass to &header to include  
 # in call to loncommon::start_page()  
   
     if (($env{'request.course.id'} eq $content{'courseid'}) &&  
         (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {  
         my $symb;  
         if (defined($content{'symb'})) {  
             $symb = $content{'symb'};  
         } elsif (defined($content{'baseurl'})) {  
             $symb=&Apache::lonnet::symbread($content{'baseurl'});  
         }  
         if ($symb) {  
             $head_extra = &Apache::loncommon::css_links($symb);  
         }  
     }  
   
 # start output  # start output
     &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',      &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
                  $content{'baseurl'},$head_extra);  
   
 # Prepare available functions  # Prepare available functions
     my @functionlist;      my @functionlist;
Line 2504  sub displaymessage { Line 2448  sub displaymessage {
                               $showsymb,$env{'user.domain'},$env{'user.name'});                                $showsymb,$env{'user.domain'},$env{'user.name'});
                 if ($symb) {                  if ($symb) {
                     if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {                      if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
                         unless ($showsymb =~ m{^/enc/}) {                          $showsymb = &Apache::lonenc::check_encrypt($symb);
                             $showsymb = &Apache::lonenc::encrypted($showsymb);  
                         }  
                     }                      }
                     $symblink = '?symb='.$showsymb;                      $symblink = '?symb='.$showsymb;
                 }                  }
                 if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {                  if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
                     unless ($showurl =~ m{^/enc/}) {                      $showurl = $baseurl;
                         $showurl = &Apache::lonenc::encrypted($showurl);  
                     }  
                 }                  }
                 $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))                  $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
                          .'<a href="'.$showurl.$symblink.'">'.$restitle.'</a>'                           .'<a href="'.$showurl.$symblink.'">'.$restitle.'</a>'
Line 2707  sub displayresource { Line 2647  sub displayresource {
      && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {       && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
         my $symb;          my $symb;
         if (defined($content{'symb'})) {          if (defined($content{'symb'})) {
             $symb = &Apache::lonenc::check_decrypt($content{'symb'});              $symb = $content{'symb'};
         } elsif (defined($content{'baseurl'})) {          } else { 
             $symb =      $symb=&Apache::lonnet::symbread($content{'baseurl'});
                 &Apache::lonnet::symbread(&Apache::lonenc::check_decrypt($content{'baseurl'}));  
         }          }
 # Could not get a symb, give up  # Could not get a symb, give up
  unless ($symb) { return $content{'citation'}; }   unless ($symb) { return $content{'citation'}; }
           if ($symb =~ /ext\.tool$/) {
               return '<h2>'.&mt('Current transactions for student (if applicable)').'</h2>'.
               &Apache::loncommon::get_previous_attempt($symb,
                                                        $content{'sendername'},
                                                        $content{'senderdomain'},
                                                        $content{'courseid'});
           }
 # Have a symb, can render  # Have a symb, can render
  return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'.   return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'.
     &Apache::loncommon::get_previous_attempt($symb,      &Apache::loncommon::get_previous_attempt($symb,
Line 2739  sub displayresource { Line 2685  sub displayresource {
 # ================================================================== The Header  # ================================================================== The Header
   
 sub header {  sub header {
     my ($r,$title,$baseurl,$head_extra)=@_;      my ($r,$title,$baseurl)=@_;
     my $extra = &Apache::loncommon::studentbrowser_javascript();      my $extra = &Apache::loncommon::studentbrowser_javascript();
     if ($baseurl) {      if ($baseurl) {
  $extra .= "<base href=\"".&Apache::lonnet::absolute_url()."/$baseurl\" />";   $extra .= "<base href=\"".&Apache::lonnet::absolute_url()."/$baseurl\" />";
     }      }
     $extra .= '<script type="text/javascript"      $extra .= '<script type="text/javascript"
                 src="/res/adm/includes/file_upload.js"></script>';                  src="/res/adm/includes/file_upload.js"></script>';
     if ($head_extra) {  
         $extra .= "\n$head_extra";  
     }  
     $r->print(&Apache::loncommon::start_page('Messages',      $r->print(&Apache::loncommon::start_page('Messages',
   $extra));    $extra));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs      $r->print(&Apache::lonhtmlcommon::breadcrumbs
Line 2758  sub header { Line 2701  sub header {
 # ---------------------------------------------------------------- Print header  # ---------------------------------------------------------------- Print header
   
 sub printheader {  sub printheader {
     my ($r,$url,$desc,$title,$baseurl,$head_extra)=@_;      my ($r,$url,$desc,$title,$baseurl)=@_;
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
  ({href=>$url,   ({href=>$url,
   text=>$desc});    text=>$desc});
     &header($r,$title,$baseurl,$head_extra);      &header($r,$title,$baseurl);
 }  }
   
 # ------------------------------------------------------------ Store the comment  # ------------------------------------------------------------ Store the comment
Line 2819  sub sendoffmail { Line 2762  sub sendoffmail {
         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};          $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};          $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     }      }
     my $clientip = &Apache::lonnet::get_requestor_ip($r);      if ($env{'form.send'}) {
     my %setters;          if (!$env{'form.multiforward'}) {
     my ($startblock,$endblock,$triggerblock,$by_ip,$blockdom) =  
         &Apache::loncommon::blockcheck(\%setters,'com',$clientip);  
     if ($by_ip) {  
         &printheader($r,'','Sending messages blocked from your location.');  
         return 'blocked';  
     } elsif ($env{'form.send'}) {  
         if (!$env{'form.multiforward'}) {   
             if ($group eq '') {              if ($group eq '') {
         &printheader($r,'','Messages being sent.');          &printheader($r,'','Messages being sent.');
             } else {              } else {
Line 2857  sub sendoffmail { Line 2793  sub sendoffmail {
   
  my $mode = $env{'form.sendmode'};   my $mode = $env{'form.sendmode'};
  my (%toaddr,$tos,$cc,$bcc,$broadcast);   my (%toaddr,$tos,$cc,$bcc,$broadcast);
           my (%willtrust,%trustchecked,%disallowed);
           my $serverdefdom = &Apache::lonnet::default_login_domain();
   
  if ($mode eq 'group') {   if ($mode eq 'group') {
             if (defined($env{'form.courserecips'})) {              if (defined($env{'form.courserecips'})) {
Line 2866  sub sendoffmail { Line 2804  sub sendoffmail {
                 foreach my $dest (@to) {                  foreach my $dest (@to) {
                     my ($user,$domain) = split(/:/, $dest);                      my ($user,$domain) = split(/:/, $dest);
                     if (($user ne '') && ($domain ne '')) {                      if (($user ne '') && ($domain ne '')) {
                         my $rec = $user.":".$domain;                          unless ($trustchecked{$domain}) {
                         $toaddr{$rec} = '';                              $willtrust{$domain} = &Apache::lonnet::will_trust('msg',$serverdefdom,$domain);
                         $broadcast->{$rec} = '';                              $trustchecked{$domain} = 1;
                           }
                           if ($willtrust{$domain}) {
                               my $rec = $user.":".$domain;
                               $toaddr{$rec} = '';
                               $broadcast->{$rec} = '';
                           } else {
                               $disallowed{'to'}{$user.":".$domain} = 1; 
                           }
                     }                      }
                 }                  }
             }              }
Line 2879  sub sendoffmail { Line 2825  sub sendoffmail {
  if ($txt) {   if ($txt) {
                     $rec =~ s/^\s+//;                      $rec =~ s/^\s+//;
                     $rec =~ s/\s+$//;                      $rec =~ s/\s+$//;
     $toaddr{$rec}.=$txt."\n";                      my ($recuname,$recudom) = split(/:/,$rec);
                     $broadcast->{$rec} = '';                      unless ($trustchecked{$recudom}) {
                           $willtrust{$recudom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$recudom);
                           $trustchecked{$recudom} = 1;
                       }
                       if ($willtrust{$recudom}) {
           $toaddr{$rec}.=$txt."\n";
                           $broadcast->{$rec} = '';
                       } else {
                           $disallowed{'to'}{$rec} = 1;
                       }
  }   }
     }      }
  } else {   } else {
     if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {      if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {
  $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';                  unless ($trustchecked{$env{'form.recdomain'}}) {
                 $tos->{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';                      $willtrust{$env{'form.recdomain'}} = &Apache::lonnet::will_trust('msg',$serverdefdom,$env{'form.recdomain'});
                       $trustchecked{$env{'form.recdomain'}} = 1;
                   }
                   if ($willtrust{$env{'form.recdomain'}}) {
       $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
                       $tos->{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
                   } else {
                       $disallowed{'to'}{$env{'form.recuname'}.':'.$env{'form.recdomain'}}; 
                   }
     }      }
  }   }
         if ($env{'form.additionalrec_to'}) {          if ($env{'form.additionalrec_to'}) {
             foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_to'})) {              foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_to'})) {
                 my ($auname,$audom)=split(/:/,$rec);                  my ($auname,$audom)=split(/:/,$rec);
                 if (($auname ne "") && ($audom ne "")) {                  if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';                      unless ($trustchecked{$audom}) {
                     $tos->{$auname.':'.$audom}='';                          $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                           $trustchecked{$audom} = 1;
                       }
                       if ($willtrust{$audom}) {
                           $toaddr{$auname.':'.$audom}='';
                           $tos->{$auname.':'.$audom}='';
                       } else {
                           $disallowed{'to'}{$auname.':'.$audom};
                       }
                 }                  }
             }              }
         }          }
Line 2904  sub sendoffmail { Line 2875  sub sendoffmail {
             foreach my $rec (@toreplies) {              foreach my $rec (@toreplies) {
                 my ($auname,$audom)=split(/:/,$rec);                  my ($auname,$audom)=split(/:/,$rec);
                 if (($auname ne "") && ($audom ne "")) {                  if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';                      unless ($trustchecked{$audom}) {
                     $tos->{$auname.':'.$audom}='';                          $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                           $trustchecked{$audom} = 1;
                       }
                       if ($willtrust{$audom}) {
                           $toaddr{$auname.':'.$audom}='';
                           $tos->{$auname.':'.$audom}='';
                       } else {
                           $disallowed{'to'}{$auname.':'.$audom};
                       } 
                 }                  }
             }              }
         }          }
Line 2913  sub sendoffmail { Line 2892  sub sendoffmail {
     foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_cc'})) {      foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_cc'})) {
  my ($auname,$audom)=split(/:/,$rec);   my ($auname,$audom)=split(/:/,$rec);
  if (($auname ne "") && ($audom ne "")) {   if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';  
                     if (!defined($tos->{$auname.':'.$audom})) {                      if (!defined($tos->{$auname.':'.$audom})) {
         $cc->{$auname.':'.$audom}='';                          unless ($trustchecked{$audom}) {
                               $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                               $trustchecked{$audom} = 1;
                           }
                           if ($willtrust{$audom}) {
                               $toaddr{$auname.':'.$audom}='';
               $cc->{$auname.':'.$audom}='';
                           } else {
                               $disallowed{'cc'}{$auname.':'.$audom};
                           }
                     }                      }
  }   }
     }      }
Line 2926  sub sendoffmail { Line 2913  sub sendoffmail {
             foreach my $rec (@ccreplies) {              foreach my $rec (@ccreplies) {
                 my ($auname,$audom)=split(/:/,$rec);                  my ($auname,$audom)=split(/:/,$rec);
                 if (($auname ne "") && ($audom ne "")) {                  if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';  
                     if (!defined($tos->{$auname.':'.$audom})) {                      if (!defined($tos->{$auname.':'.$audom})) {
                         $cc->{$auname.':'.$audom}='';                          unless ($trustchecked{$audom}) {
                               $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                               $trustchecked{$audom} = 1;
                           }
                           if ($willtrust{$audom}) {
                               $toaddr{$auname.':'.$audom}='';
                               $cc->{$auname.':'.$audom}='';
                           } else {
                               $disallowed{'cc'}{$auname.':'.$audom} = 1;
                           }
                     }                      }
                 }                  }
             }              }
Line 2939  sub sendoffmail { Line 2934  sub sendoffmail {
             foreach my $rec (@groupreplies) {              foreach my $rec (@groupreplies) {
                 my ($auname,$audom)=split(/:/,$rec);                  my ($auname,$audom)=split(/:/,$rec);
                 if (($auname ne "") && ($audom ne "")) {                  if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';  
                     if (!defined($tos->{$auname.':'.$audom})) {                      if (!defined($tos->{$auname.':'.$audom})) {
                         $broadcast->{$auname.':'.$audom}='';                          unless ($trustchecked{$audom}) {
                               $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                               $trustchecked{$audom} = 1;
                           }
                           if ($willtrust{$audom}) {
                               $toaddr{$auname.':'.$audom}='';
                               $broadcast->{$auname.':'.$audom}='';
                           } else {
                               $disallowed{'to'}{$auname.':'.$audom} = 1;
                           }
                     }                      }
                 }                  }
             }              }
Line 2950  sub sendoffmail { Line 2953  sub sendoffmail {
             foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_bcc'})) {              foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_bcc'})) {
                 my ($auname,$audom)=split(/:/,$rec);                  my ($auname,$audom)=split(/:/,$rec);
                 if (($auname ne "") && ($audom ne "")) {                  if (($auname ne "") && ($audom ne "")) {
                     $toaddr{$auname.':'.$audom}='';                      if ((!defined($tos->{$auname.':'.$audom})) &&
                     if ((!defined($tos->{$auname.':'.$audom})) &&   
                         (!defined($cc->{$auname.':'.$audom}))) {                          (!defined($cc->{$auname.':'.$audom}))) {
                         $bcc->{$auname.':'.$audom}='';                          unless ($trustchecked{$audom}) {
                               $willtrust{$audom} = &Apache::lonnet::will_trust('msg',$serverdefdom,$audom);
                               $trustchecked{$audom} = 1;
                           }
                           if ($willtrust{$audom}) {
                               $toaddr{$auname.':'.$audom}='';
                               $bcc->{$auname.':'.$audom}='';
                           } else {
                               $disallowed{'bcc'}{$auname.':'.$audom} = 1;
                           }
                     }                      }
                 }                  }
             }              }
Line 2973  sub sendoffmail { Line 2984  sub sendoffmail {
         } else {          } else {
             $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});              $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
         }          }
         my %reciphash = (          my ($recipid, @recusers, @recudoms, %permresults);
                            to => $tos,          if (keys(%toaddr) > 0) {
                            cc => $cc,              my %reciphash = (
                            bcc => $bcc,                                 to => $tos,
                         );                                 cc => $cc,
         if ($mode eq 'group') {                                 bcc => $bcc,
             if ($group eq '') {                              );
                 $reciphash{'course_broadcast'} = $broadcast;              if ($mode eq 'group') {
             } else {                  if ($group eq '') {
                 if ($env{'form.groupmail'} eq 'cc') {                      $reciphash{'course_broadcast'} = $broadcast;
                     $reciphash{'group_cc_broadcast'} = $broadcast;  
                 } else {                  } else {
                     $reciphash{'group_bcc_broadcast'} = $broadcast;                      if ($env{'form.groupmail'} eq 'cc') {
                           $reciphash{'group_cc_broadcast'} = $broadcast;
                       } else {
                           $reciphash{'group_bcc_broadcast'} = $broadcast;
                       }
                 }                  }
             }              }
         }              ($recipid,my $recipstatus) = 
         my ($recipid,$recipstatus) =                   &Apache::lonmsg::store_recipients($msgsubj,$env{'user.name'},
             &Apache::lonmsg::store_recipients($msgsubj,$env{'user.name'},                                                    $env{'user.domain'},\%reciphash);
                                        $env{'user.domain'},\%reciphash);              if ($recipstatus ne 'ok') {
         if ($recipstatus ne 'ok') {                  &Apache::lonnet::logthis('Failed to store To, Bcc and Cc recipients for '.$env{'user.name'}.':'.$env{'user.domain'});
             &Apache::lonnet::logthis('Failed to store To, Bcc and Cc recipients for '.$env{'user.name'}.':'.$env{'user.domain'});  
         }  
         if ($env{'form.attachment'}) {  
             if (length($env{'form.attachment'}) <= 1048576) {  
                 $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback/'.$now);  
             } else {  
                 $r->print('<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>');  
             }              }
         } elsif ($env{'form.multiforward'}) {              if ($env{'form.attachment'}) {
             if ($env{'form.attachmenturl'} ne '') {                  if (length($env{'form.attachment'}) <= 1048576) {
                 $attachmenturl = $env{'form.attachmenturl'};                      $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback/'.$now);
                   } else {
                       $r->print('<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>');
                   }
               } elsif ($env{'form.multiforward'}) {
                   if ($env{'form.attachmenturl'} ne '') {
                       $attachmenturl = $env{'form.attachmenturl'};
                   }
             }              }
         }          }
         my @recusers;  
         my @recudoms;  
         my %permresults;  
  foreach my $address (sort(keys(%toaddr))) {   foreach my $address (sort(keys(%toaddr))) {
     my ($recuname,$recdomain)=split(/\:/,$address);      my ($recuname,$recdomain)=split(/\:/,$address);
             my $msgtxt = $savemsg;              my $msgtxt = $savemsg;
Line 3146  sub sendoffmail { Line 3157  sub sendoffmail {
                 $r->print($message);                  $r->print($message);
             }              }
         }          }
           if (keys(%disallowed)) {
               if ((ref($disallowed{'to'}) eq 'HASH') && (keys(%{$disallowed{'to'}}) > 0)) {
                   $r->print(&mt("The following recipients were excluded because the user's domain does not accept messages from server's domain:").'<ul><li>'.
                             join("</li><li>\n",sort(keys(%{$disallowed{'to'}}))).
                             '</li><ul><br />');
               }
               if (ref($disallowed{'cc'}) eq 'HASH') {
                   $r->print(&mt("The following CCs were excluded because the user's domain does not accept messages from server's domain:").'<ul><li>'.
                             join("</li><li>\n",sort(keys(%{$disallowed{'cc'}}))).
                             '</li><ul><br />');
               }
               if (ref($disallowed{'bcc'}) eq 'HASH') {
                   $r->print(&mt("The following BCCs were excluded because the user's domain does not accept messages from server's domain:").'<ul><li>'.
                             join("</li><li>\n",sort(keys(%{$disallowed{'bcc'}}))).
                             '</li><ul><br />');
               }
           }
     } else {      } else {
         &printheader($r,'','Messages cancelled.');          &printheader($r,'','Messages cancelled.');
         return 'cancelled';          return 'cancelled';
Line 3171  sub handler { Line 3199  sub handler {
          'sendreply','compose','sendmail','critical','recname','recdom',           'sendreply','compose','sendmail','critical','recname','recdom',
          'recordftf','sortedby','folder','startdis','interdis',           'recordftf','sortedby','folder','startdis','interdis',
  'showcommentbaseurl','dismode','group','subject','text','ref',   'showcommentbaseurl','dismode','group','subject','text','ref',
          'msgstatus','btoken']);           'msgstatus']);
     $sqs='&amp;sortedby='.$env{'form.sortedby'};      $sqs='&amp;sortedby='.$env{'form.sortedby'};
   
 # ----------- Check if access was from balancer to server with existing session  
   
     if ($env{'form.btoken'}) {  
         my %info = &Apache::lonnet::tmpget($env{'form.btoken'});  
         &Apache::lonnet::tmpdel($env{'form.btoken'});  
         delete($env{'form.btoken'});  
         unless ($env{'form.display'}) {  
             if (($info{'display'}) && ($info{'mailrecip'})) {  
                 if (&unescape($info{'mailrecip'}) eq $env{'user.name'}.':'.$env{'user.domain'}) {  
                     $env{'form.display'} = &unescape($info{'display'});  
                 }  
             }  
         }  
     }  
   
 # ------------------------------------------------------ They checked for email  # ------------------------------------------------------ They checked for email
     &Apache::lonnet::put('email_status',{'recnewemail'=>0});      &Apache::lonnet::put('email_status',{'recnewemail'=>0});
   
Line 3443  sub handler { Line 3456  sub handler {
                 my $count = keys(%forwardfail);                  my $count = keys(%forwardfail);
                 my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);                  my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);
                 foreach my $key (keys(%forwardfail)) {                  foreach my $key (keys(%forwardfail)) {
                     $message .= '<br />'.&mt('Could not deliver forwarded message.').' ';                      $message .= '<br />'.&mt('Could not deliver forwarded message.').'</span> '.
                     if ($forwardfail{$key} eq 'blocked') {                                  &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
                         $message .= &mt('Sending messages is blocked from your IP address');  
                     } else {  
                         $message .= &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';  
                     }  
                 }                  }
                 $message = &Apache::loncommon::confirmwrapper($message);                  $message = &Apache::loncommon::confirmwrapper($message);
                 $r->print($message);                  $r->print($message);

Removed from v.1.181.2.9.2.3  
changed lines
  Added in v.1.191


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>