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