Annotation of loncom/interface/lonmsg.pm, revision 1.24
1.1 www 1: # The LearningOnline Network with CAPA
2: #
3: # Routines for messaging
4: #
5: # (Routines to control the menu
6: #
7: # (TeX Conversion Module
8: #
9: # 05/29/00,05/30 Gerd Kortemeyer)
10: #
11: # 10/05 Gerd Kortemeyer)
12: #
1.6 www 13: # 10/19,10/20,10/30,
14: # 02/06/01 Gerd Kortemeyer
1.11 www 15: # 07/27 Guy Albertelli
1.23 www 16: # 07/27,07/28,07/30,08/03,08/06,08/08,08/09,08/10,8/13,8/15,
1.24 ! www 17: # 10/1,11/5 Gerd Kortemeyer
1.1 www 18:
19: package Apache::lonmsg;
20:
21: use strict;
22: use Apache::lonnet();
1.2 www 23: use vars qw($msgcount);
24: use HTML::TokeParser;
1.5 www 25: use Apache::Constants qw(:common);
1.1 www 26:
27: # ===================================================================== Package
28:
1.3 www 29: sub packagemsg {
1.7 www 30: my ($subject,$message,$citation)=@_;
1.1 www 31: $message=~s/\</\<\;/g;
32: $message=~s/\>/\>\;/g;
1.7 www 33: $citation=~s/\</\<\;/g;
34: $citation=~s/\>/\>\;/g;
1.1 www 35: $subject=~s/\</\<\;/g;
36: $subject=~s/\>/\>\;/g;
1.2 www 37: my $now=time;
38: $msgcount++;
1.6 www 39: my $partsubj=$subject;
40: $partsubj=&Apache::lonnet::escape($partsubj);
41: $partsubj=substr($partsubj,0,50);
42: my $msgid=&Apache::lonnet::escape(
43: $now.':'.$partsubj.':'.$ENV{'user.name'}.':'.
44: $ENV{'user.domain'}.':'.$msgcount.':'.$$);
1.2 www 45: return $msgid,
46: '<sendername>'.$ENV{'user.name'}.'</sendername>'.
1.1 www 47: '<senderdomain>'.$ENV{'user.domain'}.'</senderdomain>'.
48: '<subject>'.$subject.'</subject>'.
1.2 www 49: '<time>'.localtime($now).'</time>'.
1.1 www 50: '<servername>'.$ENV{'SERVER_NAME'}.'</servername>'.
51: '<host>'.$ENV{'HTTP_HOST'}.'</host>'.
52: '<client>'.$ENV{'REMOTE_ADDR'}.'</client>'.
53: '<browsertype>'.$ENV{'browser.type'}.'</browsertype>'.
54: '<browseros>'.$ENV{'browser.os'}.'</browseros>'.
55: '<browserversion>'.$ENV{'browser.version'}.'</browserversion>'.
56: '<browsermathml>'.$ENV{'browser.mathml'}.'</browsermathml>'.
57: '<browserraw>'.$ENV{'HTTP_USER_AGENT'}.'</browserraw>'.
58: '<courseid>'.$ENV{'request.course.id'}.'</courseid>'.
59: '<role>'.$ENV{'request.role'}.'</role>'.
60: '<resource>'.$ENV{'request.filename'}.'</resource>'.
1.2 www 61: '<msgid>'.$msgid.'</msgid>'.
1.7 www 62: '<message>'.$message.'</message>'.
63: '<citation>'.$citation.'</citation>';
1.1 www 64: }
65:
1.2 www 66: # ================================================== Unpack message into a hash
67:
1.3 www 68: sub unpackagemsg {
1.2 www 69: my $message=shift;
70: my %content=();
71: my $parser=HTML::TokeParser->new(\$message);
72: my $token;
73: while ($token=$parser->get_token) {
74: if ($token->[0] eq 'S') {
75: my $entry=$token->[1];
76: my $value=$parser->get_text('/'.$entry);
77: $content{$entry}=$value;
78: }
79: }
80: return %content;
81: }
82:
1.6 www 83: # ======================================================= Get info out of msgid
84:
85: sub unpackmsgid {
1.7 www 86: my $msgid=&Apache::lonnet::unescape(shift);
1.6 www 87: my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
1.7 www 88: &Apache::lonnet::unescape($msgid));
1.8 albertel 89: my %status=&Apache::lonnet::get('email_status',[$msgid]);
1.6 www 90: if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
91: unless ($status{$msgid}) { $status{$msgid}='new'; }
92: return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
93: }
94:
1.1 www 95: # =============================== Automated message to the author of a resource
96:
97: sub author_res_msg {
98: my ($filename,$message)=@_;
1.2 www 99: unless ($message) { return 'empty'; }
1.1 www 100: $filename=&Apache::lonnet::declutter($filename);
101: my ($domain,$author,@dummy)=split(/\//,$filename);
102: my $homeserver=&Apache::lonnet::homeserver($author,$domain);
103: if ($homeserver ne 'no_host') {
104: my $id=unpack("%32C*",$message);
1.2 www 105: my $msgid;
1.3 www 106: ($msgid,$message)=&packagemsg($filename,$message);
107: return &Apache::lonnet::reply('put:'.$domain.':'.$author.
108: ':nohist_res_msgs:'.
109: &Apache::lonnet::escape($filename.'_'.$id).'='.
110: &Apache::lonnet::escape($message),$homeserver);
1.1 www 111: }
1.2 www 112: return 'no_host';
1.1 www 113: }
114:
115: # ================================================== Critical message to a user
116:
117: sub user_crit_msg {
1.24 ! www 118: my ($user,$domain,$subject,$message,$sendback)=@_;
1.2 www 119: # Check if allowed missing
120: my $status='';
121: my $msgid='undefined';
122: unless (($message)&&($user)&&($domain)) { $status='empty'; };
123: my $homeserver=&Apache::lonnet::homeserver($user,$domain);
124: if ($homeserver ne 'no_host') {
1.3 www 125: ($msgid,$message)=&packagemsg($subject,$message);
1.24 ! www 126: if ($sendback) { $message.='<sendback>true</sendback>'; }
1.4 www 127: $status=&Apache::lonnet::critical(
128: 'put:'.$domain.':'.$user.':critical:'.
129: &Apache::lonnet::escape($msgid).'='.
130: &Apache::lonnet::escape($message),$homeserver);
1.2 www 131: } else {
132: $status='no_host';
133: }
134: &Apache::lonnet::logthis(
1.4 www 135: 'Sending critical email '.$msgid.
1.2 www 136: ', log status: '.
137: &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
138: $ENV{'user.home'},
139: 'Sending critical '.$msgid.' to '.$user.' at '.$domain.' with status: '
1.4 www 140: .$status));
1.2 www 141: return $status;
142: }
143:
144: # =================================================== Critical message received
145:
146: sub user_crit_received {
1.12 www 147: my $msgid=shift;
148: my %message=&Apache::lonnet::get('critical',[$msgid]);
149: my %contents=&unpackagemsg($message{$msgid});
1.24 ! www 150: my $status='rec: '.($contents{'sendback'}?
1.5 www 151: &user_normal_msg($contents{'sendername'},$contents{'senderdomain'},
1.4 www 152: 'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'},
153: 'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}.
154: ' acknowledged receipt of message "'.
155: $contents{'subject'}.'" dated '.$contents{'time'}.".\n\n"
1.24 ! www 156: .'Message ID: '.$contents{'msgid'}):'no msg req');
1.5 www 157: $status.=' trans: '.
1.12 www 158: &Apache::lonnet::put(
159: 'nohist_email',{$contents{'msgid'} => $message{$msgid}});
1.5 www 160: $status.=' del: '.
1.9 albertel 161: &Apache::lonnet::del('critical',[$contents{'msgid'}]);
1.5 www 162: &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
163: $ENV{'user.home'},'Received critical message '.
164: $contents{'msgid'}.
165: ', '.$status);
1.12 www 166: return $status;
1.2 www 167: }
168:
169: # ======================================================== Normal communication
170:
171: sub user_normal_msg {
1.7 www 172: my ($user,$domain,$subject,$message,$citation)=@_;
1.2 www 173: # Check if allowed missing
174: my $status='';
175: my $msgid='undefined';
176: unless (($message)&&($user)&&($domain)) { $status='empty'; };
177: my $homeserver=&Apache::lonnet::homeserver($user,$domain);
178: if ($homeserver ne 'no_host') {
1.7 www 179: ($msgid,$message)=&packagemsg($subject,$message,$citation);
1.4 www 180: $status=&Apache::lonnet::critical(
181: 'put:'.$domain.':'.$user.':nohist_email:'.
182: &Apache::lonnet::escape($msgid).'='.
183: &Apache::lonnet::escape($message),$homeserver);
1.2 www 184: } else {
185: $status='no_host';
186: }
187: &Apache::lonnet::log($ENV{'user.domain'},$ENV{'user.name'},
188: $ENV{'user.home'},
189: 'Sending '.$msgid.' to '.$user.' at '.$domain.' with status: '.$status);
190: return $status;
191: }
192:
1.7 www 193: # =============================================================== Status Change
194:
195: sub statuschange {
196: my ($msgid,$newstatus)=@_;
1.8 albertel 197: my %status=&Apache::lonnet::get('email_status',[$msgid]);
1.7 www 198: if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
199: unless ($status{$msgid}) { $status{$msgid}='new'; }
200: unless (($status{$msgid} eq 'replied') ||
201: ($status{$msgid} eq 'forwarded')) {
1.10 albertel 202: &Apache::lonnet::put('email_status',{$msgid => $newstatus});
1.7 www 203: }
1.14 www 204: if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
205: &Apache::lonnet::put('email_status',{$msgid => $newstatus});
206: }
1.7 www 207: }
1.14 www 208:
1.17 www 209: # ======================================================= Display a course list
210:
211: sub discourse {
212: my $r=shift;
213: my %courselist=&Apache::lonnet::dump(
214: 'classlist',
215: $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
216: $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
217: my $now=time;
218: $r->print(<<ENDDISHEADER);
219: <input type=hidden name=sendmode value=group>
220: <script>
221: function checkall() {
222: for (i=0; i<document.forms.compemail.elements.length; i++) {
223: if
224: (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
225: document.forms.compemail.elements[i].checked=true;
226: }
227: }
228: }
229:
1.19 www 230: function checksec() {
231: for (i=0; i<document.forms.compemail.elements.length; i++) {
232: if
233: (document.forms.compemail.elements[i].name.indexOf
234: ('send_to_&&&'+document.forms.compemail.chksec.value)==0) {
235: document.forms.compemail.elements[i].checked=true;
236: }
237: }
238: }
239:
1.17 www 240: function uncheckall() {
241: for (i=0; i<document.forms.compemail.elements.length; i++) {
242: if
243: (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
244: document.forms.compemail.elements[i].checked=false;
245: }
246: }
247: }
248: </script>
1.19 www 249: <input type=button onClick="checkall()" value="Check for All">
250: <input type=button onClick="checksec()" value="Check for Section/Group">
251: <input type=text size=5 name=chksec>
1.17 www 252: <input type=button onClick="uncheckall()" value="Check for None">
253: <p>
254: ENDDISHEADER
255: map {
256: my ($end,$start)=split(/\:/,$courselist{$_});
257: my $active=1;
258: if (($end) && ($now>$end)) { $active=0; }
259: if ($active) {
260: my ($sname,$sdom)=split(/\:/,$_);
261: my %reply=&Apache::lonnet::get('environment',
262: ['firstname','middlename','lastname','generation'],
263: $sdom,$sname);
1.19 www 264: my $section=&Apache::lonnet::usection
265: ($sdom,$sname,$ENV{'request.course.id'});
266: $r->print(
267: '<br><input type=checkbox name="send_to_&&&'.$section.'&&&_'.$_.'"> '.
1.17 www 268: $reply{'firstname'}.' '.
269: $reply{'middlename'}.' '.
270: $reply{'lastname'}.' '.
271: $reply{'generation'}.
1.19 www 272: ' ('.$_.') '.$section);
1.17 www 273: }
274: } sort keys %courselist;
275: }
276:
1.13 www 277: # ==================================================== Display Critical Message
1.5 www 278:
1.12 www 279: sub discrit {
280: my $r=shift;
281: $r->print('<h1><font color=red>Critical Messages</font></h1>'.
282: '<form action=/adm/email method=post>'.
283: '<input type=hidden name=confirm value=true>');
284: my %what=&Apache::lonnet::dump('critical');
285: map {
286: my %content=&unpackagemsg($what{$_});
287: $content{'message'}=~s/\n/\<br\>/g;
288: $r->print('<hr>From: <b>'.$content{'sendername'}.'@'.
289: $content{'senderdomain'}.'</b> ('.$content{'time'}.
290: ')<br><blockquote>'.$content{'message'}.'</blockquote>'.
1.13 www 291: '<input type=submit name="rec_'.$_.'" value="Confirm Receipt">'.
292: '<input type=submit name="reprec_'.$_.'" value="Confirm Receipt and Reply">');
1.12 www 293: } sort keys %what;
1.16 www 294: $r->print(
295: '<input type=hidden name="displayedcrit" value="true"></form>');
1.12 www 296: }
297:
1.13 www 298: # =============================================================== Compose reply
299:
300: sub comprep {
301: my ($r,$msgid)=@_;
302: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
303: my %content=&unpackagemsg($message{$msgid});
304: my $quotemsg='> '.$content{'message'};
305: $quotemsg=~s/\r/\n/g;
306: $quotemsg=~s/\f/\n/g;
307: $quotemsg=~s/\n+/\n\> /g;
308: my $subject='Re: '.$content{'subject'};
309: my $dispcrit='';
310: if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
311: $dispcrit=
1.24 ! www 312: '<input type=checkbox name=critmsg> Send as critical message<br>'.
! 313: '<input type=checkbox name=sendbck> Send as critical message'.
! 314: ' and return receipt<p>';
1.13 www 315: }
316: $r->print(<<"ENDREPLY");
317: <form action="/adm/email" method=post>
318: <input type=hidden name=sendreply value="$msgid">
319: Subject: <input type=text size=50 name=subject value="$subject"><p>
1.23 www 320: <textarea name=message cols=64 rows=10 wrap=hard>
1.13 www 321: $quotemsg
322: </textarea><p>
323: $dispcrit
324: <input type=submit value="Send Reply">
325: </form>
326: ENDREPLY
327: }
328:
1.15 www 329: # ======================================================== Display all messages
330:
1.14 www 331: sub disall {
332: my $r=shift;
333: $r->print('<h1>Display All Messages</h1>'.
334: '<table border=2><tr><th colspan=2> </th><th>Date</th>'.
335: '<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>');
336: map {
337: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
338: &Apache::lonmsg::unpackmsgid($_);
339: unless ($status eq 'deleted') {
340: if ($status eq 'new') {
341: $r->print('<tr bgcolor="#FFBB77">');
342: } elsif ($status eq 'read') {
343: $r->print('<tr bgcolor="#BBBB77">');
344: } elsif ($status eq 'replied') {
345: $r->print('<tr bgcolor="#AAAA88">');
346: } else {
347: $r->print('<tr bgcolor="#99BBBB">');
348: }
349: $r->print('<td><a href="/adm/email?display='.$_.
350: '">Open</a></td><td><a href="/adm/email?markdel='.$_.
351: '">Delete</a></td><td>'.localtime($sendtime).'</td><td>'.
352: $fromname.'</td><td>'.$fromdomain.'</td><td>'.
353: &Apache::lonnet::unescape($shortsubj).'</td><td>'.
354: $status.'</td></tr>');
355: }
356: } sort split(/\&/,&Apache::lonnet::reply('keys:'.
357: $ENV{'user.domain'}.':'.
358: $ENV{'user.name'}.':nohist_email',
359: $ENV{'user.home'}));
360: $r->print('</table></body></html>');
361: }
362:
1.15 www 363: # ============================================================== Compose output
364:
365: sub compout {
1.17 www 366: my ($r,$forwarding,$broadcast)=@_;
1.15 www 367: my $dispcrit='';
368: my $dissub='';
369: my $dismsg='';
370: my $func='Send New';
371: if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
372: $dispcrit=
1.24 ! www 373: '<input type=checkbox name=critmsg> Send as critical message<br>'.
! 374: '<input type=checkbox name=sendbck> Send as critical message'.
! 375: ' and return receipt<p>';
1.15 www 376: }
377: if ($forwarding) {
378: $dispcrit.='<input type=hidden name=forwid value="'.
379: $forwarding.'">';
380: $func='Forward';
381: my %message=&Apache::lonnet::get('nohist_email',[$forwarding]);
382: my %content=&unpackagemsg($message{$forwarding});
383:
384: $dissub='Forwarding: '.$content{'subject'};
385: $dismsg='Forwarded message from '.
386: $content{'sendername'}.' at '.$content{'senderdomain'};
387: }
388: my $defdom=$ENV{'user.domain'};
1.22 www 389: $r->print(
390: '<form action="/adm/email" name="compemail" method=post'.
391: ' enctype="multipart/form-data">'.
1.17 www 392: '<input type=hidden name=sendmail value=on><table>');
1.22 www 393: unless (($broadcast eq 'group') || ($broadcast eq 'upload')) {
1.17 www 394: $r->print(<<"ENDREC");
1.15 www 395: <table>
396: <tr><td>Username:</td><td><input type=text size=12 name=recuname></td></tr>
397: <tr><td>Domain:</td>
398: <td><input type=text size=12 name=recdomain value="$defdom"></td></tr>
1.17 www 399: ENDREC
400: }
1.22 www 401: unless ($broadcast eq 'upload') {
402: $r->print(<<"ENDCOMP");
1.20 www 403: <tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ...
404: </tt></td><td>
405: <input type=text size=50 name=additionalrec></td></tr>
1.15 www 406: <tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub">
407: </td></tr></table>
1.23 www 408: <textarea name=message cols=60 rows=10 wrap=hard>$dismsg
1.15 www 409: </textarea><p>
410: $dispcrit
411: <input type=submit value="$func Mail">
412: ENDCOMP
1.22 www 413: }
414: if ($broadcast eq 'upload') {
415: $r->print(<<ENDUPLOAD);
416: <input type=hidden name=sendmode value=upload>
417: <h3>Generate messages from a file</h3>
418: Subject: <input type=text size=50 name=subject>
419: <pre>
420: username1\@domain1: text
421: username2\@domain2: text
422: username1\@domain1: text
423: </pre>
424: The messages will be assembled from all lines with the respective
425: <tt>username\@domain</tt>, and appended to the general message text.<p>
426: <input type=file name=upfile size=20><p>
427: General message text:<p>
1.23 www 428: <textarea name=message cols=60 rows=10 wrap=hard>$dismsg
1.22 www 429: </textarea><p>
430: $dispcrit
431: <input type=submit value="Upload and send">
432: ENDUPLOAD
433: }
1.17 www 434: if ($broadcast eq 'group') {
435: &discourse;
436: }
437: $r->print('</form>');
1.15 www 438: }
439:
1.13 www 440: # ===================================================================== Handler
441:
1.5 www 442: sub handler {
443: my $r=shift;
444:
445: # ----------------------------------------------------------- Set document type
446:
447: $r->content_type('text/html');
448: $r->send_http_header;
449:
450: return OK if $r->header_only;
451:
1.6 www 452: # --------------------------- Get query string for limited number of parameters
453:
454: map {
455: my ($name, $value) = split(/=/,$_);
456: $value =~ tr/+/ /;
457: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
458: if (($name eq 'display') || ($name eq 'replyto') ||
1.14 www 459: ($name eq 'forward') || ($name eq 'markread') ||
460: ($name eq 'markdel') || ($name eq 'markunread') ||
1.12 www 461: ($name eq 'sendreply') || ($name eq 'compose') ||
462: ($name eq 'sendmail') || ($name eq 'critical')) {
1.6 www 463: unless ($ENV{'form.'.$name}) {
464: $ENV{'form.'.$name}=$value;
465: }
466: }
467: } (split(/&/,$ENV{'QUERY_STRING'}));
468:
1.5 www 469: # --------------------------------------------------------------- Render Output
470:
471: $r->print('<html><head><title>EMail and Messaging</title></head>');
1.7 www 472: $r->print(
473: '<body bgcolor="#FFFFFF"><img align=right src=/adm/lonIcons/lonlogos.gif>');
1.5 www 474: $r->print('<h1>EMail</h1>');
1.6 www 475: if ($ENV{'form.display'}) {
1.7 www 476: my $msgid=$ENV{'form.display'};
477: &statuschange($msgid,'read');
1.8 albertel 478: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
1.7 www 479: my %content=&unpackagemsg($message{$msgid});
480: $r->print('<b>Subject:</b> '.$content{'subject'}.
481: '<br><b>From:</b> '.$content{'sendername'}.' at '.
482: $content{'senderdomain'}.
1.14 www 483: '<br><b>Time:</b> '.$content{'time'}.'<p>'.
484: '<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'.
485: '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).
486: '"><b>Reply</b></a></td>'.
1.15 www 487: '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).
1.14 www 488: '"><b>Forward</b></a></td>'.
1.15 www 489: '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).
490: '"><b>Mark Unread</b></a></td>'.
491: '<td><a href="/adm/email"><b>Display all Messages</b></a></td>'.
1.14 www 492: '</tr></table><p><pre>'.
1.7 www 493: $content{'message'}.'</pre><hr>'.$content{'citation'});
1.6 www 494: } elsif ($ENV{'form.replyto'}) {
1.13 www 495: &comprep($r,$ENV{'form.replyto'});
1.7 www 496: } elsif ($ENV{'form.sendreply'}) {
497: my $msgid=$ENV{'form.sendreply'};
1.8 albertel 498: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
1.7 www 499: my %content=&unpackagemsg($message{$msgid});
500: &statuschange($msgid,'replied');
1.24 ! www 501: if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
1.12 www 502: (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
503: $r->print('Sending critical: '.
504: &user_crit_msg($content{'sendername'},
1.7 www 505: $content{'senderdomain'},
506: $ENV{'form.subject'},
1.24 ! www 507: $ENV{'form.message'},
! 508: $ENV{'form.sendbck'}));
1.12 www 509: } else {
510: $r->print('Sending: '.&user_normal_msg($content{'sendername'},
511: $content{'senderdomain'},
512: $ENV{'form.subject'},
513: $ENV{'form.message'}));
514: }
1.14 www 515: if ($ENV{'form.displayedcrit'}) {
516: &discrit($r);
517: } else {
518: &disall($r);
519: }
1.12 www 520: } elsif ($ENV{'form.confirm'}) {
521: map {
522: if ($_=~/^form\.rec\_(.*)$/) {
523: $r->print('<b>Confirming Receipt:</b> '.
524: &user_crit_received($1).'<br>');
1.13 www 525: }
526: if ($_=~/^form\.reprec\_(.*)$/) {
527: my $msgid=$1;
528: $r->print('<b>Confirming Receipt:</b> '.
529: &user_crit_received($msgid).'<br>');
530: &comprep($r,$msgid);
1.12 www 531: }
532: } keys %ENV;
533: &discrit($r);
534: } elsif ($ENV{'form.critical'}) {
535: &discrit($r);
1.6 www 536: } elsif ($ENV{'form.forward'}) {
1.15 www 537: &compout($r,$ENV{'form.forward'});
1.14 www 538: } elsif ($ENV{'form.markread'}) {
539: } elsif ($ENV{'form.markdel'}) {
540: &statuschange($ENV{'form.markdel'},'deleted');
541: &disall($r);
542: } elsif ($ENV{'form.markunread'}) {
1.15 www 543: &statuschange($ENV{'form.markunread'},'new');
544: &disall($r);
1.11 www 545: } elsif ($ENV{'form.compose'}) {
1.17 www 546: &compout($r,'',$ENV{'form.compose'});
1.11 www 547: } elsif ($ENV{'form.sendmail'}) {
1.16 www 548: my %content=();
549: undef %content;
550: if ($ENV{'form.forwid'}) {
551: my $msgid=$ENV{'form.forwid'};
552: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
553: %content=&unpackagemsg($message{$msgid});
554: &statuschange($msgid,'forwarded');
555: $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
556: $content{'message'};
557: }
1.18 www 558: my %toaddr=();
559: undef %toaddr;
560: if ($ENV{'form.sendmode'} eq 'group') {
561: map {
1.19 www 562: if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
1.22 www 563: $toaddr{$1}='';
1.18 www 564: }
565: } keys %ENV;
1.22 www 566: } elsif ($ENV{'form.sendmode'} eq 'upload') {
567: map {
568: my ($rec,$txt)=split(/\s*\:\s*/,$_);
569: if ($txt) {
570: $rec=~s/\@/\:/;
571: $toaddr{$rec}.=$txt."\n";
572: }
573: } split(/[\n\r\f]+/,$ENV{'form.upfile'});
1.18 www 574: } else {
1.22 www 575: $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
1.20 www 576: }
577: if ($ENV{'form.additionalrec'}) {
578: map {
579: my ($auname,$audom)=split(/\@/,$_);
1.22 www 580: $toaddr{$auname.':'.$audom}='';
1.20 www 581: } split(/\,/,$ENV{'form.additionalrec'});
1.18 www 582: }
583: map {
584: my ($recuname,$recdomain)=split(/\:/,$_);
1.22 www 585: my $msgtxt=$ENV{'form.message'};
586: if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }
1.24 ! www 587: if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
1.16 www 588: (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
589: $r->print('Sending critical: '.
1.18 www 590: &user_crit_msg($recuname,$recdomain,
1.16 www 591: $ENV{'form.subject'},
1.22 www 592: $msgtxt,
1.24 ! www 593: $ENV{'form.sendbck'}));
1.16 www 594: } else {
1.18 www 595: $r->print('Sending: '.&user_normal_msg($recuname,$recdomain,
1.16 www 596: $ENV{'form.subject'},
1.22 www 597: $msgtxt,
1.16 www 598: $content{'citation'}));
599: }
1.18 www 600: $r->print('<br>');
601: } keys %toaddr;
1.16 www 602: if ($ENV{'form.displayedcrit'}) {
603: &discrit($r);
604: } else {
605: &disall($r);
606: }
1.6 www 607: } else {
1.14 www 608: &disall($r);
1.6 www 609: }
1.5 www 610: $r->print('</body></html>');
611: return OK;
612:
613: }
1.2 www 614: # ================================================= Main program, reset counter
615:
616: sub BEGIN {
617: $msgcount=0;
1.1 www 618: }
619:
620: 1;
621: __END__
622:
623:
624:
625:
626:
627:
628:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>