Annotation of loncom/interface/lonmsgdisplay.pm, revision 1.21
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # Routines for messaging display
3: #
1.21 ! albertel 4: # $Id: lonmsgdisplay.pm,v 1.20 2006/05/01 05:57:26 raeburn Exp $
1.1 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29:
30: package Apache::lonmsgdisplay;
31:
32: =pod
33:
34: =head1 NAME
35:
36: Apache::lonmsg: supports internal messaging
37:
38: =head1 SYNOPSIS
39:
40: lonmsg provides routines for sending messages, receiving messages, and
41: a handler to allow users to read, send, and delete messages.
42:
43: =head1 OVERVIEW
44:
45: =head2 Messaging Overview
46:
47: X<messages>LON-CAPA provides an internal messaging system similar to
48: email, but customized for LON-CAPA's usage. LON-CAPA implements its
49: own messaging system, rather then building on top of email, because of
50: the features LON-CAPA messages can offer that conventional e-mail can
51: not:
52:
53: =over 4
54:
55: =item * B<Critical messages>: A message the recipient B<must>
56: acknowlegde receipt of before they are allowed to continue using the
57: system, preventing a user from claiming they never got a message
58:
59: =item * B<Receipts>: LON-CAPA can reliably send reciepts informing the
60: sender that it has been read; again, useful for preventing students
61: from claiming they did not see a message. (While conventional e-mail
62: has some reciept support, it's sporadic, e-mail client-specific, and
63: generally the receiver can opt to not send one, making it useless in
64: this case.)
65:
66: =item * B<Context>: LON-CAPA knows about the sender, such as where
67: they are in a course. When a student mails an instructor asking for
68: help on the problem, the instructor receives not just the student's
69: question, but all submissions the student has made up to that point,
70: the user's rendering of the problem, and the complete view the student
71: saw of the resource, including discussion up to that point. Finally,
72: the instructor is reading all of this inside of LON-CAPA, not their
73: email program, so they have full access to LON-CAPA's grading
74: interface, or other features they may wish to use in response to the
75: student's query.
76:
77: =item * B<Blocking>: LON-CAPA can block display of e-mails that are
78: sent to a student during an online exam. A course coordinator or
79: instructor can set an open and close date/time for scheduled online
80: exams in a course. If a user uses the LON-CAPA internal messaging
81: system to display e-mails during the scheduled blocking event,
82: display of all e-mail sent during the blocking period will be
83: suppressed, and a message of explanation, including details of the
84: currently active blocking periods will be displayed instead. A user
85: who has a course coordinator or instructor role in a course will be
86: unaffected by any blocking periods for the course, unless the user
87: also has a student role in the course, AND has selected the student role.
88:
89: =back
90:
91: Users can ask LON-CAPA to forward messages to conventional e-mail
92: addresses on their B<PREF> screen, but generally, LON-CAPA messages
93: are much more useful than traditional email can be made to be, even
94: with HTML support.
95:
96: Right now, this document will cover just how to send a message, since
97: it is likely you will not need to programmatically read messages,
98: since lonmsg already implements that functionality.
99:
100: The routines used to package messages and unpackage messages are not
101: only used by lonmsg when creating/extracting messages for LON-CAPA's
102: internal messaging system, but also by lonnotify.pm which is available
103: for use by Domain Coordinators to broadcast standard e-mail to specified
104: users in their domain. The XML packaging used in the two cases is very
105: similar. The differences are the use of <recuser>$uname</recuser> and
106: <recdomain>$udom</recdomain> in stored internal messages, compared
107: with <recipient username="$uname:$udom">$email</recipient> in stored
108: Domain Coordinator e-mail for the storage of information about
109: recipients of the message/e-mail.
110:
111: =head1 FUNCTIONS
112:
113: =over 4
114:
115: =cut
116:
117: use strict;
118: use Apache::lonnet;
119: use HTML::TokeParser();
120: use Apache::Constants qw(:common);
121: use Apache::loncommon();
122: use Apache::lontexconvert();
123: use HTML::Entities();
124: use Apache::lonlocal;
125: use Apache::loncommunicate;
126: use Apache::lonfeedback;
127: use Apache::lonrss();
128:
129: # Querystring component with sorting type
130: my $sqs;
131: my $startdis;
132: my $interdis;
133:
134: # ============================================================ List all folders
135:
136: sub folderlist {
137: my $folder=shift;
138: my @allfolders=&Apache::lonnet::getkeys('email_folders');
139: if ($allfolders[0]=~/^error:/) { @allfolders=(); }
140: return '<form method="post" action="/adm/email">'.
141: &mt('Folder').': '.
142: &Apache::loncommon::select_form($folder,'folder',
143: ('' => &mt('INBOX'),'trash' => &mt('TRASH'),
144: 'new' => &mt('New Messages Only'),
145: 'critical' => &mt('Critical'),
146: 'sent' => &mt('Sent Messages'),
147: map { $_ => $_ } @allfolders)).
148: ' '.&mt('Show').
149: '<select name="interdis">'.
150: join("\n",map { '<option value="'.$_.'"'.
151: ($_==$interdis?' selected="selected"':'').'>'.$_.'</option>' }
152: (10,20,50,100,200)).'</select>'.
153: '<input type="submit" value="'.&mt('View Folder').'" /><br />'.
154: '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />'.
155: ($folder=~/^(new|critical)/?'</form>':'');
156: }
157:
158: sub scrollbuttons {
159: my ($start,$maxdis,$first,$finish,$total)=@_;
160: unless ($total>0) { return ''; }
161: $start++; $maxdis++;$first++;$finish++;
162: return
163: &mt('Page').': '.
164: '<input type="submit" name="firstview" value="'.&mt('First').'" />'.
165: '<input type="submit" name="prevview" value="'.&mt('Previous').'" />'.
166: '<input type="text" size="5" name="startdis" value="'.$start.'" onChange="this.form.submit()" /> of '.$maxdis.
167: '<input type="submit" name="nextview" value="'.&mt('Next').'" />'.
168: '<input type="submit" name="lastview" value="'.&mt('Last').'" /><br />'.
169: &mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).'</form>';
170: }
171: # =============================================================== Status Change
172:
173: sub statuschange {
174: my ($msgid,$newstatus,$folder)=@_;
1.3 albertel 175: my $suffix=&Apache::lonmsg::foldersuffix($folder);
1.1 albertel 176: my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
177: if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
178: unless ($status{$msgid}) { $status{$msgid}='new'; }
179: unless (($status{$msgid} eq 'replied') ||
180: ($status{$msgid} eq 'forwarded')) {
181: &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
182: }
183: if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
184: &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
185: }
186: if ($newstatus eq 'deleted') {
1.9 albertel 187: return &movemsg($msgid,$folder,'trash');
188: }
189: return ;
1.1 albertel 190: }
191:
192: # ============================================================= Make new folder
193:
194: sub makefolder {
195: my ($newfolder)=@_;
196: if (($newfolder eq 'sent')
197: || ($newfolder eq 'critical')
198: || ($newfolder eq 'trash')
199: || ($newfolder eq 'new')) { return; }
200: &Apache::lonnet::put('email_folders',{$newfolder => time});
201: }
202:
203: # ======================================================== Move between folders
204:
205: sub movemsg {
206: my ($msgid,$srcfolder,$trgfolder)=@_;
207: if ($srcfolder eq 'new') { $srcfolder=''; }
1.3 albertel 208: my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);
209: my $trgsuffix=&Apache::lonmsg::foldersuffix($trgfolder);
1.9 albertel 210: if ($srcsuffix eq $trgsuffix) {
211: return (0,&mt('Message not moved, Attempted to move message to the same folder as it already is in.'));
212: }
1.1 albertel 213:
214: # Copy message
215: my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
1.9 albertel 216: if (!exists($message{$msgid}) || $message{$msgid} eq '') {
217: if (&Apache::slotrequest::network_error(%message)) {
218: return (0,&mt('Message not moved, A network error occurred.'));
219: } else {
220: return (0,&mt('Message not moved as the message is no longer in the source folder.'));
221: }
222: }
223:
224: my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
225: {$msgid => $message{$msgid}});
226: if (&Apache::slotrequest::network_error($result)) {
227: return (0,&mt('Message not moved, A network error occurred.'));
228: }
1.1 albertel 229:
230: # Copy status
231: unless ($trgfolder eq 'trash') {
1.9 albertel 232: my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
233: # a non-existant status is the mark of an unread msg
234: if (&Apache::slotrequest::network_error(%status)) {
235: return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
236: }
237: my $result=&Apache::lonnet::put('email_status'.$trgsuffix,
238: {$msgid => $status{$msgid}});
239: if (&Apache::slotrequest::network_error($result)) {
240: return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
241: }
1.1 albertel 242: }
1.9 albertel 243:
1.1 albertel 244: # Delete orginals
1.9 albertel 245: my $result_del_msg =
246: &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
247: my $result_del_stat =
248: &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
249: if (&Apache::slotrequest::network_error($result_del_msg)) {
250: return (0,&mt('Message copied, but unable to delete the original from the source folder.'));
251: }
252: if (&Apache::slotrequest::network_error($result_del_stat)) {
253: return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
254: }
255:
256: return (1);
1.1 albertel 257: }
258:
259: # ======================================================= Display a course list
260:
261: sub discourse {
262: my $r=shift;
263: my $classlist = &Apache::loncoursedata::get_classlist();
1.20 raeburn 264: my ($classgroups,$studentgroups) =
1.21 ! albertel 265: &Apache::loncoursedata::get_group_memberships($classlist);
1.1 albertel 266: my %lt=&Apache::lonlocal::texthash('cfa' => 'Check All',
267: 'cfs' => 'Check Section/Group',
268: 'cfn' => 'Uncheck All');
1.20 raeburn 269: if (defined($env{'form.group'})) {
270: $r->print('<input type="hidden" name="group" value="'.
271: $env{'form.group'}.'" />'."\n");
272: }
1.1 albertel 273: $r->print(<<ENDDISHEADER);
274: <input type="hidden" name="sendmode" value="group" />
1.17 albertel 275: <script pe="text/javascript">
1.1 albertel 276: function checkall() {
277: for (i=0; i<document.forms.compemail.elements.length; i++) {
278: if
279: (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
280: document.forms.compemail.elements[i].checked=true;
281: }
282: }
283: }
284:
285: function checksec() {
286: for (i=0; i<document.forms.compemail.elements.length; i++) {
287: if
288: (document.forms.compemail.elements[i].name.indexOf
289: ('send_to_&&&'+document.forms.compemail.chksec.value+'&&&')==0) {
290: document.forms.compemail.elements[i].checked=true;
291: }
1.20 raeburn 292: if
293: (document.forms.compemail.elements[i].name.indexOf
294: ('group_&&&'+document.forms.compemail.chksec.value+'&&&_')==0) {
295: var count = i - document.forms.compemail.elements[i].value;
296: document.forms.compemail.elements[count].checked=true;
297: }
1.1 albertel 298: }
299: }
300:
301: function uncheckall() {
302: for (i=0; i<document.forms.compemail.elements.length; i++) {
303: if
304: (document.forms.compemail.elements[i].name.indexOf('send_to_')==0) {
305: document.forms.compemail.elements[i].checked=false;
306: }
307: }
308: }
309: </script>
310: <input type="button" onClick="checkall()" value="$lt{'cfa'}" />
311: <input type="button" onClick="checksec()" value="$lt{'cfs'}" />
1.20 raeburn 312: <input type="text" size="15" name="chksec" value="$env{'form.group'}" />
1.1 albertel 313: <input type="button" onClick="uncheckall()" value="$lt{'cfn'}" />
314: <p>
315: ENDDISHEADER
316: my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
1.20 raeburn 317: $r->print(&Apache::loncommon::start_data_table());
318: if (keys(%coursepersonnel) > 0) {
319: $r->print('<h3>Non-students</h3>');
320: $r->print(&Apache::loncommon::start_data_table());
1.21 ! albertel 321: $r->print('<tr><th>Name</th><th>Username:Domain</th><th>Role</th></tr>');
! 322: foreach my $role (sort(keys(%coursepersonnel))) {
! 323: foreach my $user (split(/\,/,$coursepersonnel{$role})) {
! 324: my ($puname,$pudom)=split(/\:/,$user);
1.20 raeburn 325: $r->print(&Apache::loncommon::start_data_table_row());
326: $r->print('<td><label>'.
327: '<input type="checkbox" name="send_to_&&&&&&_'.
328: $puname.':'.$pudom.'" /> '.
329: &Apache::loncommon::plainname($puname,$pudom).
330: '</label></td>'.
1.21 ! albertel 331: '<td>('.$user.'),</td><td><i>'.$role.'</i></td>');
1.20 raeburn 332: $r->print(&Apache::loncommon::end_data_table_row());
333: }
334: }
335: $r->print(&Apache::loncommon::end_data_table());
336: }
337: if (keys(%{$classlist}) > 0) {
338: $r->print('<h3>Students</h3>');
339: $r->print(&Apache::loncommon::start_data_table());
1.21 ! albertel 340: $r->print('<tr><th>Name</th><th>Username:Domain</th><th>Section</th><th>Groups</th></tr>');
1.20 raeburn 341: my $sort = sub {
342: my $aname=lc($classlist->{$a}[&Apache::loncoursedata::CL_FULLNAME()]);
343: if (!$aname) { $aname=$a; }
344: my $bname=lc($classlist->{$b}[&Apache::loncoursedata::CL_FULLNAME()]);
345: if (!$bname) { $bname=$b; }
346: return $aname cmp $bname;
347: };
348: foreach my $student (sort $sort (keys(%{$classlist}))) {
349: my $info=$classlist->{$student};
350: my ($sname,$sdom,$status,$fullname,$section) =
351: (@{$info}[&Apache::loncoursedata::CL_SNAME(),
352: &Apache::loncoursedata::CL_SDOM(),
353: &Apache::loncoursedata::CL_STATUS(),
354: &Apache::loncoursedata::CL_FULLNAME(),
355: &Apache::loncoursedata::CL_SECTION()]);
356: next if ($status ne 'Active');
357: next if ($env{'request.course.sec'} &&
358: $section ne $env{'request.course.sec'});
1.21 ! albertel 359: my @studentsgroups =
! 360: &Apache::loncoursedata::get_students_groups($student,$status,
! 361: $classgroups);
1.20 raeburn 362: my $grouplist = join(', ',@studentsgroups);
363: my $key = 'send_to_&&&'.$section.'&&&_'.$student;
364: if (! defined($fullname) || $fullname eq '') {$fullname = $sname;}
365: my $checked = '';
366: my $groupcount = 0;
367: my $groupitems;
368: $r->print(&Apache::loncommon::start_data_table_row());
369: $r->print('<td><label>');
370: foreach my $group (@studentsgroups) {
371: $groupcount ++;
372: $groupitems .= ('<input type="hidden" name="group_&&&'.
373: $group.'&&&_'.$student.'" value="'.
374: $groupcount.'" />');
375: if (defined($env{'form.group'})) {
376: if ($env{'form.group'} eq $group) {
1.21 ! albertel 377: $checked = 'checked="checked"';
1.20 raeburn 378: }
379: }
380: }
381: $r->print(qq{<input type="checkbox" name="$key" $checked />}.
382: (' 'x2).$fullname.'</label>'.$groupitems.
383: '</td><td>'.$sname.':'.$sdom.'</td><td>'.$section.
384: '</td><td>'.$grouplist.'</td>');
385: $r->print(&Apache::loncommon::end_data_table_row());
386: }
387: $r->print(&Apache::loncommon::end_data_table());
1.1 albertel 388: }
389: }
390:
391: # ==================================================== Display Critical Message
392:
393: sub discrit {
394: my $r=shift;
1.5 albertel 395: my $header = '<h1><font color="red">'.&mt('Critical Messages').'</font></h1>'.
1.1 albertel 396: '<form action="/adm/email" method="POST">'.
397: '<input type="hidden" name="confirm" value="true" />';
398: my %what=&Apache::lonnet::dump('critical');
399: my $result = '';
400: foreach (sort keys %what) {
401: my %content=&Apache::lonmsg::unpackagemsg($what{$_});
402: next if ($content{'senderdomain'} eq '');
403: $result.='<hr />'.&mt('From').': <b>'.
404: &Apache::loncommon::aboutmewrapper(
405: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
1.14 albertel 406: $content{'sendername'}.':'.
1.1 albertel 407: $content{'senderdomain'}.') '.$content{'time'}.
408: '<br />'.&mt('Subject').': '.$content{'subject'}.
409: '<br /><pre>'.
410: &Apache::lontexconvert::msgtexconverted($content{'message'}).
411: '</pre><small>'.
412: &mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
413: '</small><br />'.
414: '<input type="submit" name="rec_'.$_.'" value="'.&mt('Confirm Receipt').'" />'.
415: '<input type="submit" name="reprec_'.$_.'" '.
416: 'value="'.&mt('Confirm Receipt and Reply').'" />';
417: }
418: # Check to see if there were any messages.
419: if ($result eq '') {
420: $result = "<h2>".&mt('You have no critical messages.')."</h2>".
421: '<a href="/adm/roles">'.&mt('Select a course').'</a><br />'.
422: '<a href="/adm/email">'.&mt('Communicate').'</a>';
423: } else {
424: $r->print($header);
425: }
426: $r->print($result);
427: $r->print('<input type="hidden" name="displayedcrit" value="true" /></form>');
428: }
429:
430: sub sortedmessages {
431: my ($blocked,$startblock,$endblock,$numblocked,$folder) = @_;
432: my $suffix=&Apache::lonmsg::foldersuffix($folder);
433: my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
434: #unpack the varibles and repack into temp for sorting
435: my @temp;
436: my %descriptions;
437: my %status_cache =
438: &Apache::lonnet::get('email_status'.&Apache::lonmsg::foldersuffix($folder),\@messages);
1.11 albertel 439:
440: my $get_received;
441: if ($folder eq 'sent'
442: && ($env{'form.sortedby'} =~ m/^(rev)?(user|domain)$/)) {
443: $get_received = 1;
444: }
445:
446: foreach my $msgid (@messages) {
447: my $esc_msgid=&Apache::lonnet::escape($msgid);
1.1 albertel 448: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
1.11 albertel 449: &Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
1.1 albertel 450: \%status_cache);
451: my $description = &get_course_desc($fromcid,\%descriptions);
452: my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
1.11 albertel 453: $esc_msgid,$description);
454: if ($get_received) {
455: my %message = &Apache::lonnet::get('nohist_email'.$suffix,
456: [$msgid]);
457: my %content = &Apache::lonmsg::unpackagemsg($message{$msgid});
458: push(@temp1,$content{'recuser'},$content{'recdomain'});
459: }
1.1 albertel 460: # Check whether message was sent during blocking period.
461: if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
1.11 albertel 462: $$blocked{$msgid} = 'ON';
1.1 albertel 463: $$numblocked ++;
464: } else {
465: push @temp ,\@temp1;
466: }
467: }
468: #default sort
469: @temp = sort {$a->[0] <=> $b->[0]} @temp;
470: if ($env{'form.sortedby'} eq "date"){
471: @temp = sort {$a->[0] <=> $b->[0]} @temp;
472: }
473: if ($env{'form.sortedby'} eq "revdate"){
474: @temp = sort {$b->[0] <=> $a->[0]} @temp;
475: }
476: if ($env{'form.sortedby'} eq "user"){
1.11 albertel 477: if ($get_received) {
478: @temp = sort {lc($a->[7][0]) cmp lc($b->[7][0])} @temp;
479: } else {
480: @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
481: }
1.1 albertel 482: }
483: if ($env{'form.sortedby'} eq "revuser"){
1.11 albertel 484: if ($get_received) {
485: @temp = sort {lc($b->[7][0]) cmp lc($a->[7][0])} @temp;
486: } else {
487: @temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp;
488: }
1.1 albertel 489: }
490: if ($env{'form.sortedby'} eq "domain"){
1.11 albertel 491: if ($get_received) {
492: @temp = sort {$a->[8][0] cmp $b->[8][0]} @temp;
493: } else {
494: @temp = sort {$a->[3] cmp $b->[3]} @temp;
495: }
1.1 albertel 496: }
497: if ($env{'form.sortedby'} eq "revdomain"){
1.11 albertel 498: if ($get_received) {
499: @temp = sort {$b->[8][0] cmp $a->[8][0]} @temp;
500: } else {
501: @temp = sort {$b->[3] cmp $a->[3]} @temp;
502: }
1.1 albertel 503: }
504: if ($env{'form.sortedby'} eq "subject"){
505: @temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
506: }
507: if ($env{'form.sortedby'} eq "revsubject"){
508: @temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
509: }
510: if ($env{'form.sortedby'} eq "course"){
511: @temp = sort {lc($a->[6]) cmp lc($b->[6])} @temp;
512: }
513: if ($env{'form.sortedby'} eq "revcourse"){
514: @temp = sort {lc($b->[6]) cmp lc($a->[6])} @temp;
515: }
516: if ($env{'form.sortedby'} eq "status"){
517: @temp = sort {$a->[4] cmp $b->[4]} @temp;
518: }
519: if ($env{'form.sortedby'} eq "revstatus"){
520: @temp = sort {$b->[4] cmp $a->[4]} @temp;
521: }
522: return @temp;
523: }
524:
525: sub get_course_desc {
526: my ($fromcid,$descriptions) = @_;
527: my $description;
528: if (!$fromcid) {
529: return $description;
530: } else {
531: if (defined($$descriptions{$fromcid})) {
532: $description = $$descriptions{$fromcid};
533: } else {
534: if (defined($env{'course.'.$fromcid.'.description'})) {
535: $description = $env{'course.'.$fromcid.'.description'};
536: } else {
537: my %courseinfo=&Apache::lonnet::coursedescription($fromcid); $description = $courseinfo{'description'};
538: $description = $courseinfo{'description'};
539: }
540: $$descriptions{$fromcid} = $description;
541: }
542: return $description;
543: }
544: }
545:
546: # ======================================================== Display new messages
547:
548:
549: sub disnew {
550: my $r=shift;
551: my %lt=&Apache::lonlocal::texthash(
552: 'nm' => 'New Messages',
553: 'su' => 'Subject',
554: 'co' => 'Course',
555: 'da' => 'Date',
556: 'us' => 'Username',
557: 'op' => 'Open',
558: 'do' => 'Domain'
559: );
560: my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
561: my @newmsgs;
562: my %setters = ();
563: my $startblock = 0;
564: my $endblock = 0;
565: my %blocked = ();
566: my $numblocked = 0;
567: # Check for blocking of display because of scheduled online exams.
568: &blockcheck(\%setters,\$startblock,\$endblock);
569: my %status_cache =
570: &Apache::lonnet::get('email_status',\@msgids);
571: my %descriptions;
572: foreach (@msgids) {
573: my $msgid=&Apache::lonnet::escape($_);
574: my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
575: &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
576: if (defined($sendtime) && $sendtime!~/error/) {
577: my $description = &get_course_desc($fromcid,\%descriptions);
578: my $numsendtime = $sendtime;
579: $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
580: if ($status eq 'new') {
581: if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
582: $blocked{$_} = 'ON';
583: $numblocked ++;
584: } else {
585: push @newmsgs, {
586: msgid => $msgid,
587: sendtime => $sendtime,
1.8 albertel 588: shortsub => $shortsubj,
1.1 albertel 589: from => $fromname,
590: fromdom => $fromdom,
591: course => $description
592: }
593: }
594: }
595: }
596: }
597: if ($#newmsgs >= 0) {
598: $r->print(<<TABLEHEAD);
599: <h2>$lt{'nm'}</h2>
1.4 albertel 600: <table class="LC_mail_list"><tr><th> </th>
1.1 albertel 601: <th>$lt{'da'}</th><th>$lt{'us'}</th><th>$lt{'do'}</th><th>$lt{'su'}</th><th>$lt{'co'}</th></tr>
602: TABLEHEAD
603: foreach my $msg (@newmsgs) {
604: $r->print(<<"ENDLINK");
1.4 albertel 605: <tr class="LC_mail_new">
1.1 albertel 606: <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>
607: ENDLINK
608: foreach ('sendtime','from','fromdom','shortsub','course') {
609: $r->print("<td>$msg->{$_}</td>");
610: }
611: $r->print("</td></tr>");
612: }
613: $r->print('</table>');
614: } elsif ($numblocked == 0) {
615: $r->print("<h3>".&mt('You have no unread messages')."</h3>");
616: }
617: if ($numblocked > 0) {
618: my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
619: my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
620: if ($numblocked == 1) {
621: $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".</h3>");
622: $r->print(&mt('This message is not viewable because').' ');
623: } else {
624: $r->print("<h3>".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".</h3>");
625: $r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because '));
626: }
627: $r->print(
628: &mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
629: &build_block_table($r,$startblock,$endblock,\%setters);
630: }
631: }
632:
633:
634: # ======================================================== Display all messages
635:
636: sub disall {
637: my ($r,$folder)=@_;
638: $r->print(&folderlist($folder));
639: if ($folder eq 'new') {
640: &disnew($r);
641: } elsif ($folder eq 'critical') {
642: &discrit($r);
643: } else {
644: &disfolder($r,$folder);
645: }
646: }
647:
648: # ============================================================ Display a folder
649:
650: sub disfolder {
651: my ($r,$folder)=@_;
652: my %blocked = ();
653: my %setters = ();
654: my $startblock;
655: my $endblock;
656: my $numblocked = 0;
657: &blockcheck(\%setters,\$startblock,\$endblock);
658: $r->print(<<ENDDISHEADER);
1.16 albertel 659: <script type="text/javascript">
1.1 albertel 660: function checkall() {
661: for (i=0; i<document.forms.disall.elements.length; i++) {
662: if
663: (document.forms.disall.elements[i].name.indexOf('delmark_')==0) {
664: document.forms.disall.elements[i].checked=true;
665: }
666: }
667: }
668:
669: function uncheckall() {
670: for (i=0; i<document.forms.disall.elements.length; i++) {
671: if
672: (document.forms.disall.elements[i].name.indexOf('delmark_')==0) {
673: document.forms.disall.elements[i].checked=false;
674: }
675: }
676: }
677: </script>
678: ENDDISHEADER
679: my $fsqs='&folder='.$folder;
680: my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
681: my $totalnumber=$#temp+1;
682: unless ($totalnumber>0) {
683: $r->print('<h2>'.&mt('Empty Folder').'</h2>');
684: return;
685: }
686: unless ($interdis) {
687: $interdis=20;
688: }
689: my $number=int($totalnumber/$interdis);
690: if (($startdis<0) || ($startdis>$number)) { $startdis=$number; }
691: my $firstdis=$interdis*$startdis;
692: if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; }
693: my $lastdis=$firstdis+$interdis-1;
694: if ($lastdis>$#temp) { $lastdis=$#temp; }
695: $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));
696: $r->print('<form method="post" name="disall" action="/adm/email">'.
1.4 albertel 697: '<table class="LC_mail_list"><tr><th colspan="3"> </th><th>');
1.1 albertel 698: if ($env{'form.sortedby'} eq "revdate") {
699: $r->print('<a href = "?sortedby=date'.$fsqs.'">'.&mt('Date').'</a></th>');
700: } else {
701: $r->print('<a href = "?sortedby=revdate'.$fsqs.'">'.&mt('Date').'</a></th>');
702: }
703: $r->print('<th>');
704: if ($env{'form.sortedby'} eq "revuser") {
705: $r->print('<a href = "?sortedby=user'.$fsqs.'">'.&mt('Username').'</a>');
706: } else {
707: $r->print('<a href = "?sortedby=revuser'.$fsqs.'">'.&mt('Username').'</a>');
708: }
709: $r->print('</th><th>');
710: if ($env{'form.sortedby'} eq "revdomain") {
711: $r->print('<a href = "?sortedby=domain'.$fsqs.'">'.&mt('Domain').'</a>');
712: } else {
713: $r->print('<a href = "?sortedby=revdomain'.$fsqs.'">'.&mt('Domain').'</a>');
714: }
715: $r->print('</th><th>');
716: if ($env{'form.sortedby'} eq "revsubject") {
717: $r->print('<a href = "?sortedby=subject'.$fsqs.'">'.&mt('Subject').'</a>');
718: } else {
719: $r->print('<a href = "?sortedby=revsubject'.$fsqs.'">'.&mt('Subject').'</a>');
720: }
721: $r->print('</th><th>');
722: if ($env{'form.sortedby'} eq "revcourse") {
723: $r->print('<a href = "?sortedby=course'.$fsqs.'">'.&mt('Course').'</a>');
724: } else {
725: $r->print('<a href = "?sortedby=revcourse'.$fsqs.'">'.&mt('Course').'</a>');
726: }
727: $r->print('</th><th>');
728: if ($env{'form.sortedby'} eq "revstatus") {
729: $r->print('<a href = "?sortedby=status'.$fsqs.'">'.&mt('Status').'</a></th>');
730: } else {
731: $r->print('<a href = "?sortedby=revstatus'.$fsqs.'">'.&mt('Status').'</a></th>');
732: }
733: $r->print("</tr>\n");
1.6 albertel 734:
735: my $suffix = &Apache::lonmsg::foldersuffix($folder);
1.1 albertel 736: for (my $n=$firstdis;$n<=$lastdis;$n++) {
1.11 albertel 737: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,
738: $description,$recv_name,$recv_domain)=
739: @{$temp[$n]};
1.1 albertel 740: if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
741: if ($status eq 'new') {
1.4 albertel 742: $r->print('<tr class="LC_mail_new">');
1.1 albertel 743: } elsif ($status eq 'read') {
1.4 albertel 744: $r->print('<tr class="LC_mail_read">');
1.1 albertel 745: } elsif ($status eq 'replied') {
1.4 albertel 746: $r->print('<tr class="LC_mail_replied">');
1.1 albertel 747: } else {
1.4 albertel 748: $r->print('<tr class="LC_mail_other">');
1.1 albertel 749: }
1.6 albertel 750: my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
751: if ($folder eq 'sent') {
1.11 albertel 752: if (defined($recv_name) && !defined($recv_domain)) {
753: $dis_name = join('<br />',@{$recv_name});
754: $dis_domain = join('<br />',@{$recv_domain});
755: } else {
756: my $msg_id = &Apache::lonnet::unescape($origID);
757: my %message = &Apache::lonnet::get('nohist_email'.$suffix,
758: [$msg_id]);
759: my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
760: $dis_name = join('<br />',@{$content{'recuser'}});
761: $dis_domain = join('<br />',@{$content{'recdomain'}});
762: }
1.6 albertel 763: }
1.1 albertel 764: $r->print('<td><input type="checkbox" name="delmark_'.$origID.'" /></td><td><a href="/adm/email?display='.$origID.$sqs.
765: '">'.&mt('Open').'</a></td><td>'.
766: ($folder ne 'trash'?'<a href="/adm/email?markdel='.$origID.$sqs.
767: '">'.&mt('Delete'):' ').'</a></td>'.
768: '<td>'.&Apache::lonlocal::locallocaltime($sendtime).'</td><td>'.
1.6 albertel 769: $dis_name.'</td><td>'.$dis_domain.'</td><td>'.
1.8 albertel 770: $shortsubj.'</td><td>'.
1.1 albertel 771: $description.'</td><td>'.$status.'</td></tr>'."\n");
772: } elsif ($status eq 'deleted') {
773: # purge
1.9 albertel 774: my ($result,$msg) =
775: &movemsg(&Apache::lonnet::unescape($origID),$folder,'trash');
776:
1.1 albertel 777: }
778: }
779: $r->print("</table>\n<p>".
780: '<a href="javascript:checkall()">'.&mt('Check All').'</a> '.
781: '<a href="javascript:uncheckall()">'.&mt('Uncheck All').'</a></p>'.
782: '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />');
783: if ($folder ne 'trash') {
784: $r->print(
785: '<p><input type="submit" name="markeddel" value="'.&mt('Delete Checked').'" /></p>');
786: }
787: $r->print('<p><input type="submit" name="markedmove" value="'.&mt('Move Checked to Folder').'" />');
788: my @allfolders=&Apache::lonnet::getkeys('email_folders');
789: if ($allfolders[0]=~/^error:/) { @allfolders=(); }
790: $r->print(
791: &Apache::loncommon::select_form('','movetofolder',
792: ( map { $_ => $_ } @allfolders))
793: );
794: my $postedstartdis=$startdis+1;
795: $r->print('<input type="hidden" name="folder" value="'.$folder.'" /><input type="hidden" name="startdis" value="'.$postedstartdis.'" /><input type="hidden" name="interdis" value="'.$env{'form.interdis'}.'" /></form>');
796: if ($numblocked > 0) {
797: my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
798: my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
799: $r->print('<br /><br />'.
800: $numblocked.' '.&mt('message(s) is/are not viewable because display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams.'));
801: &build_block_table($r,$startblock,$endblock,\%setters);
802: }
803: }
804:
805: # ============================================================== Compose output
806:
807: sub compout {
808: my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode)=@_;
809: my $suffix=&Apache::lonmsg::foldersuffix($folder);
810:
811: if ($broadcast eq 'individual') {
812: &printheader($r,'/adm/email?compose=individual',
813: 'Send a Message');
814: } elsif ($broadcast) {
815: &printheader($r,'/adm/email?compose=group',
816: 'Broadcast Message');
817: } elsif ($forwarding) {
818: &Apache::lonhtmlcommon::add_breadcrumb
819: ({href=>"/adm/email?display=".&Apache::lonnet::escape($forwarding),
820: text=>"Display Message"});
821: &printheader($r,'/adm/email?forward='.&Apache::lonnet::escape($forwarding),
822: 'Forwarding a Message');
823: } elsif ($replying) {
824: &Apache::lonhtmlcommon::add_breadcrumb
825: ({href=>"/adm/email?display=".&Apache::lonnet::escape($replying),
826: text=>"Display Message"});
827: &printheader($r,'/adm/email?replyto='.&Apache::lonnet::escape($replying),
828: 'Replying to a Message');
829: } elsif ($replycrit) {
830: $r->print('<h3>'.&mt('Replying to a Critical Message').'</h3>');
831: $replying=$replycrit;
832: } else {
833: &printheader($r,'/adm/email?compose=upload',
834: 'Distribute from Uploaded File');
835: }
836:
837: my $dispcrit='';
838: my $dissub='';
839: my $dismsg='';
840: my $disbase='';
841: my $func=&mt('Send New');
842: my %lt=&Apache::lonlocal::texthash('us' => 'Username',
843: 'do' => 'Domain',
844: 'ad' => 'Additional Recipients',
845: 'sb' => 'Subject',
846: 'ca' => 'Cancel',
847: 'ma' => 'Mail');
848:
849: if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
850: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
851: '/'.$env{'request.course.sec'})) {
852: my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
853: $dispcrit=
854: '<p><label><input type="checkbox" name="critmsg" /> '.&mt('Send as critical message').'</label> ' . $crithelp .
855: '</p><p>'.
856: '<label><input type="checkbox" name="sendbck" /> '.&mt('Send as critical message').' ' .
857: &mt('and return receipt') . '</label>' . $crithelp .
858: '</p><p><label><input type="checkbox" name="permanent" /> '.
859: &mt('Send copy to permanent email address (if known)').'</label></p>'.
860: '<p><label><input type="checkbox" name="rsspost" /> '.
861: &mt('Include in course RSS newsfeed').'</label></p>';
862: }
863: my %message;
864: my %content;
865: my $defdom=$env{'user.domain'};
866: if ($forwarding) {
867: %message=&Apache::lonnet::get('nohist_email'.$suffix,[$forwarding]);
868: %content=&Apache::lonmsg::unpackagemsg($message{$forwarding},$folder);
869: $dispcrit.='<input type="hidden" name="forwid" value="'.
870: $forwarding.'" />';
871: $func=&mt('Forward');
872:
873: $dissub=&mt('Forwarding').': '.$content{'subject'};
874: $dismsg=&mt('Forwarded message from').' '.
875: $content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'};
876: if ($content{'baseurl'}) {
877: $disbase='<input type="hidden" name="baseurl" value="'.&Apache::lonnet::escape($content{'baseurl'}).'" />';
878: }
879: }
880: if ($replying) {
881: %message=&Apache::lonnet::get('nohist_email'.$suffix,[$replying]);
882: %content=&Apache::lonmsg::unpackagemsg($message{$replying},$folder);
883: $dispcrit.='<input type="hidden" name="replyid" value="'.
884: $replying.'" />';
885: $func=&mt('Send Reply to');
886:
887: $dissub=&mt('Reply').': '.$content{'subject'};
888: $dismsg='> '.$content{'message'};
889: $dismsg=~s/\r/\n/g;
890: $dismsg=~s/\f/\n/g;
891: $dismsg=~s/\n+/\n\> /g;
892: if ($content{'baseurl'}) {
893: $disbase='<input type="hidden" name="baseurl" value="'.&Apache::lonnet::escape($content{'baseurl'}).'" />';
894: if ($env{'user.adv'}) {
895: $disbase.='<label><input type="checkbox" name="storebasecomment" />'.&mt('Store message for re-use').
896: '</label> <a href="/adm/email?showcommentbaseurl='.
897: &Apache::lonnet::escape($content{'baseurl'}).'" target="comments">'.
898: &mt('Show re-usable messages').'</a><br />';
899: }
900: }
901: }
902: my $citation=&displayresource(%content);
903: if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; }
904: $r->print(
905: '<form action="/adm/email" name="compemail" method="post"'.
906: ' enctype="multipart/form-data">'."\n".
907: '<input type="hidden" name="sendmail" value="on" />'."\n".
908: '<table>');
909: unless (($broadcast eq 'group') || ($broadcast eq 'upload')) {
910: if ($replying) {
911: $r->print('<tr><td colspan="2">'.&mt('Replying to').' '.
912: &Apache::loncommon::aboutmewrapper(
913: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
1.14 albertel 914: $content{'sendername'}.':'.
1.1 albertel 915: $content{'senderdomain'}.')'.
916: '<input type="hidden" name="recuname" value="'.$content{'sendername'}.'" />'.
917: '<input type="hidden" name="recdomain" value="'.$content{'senderdomain'}.'" />'.
918: '</td></tr>');
919: } else {
920: my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
921: my $selectlink=&Apache::loncommon::selectstudent_link
922: ('compemail','recuname','recdomain');
923: $r->print(<<"ENDREC");
924: <tr><td>$lt{'us'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recname'}" /></td><td rowspan="2">$selectlink</td></tr>
925: <tr><td>$lt{'do'}:</td>
926: <td>$domform</td></tr>
927: ENDREC
928: }
929: }
930: my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
931: if ($broadcast ne 'upload') {
932: $r->print(<<"ENDCOMP");
933: <tr><td>$lt{'ad'}<br /><tt>username\@domain,username\@domain, ...
934: </tt></td><td>
935: <input type="text" size="50" name="additionalrec" /></td></tr>
936: <tr><td>$lt{'sb'}:</td><td><input type="text" size="50" name="subject" value="$dissub" />
937: </td></tr></table>
938: $latexHelp
939: <textarea name="message" id="message" cols="80" rows="15" wrap="hard">$dismsg
940: </textarea></p><br />
941: $dispcrit
942: $disbase
943: <input type="hidden" name="folder" value="$folder" />
944: <input type="hidden" name="dismode" value="$dismode" />
945: <input type="submit" name="send" value="$func $lt{'ma'}" />
946: <input type="submit" name="cancel" value="$lt{'ca'}" /><hr />
947: $citation
948: ENDCOMP
949: } else { # $broadcast is 'upload'
950: $r->print(<<ENDUPLOAD);
951: <input type="hidden" name="sendmode" value="upload" />
952: <input type="hidden" name="send" value="on" />
953: <h3>Generate messages from a file</h3>
954: <p>
955: Subject: <input type="text" size="50" name="subject" />
956: </p>
957: <p>General message text<br />
958: <textarea name="message" id="message" cols="60" rows="10" wrap="hard">$dismsg
959: </textarea></p>
960: <p>
961: The file format for the uploaded portion of the message is:
962: <pre>
963: username1\@domain1: text
964: username2\@domain2: text
965: username3\@domain1: text
966: </pre>
967: </p>
968: <p>
969: The messages will be assembled from all lines with the respective
970: <tt>username\@domain</tt>, and appended to the general message text.</p>
971: <p>
972: <input type="file" name="upfile" size="40" /></p><p>
973: $dispcrit
974: <input type="submit" value="Upload and Send" /></p>
975: ENDUPLOAD
976: }
977: if ($broadcast eq 'group') {
978: &discourse($r);
979: }
980: $r->print('</form>'.
981: &Apache::lonfeedback::generate_preview_button('compemail','message').
982: &Apache::lonhtmlcommon::htmlareaselectactive('message'));
983: }
984:
985: # ---------------------------------------------------- Display all face to face
986:
987: sub retrieve_instructor_comments {
988: my ($user,$domain)=@_;
989: my $target=$env{'form.grade_target'};
990: if (! $env{'request.course.id'}) { return; }
991: if (! &Apache::lonnet::allowed('srm',$env{'request.course.id'})
992: && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
993: '/'.$env{'request.course.sec'})) {
994: return;
995: }
996: my %records=&Apache::lonnet::dump('nohist_email',
997: $env{'course.'.$env{'request.course.id'}.'.domain'},
998: $env{'course.'.$env{'request.course.id'}.'.num'},
999: '%255b'.$user.'%253a'.$domain.'%255d');
1000: my $result='';
1001: foreach (sort(keys(%records))) {
1002: my %content=&Apache::lonmsg::unpackagemsg($records{$_});
1003: next if ($content{'senderdomain'} eq '');
1004: next if ($content{'subject'} !~ /^Record/);
1005: # &Apache::lonfeedback::newline_to_br(\$content{'message'});
1006: $result.='Recorded by '.
1.14 albertel 1007: $content{'sendername'}.':'.$content{'senderdomain'}."\n";
1.1 albertel 1008: $result.=
1009: &Apache::lontexconvert::msgtexconverted($content{'message'})."\n";
1010: }
1011: return $result;
1012: }
1013:
1014: sub disfacetoface {
1015: my ($r,$user,$domain)=@_;
1016: my $target=$env{'form.grade_target'};
1017: unless ($env{'request.course.id'}) { return; }
1018: if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1019: && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1020: '/'.$env{'request.course.sec'})) {
1021: $r->print('Not allowed');
1022: return;
1023: }
1024: my %records=&Apache::lonnet::dump('nohist_email',
1025: $env{'course.'.$env{'request.course.id'}.'.domain'},
1026: $env{'course.'.$env{'request.course.id'}.'.num'},
1027: '%255b'.$user.'%253a'.$domain.'%255d');
1028: my $result='';
1029: foreach (sort keys %records) {
1030: my %content=&Apache::lonmsg::unpackagemsg($records{$_});
1031: next if ($content{'senderdomain'} eq '');
1032: &Apache::lonfeedback::newline_to_br(\$content{'message'});
1033: if ($content{'subject'}=~/^Record/) {
1034: $result.='<h3>'.&mt('Record').'</h3>';
1035: } elsif ($content{'subject'}=~/^Broadcast/) {
1036: $result .='<h3>'.&mt('Broadcast Message').'</h3>';
1037: if ($content{'subject'}=~/^Broadcast\./) {
1038: if (defined($content{'coursemsgid'})) {
1039: my $crsmsgid = &Apache::lonnet::escape($content{'coursemsgid'});
1040: my $broadcast_message = &general_message($crsmsgid);
1041: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$broadcast_message;
1042: } else {
1043: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1044: $content{'message'} =
1045: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1046: $content{'message'};
1047: }
1048: }
1049: } else {
1050: $result.='<h3>'.&mt('Critical Message').'</h3>';
1051: if (defined($content{'coursemsgid'})) {
1052: my $crsmsgid=&Apache::lonnet::escape($content{'coursemsgid'});
1053: my $critical_message = &general_message($crsmsgid);
1054: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$critical_message;
1055: } else {
1056: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1057: $content{'message'}=
1058: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1059: $content{'message'};
1060: }
1061: }
1062: $result.=&mt('By').': <b>'.
1063: &Apache::loncommon::aboutmewrapper(
1064: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
1.14 albertel 1065: $content{'sendername'}.':'.
1.1 albertel 1066: $content{'senderdomain'}.') '.$content{'time'}.
1067: '<br /><pre>'.
1068: &Apache::lontexconvert::msgtexconverted($content{'message'}).
1069: '</pre>';
1070: }
1071: # Check to see if there were any messages.
1072: if ($result eq '') {
1073: if ($target ne 'tex') {
1074: $r->print("<p><b>".&mt("No notes, face-to-face discussion records, critical messages, or broadcast messages in this course.")."</b></p>");
1075: } else {
1076: $r->print('\textbf{'.&mt("No notes, face-to-face discussion records, critical messages or broadcast messages in this course.").'}\\\\');
1077: }
1078: } else {
1079: $r->print($result);
1080: }
1081: }
1082:
1083: sub general_message {
1084: my ($crsmsgid) = @_;
1085: my %general_content;
1086: if ($crsmsgid) {
1087: my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
1088: $env{'course.'.$env{'request.course.id'}.'.domain'},
1089: $env{'course.'.$env{'request.course.id'}.'.num'});
1090: %general_content = &Apache::lonmsg::unpackagemsg($course_content{$crsmsgid});
1091: }
1092: return $general_content{'message'};
1093: }
1094:
1095: # ---------------------------------------------------------------- Face to face
1096:
1097: sub facetoface {
1098: my ($r,$stage)=@_;
1099: if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1100: && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1101: '/'.$env{'request.course.sec'})) {
1102: $r->print('Not allowed');
1103: return;
1104: }
1105: &printheader($r,
1106: '/adm/email?recordftf=query',
1107: "User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
1108: # from query string
1109:
1110: if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
1111: if ($env{'form.recdom'}) { $env{'form.recdomain'}=$env{'form.recdom'}; }
1112:
1113: my $defdom=$env{'user.domain'};
1114: # already filled in
1115: if ($env{'form.recdomain'}) { $defdom=$env{'form.recdomain'}; }
1116: # generate output
1117: my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
1118: my $stdbrws = &Apache::loncommon::selectstudent_link
1119: ('stdselect','recuname','recdomain');
1120: my %lt=&Apache::lonlocal::texthash('user' => 'Username',
1121: 'dom' => 'Domain',
1122: 'head' => 'User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in Course',
1123: 'subm' => 'Retrieve discussion and message records',
1124: 'newr' => 'New Record (record is visible to course faculty and staff)',
1125: 'post' => 'Post this Record');
1126: $r->print(<<"ENDTREC");
1127: <h3>$lt{'head'}</h3>
1128: <form method="post" action="/adm/email" name="stdselect">
1129: <input type="hidden" name="recordftf" value="retrieve" />
1130: <table>
1131: <tr><td>$lt{'user'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recuname'}" /></td>
1132: <td rowspan="2">
1133: $stdbrws
1134: <input type="submit" value="$lt{'subm'}" /></td>
1135: </tr>
1136: <tr><td>$lt{'dom'}:</td>
1137: <td>$domform</td></tr>
1138: </table>
1139: </form>
1140: ENDTREC
1141: if (($stage ne 'query') &&
1142: ($env{'form.recdomain'}) && ($env{'form.recuname'})) {
1143: chomp($env{'form.newrecord'});
1144: if ($env{'form.newrecord'}) {
1145: my $recordtxt = $env{'form.newrecord'};
1146: &Apache::lonmsg::user_normal_msg_raw(
1147: $env{'course.'.$env{'request.course.id'}.'.num'},
1148: $env{'course.'.$env{'request.course.id'}.'.domain'},
1149: &mt('Record').
1150: ' ['.$env{'form.recuname'}.':'.$env{'form.recdomain'}.']',
1151: $recordtxt);
1152: }
1153: $r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'},
1154: $env{'form.recdomain'}).'</h3>');
1155: &disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
1156: $r->print(<<ENDRHEAD);
1157: <form method="post" action="/adm/email">
1158: <input name="recdomain" value="$env{'form.recdomain'}" type="hidden" />
1159: <input name="recuname" value="$env{'form.recuname'}" type="hidden" />
1160: ENDRHEAD
1161: $r->print(<<ENDBFORM);
1162: <hr />$lt{'newr'}<br />
1163: <textarea name="newrecord" cols="80" rows="10" wrap="hard"></textarea>
1164: <br />
1165: <input type="hidden" name="recordftf" value="post" />
1166: <input type="submit" value="$lt{'post'}" />
1167: </form>
1168: ENDBFORM
1169: }
1170: }
1171:
1172: # ----------------------------------------------------------- Blocking during exams
1173:
1174: sub examblock {
1175: my ($r,$action) = @_;
1176: unless ($env{'request.course.id'}) { return;}
1177: if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1178: && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1179: '/'.$env{'request.course.sec'})) {
1180: $r->print('Not allowed');
1181: return;
1182: }
1183: my %lt=&Apache::lonlocal::texthash(
1184: 'comb' => 'Communication Blocking',
1185: 'cbds' => 'Communication blocking during scheduled exams',
1186: 'desc' => 'You can use communication blocking to prevent students enrolled in this course from displaying LON-CAPA messages sent by other students during an online exam. As blocking of communication could potentially interrupt legitimate communication between students who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.',
1187: 'mecb' => 'Modify existing communication blocking periods',
1188: 'ncbc' => 'No communication blocks currently stored'
1189: );
1190:
1191: my %ltext = &Apache::lonlocal::texthash(
1192: 'dura' => 'Duration',
1193: 'setb' => 'Set by',
1194: 'even' => 'Event',
1195: 'actn' => 'Action',
1196: 'star' => 'Start',
1197: 'endd' => 'End'
1198: );
1199:
1200: &printheader($r,'/adm/email?block=display',$lt{'comb'});
1201: $r->print('<h3>'.$lt{'cbds'}.'</h3>');
1202:
1203: if ($action eq 'store') {
1204: &blockstore($r);
1205: }
1206:
1207: $r->print($lt{'desc'}.'<br /><br />
1208: <form name="blockform" method="post" action="/adm/email?block=store">
1209: ');
1210:
1211: $r->print('<h4>'.$lt{'mecb'}.'</h4>');
1212: my %records = ();
1213: my $blockcount = 0;
1214: my $parmcount = 0;
1215: &get_blockdates(\%records,\$blockcount);
1216: if ($blockcount > 0) {
1217: $parmcount = &display_blocker_status($r,\%records,\%ltext);
1218: } else {
1219: $r->print($lt{'ncbc'}.'<br /><br />');
1220: }
1221: &display_addblocker_table($r,$parmcount,\%ltext);
1222: my $end_page=&Apache::loncommon::end_page();
1223: $r->print(<<"END");
1224: <br />
1225: <input type="hidden" name="blocktotal" value="$blockcount" />
1226: <input type ="submit" value="Save Changes" />
1227: </form>
1228: $end_page
1229: END
1230: return;
1231: }
1232:
1233: sub blockstore {
1234: my $r = shift;
1235: my %lt=&Apache::lonlocal::texthash(
1236: 'tfcm' => 'The following changes were made',
1237: 'cbps' => 'communication blocking period(s)',
1238: 'werm' => 'was/were removed',
1239: 'wemo' => 'was/were modified',
1240: 'wead' => 'was/were added',
1241: 'ncwm' => 'No changes were made.'
1242: );
1243: my %adds = ();
1244: my %removals = ();
1245: my %cancels = ();
1246: my $modtotal = 0;
1247: my $canceltotal = 0;
1248: my $addtotal = 0;
1249: my %blocking = ();
1250: $r->print('<h3>'.$lt{'head'}.'</h3>');
1251: foreach (keys %env) {
1252: if ($_ =~ m/^form\.modify_(\w+)$/) {
1253: $adds{$1} = $1;
1254: $removals{$1} = $1;
1255: $modtotal ++;
1256: } elsif ($_ =~ m/^form\.cancel_(\d+)$/) {
1257: $cancels{$1} = $1;
1258: unless ( defined($removals{$1}) ) {
1259: $removals{$1} = $1;
1260: $canceltotal ++;
1261: }
1262: } elsif ($_ =~ m/^form\.add_(\d+)$/) {
1263: $adds{$1} = $1;
1264: $addtotal ++;
1265: }
1266: }
1267:
1268: foreach (keys %removals) {
1269: my $hashkey = $env{'form.key_'.$_};
1270: &Apache::lonnet::del('comm_block',["$hashkey"],
1271: $env{'course.'.$env{'request.course.id'}.'.domain'},
1272: $env{'course.'.$env{'request.course.id'}.'.num'}
1273: );
1274: }
1275: foreach (keys %adds) {
1276: unless ( defined($cancels{$_}) ) {
1277: my ($newstart,$newend) = &get_dates_from_form($_);
1278: my $newkey = $newstart.'____'.$newend;
1.14 albertel 1279: $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$_};
1.1 albertel 1280: }
1281: }
1282: if ($addtotal + $modtotal > 0) {
1283: &Apache::lonnet::put('comm_block',\%blocking,
1284: $env{'course.'.$env{'request.course.id'}.'.domain'},
1285: $env{'course.'.$env{'request.course.id'}.'.num'}
1286: );
1287: }
1288: my $chgestotal = $canceltotal + $modtotal + $addtotal;
1289: if ($chgestotal > 0) {
1290: $r->print($lt{'tfcm'}.'<ul>');
1291: if ($canceltotal > 0) {
1292: $r->print('<li>'.$canceltotal.' '.$lt{'cbps'},' '.$lt{'werm'}.'</li>');
1293: }
1294: if ($modtotal > 0) {
1295: $r->print('<li>'.$modtotal.' '.$lt{'cbps'},' '.$lt{'wemo'}.'</li>');
1296: }
1297: if ($addtotal > 0) {
1298: $r->print('<li>'.$addtotal.' '.$lt{'cbps'},' '.$lt{'wead'}.'</li>');
1299: }
1300: $r->print('</ul>');
1301: } else {
1302: $r->print($lt{'ncwm'});
1303: }
1304: $r->print('<br />');
1305: return;
1306: }
1307:
1308: sub get_dates_from_form {
1309: my $item = shift;
1310: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
1311: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
1312: return ($startdate,$enddate);
1313: }
1314:
1315: sub get_blockdates {
1316: my ($records,$blockcount) = @_;
1317: $$blockcount = 0;
1318: %{$records} = &Apache::lonnet::dump('comm_block',
1319: $env{'course.'.$env{'request.course.id'}.'.domain'},
1320: $env{'course.'.$env{'request.course.id'}.'.num'}
1321: );
1.15 albertel 1322: $$blockcount = keys(%{$records});
1323:
1324: if ((keys(%{$records}))[0] =~ /^error: 2 /) {
1325: $records = {};
1326: $$blockcount = 0;
1.1 albertel 1327: }
1328: }
1329:
1330: sub display_blocker_status {
1331: my ($r,$records,$ltext) = @_;
1332: my $parmcount = 0;
1.16 albertel 1333:
1.1 albertel 1334: my %lt = &Apache::lonlocal::texthash(
1335: 'modi' => 'Modify',
1336: 'canc' => 'Cancel',
1337: );
1.18 albertel 1338: $r->print(&Apache::loncommon::start_data_table());
1.1 albertel 1339: $r->print(<<"END");
1.16 albertel 1340: <tr>
1341: <th>$$ltext{'dura'}</th>
1342: <th>$$ltext{'setb'}</th>
1343: <th>$$ltext{'even'}</th>
1344: <th>$$ltext{'actn'}?</th>
1345: </tr>
1.1 albertel 1346: END
1.18 albertel 1347: foreach my $record (sort(keys(%{$records}))) {
1.1 albertel 1348: my $onchange = 'onFocus="javascript:window.document.forms['.
1349: "'blockform'].elements['modify_".$parmcount."'].".
1350: 'checked=true;"';
1.18 albertel 1351: my ($start,$end) = split(/____/,$record);
1.1 albertel 1352: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
1353: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
1.15 albertel 1354:
1.18 albertel 1355: my ($setuname,$setudom,$title) =
1356: &parse_block_record($$records{$record});
1.21 ! albertel 1357: $title = &HTML::Entities::encode($title,'"<>&');
1.1 albertel 1358: my $settername = &Apache::loncommon::plainname($setuname,$setudom);
1.18 albertel 1359: $r->print(&Apache::loncommon::start_data_table_row());
1.1 albertel 1360: $r->print(<<"END");
1361: <td>$$ltext{'star'}: $startform<br/>$$ltext{'endd'}: $endform</td>
1362: <td>$settername</td>
1.18 albertel 1363: <td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td>
1.1 albertel 1364: <td><label>$lt{'modi'}? <input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}? <input type="checkbox" name="cancel_$parmcount" /></label>
1365: END
1.18 albertel 1366: $r->print(&Apache::loncommon::end_data_table_row());
1367: $parmcount++;
1.1 albertel 1368: }
1369: $r->print(<<"END");
1370: </table>
1371: <br />
1372: <br />
1373: END
1374: return $parmcount;
1375: }
1376:
1.15 albertel 1377: sub parse_block_record {
1378: my ($record) = @_;
1379: my ($setuname,$setudom,$title);
1380: my @data = split(/:/,$record,3);
1381: if (scalar(@data) eq 2) {
1382: $title = $data[1];
1383: ($setuname,$setudom) = split(/@/,$data[0]);
1384: } else {
1385: ($setuname,$setudom,$title) = @data;
1386: }
1387: return ($setuname,$setudom,$title);
1388: }
1389:
1.1 albertel 1390: sub display_addblocker_table {
1391: my ($r,$parmcount,$ltext) = @_;
1392: my $start = time;
1393: my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
1394: my $onchange = 'onFocus="javascript:window.document.forms['.
1395: "'blockform'].elements['add_".$parmcount."'].".
1396: 'checked=true;"';
1397: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
1398: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
1399: my %lt = &Apache::lonlocal::texthash(
1400: 'addb' => 'Add block',
1401: 'exam' => 'e.g., Exam 1',
1402: 'addn' => 'Add new communication blocking periods'
1403: );
1404: $r->print(<<"END");
1405: <h4>$lt{'addn'}</h4>
1.18 albertel 1406: END
1407: $r->print(&Apache::loncommon::start_data_table());
1408: $r->print(<<"END");
1.16 albertel 1409: <tr>
1410: <th>$$ltext{'dura'}</th>
1411: <th>$$ltext{'even'} $lt{'exam'}</th>
1412: <th>$$ltext{'actn'}?</th>
1413: </tr>
1.18 albertel 1414: END
1415: $r->print(&Apache::loncommon::start_data_table_row());
1416: $r->print(<<"END");
1.16 albertel 1417: <td>$$ltext{'star'}: $startform<br />$$ltext{'endd'}: $endform</td>
1418: <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
1419: <td><label>$lt{'addb'}? <input type="checkbox" name="add_$parmcount" value="1" /></label></td>
1.1 albertel 1420: END
1.18 albertel 1421: $r->print(&Apache::loncommon::end_data_table_row());
1422: $r->print(&Apache::loncommon::end_data_table());
1.1 albertel 1423: return;
1424: }
1425:
1426: sub blockcheck {
1427: my ($setters,$startblock,$endblock) = @_;
1428: # Retrieve active student roles and active course coordinator/instructor roles
1.15 albertel 1429: my %live_courses =
1430: map { $_ => 1} &Apache::loncommon::findallcourses();
1431: # FIXME should really probe for apriv, but ::allowed can only probe the
1432: # currently active role
1433: my %staff_of =
1434: map { $_ => 1} &Apache::loncommon::findallcourses(['cc','in']);
1435:
1436: # Retrieve blocking times and identity of blocker for active courses
1437: # for students.
1438: return if (!%live_courses);
1439:
1440: foreach my $course (keys(%live_courses)) {
1.19 albertel 1441: my $cdom = $env{'course.'.$course.'.domain'};
1442: my $cnum = $env{'course.'.$course.'.num'};
1.15 albertel 1443:
1444: # if they are a staff member and are currently not playing student
1445: next if ( $staff_of{$course}
1446: && ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));
1447:
1448: $setters->{$course} = {};
1449: $setters->{$course}{'staff'} = [];
1450: $setters->{$course}{'times'} = [];
1451: my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);
1452: foreach my $record (keys %records) {
1453: my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);
1454: if ($start <= time && $end >= time) {
1455: my ($staff_name,$staff_dom,$title) =
1456: &parse_block_record($records{$record});
1457: push(@{$$setters{$course}{'staff'}}, [$staff_name,$staff_dom]);
1458: push(@{$$setters{$course}{'times'}}, [$start,$end]);
1459: if ( ($$startblock == 0) || ($$startblock > $1) ) {
1460: $$startblock = $1;
1461: }
1462: if ( ($$endblock == 0) || ($$endblock < $2) ) {
1463: $$endblock = $2;
1464: }
1465: }
1466: }
1.1 albertel 1467: }
1468: }
1469:
1470: sub build_block_table {
1471: my ($r,$startblock,$endblock,$setters) = @_;
1472: my %lt = &Apache::lonlocal::texthash(
1473: 'cacb' => 'Currently active communication blocks',
1474: 'cour' => 'Course',
1475: 'dura' => 'Duration',
1476: 'blse' => 'Block set by'
1.18 albertel 1477: );
1478: $r->print(<<"END");
1479: <br /><br />$lt{'cacb'}:<br /><br />
1480: END
1481: $r->print(&Apache::loncommon::start_data_table());
1.1 albertel 1482: $r->print(<<"END");
1.16 albertel 1483: <tr>
1484: <th>$lt{'cour'}</th>
1485: <th>$lt{'dura'}</th>
1486: <th>$lt{'blse'}</th>
1487: </tr>
1.1 albertel 1488: END
1.18 albertel 1489: foreach my $course (keys(%{$setters})) {
1490: my %courseinfo=&Apache::lonnet::coursedescription($course);
1491: for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
1492: my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
1.1 albertel 1493: my $fullname = &Apache::loncommon::plainname($uname,$udom);
1.18 albertel 1494: my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
1.1 albertel 1495: $openblock = &Apache::lonlocal::locallocaltime($openblock);
1496: $closeblock= &Apache::lonlocal::locallocaltime($closeblock);
1.18 albertel 1497: $r->print(&Apache::loncommon::start_data_table_row().
1498: '<td>'.$courseinfo{'description'}.'</td>'.
1.1 albertel 1499: '<td>'.$openblock.' to '.$closeblock.'</td>'.
1.14 albertel 1500: '<td>'.$fullname.' ('.$uname.':'.$udom.
1.18 albertel 1501: ')</td>'.
1502: &Apache::loncommon::end_data_table_row());
1.1 albertel 1503: }
1504: }
1.18 albertel 1505: $r->print(&Apache::loncommon::end_data_table());
1.1 albertel 1506: }
1507:
1508: # ----------------------------------------------------------- Display a message
1509:
1510: sub displaymessage {
1511: my ($r,$msgid,$folder)=@_;
1512: my $suffix=&Apache::lonmsg::foldersuffix($folder);
1513: my %blocked = ();
1514: my %setters = ();
1515: my $startblock = 0;
1516: my $endblock = 0;
1517: my $numblocked = 0;
1518: # info to generate "next" and "previous" buttons and check if message is blocked
1519: &blockcheck(\%setters,\$startblock,\$endblock);
1520: my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
1521: if ( $blocked{$msgid} eq 'ON' ) {
1522: &printheader($r,'/adm/email',&mt('Display a Message'));
1523: $r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
1524: &build_block_table($r,$startblock,$endblock,\%setters);
1525: return;
1526: }
1527: &statuschange($msgid,'read',$folder);
1528: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1529: my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
1530:
1531: my $counter=0;
1532: $r->print('<pre>');
1533: my $escmsgid=&Apache::lonnet::escape($msgid);
1534: foreach (@messages) {
1535: if ($_->[5] eq $escmsgid){
1536: last;
1537: }
1538: $counter++;
1539: }
1540: $r->print('</pre>');
1541: my $number_of_messages = scalar(@messages); #subtract 1 for last index
1542: # start output
1543: &printheader($r,'/adm/email?display='.&Apache::lonnet::escape($msgid),'Display a Message','',$content{'baseurl'});
1544: my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
1545: # Functions
1546: $r->print('<table border="2" width="100%"><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>'.
1547: '<td><a href="/adm/email?replyto='.&Apache::lonnet::escape($msgid).$sqs.
1548: '"><b>'.&mt('Reply').'</b></a></td>'.
1549: '<td><a href="/adm/email?forward='.&Apache::lonnet::escape($msgid).$sqs.
1550: '"><b>'.&mt('Forward').'</b></a></td>'.
1551: '<td><a href="/adm/email?markunread='.&Apache::lonnet::escape($msgid).$sqs.
1552: '"><b>'.&mt('Mark Unread').'</b></a></td>'.
1553: '<td><a href="/adm/email?markdel='.&Apache::lonnet::escape($msgid).$sqs.
1554: '"><b>'.&mt('Delete').'</b></a></td>'.
1555: '<td><a href="/adm/email?'.$sqs.
1556: ($env{'form.dismode'} eq 'new'?'&folder=new':'').
1557: '"><b>'.&mt('Back to Folder Display').'</b></a></td>');
1558: if ($counter > 0){
1559: $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
1560: '"><b>'.&mt('Previous').'</b></a></td>');
1561: }
1562: if ($counter < $number_of_messages - 1){
1563: $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
1564: '"><b>'.&mt('Next').'</b></a></td>');
1565: }
1566: $r->print('</tr></table>');
1567: if ($env{'user.adv'}) {
1568: $r->print('<table border="2" width="100%"><tr bgcolor="#FFAAAA"><td>'.&mt('Currently available actions (will open extra window)').':</td>');
1569: my $symb=&Apache::lonnet::symbread($content{'baseurl'});
1570: if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
1571: $r->print('<td><b>'.&Apache::loncommon::track_student_link(&mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check').'</b></td>');
1572: }
1573: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) {
1574: $r->print('<td><b>'.&Apache::loncommon::pprmlink(&mt('Set/Change parameters'),$content{'sendername'},$content{'senderdomain'},$symb,'check').'</b></td>');
1575: }
1576: if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) {
1577: $r->print('<td><b>'.&Apache::loncommon::pgrdlink(&mt('Set/Change grades'),$content{'sendername'},$content{'senderdomain'},$symb,'check').'</b></td>');
1578: }
1579: $r->print('</tr></table>');
1580: }
1581: my $tolist;
1582: my @recipients = ();
1583: for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
1584: $recipients[$i] = &Apache::loncommon::aboutmewrapper(
1585: &Apache::loncommon::plainname($content{'recuser'}[$i],
1586: $content{'recdomain'}[$i]),
1587: $content{'recuser'}[$i],$content{'recdomain'}[$i]).
1588: ' ('.$content{'recuser'}[$i].' at '.$content{'recdomain'}[$i].') ';
1589: }
1590: $tolist = join(', ',@recipients);
1591: $r->print('<br /><b>'.&mt('Subject').':</b> '.$content{'subject'}.
1592: ($folder ne 'sent'?'<br /><b>'.&mt('From').':</b> '.
1593: &Apache::loncommon::aboutmewrapper(
1594: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
1595: $content{'sendername'},$content{'senderdomain'}).' ('.
1596: $content{'sendername'}.' at '.
1597: $content{'senderdomain'}.') ':'<br /><b>'.&mt('To').':</b> '.
1598: $tolist).
1599: ($content{'courseid'}?'<br /><b>'.&mt('Course').':</b> '.$courseinfo{'description'}.
1600: ($content{'coursesec'}?' ('.&mt('Group/Section').': '.$content{'coursesec'}.')':''):'').
1601: '<br /><b>'.&mt('Time').':</b> '.$content{'time'}.
1602: ($content{'baseurl'}?'<br /><b>'.&mt('Refers to').':</b> <a href="'.$content{'baseurl'}.'">'.
1603: $content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')</a>':'').
1604: '<p><pre>'.
1605: &Apache::lontexconvert::msgtexconverted($content{'message'},1).
1606: '</pre><hr />'.&displayresource(%content).'</p>');
1607: return;
1608: }
1609:
1610: # =========================================================== Show the citation
1611:
1612: sub displayresource {
1613: my %content=@_;
1614: #
1615: # If the recipient is in the same course that the message was sent from and
1616: # has sufficient privileges, show "all details," else show citation
1617: #
1618: if (($env{'request.course.id'} eq $content{'courseid'})
1619: && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
1620: my $symb=&Apache::lonnet::symbread($content{'baseurl'});
1621: # Could not get a symb, give up
1622: unless ($symb) { return $content{'citation'}; }
1623: # Have a symb, can render
1624: return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'.
1625: &Apache::loncommon::get_previous_attempt($symb,
1626: $content{'sendername'},
1627: $content{'senderdomain'},
1628: $content{'courseid'}).
1629: '<hr /><h2>'.&mt('Current screen output (if applicable)').'</h2>'.
1630: &Apache::loncommon::get_student_view($symb,
1631: $content{'sendername'},
1632: $content{'senderdomain'},
1633: $content{'courseid'}).
1634: '<h2>'.&mt('Correct Answer(s) (if applicable)').'</h2>'.
1635: &Apache::loncommon::get_student_answers($symb,
1636: $content{'sendername'},
1637: $content{'senderdomain'},
1638: $content{'courseid'});
1639: } elsif ($env{'user.adv'}) {
1640: return $content{'citation'};
1641: }
1642: return '';
1643: }
1644:
1645: # ================================================================== The Header
1646:
1647: sub header {
1648: my ($r,$title,$baseurl)=@_;
1649:
1650: my $extra = &Apache::loncommon::studentbrowser_javascript();
1651: if ($baseurl) {
1652: $extra .= "<base href=\"http://$ENV{'SERVER_NAME'}/$baseurl\" />";
1653: }
1654: $r->print(&Apache::loncommon::start_page('Communication and Messages',
1655: $extra));
1656: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1657: (undef,($title?$title:'Communication and Messages')));
1658:
1659: }
1660:
1661: # ---------------------------------------------------------------- Print header
1662:
1663: sub printheader {
1664: my ($r,$url,$desc,$title,$baseurl)=@_;
1665: &Apache::lonhtmlcommon::add_breadcrumb
1666: ({href=>$url,
1667: text=>$desc});
1668: &header($r,$title,$baseurl);
1669: }
1670:
1671: # ------------------------------------------------------------ Store the comment
1672:
1673: sub storecomment {
1674: my ($r)=@_;
1675: my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
1676: my $cleanmsgtxt='';
1677: foreach (split(/[\n\r]/,$msgtxt)) {
1678: unless ($_=~/^\s*(\>|\>\;)/) {
1679: $cleanmsgtxt.=$_."\n";
1680: }
1681: }
1682: my $key=&Apache::lonnet::escape($env{'form.baseurl'}).'___'.time;
1683: &Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
1684: }
1685:
1686: sub storedcommentlisting {
1687: my ($r)=@_;
1688: my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
1689: '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($env{'form.showcommentbaseurl'})));
1690: $r->print(&Apache::loncommon::start_page('Stored Comment Listing',undef,
1691: {'onlybody' => 1}));
1692: if ((keys %msgs)[0]=~/^error\:/) {
1693: $r->print(&mt('No stored comments yet.'));
1694: } else {
1695: my $found=0;
1696: foreach (sort keys %msgs) {
1697: $r->print("\n".$msgs{$_}."<hr />");
1698: $found=1;
1699: }
1700: unless ($found) {
1701: $r->print(&mt('No stored comments yet for this resource.'));
1702: }
1703: }
1704: }
1705:
1706: # ---------------------------------------------------------------- Send an email
1707:
1708: sub sendoffmail {
1709: my ($r,$folder)=@_;
1710: my $suffix=&Apache::lonmsg::foldersuffix($folder);
1711: my $sendstatus='';
1712: my %specialmsg_status;
1713: my $numspecial = 0;
1714: if ($env{'form.send'}) {
1715: &printheader($r,'','Messages being sent.');
1716: $r->rflush();
1717: my %content=();
1718: undef %content;
1719: if ($env{'form.forwid'}) {
1720: my $msgid=$env{'form.forwid'};
1721: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1722: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
1723: &statuschange($msgid,'forwarded',$folder);
1724: $env{'form.message'}.="\n\n-- Forwarded message --\n\n".
1725: $content{'message'};
1726: }
1727: if ($env{'form.replyid'}) {
1728: my $msgid=$env{'form.replyid'};
1729: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1730: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
1731: &statuschange($msgid,'replied',$folder);
1732: }
1.13 albertel 1733:
1734: my %toaddr;
1.1 albertel 1735: if ($env{'form.sendmode'} eq 'group') {
1.14 albertel 1736: foreach my $address (keys(%env)) {
1.13 albertel 1737: if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) {
1.1 albertel 1738: $toaddr{$1}='';
1739: }
1740: }
1741: } elsif ($env{'form.sendmode'} eq 'upload') {
1.13 albertel 1742: foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
1743: my ($rec,$txt)=split(/\s*\:\s*/,$line);
1.1 albertel 1744: if ($txt) {
1745: $rec=~s/\@/\:/;
1746: $toaddr{$rec}.=$txt."\n";
1747: }
1748: }
1749: } else {
1750: $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
1751: }
1752: if ($env{'form.additionalrec'}) {
1753: foreach (split(/\,/,$env{'form.additionalrec'})) {
1754: my ($auname,$audom)=split(/\@/,$_);
1755: $toaddr{$auname.':'.$audom}='';
1756: }
1757: }
1758:
1759: my $savemsg;
1760: my $msgtype;
1761: my %sentmessage;
1.7 albertel 1762: my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'},
1763: undef,1);
1.1 albertel 1764: if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
1765: (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1766: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1767: '/'.$env{'request.course.sec'})
1768: )) {
1769: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1);
1770: $msgtype = 'critical';
1771: } else {
1772: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
1773: }
1774:
1.13 albertel 1775: foreach my $address (sort(keys(%toaddr))) {
1776: my ($recuname,$recdomain)=split(/\:/,$address);
1.1 albertel 1777: my $msgtxt = $savemsg;
1.13 albertel 1778: if ($toaddr{$address}) { $msgtxt.='<hr />'.$toaddr{$address}; }
1.12 albertel 1779: my @thismsg;
1.1 albertel 1780: if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
1781: (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1782: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1783: '/'.$env{'request.course.sec'}))) {
1.13 albertel 1784: $r->print(&mt('Sending critical message').' '.$recuname.':'.$recdomain.': ');
1785: @thismsg=
1786: &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
1787: $msgsubj,$msgtxt,
1788: $env{'form.sendbck'},
1789: $env{'form.permanent'},
1790: \$sentmessage{$address});
1.1 albertel 1791: } else {
1.14 albertel 1792: $r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': ');
1.13 albertel 1793: @thismsg=
1794: &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
1795: $msgsubj,$msgtxt,
1796: $content{'citation'},
1797: undef,undef,
1798: $env{'form.permanent'},
1799: \$sentmessage{$address});
1.1 albertel 1800: }
1801: if (($env{'request.course.id'}) && (($msgtype eq 'critical') ||
1802: ($env{'form.sendmode'} eq 'group'))) {
1.12 albertel 1803: $specialmsg_status{$recuname.':'.$recdomain} =
1804: join(' ',@thismsg);
1805: foreach my $result (@thismsg) {
1806: if ($result eq 'ok') {
1807: $numspecial++;
1808: }
1809: }
1.1 albertel 1810: }
1.12 albertel 1811: $sendstatus.=' '.join(' ',@thismsg);
1.1 albertel 1812: }
1813: if (($env{'request.course.id'}) && (($env{'form.sendmode'} eq 'group')
1814: || ($msgtype eq 'critical'))) {
1815: my $subj_prefix;
1816: if ($msgtype eq 'critical') {
1817: $subj_prefix = 'Critical.';
1818: } else {
1819: $subj_prefix = 'Broadcast.';
1820: }
1821: my ($specialmsgid,$specialresult);
1822: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1823: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1824: my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']');
1825:
1826: if ($numspecial) {
1827: $specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
1828: ' '.$course_str,$savemsg,undef,undef,undef,
1829: undef,undef,\$specialmsgid);
1830: $specialmsgid = &Apache::lonnet::unescape($specialmsgid);
1831: }
1832: if ($specialresult eq 'ok') {
1833: my $record_sent;
1.13 albertel 1834: my @recusers;
1835: my @recudoms;
1836: my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
1837: split(/\:/,&Apache::lonnet::unescape($specialmsgid));
1838:
1.1 albertel 1839: foreach my $recipient (sort(keys(%toaddr))) {
1840: if ($specialmsg_status{$recipient} eq 'ok') {
1841: my $usersubj = $subj_prefix.'['.$recipient.']';
1842: my $usermsgid =
1843: &Apache::lonmsg::buildmsgid($stamp,$usersubj,
1844: $msgname,$msgdom,
1845: $msgcount,$context,
1846: $pid);
1847: &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
1848: ' ['.$recipient.']',$msgsubj,undef,
1849: undef,undef,undef,$usermsgid,undef,undef,$specialmsgid);
1.13 albertel 1850: my ($uname,$udom) = split(/:/,$recipient);
1.1 albertel 1851: push(@recusers,$uname);
1852: push(@recudoms,$udom);
1853: }
1854: }
1855: if (@recusers) {
1856: my $specialmessage;
1.13 albertel 1857: my $sentsubj =
1858: $subj_prefix.' ('.$numspecial.' sent) '.$msgsubj;
1.1 albertel 1859: $sentsubj = &HTML::Entities::encode($sentsubj,'<>&"');
1860: my $sentmsgid =
1861: &Apache::lonmsg::buildmsgid($stamp,$sentsubj,$msgname,
1862: $msgdom,$msgcount,$context,
1863: $pid);
1864: ($specialmsgid,$specialmessage) = &Apache::lonmsg::packagemsg($msgsubj,$savemsg,
1865: undef,undef,undef,\@recusers,\@recudoms,$sentmsgid);
1866: $record_sent = &Apache::lonmsg::store_sent_mail($specialmsgid,$specialmessage);
1867: }
1868: } else {
1869: &Apache::lonnet::logthis('Failed to create record of critical message or broadcast in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' at '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
1870: }
1871: }
1872: } else {
1873: &printheader($r,'','No messages sent.');
1874: }
1875: if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
1.5 albertel 1876: $r->print('<br /><span class="LC_success">'.&mt('Completed.').'</span>');
1.1 albertel 1877: if ($env{'form.displayedcrit'}) {
1878: &discrit($r);
1879: } else {
1880: &Apache::loncommunicate::menu($r);
1881: }
1882: } else {
1.5 albertel 1883: $r->print('<p><span class="LC_error">'.&mt('Could not deliver message').'</span> '.
1884: &mt('Please use the browser "Back" button and correct the recipient addresses').'</p>');
1.1 albertel 1885: }
1886: }
1887:
1888: # ===================================================================== Handler
1889:
1890: sub handler {
1891: my $r=shift;
1892:
1893: # ----------------------------------------------------------- Set document type
1894:
1895: &Apache::loncommon::content_type($r,'text/html');
1896: $r->send_http_header;
1897:
1898: return OK if $r->header_only;
1899:
1900: # --------------------------- Get query string for limited number of parameters
1901: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1902: ['display','replyto','forward','markread','markdel','markunread',
1903: 'sendreply','compose','sendmail','critical','recname','recdom',
1904: 'recordftf','sortedby','block','folder','startdis','interdis',
1.20 raeburn 1905: 'showcommentbaseurl','dismode','group']);
1.1 albertel 1906: $sqs='&sortedby='.$env{'form.sortedby'};
1907:
1908: # ------------------------------------------------------ They checked for email
1909: unless ($env{'form.block'}) {
1910: &Apache::lonnet::put('email_status',{'recnewemail'=>0});
1911: }
1912:
1913: # ----------------------------------------------------------------- Breadcrumbs
1914:
1915: &Apache::lonhtmlcommon::clear_breadcrumbs();
1916: &Apache::lonhtmlcommon::add_breadcrumb
1917: ({href=>"/adm/communicate",
1918: text=>"Communication/Messages",
1919: faq=>12,bug=>'Communication Tools',});
1920:
1921: # ------------------------------------------------------------------ Get Folder
1922:
1923: my $folder=$env{'form.folder'};
1924: unless ($folder) {
1925: $folder='';
1926: } else {
1927: $sqs.='&folder='.&Apache::lonnet::escape($folder);
1928: }
1929: # ------------------------------------------------------------ Get Display Mode
1930:
1931: my $dismode=$env{'form.dismode'};
1932: unless ($dismode) {
1933: $dismode='';
1934: } else {
1935: $sqs.='&dismode='.&Apache::lonnet::escape($dismode);
1936: }
1937:
1938: # --------------------------------------------------------------------- Display
1939:
1940: $startdis=$env{'form.startdis'};
1941: $startdis--;
1942: unless ($startdis) { $startdis=0; }
1943:
1944: $interdis=$env{'form.interdis'};
1945: unless ($interdis) { $interdis=20; }
1946: $sqs.='&interdis='.$interdis;
1947:
1948: if ($env{'form.firstview'}) {
1949: $startdis=0;
1950: }
1951: if ($env{'form.lastview'}) {
1952: $startdis=-1;
1953: }
1954: if ($env{'form.prevview'}) {
1955: $startdis--;
1956: }
1957: if ($env{'form.nextview'}) {
1958: $startdis++;
1959: }
1960: my $postedstartdis=$startdis+1;
1961: $sqs.='&startdis='.$postedstartdis;
1962:
1963: # --------------------------------------------------------------- Render Output
1964:
1965: if ($env{'form.display'}) {
1966: &displaymessage($r,$env{'form.display'},$folder);
1967: } elsif ($env{'form.replyto'}) {
1968: &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
1969: } elsif ($env{'form.confirm'}) {
1970: &printheader($r,'','Confirmed Receipt');
1971: foreach (keys %env) {
1972: if ($_=~/^form\.rec\_(.*)$/) {
1973: $r->print('<b>'.&mt('Confirming Receipt').':</b> '.
1974: &Apache::lonmsg::user_crit_received($1).'<br>');
1975: }
1976: if ($_=~/^form\.reprec\_(.*)$/) {
1977: my $msgid=$1;
1978: $r->print('<b>'.&mt('Confirming Receipt').':</b> '.
1979: &Apache::lonmsg::user_crit_received($msgid).'<br>');
1980: &compout($r,'','','',$msgid);
1981: }
1982: }
1983: &discrit($r);
1984: } elsif ($env{'form.critical'}) {
1985: &printheader($r,'','Displaying Critical Messages');
1986: &discrit($r);
1987: } elsif ($env{'form.forward'}) {
1988: &compout($r,$env{'form.forward'},undef,undef,undef,$folder);
1989: } elsif ($env{'form.markdel'}) {
1990: &printheader($r,'','Deleted Message');
1.9 albertel 1991: my ($result,$msg) =
1992: &statuschange($env{'form.markdel'},'deleted',$folder);
1993: if (!$result) {
1.10 albertel 1994: $r->print('<p class="LC_error">'.
1995: &mt('Failed to delete the message.').'</p>'.
1.9 albertel 1996: '<p class="LC_error">'.$msg."</p>\n");
1997: }
1.1 albertel 1998: &Apache::loncommunicate::menu($r);
1999: &disall($r,($folder?$folder:$dismode));
2000: } elsif ($env{'form.markedmove'}) {
1.9 albertel 2001: my ($total,$failed,@failed_msg)=(0,0);
2002: foreach my $key (keys(%env)) {
2003: if ($key=~/^form\.delmark_(.*)$/) {
2004: my ($result,$msg) =
2005: &movemsg(&Apache::lonnet::unescape($1),$folder,
2006: $env{'form.movetofolder'});
2007: if ($result) {
2008: $total++;
2009: } else {
2010: $failed++;
2011: push(@failed_msg,$msg);
2012: }
1.1 albertel 2013: }
2014: }
2015: &printheader($r,'','Moved Messages');
1.9 albertel 2016: if ($failed) {
2017: $r->print('<p class="LC_error">
1.10 albertel 2018: '.&mt('Failed to move [_1] message(s)',$failed).
2019: '</p>');
1.9 albertel 2020: $r->print('<p class="LC_error">'.
2021: join("</p>\n<p class=\"LC_error\">",@failed_msg).
2022: "</p>\n");
2023: }
1.10 albertel 2024: $r->print(&mt('Moved [_1] message(s)',$total).'<p>');
1.1 albertel 2025: &Apache::loncommunicate::menu($r);
2026: &disall($r,($folder?$folder:$dismode));
2027: } elsif ($env{'form.markeddel'}) {
1.9 albertel 2028: my ($total,$failed,@failed_msg)=(0,0);
2029: foreach my $key (keys(%env)) {
2030: if ($key=~/^form\.delmark_(.*)$/) {
2031: my ($result,$msg) =
2032: &statuschange(&Apache::lonnet::unescape($1),'deleted',
2033: $folder);
2034: if ($result) {
2035: $total++;
2036: } else {
2037: $failed++;
2038: push(@failed_msg,$msg);
2039: }
1.1 albertel 2040: }
2041: }
2042: &printheader($r,'','Deleted Messages');
1.9 albertel 2043: if ($failed) {
2044: $r->print('<p class="LC_error">
1.10 albertel 2045: '.&mt('Failed to delete [_1] message(s)',$failed).
2046: '</p>');
1.9 albertel 2047: $r->print('<p class="LC_error">'.
2048: join("</p>\n<p class=\"LC_error\">",@failed_msg).
2049: "</p>\n");
2050: }
1.10 albertel 2051: $r->print(&mt('Deleted [_1] message(s)',$total).'<p>');
1.1 albertel 2052: &Apache::loncommunicate::menu($r);
2053: &disall($r,($folder?$folder:$dismode));
2054: } elsif ($env{'form.markunread'}) {
2055: &printheader($r,'','Marked Message as Unread');
2056: &statuschange($env{'form.markunread'},'new');
2057: &Apache::loncommunicate::menu($r);
2058: &disall($r,($folder?$folder:$dismode));
2059: } elsif ($env{'form.compose'}) {
2060: &compout($r,'','',$env{'form.compose'});
2061: } elsif ($env{'form.recordftf'}) {
2062: &facetoface($r,$env{'form.recordftf'});
2063: } elsif ($env{'form.block'}) {
2064: &examblock($r,$env{'form.block'});
2065: } elsif ($env{'form.sendmail'}) {
2066: &sendoffmail($r,$folder);
2067: if ($env{'form.storebasecomment'}) {
2068: &storecomment($r);
2069: }
2070: if (($env{'form.rsspost'}) && ($env{'request.course.id'})) {
2071: &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
2072: $env{'course.'.$env{'request.course.id'}.'.domain'},
2073: 'Course_Announcements',
2074: $env{'form.subject'},
2075: $env{'form.message'},'/adm/communicate','public');
2076: }
2077: &disall($r,($folder?$folder:$dismode));
2078: } elsif ($env{'form.newfolder'}) {
2079: &printheader($r,'','New Folder');
2080: &makefolder($env{'form.newfolder'});
2081: &Apache::loncommunicate::menu($r);
2082: &disall($r,$env{'form.newfolder'});
2083: } elsif ($env{'form.showcommentbaseurl'}) {
2084: &storedcommentlisting($r);
2085: } else {
2086: &printheader($r,'','Display All Messages');
2087: &Apache::loncommunicate::menu($r);
2088: &disall($r,($folder?$folder:$dismode));
2089: }
2090: $r->print(&Apache::loncommon::end_page());
2091: return OK;
2092: }
2093: # ================================================= Main program, reset counter
2094:
2095: =pod
2096:
2097: =back
2098:
2099: =cut
2100:
2101: 1;
2102:
2103: __END__
2104:
2105:
2106:
2107:
2108:
2109:
2110:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>