Annotation of loncom/interface/lonmsg.pm, revision 1.25
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;
1.25 ! www 333: $r->print(
! 334: '<h1>Display All Messages</h1><form method=post action="/adm/email">'.
1.14 www 335: '<table border=2><tr><th colspan=2> </th><th>Date</th>'.
336: '<th>Username</th><th>Domain</th><th>Subject</th><th>Status</th></tr>');
337: map {
338: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status)=
339: &Apache::lonmsg::unpackmsgid($_);
340: unless ($status eq 'deleted') {
341: if ($status eq 'new') {
342: $r->print('<tr bgcolor="#FFBB77">');
343: } elsif ($status eq 'read') {
344: $r->print('<tr bgcolor="#BBBB77">');
345: } elsif ($status eq 'replied') {
346: $r->print('<tr bgcolor="#AAAA88">');
347: } else {
348: $r->print('<tr bgcolor="#99BBBB">');
349: }
350: $r->print('<td><a href="/adm/email?display='.$_.
351: '">Open</a></td><td><a href="/adm/email?markdel='.$_.
1.25 ! www 352: '">Delete</a><input type=checkbox name="delmark_'.$_.'"></td>'.
! 353: '<td>'.localtime($sendtime).'</td><td>'.
1.14 www 354: $fromname.'</td><td>'.$fromdomain.'</td><td>'.
355: &Apache::lonnet::unescape($shortsubj).'</td><td>'.
356: $status.'</td></tr>');
357: }
358: } sort split(/\&/,&Apache::lonnet::reply('keys:'.
359: $ENV{'user.domain'}.':'.
360: $ENV{'user.name'}.':nohist_email',
361: $ENV{'user.home'}));
1.25 ! www 362: $r->print('</table><p>'.
! 363: '<input type=submit name="markeddel" value="Delete Checked">'.
! 364: '</form></body></html>');
1.14 www 365: }
366:
1.15 www 367: # ============================================================== Compose output
368:
369: sub compout {
1.17 www 370: my ($r,$forwarding,$broadcast)=@_;
1.15 www 371: my $dispcrit='';
372: my $dissub='';
373: my $dismsg='';
374: my $func='Send New';
375: if (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) {
376: $dispcrit=
1.24 www 377: '<input type=checkbox name=critmsg> Send as critical message<br>'.
378: '<input type=checkbox name=sendbck> Send as critical message'.
379: ' and return receipt<p>';
1.15 www 380: }
381: if ($forwarding) {
382: $dispcrit.='<input type=hidden name=forwid value="'.
383: $forwarding.'">';
384: $func='Forward';
385: my %message=&Apache::lonnet::get('nohist_email',[$forwarding]);
386: my %content=&unpackagemsg($message{$forwarding});
387:
388: $dissub='Forwarding: '.$content{'subject'};
389: $dismsg='Forwarded message from '.
390: $content{'sendername'}.' at '.$content{'senderdomain'};
391: }
392: my $defdom=$ENV{'user.domain'};
1.22 www 393: $r->print(
394: '<form action="/adm/email" name="compemail" method=post'.
395: ' enctype="multipart/form-data">'.
1.17 www 396: '<input type=hidden name=sendmail value=on><table>');
1.22 www 397: unless (($broadcast eq 'group') || ($broadcast eq 'upload')) {
1.17 www 398: $r->print(<<"ENDREC");
1.15 www 399: <table>
400: <tr><td>Username:</td><td><input type=text size=12 name=recuname></td></tr>
401: <tr><td>Domain:</td>
402: <td><input type=text size=12 name=recdomain value="$defdom"></td></tr>
1.17 www 403: ENDREC
404: }
1.22 www 405: unless ($broadcast eq 'upload') {
406: $r->print(<<"ENDCOMP");
1.20 www 407: <tr><td>Additional Recipients<br><tt>username\@domain,username\@domain, ...
408: </tt></td><td>
409: <input type=text size=50 name=additionalrec></td></tr>
1.15 www 410: <tr><td>Subject:</td><td><input type=text size=50 name=subject value="$dissub">
411: </td></tr></table>
1.23 www 412: <textarea name=message cols=60 rows=10 wrap=hard>$dismsg
1.15 www 413: </textarea><p>
414: $dispcrit
415: <input type=submit value="$func Mail">
416: ENDCOMP
1.22 www 417: }
418: if ($broadcast eq 'upload') {
419: $r->print(<<ENDUPLOAD);
420: <input type=hidden name=sendmode value=upload>
421: <h3>Generate messages from a file</h3>
422: Subject: <input type=text size=50 name=subject>
423: <pre>
424: username1\@domain1: text
425: username2\@domain2: text
426: username1\@domain1: text
427: </pre>
428: The messages will be assembled from all lines with the respective
429: <tt>username\@domain</tt>, and appended to the general message text.<p>
430: <input type=file name=upfile size=20><p>
431: General message text:<p>
1.23 www 432: <textarea name=message cols=60 rows=10 wrap=hard>$dismsg
1.22 www 433: </textarea><p>
434: $dispcrit
435: <input type=submit value="Upload and send">
436: ENDUPLOAD
437: }
1.17 www 438: if ($broadcast eq 'group') {
439: &discourse;
440: }
441: $r->print('</form>');
1.15 www 442: }
443:
1.13 www 444: # ===================================================================== Handler
445:
1.5 www 446: sub handler {
447: my $r=shift;
448:
449: # ----------------------------------------------------------- Set document type
450:
451: $r->content_type('text/html');
452: $r->send_http_header;
453:
454: return OK if $r->header_only;
455:
1.6 www 456: # --------------------------- Get query string for limited number of parameters
457:
458: map {
459: my ($name, $value) = split(/=/,$_);
460: $value =~ tr/+/ /;
461: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
462: if (($name eq 'display') || ($name eq 'replyto') ||
1.14 www 463: ($name eq 'forward') || ($name eq 'markread') ||
464: ($name eq 'markdel') || ($name eq 'markunread') ||
1.12 www 465: ($name eq 'sendreply') || ($name eq 'compose') ||
466: ($name eq 'sendmail') || ($name eq 'critical')) {
1.6 www 467: unless ($ENV{'form.'.$name}) {
468: $ENV{'form.'.$name}=$value;
469: }
470: }
471: } (split(/&/,$ENV{'QUERY_STRING'}));
472:
1.5 www 473: # --------------------------------------------------------------- Render Output
474:
475: $r->print('<html><head><title>EMail and Messaging</title></head>');
1.7 www 476: $r->print(
477: '<body bgcolor="#FFFFFF"><img align=right src=/adm/lonIcons/lonlogos.gif>');
1.5 www 478: $r->print('<h1>EMail</h1>');
1.6 www 479: if ($ENV{'form.display'}) {
1.7 www 480: my $msgid=$ENV{'form.display'};
481: &statuschange($msgid,'read');
1.8 albertel 482: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
1.7 www 483: my %content=&unpackagemsg($message{$msgid});
484: $r->print('<b>Subject:</b> '.$content{'subject'}.
485: '<br><b>From:</b> '.$content{'sendername'}.' at '.
486: $content{'senderdomain'}.
1.14 www 487: '<br><b>Time:</b> '.$content{'time'}.'<p>'.
488: '<table border=2><tr bgcolor="#FFFFAA"><td>Functions:</td>'.
489: '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).
490: '"><b>Reply</b></a></td>'.
1.15 www 491: '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).
1.14 www 492: '"><b>Forward</b></a></td>'.
1.15 www 493: '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).
494: '"><b>Mark Unread</b></a></td>'.
495: '<td><a href="/adm/email"><b>Display all Messages</b></a></td>'.
1.14 www 496: '</tr></table><p><pre>'.
1.7 www 497: $content{'message'}.'</pre><hr>'.$content{'citation'});
1.6 www 498: } elsif ($ENV{'form.replyto'}) {
1.13 www 499: &comprep($r,$ENV{'form.replyto'});
1.7 www 500: } elsif ($ENV{'form.sendreply'}) {
501: my $msgid=$ENV{'form.sendreply'};
1.8 albertel 502: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
1.7 www 503: my %content=&unpackagemsg($message{$msgid});
504: &statuschange($msgid,'replied');
1.24 www 505: if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
1.12 www 506: (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
507: $r->print('Sending critical: '.
508: &user_crit_msg($content{'sendername'},
1.7 www 509: $content{'senderdomain'},
510: $ENV{'form.subject'},
1.24 www 511: $ENV{'form.message'},
512: $ENV{'form.sendbck'}));
1.12 www 513: } else {
514: $r->print('Sending: '.&user_normal_msg($content{'sendername'},
515: $content{'senderdomain'},
516: $ENV{'form.subject'},
517: $ENV{'form.message'}));
518: }
1.14 www 519: if ($ENV{'form.displayedcrit'}) {
520: &discrit($r);
521: } else {
522: &disall($r);
523: }
1.12 www 524: } elsif ($ENV{'form.confirm'}) {
525: map {
526: if ($_=~/^form\.rec\_(.*)$/) {
527: $r->print('<b>Confirming Receipt:</b> '.
528: &user_crit_received($1).'<br>');
1.13 www 529: }
530: if ($_=~/^form\.reprec\_(.*)$/) {
531: my $msgid=$1;
532: $r->print('<b>Confirming Receipt:</b> '.
533: &user_crit_received($msgid).'<br>');
534: &comprep($r,$msgid);
1.12 www 535: }
536: } keys %ENV;
537: &discrit($r);
538: } elsif ($ENV{'form.critical'}) {
539: &discrit($r);
1.6 www 540: } elsif ($ENV{'form.forward'}) {
1.15 www 541: &compout($r,$ENV{'form.forward'});
1.14 www 542: } elsif ($ENV{'form.markread'}) {
543: } elsif ($ENV{'form.markdel'}) {
544: &statuschange($ENV{'form.markdel'},'deleted');
1.25 ! www 545: &disall($r);
! 546: } elsif ($ENV{'form.markeddel'}) {
! 547: my $total=0;
! 548: map {
! 549: if ($_=~/^form\.delmark_(.*)$/) {
! 550: &statuschange(&Apache::lonnet::unescape($1),'deleted');
! 551: $total++;
! 552: }
! 553: } keys %ENV;
! 554: $r->print('Deleted '.$total.' message(s)<p>');
1.14 www 555: &disall($r);
556: } elsif ($ENV{'form.markunread'}) {
1.15 www 557: &statuschange($ENV{'form.markunread'},'new');
558: &disall($r);
1.11 www 559: } elsif ($ENV{'form.compose'}) {
1.17 www 560: &compout($r,'',$ENV{'form.compose'});
1.11 www 561: } elsif ($ENV{'form.sendmail'}) {
1.16 www 562: my %content=();
563: undef %content;
564: if ($ENV{'form.forwid'}) {
565: my $msgid=$ENV{'form.forwid'};
566: my %message=&Apache::lonnet::get('nohist_email',[$msgid]);
567: %content=&unpackagemsg($message{$msgid});
568: &statuschange($msgid,'forwarded');
569: $ENV{'form.message'}.="\n\n-- Forwarded message --\n\n".
570: $content{'message'};
571: }
1.18 www 572: my %toaddr=();
573: undef %toaddr;
574: if ($ENV{'form.sendmode'} eq 'group') {
575: map {
1.19 www 576: if ($_=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
1.22 www 577: $toaddr{$1}='';
1.18 www 578: }
579: } keys %ENV;
1.22 www 580: } elsif ($ENV{'form.sendmode'} eq 'upload') {
581: map {
582: my ($rec,$txt)=split(/\s*\:\s*/,$_);
583: if ($txt) {
584: $rec=~s/\@/\:/;
585: $toaddr{$rec}.=$txt."\n";
586: }
587: } split(/[\n\r\f]+/,$ENV{'form.upfile'});
1.18 www 588: } else {
1.22 www 589: $toaddr{$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}}='';
1.20 www 590: }
591: if ($ENV{'form.additionalrec'}) {
592: map {
593: my ($auname,$audom)=split(/\@/,$_);
1.22 www 594: $toaddr{$auname.':'.$audom}='';
1.20 www 595: } split(/\,/,$ENV{'form.additionalrec'});
1.18 www 596: }
597: map {
598: my ($recuname,$recdomain)=split(/\:/,$_);
1.22 www 599: my $msgtxt=$ENV{'form.message'};
600: if ($toaddr{$_}) { $msgtxt.='<hr>'.$toaddr{$_}; }
1.24 www 601: if ((($ENV{'form.critmsg'}) || ($ENV{'form.sendbck'})) &&
1.16 www 602: (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
603: $r->print('Sending critical: '.
1.18 www 604: &user_crit_msg($recuname,$recdomain,
1.16 www 605: $ENV{'form.subject'},
1.22 www 606: $msgtxt,
1.24 www 607: $ENV{'form.sendbck'}));
1.16 www 608: } else {
1.18 www 609: $r->print('Sending: '.&user_normal_msg($recuname,$recdomain,
1.16 www 610: $ENV{'form.subject'},
1.22 www 611: $msgtxt,
1.16 www 612: $content{'citation'}));
613: }
1.18 www 614: $r->print('<br>');
615: } keys %toaddr;
1.16 www 616: if ($ENV{'form.displayedcrit'}) {
617: &discrit($r);
618: } else {
619: &disall($r);
620: }
1.6 www 621: } else {
1.14 www 622: &disall($r);
1.6 www 623: }
1.5 www 624: $r->print('</body></html>');
625: return OK;
626:
627: }
1.2 www 628: # ================================================= Main program, reset counter
629:
630: sub BEGIN {
631: $msgcount=0;
1.1 www 632: }
633:
634: 1;
635: __END__
636:
637:
638:
639:
640:
641:
642:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>