[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm lonmsgdisplay.pm

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Sat, 05 May 2007 03:14:21 -0000


This is a MIME encoded message

--raeburn1178334861
Content-Type: text/plain

raeburn		Fri May  4 23:14:21 2007 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm lonmsg.pm 
  Log:
  bug 5168.
  - users with srm priv can designate a reply-to address (which may not be the same as the sender's) for messages
  - users with srm priv can specify that a specific message should be eligible fo replies.
  - some modification of button display for critical messages for consistency with this.
  - Reply link elininated in essage display functions if message is not allowed relies
  - Critical message receipts go to reply to address (if different from original sender).
  
  
--raeburn1178334861
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20070504231421.txt"

Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.77 loncom/interface/lonmsgdisplay.pm:1.78
--- loncom/interface/lonmsgdisplay.pm:1.77	Fri May  4 22:50:27 2007
+++ loncom/interface/lonmsgdisplay.pm	Fri May  4 23:14:21 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.77 2007/05/05 02:50:27 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.78 2007/05/05 03:14:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -738,19 +738,26 @@
             '<br /><pre>'.
               &Apache::lontexconvert::msgtexconverted($content{'message'}).
             '</pre><small>';
-        my $rec_button = &mt('Move to Inbox');
-        my $reprec_button = &mt('Move to Inbox/Compose reply');
+        my ($rec_button,$reprec_button);
+        $rec_button = &mt('Move to Inbox');
+        if (!$content{'noreplies'}) {
+            $reprec_button = &mt('Move to Inbox/Compose reply');
+        }
         if ($content{'sendback'}) {
             $rec_button = &mt('Confirm Receipt');
-            $reprec_button = &mt('Confirm Receipt and Reply');
+            if (!$content{'noreplies'}) {
+                $reprec_button = &mt('Confirm Receipt and Reply');
+            }
             $result .= &mt('You have to confirm that you have received this message before you can view other pages. After confirmation, this message will be moved to your regular inbox');
         } else {
-            $result .= &mt('Click one of the buttons below to move the message to your inbox').' '.&mt('Access to other pages will be prevented until you have done this.');
+            $result .= &mt('Access to other pages will be prevented until you have moved the message to your inbox.'); 
         }
         $result .= '</small><br />'.
-            '<input type="submit" name="rec_'.$key.'" value="'.$rec_button.'" />'.
-            '<input type="submit" name="reprec_'.$key.'" '.
+            '<input type="submit" name="rec_'.$key.'" value="'.$rec_button.'" />';
+        if (!$content{'noreplies'}) {
+            $result .= '<input type="submit" name="reprec_'.$key.'" '.
                   'value="'.$reprec_button.'" />';
+        }
     }
     # Check to see if there were any messages.
     if ($result eq '') {
@@ -1217,6 +1224,8 @@
     my %lt=&Apache::lonlocal::texthash('us'  => 'Username',
 				       'do'  => 'Domain',
 				       'ad'  => 'Additional Recipients',
+                                       'rt'  => 'Reply to',
+                                       'ar'  => 'Allow replies',
 				       'sb'  => 'Subject',
 				       'ca'  => 'Cancel',
 				       'ma'  => 'Mail',
@@ -1327,14 +1336,36 @@
     } 
     if (($broadcast ne 'group') && ($broadcast ne 'upload')) {
 	if ($replying) {
-	    $r->print('<tr><td colspan="2">'.&mt('Replying to').' '.
-		      &Apache::loncommon::aboutmewrapper(
+            if ($content{'noreplies'}) {
+                $r->print('<tr><td>'.&mt('This message was designated by the sender not to allow replies.').'</td></tr></table></form>');
+                return;
+            }
+            $r->print('<tr><td colspan="2">'.&mt('Replying to').' ');
+            if ($content{'replytoaddr'}) {
+                my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+                if ($replytoname ne '' && $replytodom ne '') {
+                    $r->print(&Apache::loncommon::plainname($replytoname,
+                                 $replytodom).' ('.$replytoname.':'.
+                                 $replytodom.')');
+                    $r->print('<input type="hidden" name="recuname" value="'.
+                          $replytoname.'" />'.
+                          '<input type="hidden" name="recdomain" value="'.
+                          $replytodom.'" /></td></tr>');
+
+                } else {
+                    $r->print(&mt('The sender did not designate a reply to address for this message.').'</td></tr></table>');
+                    return;
+                }
+            } else {
+	        $r->print(&Apache::loncommon::aboutmewrapper(
 							 &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
 		      $content{'sendername'}.':'.
-		      $content{'senderdomain'}.')'.
-		      '<input type="hidden" name="recuname" value="'.$content{'sendername'}.'" />'.
-		      '<input type="hidden" name="recdomain" value="'.$content{'senderdomain'}.'" />'.
-		      '</td></tr>');
+		      $content{'senderdomain'}.')');
+                $r->print('<input type="hidden" name="recuname" value="'.
+		          $content{'sendername'}.'" />'.
+		          '<input type="hidden" name="recdomain" value="'.
+                          $content{'senderdomain'}.'" /></td></tr>');
+            }
             if ($content{'recipid'}) {
                 my @ccs = &retrieve_cc_recips('replying',%content);
                 if (@ccs > 0) {
@@ -1387,6 +1418,11 @@
     } elsif ($broadcast ne 'upload') {
         $subj_size = '50';
         $r->print(&additional_rec_row(\%lt));
+        if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+            || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+                                        '/'.$env{'request.course.sec'})) {
+            $r->print(&reply_to_row(\%lt));
+        }
         $r->print(&msg_subject_row($dissub,\%lt,$subj_size));
         $r->print(<<"ENDCOMP");
 </table>
@@ -1461,13 +1497,21 @@
       &Apache::loncommon::selectstudent_link('compemail','recuname',
                                              'recdomain');
     my $output = <<"ENDREC";
-<tr><td>$lt{'us'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recname'}" /></td><td rowspan="2">$selectlink</td></tr>
-<tr><td>$lt{'do'}:</td>
-<td>$domform</td></tr>
+<tr><td colspan="2"><span class="LC_nobreak">$lt{'us'}:&nbsp;<input type="text" size="12" name="recuname" value="$env{'form.recname'}" />&nbsp;$lt{'do'}:&nbsp;$domform&nbsp;&nbsp;$selectlink</span></td></tr>
 ENDREC
     return $output;
 }
 
+sub reply_to_row {
+    my ($lt) = @_;
+    my $radioyes = &mt('Yes');
+    my $radiono = &mt('No');
+    my $output = <<"ENDREP";
+<tr><td colspan="2"><span class="LC_nobreak">$lt->{'ar'}:<label><input type="radio" name="can_reply" value="Y" checked="checked" />$radioyes</label>&nbsp;&nbsp;<label><input type="radio" name="can_reply" value="N" />$radiono</label></span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="LC_nobreak">$lt->{'rt'}:&nbsp;<input type="text" size="25" name="reply_to_addr" value="$env{'user.name'}:$env{'user.domain'}" /></span></td></tr>
+ENDREP
+    return $output;
+}
+
 sub additional_rec_row {
     my ($lt) = @_;
     my $cc = &mt('Cc:');
@@ -1475,8 +1519,8 @@
     my $output = <<"ENDADD";
 <tr><td>$lt->{'ad'} :<br /><tt>username:domain,username:domain, ...
 </tt></td><td>&nbsp;<span class="span.LC_nobreak">$cc 
-<input type="text" size="50" name="additionalrec_cc" /></nospan><br />
-<span class="span.LC_nobreak">$bcc <input type="text" size="50" name="additionalrec_bcc" /></nospan></td></tr>
+<input type="text" size="50" name="additionalrec_cc" /></span><br />
+<span class="span.LC_nobreak">$bcc <input type="text" size="50" name="additionalrec_bcc" /></span></td></tr>
 ENDADD
     return $output;
 }
@@ -1494,7 +1538,7 @@
 
 sub msg_subject_row {
     my ($dissub,$lt,$subj_size,$extra) = @_;
-    my $output = '<tr><td>'.$lt->{'sb'}.':</td><td><input type="text" size="'.
+    my $output = '<tr><td colspan="2">'.$lt->{'sb'}.':&nbsp;<input type="text" size="'.
                  $subj_size.'" name="subject" value="'.$dissub.'" />'.$extra.
                  '</td></tr>';
     return $output;
@@ -2035,10 +2079,12 @@
     &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
     my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
 # Functions
-    $r->print('<table border="2" width="100%"><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
-	      '<td><a href="/adm/email?replyto='.&escape($msgid).$sqs.
-	      '"><b>'.&mt('Reply').'</b></a></td>'.
-	      '<td><a href="/adm/email?forward='.&escape($msgid).$sqs.
+    $r->print('<table border="2" width="100%"><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>');
+    if (!$content{'noreplies'}) {
+        $r->print('<td><a href="/adm/email?replyto='.&escape($msgid).$sqs.
+	          '"><b>'.&mt('Reply').'</b></a></td>');
+    }
+    $r->print('<td><a href="/adm/email?forward='.&escape($msgid).$sqs.
 	      '"><b>'.&mt('Forward').'</b></a></td>'.
 	      '<td><a href="/adm/email?markunread='.&escape($msgid).$sqs.
 	      '"><b>'.&mt('Mark Unread').'</b></a></td>'.
@@ -2082,7 +2128,7 @@
                &Apache::loncommon::plainname($content{'recuser'}[$i],
                                       $content{'recdomain'}[$i]),
                   $content{'recuser'}[$i],$content{'recdomain'}[$i]).
-           ' ('.$content{'recuser'}[$i].' at '.$content{'recdomain'}[$i].') ';
+           ' ('.$content{'recuser'}[$i].' '.&mt('at').' '.$content{'recdomain'}[$i].') ';
         }
     }
     $tolist = join(', ',@recipients);
@@ -2105,16 +2151,35 @@
     $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'});
     if ($folder eq 'sent') {
         $r->print('<br /><b>'.&mt('To').':</b> '.$tolist);
+        if ($content{'replytoaddr'}) {
+            my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+            if ($replytoname ne '' && $replytodom ne '') {
+                $r->print('<br /><b>'.&mt('Reply To').':</b> '.
+                          $replytoname.' '.&mt('at').' '.$replytodom);
+            }
+        }
     } else {
         $r->print('<br /><b>'.&mt('From').':</b> '.
 	      &Apache::loncommon::aboutmewrapper(
 						 &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
-						 $content{'sendername'},$content{'senderdomain'}).' ('.
-	      $content{'sendername'}.' at '.
-	      $content{'senderdomain'}.') ');
-        if ($cclist) {
-            $r->print('<br /><b>'.&mt('Cc').':</b> '.$cclist);
-        }
+						 $content{'sendername'},$content{'senderdomain'}));
+        if ($content{'noreplies'}) {
+            $r->print(' ('.&mt('No replies to sender').')'); 
+        } else {
+            if ($content{'replytoaddr'}) {
+                my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
+                if ($replytoname ne '' && $replytodom ne '') {
+                    $r->print('<br /><b>'.&mt('Reply To').':</b> '.
+                              $replytoname.' '.&mt('at').' '.$replytodom);
+                }
+            } else {
+                $r->print(' ('.$content{'sendername'}.' '&mt('at').' '.
+                          $content{'senderdomain'}.') ');
+            }
+            if ($cclist) {
+                $r->print('<br /><b>'.&mt('Cc').':</b> '.$cclist);
+            }
+        } 
     }
     if ($content{'courseid'}) {
         $r->print('<br /><b>'.&mt($crstype).':</b> '.$courseinfo{'description'});
@@ -2527,7 +2592,7 @@
                            \@recudoms);
                     }
                 } else {
-                    &Apache::lonnet::logthis('Failed to create record of critical, broadcast or archived message in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
+                    &Apache::lonnet::logthis('Failed to create record of critical, broadcast or archived message in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' '&mt('at').' '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
                 }
             } else {
                 my $stamp = time;
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.203 loncom/interface/lonmsg.pm:1.204
--- loncom/interface/lonmsg.pm:1.203	Wed May  2 16:26:08 2007
+++ loncom/interface/lonmsg.pm	Fri May  4 23:14:21 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.203 2007/05/02 20:26:08 albertel Exp $
+# $Id: lonmsg.pm,v 1.204 2007/05/05 03:14:21 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -163,6 +163,17 @@
     if (defined($recipid)) {
         $result.= '<recipid>'.$recipid.'</recipid>';
     }
+    if ($env{'form.can_reply'} eq 'N') {
+        $result .= '<noreplies>1</noreplies>';
+    }
+    if ($env{'form.reply_to_addr'}) {
+        my ($replytoname,$replytodom) = split(/:/,$env{'form.reply_to_addr'});
+        if (!($replytoname eq $env{'user.name'} && $replytodom eq $env{'user.domain'})) {
+            if (&Apache::lonnet::homeserver($replytoname,$replytodom) ne 'no_host') {
+                $result .= '<replytoaddr>'.$env{'form.reply_to_addr'}.'</replytoaddr>';
+            }
+        }
+    }
     return ($msgid,$result);
 }
 
@@ -551,14 +562,24 @@
     my $msgid=shift;
     my %message=&Apache::lonnet::get('critical',[$msgid]);
     my %contents=&unpackagemsg($message{$msgid},1);
+    my $destname = $contents{'sendername'};
+    my $destdom = $contents{'senderdomain'};
+    if ($contents{'replytoaddr'}) {
+        my ($repname,$repdom) = split(/:/,$contents{'replytoaddr'});
+        if (&Apache::lonnet::homeserver($repname,$repdom) ne 'no_host') {
+            $destname = $repname;
+            $destdom = $repdom;    
+        }
+    }
     my $status='rec: '.($contents{'sendback'}?
-     &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
-                     &mt('Receipt').': '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}.', '.$contents{'subject'},
-                     &mt('User').' '.$env{'user.name'}.' '.&mt('at').' '.$env{'user.domain'}.
-                     ' acknowledged receipt of message'."\n".'   "'.
-                     $contents{'subject'}.'"'."\n".&mt('dated').' '.
-                     $contents{'time'}.".\n"
-                     ):'no msg req');
+     &user_normal_msg($destname,$destdom,&mt('Receipt').': '.$env{'user.name'}.
+                      ' '.&mt('at').' '.$env{'user.domain'}.', '.
+                      $contents{'subject'},&mt('User').' '.$env{'user.name'}.
+                      ' '.&mt('at').' '.$env{'user.domain'}.
+                      ' acknowledged receipt of message'."\n".'   "'.
+                      $contents{'subject'}.'"'."\n".&mt('dated').' '.
+                      $contents{'time'}.".\n"
+                      ):'no msg req');
     $status.=' trans: '.
      &Apache::lonnet::put(
      'nohist_email',{$contents{'msgid'} => $message{$msgid}});

--raeburn1178334861--