Diff for /loncom/interface/lonmsg.pm between versions 1.37 and 1.44

version 1.37, 2002/08/28 14:11:27 version 1.44, 2002/12/27 14:59:42
Line 119  sub unpackmsgid { Line 119  sub unpackmsgid {
     return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});      return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
 }   } 
   
   # ============================================================= Check for email
   
   sub newmail {
       if ((time-$ENV{'user.mailcheck.time'})>300) {
           my %what=&Apache::lonnet::get('email_status',['recnewemail']);
           &Apache::lonnet::appenv('user.mailcheck.time'=>time);
           if ($what{'recnewemail'}>0) { return 1; }
       }
       return 0;
   }
   
 # =============================== Automated message to the author of a resource  # =============================== Automated message to the author of a resource
   
 sub author_res_msg {  sub author_res_msg {
Line 141  sub author_res_msg { Line 152  sub author_res_msg {
   
 # ================================================== Critical message to a user  # ================================================== Critical message to a user
   
 sub user_crit_msg {  sub user_crit_msg_raw {
     my ($user,$domain,$subject,$message,$sendback)=@_;      my ($user,$domain,$subject,$message,$sendback)=@_;
 # Check if allowed missing  # Check if allowed missing
     my $status='';      my $status='';
Line 168  sub user_crit_msg { Line 179  sub user_crit_msg {
     return $status;      return $status;
 }  }
   
   # New routine that respects "forward" and calls old routine
   
   sub user_crit_msg {
       my ($user,$domain,$subject,$message,$sendback)=@_;
       my $status='';
       my %userenv = &Apache::lonnet::get('environment',['msgforward'],
                                          $domain,$user);
       my $msgforward=$userenv{'msgforward'};
       if ($msgforward) {
          foreach (split(/\,/,$msgforward)) {
    my ($forwuser,$forwdomain)=split(/\:/,$_);
            $status.=
      &user_crit_msg_raw($forwuser,$forwdomain,$subject,$message,
                   $sendback).' ';
          }
       } else { 
    $status=&user_crit_msg_raw($user,$domain,$subject,$message,$sendback);
       }
       return $status;
   }
   
 # =================================================== Critical message received  # =================================================== Critical message received
   
 sub user_crit_received {  sub user_crit_received {
Line 178  sub user_crit_received { Line 210  sub user_crit_received {
      &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},       &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
                      'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},                       'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
                      'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.                       'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
                      ' acknowledged receipt of message "'.                       ' acknowledged receipt of message'."\n".'   "'.
                      $contents{'subject'}.'" dated '.$contents{'time'}.".\n\n"                       $contents{'subject'}.'"'."\n".'dated '.
                      .'Message ID: '.$contents{'msgid'}):'no msg req');                       $contents{'time'}.".\n"
                        ):'no msg req');
     $status.=' trans: '.      $status.=' trans: '.
      &Apache::lonnet::put(       &Apache::lonnet::put(
      'nohist_email',{$contents{'msgid'} => $message{$msgid}});       'nohist_email',{$contents{'msgid'} => $message{$msgid}});
Line 195  sub user_crit_received { Line 228  sub user_crit_received {
   
 # ======================================================== Normal communication  # ======================================================== Normal communication
   
 sub user_normal_msg {  sub user_normal_msg_raw {
     my ($user,$domain,$subject,$message,$citation)=@_;      my ($user,$domain,$subject,$message,$citation)=@_;
 # Check if allowed missing  # Check if allowed missing
     my $status='';      my $status='';
Line 208  sub user_normal_msg { Line 241  sub user_normal_msg {
            'put:'.$domain.':'.$user.':nohist_email:'.             'put:'.$domain.':'.$user.':nohist_email:'.
            &Apache::lonnet::escape($msgid).'='.             &Apache::lonnet::escape($msgid).'='.
            &Apache::lonnet::escape($message),$homeserver);             &Apache::lonnet::escape($message),$homeserver);
          &Apache::lonnet::put
                            ('email_status',{'recnewemail'=>time},$domain,$user);
     } else {      } else {
        $status='no_host';         $status='no_host';
     }      }
Line 217  sub user_normal_msg { Line 252  sub user_normal_msg {
     return $status;      return $status;
 }  }
   
   # New routine that respects "forward" and calls old routine
   
   sub user_normal_msg {
       my ($user,$domain,$subject,$message,$citation)=@_;
       my $status='';
       my %userenv = &Apache::lonnet::get('environment',['msgforward'],
                                          $domain,$user);
       my $msgforward=$userenv{'msgforward'};
       if ($msgforward) {
          foreach (split(/\,/,$msgforward)) {
    my ($forwuser,$forwdomain)=split(/\:/,$_);
            $status.=
     &user_normal_msg_raw($forwuser,$forwdomain,$subject,$message,
                                                                $citation).' ';
          }
       } else { 
    $status=
             &user_normal_msg_raw($user,$domain,$subject,$message,$citation);
       }
       return $status;
   }
   
   
 # =============================================================== Status Change  # =============================================================== Status Change
   
 sub statuschange {  sub statuschange {
Line 406  ENDDISHEADER Line 464  ENDDISHEADER
                                         $ENV{'user.home'}))) {                                          $ENV{'user.home'}))) {
         my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=          my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
     &Apache::lonmsg::unpackmsgid($_);      &Apache::lonmsg::unpackmsgid($_);
        unless (($status eq 'deleted') || ($sendtime=~/error/)) {   if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
         if ($status eq 'new') {      if ($status eq 'new') {
     $r->print('<tr bgcolor="#FFBB77">');   $r->print('<tr bgcolor="#FFBB77">');
         } elsif ($status eq 'read') {      } elsif ($status eq 'read') {
     $r->print('<tr bgcolor="#BBBB77">');   $r->print('<tr bgcolor="#BBBB77">');
         } elsif ($status eq 'replied') {      } elsif ($status eq 'replied') {
     $r->print('<tr bgcolor="#AAAA88">');   $r->print('<tr bgcolor="#AAAA88">');
  } else {      } else {
     $r->print('<tr bgcolor="#99BBBB">');   $r->print('<tr bgcolor="#99BBBB">');
         }      }
         $r->print('<td><a href="/adm/email?display='.$_.      $r->print('<td><a href="/adm/email?display='.$_.
                   '">Open</a></td><td><a href="/adm/email?markdel='.$_.        '">Open</a></td><td><a href="/adm/email?markdel='.$_.
                 '">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'.        '">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'.
                   '<td>'.localtime($sendtime).'</td><td>'.        '<td>'.localtime($sendtime).'</td><td>'.
                   $fromname.'</td><td>'.$fromdomain.'</td><td>'.        $fromname.'</td><td>'.$fromdomain.'</td><td>'.
       &Apache::lonnet::unescape($shortsubj).'</td><td>'.        &Apache::lonnet::unescape($shortsubj).'</td><td>'.
                       $status.'</td></tr>');                        $status.'</td></tr>');
        }   }
     }      }
     $r->print('</table><p>'.      $r->print('</table><p>'.
               '<a href="javascript:checkall()">Check All</a>&nbsp;'.                '<a href="javascript:checkall()">Check All</a>&nbsp;'.
Line 521  ENDUPLOAD Line 579  ENDUPLOAD
     $r->print('</form>');      $r->print('</form>');
 }  }
   
   # ---------------------------------------------------------------- Face to face
   
   sub facetoface {
       my ($r,$stage)=@_;
       unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
    return;
       }
       my $defdom=$ENV{'user.domain'};
       if ($ENV{'form.recdomain'}) { $defdom=$ENV{'form.recdomain'}; }
       my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
       $r->print(<<"ENDTREC");
   <h2>User Records of Face-To-Face Discussions and Messages in Course</h2>
   <form method="post" action="/adm/email">
   <input type="hidden" name="recordftf" value="retrieve" />
   <table>
   <tr><td>Username:</td><td><input type=text size=12 name=recuname value="$ENV{'form.recuname'}"></td>
   <td rowspan="2">
   <input type="submit" value="Retrieve discussion and message records"></td>
   </tr>
   <tr><td>Domain:</td>
   <td>$domform</td></tr>
   </table>
   </form>
   ENDTREC
       if (($stage ne 'query') &&
           ($ENV{'form.recdomain'}) && ($ENV{'form.recuname'})) {
           chomp($ENV{'form.newrecord'});
           if ($ENV{'form.newrecord'}) {
       my $subject=
                  'Record ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']';
           }
    $r->print(<<ENDRHEAD);
   <form method="post" action="/adm/email">
   <input name="recdomain" value="$ENV{'form.recdomain'}" type="hidden" />
   <input name="recuname" value="$ENV{'form.recuname'}" type="hidden" />
   ENDRHEAD
           $r->print(<<ENDBFORM);
   <hr />New Record (record is visible to course faculty and staff)<br />
   <textarea name="newrecord" cols="80" rows="10" wrap="hard"></textarea>
   </form>
   ENDBFORM
       }
   }
   
 # ===================================================================== Handler  # ===================================================================== Handler
   
 sub handler {  sub handler {
Line 536  sub handler { Line 638  sub handler {
 # --------------------------- Get query string for limited number of parameters  # --------------------------- Get query string for limited number of parameters
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['display','replyto','forward','markread','markdel','markunread',          ['display','replyto','forward','markread','markdel','markunread',
          'sendreply','compose','sendmail','critical','recname','recdom']);           'sendreply','compose','sendmail','critical','recname','recdom',
            'recordftf']);
   
   # ------------------------------------------------------ They checked for email
     &Apache::lonnet::put('email_status',{'recnewemail'=>0});
 # --------------------------------------------------------------- Render Output  # --------------------------------------------------------------- Render Output
       
   $r->print('<html><head><title>EMail and Messaging</title></head>'.    $r->print('<html><head><title>EMail and Messaging</title></head>'.
Line 562  $content{'sendername'},$content{'senderd Line 667  $content{'sendername'},$content{'senderd
              '"><b>Forward</b></a></td>'.               '"><b>Forward</b></a></td>'.
         '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).          '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).
              '"><b>Mark Unread</b></a></td>'.               '"><b>Mark Unread</b></a></td>'.
           '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).
                '"><b>Delete</b></a></td>'.
         '<td><a href="/adm/email"><b>Display all Messages</b></a></td>'.          '<td><a href="/adm/email"><b>Display all Messages</b></a></td>'.
              '</tr></table><p><pre>'.               '</tr></table><p><pre>'.
              &Apache::lontexconvert::msgtexconverted($content{'message'}).               &Apache::lontexconvert::msgtexconverted($content{'message'}).
Line 629  $content{'sendername'},$content{'senderd Line 736  $content{'sendername'},$content{'senderd
       &disall($r);        &disall($r);
   } elsif ($ENV{'form.compose'}) {    } elsif ($ENV{'form.compose'}) {
       &compout($r,'',$ENV{'form.compose'});        &compout($r,'',$ENV{'form.compose'});
     } elsif ($ENV{'form.recordftf'}) {
         &facetoface($r,$ENV{'form.recordftf'});
   } elsif ($ENV{'form.sendmail'}) {    } elsif ($ENV{'form.sendmail'}) {
       my %content=();        my %content=();
       undef %content;        undef %content;

Removed from v.1.37  
changed lines
  Added in v.1.44


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