Annotation of loncom/interface/lonmsgdisplay.pm, revision 1.95
1.1 albertel 1: # The LearningOnline Network with CAPA
2: # Routines for messaging display
3: #
1.95 ! raeburn 4: # $Id: lonmsgdisplay.pm,v 1.94 2008/10/23 10:15:37 bisitz 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:
1.69 raeburn 36: Apache::lonmsgdisplay: supports internal messaging
1.1 albertel 37:
38: =head1 SYNOPSIS
39:
1.69 raeburn 40: lonmsgdisplay provides a handler to allow users to read, send,
41: and delete messages, and to create and delete message folders,
42: and to move messages between folders.
1.1 albertel 43:
44: =head1 OVERVIEW
45:
46: =head2 Messaging Overview
47:
48: X<messages>LON-CAPA provides an internal messaging system similar to
49: email, but customized for LON-CAPA's usage. LON-CAPA implements its
50: own messaging system, rather then building on top of email, because of
51: the features LON-CAPA messages can offer that conventional e-mail can
52: not:
53:
54: =over 4
55:
56: =item * B<Critical messages>: A message the recipient B<must>
57: acknowlegde receipt of before they are allowed to continue using the
58: system, preventing a user from claiming they never got a message
59:
60: =item * B<Receipts>: LON-CAPA can reliably send reciepts informing the
61: sender that it has been read; again, useful for preventing students
62: from claiming they did not see a message. (While conventional e-mail
63: has some reciept support, it's sporadic, e-mail client-specific, and
64: generally the receiver can opt to not send one, making it useless in
65: this case.)
66:
67: =item * B<Context>: LON-CAPA knows about the sender, such as where
68: they are in a course. When a student mails an instructor asking for
69: help on the problem, the instructor receives not just the student's
70: question, but all submissions the student has made up to that point,
71: the user's rendering of the problem, and the complete view the student
72: saw of the resource, including discussion up to that point. Finally,
73: the instructor is reading all of this inside of LON-CAPA, not their
74: email program, so they have full access to LON-CAPA's grading
75: interface, or other features they may wish to use in response to the
76: student's query.
77:
1.50 raeburn 78: =item * B<Blocking>: LON-CAPA can block selected communication
79: features for students during an online exam. A course coordinator or
1.1 albertel 80: instructor can set an open and close date/time for scheduled online
81: exams in a course. If a user uses the LON-CAPA internal messaging
82: system to display e-mails during the scheduled blocking event,
83: display of all e-mail sent during the blocking period will be
84: suppressed, and a message of explanation, including details of the
85: currently active blocking periods will be displayed instead. A user
86: who has a course coordinator or instructor role in a course will be
87: unaffected by any blocking periods for the course, unless the user
88: also has a student role in the course, AND has selected the student role.
89:
90: =back
91:
92: Users can ask LON-CAPA to forward messages to conventional e-mail
93: addresses on their B<PREF> screen, but generally, LON-CAPA messages
94: are much more useful than traditional email can be made to be, even
95: with HTML support.
96:
97: =cut
98:
99: use strict;
100: use Apache::lonnet;
101: use HTML::TokeParser();
102: use Apache::Constants qw(:common);
103: use Apache::loncommon();
1.67 www 104: use Apache::lonhtmlcommon();
1.1 albertel 105: use Apache::lontexconvert();
106: use HTML::Entities();
107: use Apache::lonlocal;
108: use Apache::loncommunicate;
109: use Apache::lonfeedback;
110: use Apache::lonrss();
1.27 albertel 111: use Apache::lonselstudent();
1.29 www 112: use lib '/home/httpd/lib/perl/';
113: use LONCAPA;
1.1 albertel 114:
115: # Querystring component with sorting type
116: my $sqs;
117: my $startdis;
118:
119: # ============================================================ List all folders
120:
121: sub folderlist {
1.53 raeburn 122: my ($folder,$msgstatus) = @_;
1.46 raeburn 123: my %lt = &Apache::lonlocal::texthash(
124: actn => 'Action',
125: fold => 'Folder',
126: show => 'Show',
1.53 raeburn 127: status => 'Message Status',
1.46 raeburn 128: go => 'Go',
1.50 raeburn 129: nnff => 'New Name for Folder',
130: newn => 'New Name',
131: thfm => 'The folder may not be renamed',
132: fmnb => 'folder may not be renamed as it is a folder provided by the system.',
133: asth => 'as this name is already in use for a system-provided or user-defined folder.',
134: the => 'The',
135: tnfm => 'The new folder may not be named',
136:
1.46 raeburn 137: );
138:
139: my %actions = &Apache::lonlocal::texthash(
140: view => 'View Folder',
141: rename => 'Rename Folder',
142: delete => 'Delete Folder',
143: );
144: $actions{'select_form_order'} = ['view','rename','delete'];
145:
1.53 raeburn 146: my %statushash = &get_msgstatus_types();
147:
148: $statushash{'select_form_order'} = ['','new','read','replied','forwarded'];
149:
1.46 raeburn 150: my %permfolders = &get_permanent_folders();
151: my $permlist = join("','",sort(keys(%permfolders)));
152: my ($permlistkeys,$permlistvals);
153: foreach my $key (sort(keys(%permfolders))) {
154: $permlistvals .= $permfolders{$key}."','";
155: $permlistkeys .= $key."','";
156: }
157: $permlistvals =~ s/','$//;
158: $permlistkeys =~ s/','$//;
159: my %gotfolders = &Apache::lonmsg::get_user_folders();
160: my %userfolders;
161:
162: foreach my $key (keys(%gotfolders)) {
1.54 albertel 163: $key =~ s/(['"])/\$1/g; #' stupid emacs
1.46 raeburn 164: $userfolders{$key} = $key;
165: }
166: my @userorder = sort(keys(%userfolders));
167: my %formhash = (%permfolders,%userfolders);
168: my $folderlist = join("','",@userorder);
169: $folderlist .= "','".$permlistvals;
170:
1.53 raeburn 171: $formhash{'select_form_order'} = ['','critical',@userorder,'sent','trash'];
1.46 raeburn 172: my $output = qq|<script type="text/javascript">
173: function folder_choice(targetform,caller) {
174: var permfolders_keys = new Array('$permlistkeys');
175: var permfolders_vals = new Array('$permlistvals');
176: var allfolders = new Array('$folderlist');
177: if (caller == 'change') {
178: if (targetform.folderaction.options[targetform.folderaction.selectedIndex].value == 'rename') {
179: for (var i=0; i<permfolders_keys.length; i++) {
180: if (permfolders_keys[i] == targetform.folder.value) {
1.50 raeburn 181: alert("$lt{'the'} '"+permfolders_vals[i]+"' $lt{'fmnb'}");
1.46 raeburn 182: return;
183: }
184: }
1.50 raeburn 185: var foldername=prompt('$lt{'nnff'}','$lt{'newn'}');
1.46 raeburn 186: if (foldername) {
187: targetform.renamed.value=foldername;
188: for (var i=0; i<allfolders.length; i++) {
189: if (allfolders[i] == foldername) {
1.50 raeburn 190: alert("$lt{'thfm'} '"+foldername+"' $lt{'asth'}");
1.46 raeburn 191: return;
192: }
193: }
194: targetform.submit();
195: }
196: }
197: else {
198: targetform.submit();
199: }
200: }
201: if (caller == 'new') {
202: var newname=targetform.newfolder.value;
203: if (newname) {
204: for (var i=0; i<allfolders.length; i++) {
205: if (allfolders[i] == newname) {
1.50 raeburn 206: alert("$lt{'tnfm'} '"+newname+"' $lt{'asth'}");
1.46 raeburn 207: return;
208: }
209: }
210: targetform.submit();
211: }
212: }
213: }
214: </script>|;
1.57 albertel 215: my %show = ('select_form_order' => [10,20,50,100,200],
216: map {$_=>$_} (10,20,50,100,200));
217:
218:
1.46 raeburn 219: $output .= '
220: <form method="post" action="/adm/email" name="folderlist">
221: <table border="0" cellspacing="2" cellpadding="2">
222: <tr>
223: <td align="left">
224: <table border="0" cellspacing="2" cellpadding="2">
225: <tr>
226: <td align="center"><b>'.$lt{'fold'}.'</b><br />'."\n".
1.47 albertel 227: &Apache::loncommon::select_form($folder,'folder',%formhash).'
1.46 raeburn 228: </td>
1.57 albertel 229: <td align="center"><b>'.$lt{'show'}.'</b><br />'."\n".
230: &Apache::loncommon::select_form($env{'form.interdis'},'interdis',
231: %show).'
1.46 raeburn 232: </td>
1.53 raeburn 233: <td align="center"><b>'.$lt{'status'}.'</b><br />'."\n".
234: &Apache::loncommon::select_form($msgstatus,'msgstatus',%statushash).'
235: </td>
1.46 raeburn 236: <td align="center"><b>'.$lt{'actn'}.'</b><br />'.
1.47 albertel 237: &Apache::loncommon::select_form('view','folderaction',%actions).'
1.46 raeburn 238: </td><td><br />'.
239: '<input type="button" value="'.$lt{'go'}.'" onClick="javascript:folder_choice(this.form,'."'change'".');" />
240: </td>
241: </tr>
242: </table>
243: </td><td> </td><td> </td><td> </td><td> </td>
244: <td align="right">
245: <table><tr><td><br />
246: <input type="button" value="'.&mt('Make New Folder').
247: '" onClick="javascript:folder_choice(this.form,'."'new'".');" /></td>'.
1.48 albertel 248: '<td align="center"><b>'.&mt('New Folder').'</b><br />'.
1.46 raeburn 249: '<input type="text" size="15" name="newfolder" value="" />
250: </td></tr></table>
251: </td>
252: </tr>
253: </table>'."\n".
1.1 albertel 254: '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" />'.
1.46 raeburn 255: '<input type="hidden" name="renamed" value="" />'.
1.53 raeburn 256: ($folder=~/^critical/?'</form>':'');
1.46 raeburn 257: return $output;
258: }
259:
260: sub get_permanent_folders {
1.47 albertel 261: my %permfolders =
262: &Apache::lonlocal::texthash('' => 'INBOX',
263: 'trash' => 'TRASH',
264: 'critical' => 'Critical',
265: 'sent' => 'Sent Messages',
266: );
1.46 raeburn 267: return %permfolders;
1.1 albertel 268: }
269:
1.53 raeburn 270: sub get_msgstatus_types {
271: my %statushash = &Apache::lonlocal::texthash(
272: '' => 'Any',
273: new => 'Unread',
274: read => 'Read',
275: replied => 'Replied to',
276: forwarded => 'Forwarded',
277: );
278: return %statushash;
279: }
280:
1.1 albertel 281: sub scrollbuttons {
1.53 raeburn 282: my ($start,$maxdis,$first,$finish,$total,$msgstatus)=@_;
1.1 albertel 283: unless ($total>0) { return ''; }
284: $start++; $maxdis++;$first++;$finish++;
1.53 raeburn 285:
286: my %statushash = &get_msgstatus_types();
287: my $status;
288: if ($msgstatus eq '') {
289: $status = &mt('All');
290: } else {
291: $status = $statushash{$msgstatus};
292: }
1.1 albertel 293: return
1.53 raeburn 294: '<b>'.&mt('Page').'</b>: '.
1.1 albertel 295: '<input type="submit" name="firstview" value="'.&mt('First').'" />'.
296: '<input type="submit" name="prevview" value="'.&mt('Previous').'" />'.
297: '<input type="text" size="5" name="startdis" value="'.$start.'" onChange="this.form.submit()" /> of '.$maxdis.
298: '<input type="submit" name="nextview" value="'.&mt('Next').'" />'.
299: '<input type="submit" name="lastview" value="'.&mt('Last').'" /><br />'.
1.53 raeburn 300: &mt('<b>[_1] messages</b>: showing messages [_2] through [_3] of [_4].',$status,$first,$finish,$total).'</form>';
1.1 albertel 301: }
302: # =============================================================== Status Change
303:
304: sub statuschange {
305: my ($msgid,$newstatus,$folder)=@_;
1.3 albertel 306: my $suffix=&Apache::lonmsg::foldersuffix($folder);
1.1 albertel 307: my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
308: if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
309: unless ($status{$msgid}) { $status{$msgid}='new'; }
310: unless (($status{$msgid} eq 'replied') ||
311: ($status{$msgid} eq 'forwarded')) {
312: &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
313: }
314: if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
315: &Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
316: }
317: if ($newstatus eq 'deleted') {
1.9 albertel 318: return &movemsg($msgid,$folder,'trash');
319: }
320: return ;
1.1 albertel 321: }
322:
323: # ============================================================= Make new folder
324:
325: sub makefolder {
1.46 raeburn 326: my ($newfolder) = @_;
327: my %permfolders = &get_permanent_folders();
328: my %userfolders = &Apache::lonmsg::get_user_folders();
329: my ($outcome,$warning);
330: if (defined($userfolders{$newfolder})) {
331: return &mt('The folder name: "[_1]" is already in use for an existing folder.',$newfolder);
332: }
333: foreach my $perm (keys(%permfolders)) {
334: if ($permfolders{$perm} eq $newfolder) {
335: return &mt('The folder name: "[_1]" is already used for one of the folders automatically generated by the system.',$newfolder);
336: }
337: }
338: if (&get_msgfolder_lock() eq 'ok') {
339: my %counter_hash = &Apache::lonnet::get('email_folders',["\0".'idcount']);
340: my $lastcount = $counter_hash{"\0".'idcount'};
341: my $folder_id = $lastcount + 1;
342: while (defined($userfolders{$folder_id})) {
343: $folder_id ++;
344: }
1.47 albertel 345: my %folderinfo = ( id => $folder_id,
346: created => time, );
1.46 raeburn 347: $outcome =
1.47 albertel 348: &Apache::lonnet::put('email_folders',{$newfolder => \%folderinfo,
349: "\0".'idcount' => $folder_id});
1.46 raeburn 350: my $releaseresult = &release_msgfolder_lock();
351: if ($releaseresult ne 'ok') {
352: $warning = $releaseresult;
353: }
354: } else {
1.47 albertel 355: $outcome =
356: &mt('Error - could not obtain lock on email folders record.');
1.46 raeburn 357: }
358: return ($outcome,$warning);
1.1 albertel 359: }
360:
1.46 raeburn 361: # ============================================================= Delete folder
362:
363: sub deletefolder {
364: my ($folder)=@_;
365: my %permfolders = &get_permanent_folders();
366: if (defined($permfolders{$folder})) {
1.56 albertel 367: return &mt('The folder "[_1]" may not be deleted',$folder);
1.46 raeburn 368: }
369: my %userfolders = &Apache::lonmsg::get_user_folders();
370: if (!defined($userfolders{$folder})) {
1.56 albertel 371: return &mt('The folder "[_1]" does not exist so deletion is not required.',
1.46 raeburn 372: $folder);
373: }
374: # check folder is empty;
375: my $suffix=&Apache::lonmsg::foldersuffix($folder);
376: my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
377: if (@messages > 0) {
1.56 albertel 378: return &mt('The folder "[_1]" contains messages so it may not be deleted.',$folder).
1.46 raeburn 379: '<br />'.
380: &mt('Delete or move the messages to a different folder first.');
381: }
382: my $delresult = &Apache::lonnet::del('email_folders',[$folder]);
383: return $delresult;
384: }
385:
386: sub renamefolder {
387: my ($folder) = @_;
388: my $newname = $env{'form.renamed'};
389: my %permfolders = &get_permanent_folders();
390: if ($env{'form.renamed'} eq '') {
391: return &mt('The folder "[_1]" may not be renamed to "[_2]" as the new name you requested is an invalid name.',$folder,$newname);
392: }
1.73 raeburn 393: if (defined($permfolders{$folder})) {
394: return &mt('The folder "[_1]" may not be renamed as it is a folder provided by the system.',$folder);
395: }
1.46 raeburn 396: if (defined($permfolders{$newname})) {
397: return &mt('The folder "[_1]" may not be renamed to "[_2]" as the new name you requested is reserved for folders provided automatically by the system.',$folder,$newname);
398: }
399: my %userfolders = &Apache::lonmsg::get_user_folders();
400: if (defined($userfolders{$newname})) {
401: return &mt('The folder "[_1]" may not be renamed to "[_2]" because the new name you requested is already being used for an existing folder.',$folder,$newname);
402: }
403: if (!defined($userfolders{$folder})) {
404: return &mt('The folder "[_1]" could not be renamed to "[_2]" because the folder does not exist.',$folder,$newname);
405: }
406: my %folderinfo;
407: if (ref($userfolders{$folder}) eq 'HASH') {
408: %folderinfo = %{$userfolders{$folder}};
409: } else {
1.47 albertel 410: %folderinfo = ( id => $folder,
411: created => $userfolders{$folder},);
1.46 raeburn 412: }
413: my $outcome =
414: &Apache::lonnet::put('email_folders',{$newname => \%folderinfo});
415: if ($outcome eq 'ok') {
416: $outcome = &Apache::lonnet::del('email_folders',[$folder]);
417: }
418: return $outcome;
419: }
420:
421: sub get_msgfolder_lock {
422: # get lock for mail folder counter.
1.47 albertel 423: my $lockhash = { "\0".'lock_counter' => time, };
1.46 raeburn 424: my $tries = 0;
425: my $gotlock = &Apache::lonnet::newput('email_folders',$lockhash);
426: while (($gotlock ne 'ok') && $tries <3) {
427: $tries ++;
1.47 albertel 428: sleep(1);
1.46 raeburn 429: $gotlock = &Apache::lonnet::newput('email_folders',$lockhash);
430: }
431: return $gotlock;
432: }
433:
434: sub release_msgfolder_lock {
435: # remove lock
436: my @del_lock = ("\0".'lock_counter');
437: my $dellockoutcome=&Apache::lonnet::del('email_folders',\@del_lock);
438: if ($dellockoutcome ne 'ok') {
439: return ('<br />'.&mt('Warning: failed to release lock for counter').'<br />');
440: } else {
441: return 'ok';
442: }
443: }
444:
445:
1.1 albertel 446: # ======================================================== Move between folders
447:
448: sub movemsg {
449: my ($msgid,$srcfolder,$trgfolder)=@_;
450: if ($srcfolder eq 'new') { $srcfolder=''; }
1.3 albertel 451: my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);
452: my $trgsuffix=&Apache::lonmsg::foldersuffix($trgfolder);
1.9 albertel 453: if ($srcsuffix eq $trgsuffix) {
454: return (0,&mt('Message not moved, Attempted to move message to the same folder as it already is in.'));
455: }
1.1 albertel 456:
457: # Copy message
458: my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
1.9 albertel 459: if (!exists($message{$msgid}) || $message{$msgid} eq '') {
1.32 albertel 460: if (&Apache::lonnet::error(%message)) {
1.9 albertel 461: return (0,&mt('Message not moved, A network error occurred.'));
462: } else {
463: return (0,&mt('Message not moved as the message is no longer in the source folder.'));
464: }
465: }
466:
467: my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
468: {$msgid => $message{$msgid}});
1.32 albertel 469: if (&Apache::lonnet::error($result)) {
1.9 albertel 470: return (0,&mt('Message not moved, A network error occurred.'));
471: }
1.1 albertel 472:
473: # Copy status
474: unless ($trgfolder eq 'trash') {
1.9 albertel 475: my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
476: # a non-existant status is the mark of an unread msg
1.32 albertel 477: if (&Apache::lonnet::error(%status)) {
1.9 albertel 478: return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
479: }
480: my $result=&Apache::lonnet::put('email_status'.$trgsuffix,
481: {$msgid => $status{$msgid}});
1.32 albertel 482: if (&Apache::lonnet::error($result)) {
1.9 albertel 483: return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
484: }
1.1 albertel 485: }
1.9 albertel 486:
1.1 albertel 487: # Delete orginals
1.9 albertel 488: my $result_del_msg =
489: &Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
490: my $result_del_stat =
491: &Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
1.32 albertel 492: if (&Apache::lonnet::error($result_del_msg)) {
1.9 albertel 493: return (0,&mt('Message copied, but unable to delete the original from the source folder.'));
494: }
1.32 albertel 495: if (&Apache::lonnet::error($result_del_stat)) {
1.9 albertel 496: return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
497: }
498:
499: return (1);
1.1 albertel 500: }
501:
502: # ======================================================= Display a course list
503:
504: sub discourse {
1.95 ! raeburn 505: my ($statushash) = @_;
! 506: my ($result,$active,$previous,$future);
1.25 foxr 507: my ($course_personnel,
508: $current_members,
509: $expired_members,
1.28 foxr 510: $future_members) =
511: &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'});
1.25 foxr 512: unshift @$current_members, (@$course_personnel);
513: my %defaultUsers;
1.40 albertel 514:
1.87 bisitz 515: my $tmptext;
516: if ($tmptext = &Apache::lonselstudent::render_student_list($current_members,
1.95 ! raeburn 517: "activeusers",
1.87 bisitz 518: "current",
519: \%defaultUsers,
1.95 ! raeburn 520: 1,"selectedusers",1,'email')
1.87 bisitz 521: ) {
1.95 ! raeburn 522: $result .= '<fieldset id="LC_activeusers"><legend><b>'.&mt('Bcc: course members with current access').'</b></legend><form name="activeusers">';
! 523: $result .= $tmptext.'</form></fieldset><br />';
! 524: if (ref($statushash) eq 'HASH') {
! 525: $statushash->{'active'} = 1;
! 526: }
1.87 bisitz 527: }
528: if ($tmptext = &Apache::lonselstudent::render_student_list($expired_members,
1.95 ! raeburn 529: "previoususers",
1.87 bisitz 530: "expired",
531: \%defaultUsers,
1.95 ! raeburn 532: 1, "selectedusers",0,'email')
1.87 bisitz 533: ) {
1.95 ! raeburn 534: $result .= '<fieldset id="LC_previoususers"><legend><b>'.&mt('Bcc: course members with expired access').'</b></legend><form name="previoususers">';
! 535: $result .= $tmptext.'</form></fieldset><br />';
! 536: if (ref($statushash) eq 'HASH') {
! 537: $statushash->{'previous'} = 1;
! 538: }
! 539:
1.87 bisitz 540: }
541: if ($tmptext = &Apache::lonselstudent::render_student_list($future_members,
1.95 ! raeburn 542: "futureusers",
1.87 bisitz 543: "future",
544: \%defaultUsers,
1.95 ! raeburn 545: 1, "selectedusers",0,'email')
1.87 bisitz 546: ) {
1.95 ! raeburn 547: $result .= '<fieldset id="LC_futureusers"><legend><b>'.&mt('Bcc: course members with future access').'</b></legend><form name="previoususers">';
! 548: $result .= $tmptext.'</form></fieldset>';
! 549: if (ref($statushash) eq 'HASH') {
! 550: $statushash->{'future'} = 1;
! 551: }
! 552:
1.87 bisitz 553: }
1.25 foxr 554: return $result;
555: }
556:
1.38 raeburn 557: sub disgroup {
1.95 ! raeburn 558: my ($cdom,$cnum,$group,$access_status) = @_;
1.38 raeburn 559: my $result;
560: # Needs to be in a course
561: if (!($env{'request.course.fn'})) {
562: $result = &mt('Error: you must have a course role selected to be able to send a broadcast message to a group in the course.');
563: return $result;
564: }
565: if ($cdom eq '' || $cnum eq '') {
566: $result = &mt('Error: could not determine domain or number of course');
567: return $result;
568: }
569: my ($memberinfo,$numitems) =
570: &Apache::longroup::group_memberlist($cdom,$cnum,$group,{},[]);
571: my @statustypes = ('active');
1.95 ! raeburn 572: my $viewgrps = &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.
! 573: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
! 574: my $editgrps = &Apache::lonnet::allowed('mdg',$env{'request.course.id'}.
! 575: ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.38 raeburn 576: if ($viewgrps || $editgrps) {
577: push(@statustypes,('future','previous'));
578: }
579: if (keys(%{$memberinfo}) == 0) {
580: $result = &mt('As this group has no members, there are no '.
581: 'recipients to select.');
582: return $result;
583: } else {
584: my %Sortby = (
585: active => {},
586: previous => {},
587: future => {},
588: );
589: my %lt = &Apache::lonlocal::texthash(
590: 'name' => 'Name',
591: 'usnm' => 'Username',
592: 'doma' => 'Domain',
1.95 ! raeburn 593: 'active' => 'Broadcast to Active Members',
! 594: 'previous' => 'Broadcast (Bcc) to Former Members',
! 595: 'future' => 'Broadcast (Bcc) to Future Members',
1.38 raeburn 596: );
597: foreach my $user (sort(keys(%{$memberinfo}))) {
598: my $status = $$memberinfo{$user}{status};
599: if ($env{'form.'.$status.'.sortby'} eq 'fullname') {
600: push(@{$Sortby{$status}{$$memberinfo{$user}{fullname}}},$user);
601: } elsif ($env{'form.'.$status.'.sortby'} eq 'username') {
602: push(@{$Sortby{$status}{$$memberinfo{$user}{uname}}},$user);
603: } elsif ($env{'form.'.$status.'.sortby'} eq 'domain') {
604: push(@{$Sortby{$status}{$$memberinfo{$user}{udom}}},$user);
605: } else {
606: push(@{$Sortby{$status}{$$memberinfo{$user}{fullname}}},$user);
607: }
608: }
609: $result .= &group_check_uncheck();
610: foreach my $status (@statustypes) {
611: if (ref($numitems) eq 'HASH') {
612: if ((defined($$numitems{$status})) && ($$numitems{$status})) {
1.95 ! raeburn 613: my $formname = $status.'users';
! 614: if (ref($access_status) eq 'HASH') {
! 615: $access_status->{$status} = $$numitems{$status};
! 616: }
! 617: $result.='<fieldset><legend><b>'.$lt{$status}.
! 618: '</b></legend><form name="'.$formname.'">'.
! 619: '<span class="LC_nobreak">'.
1.50 raeburn 620: '<input type="button" value="'.&mt('Check All').'" '.
1.95 ! raeburn 621: 'onclick="javascript:toggleAll('."this.form,'check'".')" />'.
1.38 raeburn 622: ' '.
1.50 raeburn 623: '<input type="button" value="'.&mt('Uncheck All').'" '.
1.95 ! raeburn 624: 'onclick="javascript:toggleAll('."this.form,'uncheck'".')" />'.
! 625: '</span>';
! 626: if ($status eq 'active') {
! 627: $result .= ' <select name="groupmail">'.
! 628: '<option value="bcc" selected="selected">'.&mt('Bcc').'</option>'.
! 629: '<option value="cc">'.&mt('Cc').'</option>'.
! 630: '</select>';
! 631: }
! 632: $result .= '<br />'.&Apache::loncommon::start_data_table().
! 633: &Apache::loncommon::start_data_table_header_row().
! 634: "<th>$lt{'name'}</a></th>".
1.39 raeburn 635: "<th>$lt{'usnm'}</a></th>".
636: "<th>$lt{'doma'}</a></th>".
1.95 ! raeburn 637: &Apache::loncommon::end_data_table_header_row();
1.38 raeburn 638: foreach my $key (sort(keys(%{$Sortby{$status}}))) {
639: foreach my $user (@{$Sortby{$status}{$key}}) {
640: $result .=
641: &Apache::loncommon::start_data_table_row().
642: '<td><input type="checkbox" '.
643: 'name="selectedusers_forminput" value="'.
644: $user.':'.$status.'" />'.
645: $$memberinfo{$user}{'fullname'}.'</td>'.
646: '<td>'.$$memberinfo{$user}{'uname'}.'</td>'.
647: '<td>'.$$memberinfo{$user}{'udom'}.'</td>'.
648: &Apache::loncommon::end_data_table_row();
649: }
650: }
1.95 ! raeburn 651: $result .= &Apache::loncommon::end_data_table().'</form></fieldset><br />';
1.38 raeburn 652: }
653: }
654: }
655: }
656: return $result;
657: }
658:
659: sub group_check_uncheck {
660: my $output = qq|
661: <script type="text/javascript">
1.95 ! raeburn 662: function toggleAll(form,action) {
! 663: if (typeof(form.selectedusers_forminput.length)=="undefined") {
! 664: if (action == 'check') {
! 665: form.selectedusers_forminput.checked = true;
! 666: } else {
! 667: form.selectedusers_forminput.checked = false;
! 668: }
! 669: } else {
! 670: for (var i=0; i<form.selectedusers_forminput.length; i++) {
1.38 raeburn 671: if (action == 'check') {
1.95 ! raeburn 672: form.selectedusers_forminput[i].checked = true;
1.38 raeburn 673: } else {
1.95 ! raeburn 674: form.selectedusers_forminput[i].checked = false;
1.38 raeburn 675: }
676: }
677: }
678: }
679: </script>
680: |;
681: }
682:
683: sub groupmail_header {
684: my ($action,$group,$cdom,$cnum) = @_;
685: my ($description,$refarg);
686: if (!$cdom || !$cnum) {
687: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
688: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
689: }
690: if (exists($env{'form.ref'})) {
691: $refarg = 'ref='.$env{'form.ref'};
692: }
693: if (!$group) {
694: $group = $env{'form.group'};
695: }
696: if ($group eq '') {
697: return '';
698: } else {
699: my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
700: if (defined($curr_groups{$group})) {
701: my %groupinfo =
702: &Apache::longroup::get_group_settings($curr_groups{$group});
703: $description = &unescape($groupinfo{'description'});
704: }
705: }
706: &Apache::lonhtmlcommon::clear_breadcrumbs();
707: if ($refarg) {
708: &Apache::lonhtmlcommon::add_breadcrumb
709: ({href=>"/adm/coursegroups",
710: text=>"Groups",
711: title=>"View course groups"});
712: }
713: &Apache::lonhtmlcommon::add_breadcrumb
714: ({href=>"/adm/$cdom/$cnum/$group/smppg?$refarg",
715: text=>"Group: $description",
716: title=>"Go to group's home page"},
717: {href=>"/adm/email?compose=group&group=".
718: "$env{'form.group'}&$refarg",
719: text=>"Send a Message in a Group",
720: title=>"Compose Group Email Message"},);
721: if ($action eq 'sending') {
722: &Apache::lonhtmlcommon::add_breadcrumb
723: ({text=>"Messages being sent.",
724: title=>"Messages sent"},);
725: }
726: my $groupheader = &Apache::loncommon::start_page('Group Email');
727: $groupheader .= &Apache::lonhtmlcommon::breadcrumbs
728: ('Group - '.$env{'form.group'}.' Email');
729: return $groupheader;
730: }
731:
732: sub groupmail_sent {
733: my ($group,$cdom,$cnum) = @_;
734: my $refarg;
735: if (exists($env{'form.ref'})) {
736: $refarg = 'ref='.$env{'form.ref'};
737: }
738: my $output .= '<br /><br /><a href="/adm/email?compose=group&group='.
739: $group.'&'.$refarg.'">'.
740: &mt('Send another group email').'</a>'.' '.
741: '<a href="/adm/'.$cdom.'/'.$cnum.'/'.$group.'/smppg?'.
742: $refarg.'">'. &mt('Return to group page').'</a>';
743: return $output;
744: }
745:
1.1 albertel 746: # ==================================================== Display Critical Message
747:
748: sub discrit {
749: my $r=shift;
1.89 bisitz 750: my $header = '<h1>'.&mt('Critical Messages').'</h1>'
751: .'<div class="LC_warning">'
752: .&mt('Access to other pages will be prevented until you have moved all critical messages to your inbox.')
753: .'</div><br />'
754: .'<form action="/adm/email" method="POST">'
755: .'<input type="hidden" name="confirm" value="true" />';
1.1 albertel 756: my %what=&Apache::lonnet::dump('critical');
757: my $result = '';
1.42 raeburn 758: foreach my $key (sort(keys(%what))) {
759: my %content=&Apache::lonmsg::unpackagemsg($what{$key});
1.1 albertel 760: next if ($content{'senderdomain'} eq '');
1.88 bisitz 761: $result .= &Apache::lonhtmlcommon::start_pick_box()
762: .&Apache::lonhtmlcommon::row_title(&mt('From'),undef,'LC_oddrow_value')
763: .'<b>'.&Apache::loncommon::aboutmewrapper(
764: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b>'
765: .' ('.$content{'sendername'}.':'.$content{'senderdomain'}.')'
766: .&Apache::lonhtmlcommon::row_closure(1)
767: .&Apache::lonhtmlcommon::row_title(&mt('Date'),undef,'LC_evenrow_value')
768: .$content{'time'}
769: .&Apache::lonhtmlcommon::row_closure(1)
770: .&Apache::lonhtmlcommon::row_title(&mt('Subject'),undef,'LC_oddrow_value')
771: .$content{'subject'}
772: .&Apache::lonhtmlcommon::row_closure(1)
773: .&Apache::lonhtmlcommon::row_title(&mt('Message'),undef,'LC_evenrow_value')
774: .'<pre>'.&Apache::lontexconvert::msgtexconverted($content{'message'}).'</pre>'
775: .&Apache::lonhtmlcommon::row_closure()
776: .&Apache::lonhtmlcommon::row_title('',undef,'LC_oddrow_value')
777: .'<div class="LC_warning">';
1.78 raeburn 778: my ($rec_button,$reprec_button);
779: $rec_button = &mt('Move to Inbox');
780: if (!$content{'noreplies'}) {
781: $reprec_button = &mt('Move to Inbox/Compose reply');
782: }
1.75 raeburn 783: if ($content{'sendback'}) {
784: $rec_button = &mt('Confirm Receipt');
1.78 raeburn 785: if (!$content{'noreplies'}) {
786: $reprec_button = &mt('Confirm Receipt and Reply');
787: }
1.75 raeburn 788: $result .= &mt('You have to confirm that you have received this message before you can view other pages. After confirmation, this message will be moved to your regular inbox');
789: } else {
1.78 raeburn 790: $result .= &mt('Access to other pages will be prevented until you have moved the message to your inbox.');
1.75 raeburn 791: }
1.88 bisitz 792: $result .= '</div>'
793: .&Apache::lonhtmlcommon::row_closure(1)
794: .&Apache::lonhtmlcommon::row_title('',undef,'LC_evenrow_value')
795: .'<input type="submit" name="rec_'.$key.'" value="'.$rec_button.'" />';
1.78 raeburn 796: if (!$content{'noreplies'}) {
1.88 bisitz 797: $result .= '<input type="submit" name="reprec_'.$key.'" '
798: .'value="'.$reprec_button.'" />'
1.78 raeburn 799: }
1.88 bisitz 800: $result .= &Apache::lonhtmlcommon::row_closure(1)
801: .&Apache::lonhtmlcommon::end_pick_box()
802: .'<br />';
1.1 albertel 803: }
804: # Check to see if there were any messages.
805: if ($result eq '') {
806: $result = "<h2>".&mt('You have no critical messages.')."</h2>".
1.38 raeburn 807: '<a href="/adm/roles">'.&mt('Select a course').'</a><br />'.
1.1 albertel 808: '<a href="/adm/email">'.&mt('Communicate').'</a>';
809: } else {
810: $r->print($header);
811: }
812: $r->print($result);
813: $r->print('<input type="hidden" name="displayedcrit" value="true" /></form>');
814: }
815:
816: sub sortedmessages {
1.53 raeburn 817: my ($blocked,$startblock,$endblock,$numblocked,$folder,$msgstatus) = @_;
1.1 albertel 818: my $suffix=&Apache::lonmsg::foldersuffix($folder);
819: my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
820: #unpack the varibles and repack into temp for sorting
821: my @temp;
822: my %descriptions;
823: my %status_cache =
824: &Apache::lonnet::get('email_status'.&Apache::lonmsg::foldersuffix($folder),\@messages);
1.11 albertel 825:
826: my $get_received;
827: if ($folder eq 'sent'
828: && ($env{'form.sortedby'} =~ m/^(rev)?(user|domain)$/)) {
829: $get_received = 1;
830: }
831:
832: foreach my $msgid (@messages) {
1.29 www 833: my $esc_msgid=&escape($msgid);
1.59 raeburn 834: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,$processid,$symb,$error) =
1.11 albertel 835: &Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
1.1 albertel 836: \%status_cache);
1.53 raeburn 837: next if ($msgstatus ne '' && $msgstatus ne $status);
1.1 albertel 838: my $description = &get_course_desc($fromcid,\%descriptions);
839: my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
1.11 albertel 840: $esc_msgid,$description);
841: if ($get_received) {
842: my %message = &Apache::lonnet::get('nohist_email'.$suffix,
843: [$msgid]);
844: my %content = &Apache::lonmsg::unpackagemsg($message{$msgid});
845: push(@temp1,$content{'recuser'},$content{'recdomain'});
846: }
1.1 albertel 847: # Check whether message was sent during blocking period.
848: if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
1.11 albertel 849: $$blocked{$msgid} = 'ON';
1.1 albertel 850: $$numblocked ++;
851: } else {
852: push @temp ,\@temp1;
853: }
854: }
855: #default sort
856: @temp = sort {$a->[0] <=> $b->[0]} @temp;
857: if ($env{'form.sortedby'} eq "date"){
858: @temp = sort {$a->[0] <=> $b->[0]} @temp;
859: }
860: if ($env{'form.sortedby'} eq "revdate"){
861: @temp = sort {$b->[0] <=> $a->[0]} @temp;
862: }
863: if ($env{'form.sortedby'} eq "user"){
1.11 albertel 864: if ($get_received) {
865: @temp = sort {lc($a->[7][0]) cmp lc($b->[7][0])} @temp;
866: } else {
867: @temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
868: }
1.1 albertel 869: }
870: if ($env{'form.sortedby'} eq "revuser"){
1.11 albertel 871: if ($get_received) {
872: @temp = sort {lc($b->[7][0]) cmp lc($a->[7][0])} @temp;
873: } else {
874: @temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp;
875: }
1.1 albertel 876: }
877: if ($env{'form.sortedby'} eq "domain"){
1.11 albertel 878: if ($get_received) {
879: @temp = sort {$a->[8][0] cmp $b->[8][0]} @temp;
880: } else {
881: @temp = sort {$a->[3] cmp $b->[3]} @temp;
882: }
1.1 albertel 883: }
884: if ($env{'form.sortedby'} eq "revdomain"){
1.11 albertel 885: if ($get_received) {
886: @temp = sort {$b->[8][0] cmp $a->[8][0]} @temp;
887: } else {
888: @temp = sort {$b->[3] cmp $a->[3]} @temp;
889: }
1.1 albertel 890: }
891: if ($env{'form.sortedby'} eq "subject"){
892: @temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
893: }
894: if ($env{'form.sortedby'} eq "revsubject"){
895: @temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
896: }
897: if ($env{'form.sortedby'} eq "course"){
898: @temp = sort {lc($a->[6]) cmp lc($b->[6])} @temp;
899: }
900: if ($env{'form.sortedby'} eq "revcourse"){
901: @temp = sort {lc($b->[6]) cmp lc($a->[6])} @temp;
902: }
903: if ($env{'form.sortedby'} eq "status"){
904: @temp = sort {$a->[4] cmp $b->[4]} @temp;
905: }
906: if ($env{'form.sortedby'} eq "revstatus"){
907: @temp = sort {$b->[4] cmp $a->[4]} @temp;
908: }
909: return @temp;
910: }
911:
912: sub get_course_desc {
913: my ($fromcid,$descriptions) = @_;
914: my $description;
915: if (!$fromcid) {
916: return $description;
917: } else {
918: if (defined($$descriptions{$fromcid})) {
919: $description = $$descriptions{$fromcid};
920: } else {
921: if (defined($env{'course.'.$fromcid.'.description'})) {
922: $description = $env{'course.'.$fromcid.'.description'};
923: } else {
1.48 albertel 924: my %courseinfo=&Apache::lonnet::coursedescription($fromcid);
1.1 albertel 925: $description = $courseinfo{'description'};
926: }
927: $$descriptions{$fromcid} = $description;
928: }
929: return $description;
930: }
931: }
932:
933: # ======================================================== Display all messages
934:
935: sub disall {
1.53 raeburn 936: my ($r,$folder,$msgstatus)=@_;
1.81 albertel 937: my %saveable = ('msgstatus' => 'scalar',
1.57 albertel 938: 'sortedby' => 'scalar',
939: 'interdis' => 'scalar',
940: );
941: &Apache::loncommon::store_settings('user','mail',\%saveable);
942: &Apache::loncommon::restore_settings('user','mail',\%saveable);
943: $folder ||= $env{'form.folder'};
944: $msgstatus ||= $env{'form.msgstatus'};
945: $env{'form.interdis'} ||= 20;
946:
1.53 raeburn 947: $r->print(&folderlist($folder,$msgstatus));
948: if ($folder eq 'critical') {
1.1 albertel 949: &discrit($r);
950: } else {
1.53 raeburn 951: &disfolder($r,$folder,$msgstatus);
1.1 albertel 952: }
953: }
954:
955: # ============================================================ Display a folder
956:
957: sub disfolder {
1.53 raeburn 958: my ($r,$folder,$msgstatus)=@_;
959: my %statushash = &get_msgstatus_types();
1.1 albertel 960: my %blocked = ();
961: my %setters = ();
962: my $numblocked = 0;
1.44 raeburn 963: my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
1.53 raeburn 964: my %lt = &Apache::lonlocal::texthash(
965: sede => 'Select a destination folder to which the messages will be moved.',
966: nome => 'No messages have been selected to apply ths action to.',
967: chec => 'Check the checkbox for at least one message.',
968: );
1.64 raeburn 969: my $jscript = &Apache::loncommon::check_uncheck_jscript();
1.1 albertel 970: $r->print(<<ENDDISHEADER);
1.16 albertel 971: <script type="text/javascript">
1.64 raeburn 972: $jscript
1.1 albertel 973:
1.53 raeburn 974: function validate_checkedaction() {
975: document.disall.markedaction.value = document.disall.checkedaction.options[document.disall.checkedaction.selectedIndex].value;
976: if (document.disall.checkedaction.options[document.disall.checkedaction.selectedIndex].value == 'markedmove') {
977: if (document.disall.movetofolder.options[document.disall.movetofolder.selectedIndex].value == "") {
978: alert("$lt{'sede'}");
979: return;
980: }
981: }
982: var checktotal = 0;
1.64 raeburn 983: if (document.forms.disall.delmark.length > 0) {
984: for (var i=0; i<document.forms.disall.delmark.length; i++) {
985: if (document.forms.disall.delmark[i].checked) {
986: checktotal ++;
987: }
988: }
989: } else {
990: if (document.forms.disall.delmark.checked) {
1.53 raeburn 991: checktotal ++;
992: }
1.64 raeburn 993: }
1.53 raeburn 994: if (checktotal == 0) {
995: alert("$lt{'nome'}\\n$lt{'chec'}");
996: return;
997: }
998: document.disall.submit();
999: }
1000:
1.1 albertel 1001: </script>
1002: ENDDISHEADER
1.54 albertel 1003:
1.1 albertel 1004: my $fsqs='&folder='.$folder;
1.53 raeburn 1005: my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
1.1 albertel 1006: my $totalnumber=$#temp+1;
1.53 raeburn 1007: if ($totalnumber < 1) {
1008: if ($msgstatus eq '') {
1009: $r->print('<h2>'.&mt('Empty Folder').'</h2>');
1010: } elsif ($msgstatus eq 'replied') {
1011: $r->print('<h2>'.&mt('You have not replied to any messages in this folder.').'</h2>');
1012: } else {
1.55 albertel 1013: $r->print('<h2>'.&mt('There are no '.lc($statushash{$msgstatus}).' messages in this folder.').'</h2>');
1.53 raeburn 1014: }
1.65 raeburn 1015: if ($numblocked > 0) {
1016: $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
1017: \%setters));
1018: }
1.1 albertel 1019: return;
1020: }
1.57 albertel 1021: my $interdis = $env{'form.interdis'};
1.1 albertel 1022: my $number=int($totalnumber/$interdis);
1.57 albertel 1023: if ($totalnumber%$interdis == 0) {
1024: $number--;
1.53 raeburn 1025: }
1026:
1.1 albertel 1027: if (($startdis<0) || ($startdis>$number)) { $startdis=$number; }
1028: my $firstdis=$interdis*$startdis;
1029: if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; }
1030: my $lastdis=$firstdis+$interdis-1;
1031: if ($lastdis>$#temp) { $lastdis=$#temp; }
1.53 raeburn 1032: $r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber,$msgstatus));
1.1 albertel 1033: $r->print('<form method="post" name="disall" action="/adm/email">'.
1.53 raeburn 1034: '<table class="LC_mail_list"><tr><th colspan="1"> </th><th>');
1.1 albertel 1035: if ($env{'form.sortedby'} eq "revdate") {
1036: $r->print('<a href = "?sortedby=date'.$fsqs.'">'.&mt('Date').'</a></th>');
1037: } else {
1038: $r->print('<a href = "?sortedby=revdate'.$fsqs.'">'.&mt('Date').'</a></th>');
1039: }
1040: $r->print('<th>');
1041: if ($env{'form.sortedby'} eq "revuser") {
1042: $r->print('<a href = "?sortedby=user'.$fsqs.'">'.&mt('Username').'</a>');
1043: } else {
1044: $r->print('<a href = "?sortedby=revuser'.$fsqs.'">'.&mt('Username').'</a>');
1045: }
1046: $r->print('</th><th>');
1047: if ($env{'form.sortedby'} eq "revdomain") {
1048: $r->print('<a href = "?sortedby=domain'.$fsqs.'">'.&mt('Domain').'</a>');
1049: } else {
1050: $r->print('<a href = "?sortedby=revdomain'.$fsqs.'">'.&mt('Domain').'</a>');
1051: }
1052: $r->print('</th><th>');
1053: if ($env{'form.sortedby'} eq "revsubject") {
1054: $r->print('<a href = "?sortedby=subject'.$fsqs.'">'.&mt('Subject').'</a>');
1055: } else {
1056: $r->print('<a href = "?sortedby=revsubject'.$fsqs.'">'.&mt('Subject').'</a>');
1057: }
1058: $r->print('</th><th>');
1059: if ($env{'form.sortedby'} eq "revcourse") {
1.46 raeburn 1060: $r->print('<a href = "?sortedby=course'.$fsqs.'">'.&mt('Course').'</a>');
1.1 albertel 1061: } else {
1.46 raeburn 1062: $r->print('<a href = "?sortedby=revcourse'.$fsqs.'">'.&mt('Course').'</a>');
1.1 albertel 1063: }
1064: $r->print('</th><th>');
1065: if ($env{'form.sortedby'} eq "revstatus") {
1066: $r->print('<a href = "?sortedby=status'.$fsqs.'">'.&mt('Status').'</a></th>');
1067: } else {
1068: $r->print('<a href = "?sortedby=revstatus'.$fsqs.'">'.&mt('Status').'</a></th>');
1069: }
1070: $r->print("</tr>\n");
1.6 albertel 1071:
1072: my $suffix = &Apache::lonmsg::foldersuffix($folder);
1.1 albertel 1073: for (my $n=$firstdis;$n<=$lastdis;$n++) {
1.11 albertel 1074: my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$origID,
1075: $description,$recv_name,$recv_domain)=
1076: @{$temp[$n]};
1.1 albertel 1077: if (($status ne 'deleted') && defined($sendtime) && $sendtime!~/error/) {
1078: if ($status eq 'new') {
1.4 albertel 1079: $r->print('<tr class="LC_mail_new">');
1.1 albertel 1080: } elsif ($status eq 'read') {
1.4 albertel 1081: $r->print('<tr class="LC_mail_read">');
1.1 albertel 1082: } elsif ($status eq 'replied') {
1.4 albertel 1083: $r->print('<tr class="LC_mail_replied">');
1.1 albertel 1084: } else {
1.4 albertel 1085: $r->print('<tr class="LC_mail_other">');
1.1 albertel 1086: }
1.6 albertel 1087: my ($dis_name,$dis_domain) = ($fromname,$fromdomain);
1088: if ($folder eq 'sent') {
1.69 raeburn 1089: if (defined($recv_name) && defined($recv_domain)) {
1090: if (ref($recv_name) eq 'ARRAY' &&
1091: ref($recv_domain) eq 'ARRAY') {
1092: $dis_name = join('<br />',@{$recv_name});
1093: $dis_domain = join('<br />',@{$recv_domain});
1094: }
1.11 albertel 1095: } else {
1.29 www 1096: my $msg_id = &unescape($origID);
1.11 albertel 1097: my %message = &Apache::lonnet::get('nohist_email'.$suffix,
1098: [$msg_id]);
1099: my %content = &Apache::lonmsg::unpackagemsg($message{$msg_id});
1.69 raeburn 1100: if (ref($content{'recuser'}) eq 'ARRAY') {
1101: $dis_name = join('<br />',@{$content{'recuser'}});
1102: }
1103: if (ref($content{'recdomain'}) eq 'ARRAY') {
1104: $dis_domain = join('<br />',@{$content{'recdomain'}});
1105: }
1.11 albertel 1106: }
1.6 albertel 1107: }
1.53 raeburn 1108: my $localsenttime = &Apache::lonlocal::locallocaltime($sendtime);
1109: my $count = $n +1;
1110: $r->print('<td align="right"><nobr>'.(($status eq 'new')?'<b>':'').
1111: $count.'.'.(($status eq 'new')?'</b>':'').' '.
1112: '<input type="checkbox" name="delmark"'.
1113: ' value="'.$origID.'" /></nobr></td>');
1114: foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) {
1115: $r->print('<td>'.(($status eq 'new')?'<b>':'').
1.61 raeburn 1116: '<a href="/adm/email?display='.$origID.$sqs.'">'.
1.53 raeburn 1117: $item.(($status eq 'new')?'</b>':'').'</td>');
1118: }
1119: my $showstatus;
1120: my %statushash = &get_msgstatus_types();
1121: if ($status eq '') {
1122: $showstatus = '';
1123: } else {
1124: $showstatus = $statushash{$status};
1125: }
1126: $r->print('<td>'.(($status eq 'new')?'<b>':'').$description.
1127: (($status eq 'new')?'</b>':'').'</td><td>'.
1128: (($status eq 'new')?'<b>':'').$showstatus.
1129: (($status eq 'new')?'</b>':'').'</td></tr>'."\n");
1.1 albertel 1130: } elsif ($status eq 'deleted') {
1131: # purge
1.9 albertel 1132: my ($result,$msg) =
1.29 www 1133: &movemsg(&unescape($origID),$folder,'trash');
1.9 albertel 1134:
1.1 albertel 1135: }
1136: }
1.53 raeburn 1137: $r->print("</table>\n");
1138: $r->print('<table border="0" cellspacing="2" cellpadding="2">
1139: <tr>
1140: <td>'.
1.64 raeburn 1141: '<input type="button" onclick="javascript:checkAll(document.disall.delmark)" value="'.&mt('Check All').'" /><br />'."\n".
1142: '<input type="button" onclick="javascript:uncheckAll(document.disall.delmark)" value="'.&mt('Uncheck All').'" />'."\n".
1.53 raeburn 1143: '<input type="hidden" name="sortedby" value="'.$env{'form.sortedby'}.'" /></td><td> </td>'."\n".
1144: '<td align="center"><b>'.&mt('Action').'</b><br />'."\n".
1.83 raeburn 1145: ' <select name="checkedaction">'."\n");
1.53 raeburn 1146:
1.1 albertel 1147: if ($folder ne 'trash') {
1.53 raeburn 1148: $r->print(' <option value="markeddel">'.&mt('Delete').'</option>'."\n");
1149: }
1150: if ($msgstatus ne 'read') {
1151: $r->print(' <option value="markedread">'.&mt('Mark Read').'</option>."\n"');
1152: }
1153: if ($msgstatus ne 'unread') {
1154: $r->print(' <option value="markedunread">'.&mt('Mark Unread').'</option>'."\n");
1.1 albertel 1155: }
1.53 raeburn 1156: $r->print(' <option value="markedforward">'.&mt('Forward').'</option>'."\n");
1.54 albertel 1157:
1158: my %gotfolders = &Apache::lonmsg::get_user_folders();
1.53 raeburn 1159: if (keys(%gotfolders) > 0) {
1160: $r->print(' <option value="markedmove">'.&mt('Move to Folder ->').
1161: '</option>');
1162: }
1163: $r->print("\n".'</select></td>'."\n");
1.54 albertel 1164:
1.53 raeburn 1165: if (keys(%gotfolders) > 0) {
1166: $r->print('<td align="center"><b>'.&mt('Destination folder').'<b><br />');
1.54 albertel 1167: my %userfolders;
1.53 raeburn 1168: foreach my $key (keys(%gotfolders)) {
1169: $userfolders{$key} = $key;
1170: }
1171: $userfolders{''} = "";
1172: $r->print(&Apache::loncommon::select_form('','movetofolder',%userfolders).
1173: '</td>');
1174: }
1175: $r->print('<td> </td><td> '.
1176: '<input type="button" name="go" value="'.&mt('Go').
1177: '" onclick="javascript:validate_checkedaction()"/></td>'."\n".
1178: '</tr></table>');
1.1 albertel 1179: my $postedstartdis=$startdis+1;
1.53 raeburn 1180: $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'}.'" /><input type="hidden" name="msgstatus" value="'.$msgstatus.'" ><input type="hidden" name="markedaction" value="" /></form>');
1.1 albertel 1181: if ($numblocked > 0) {
1.65 raeburn 1182: $r->print(&blocked_in_folder($numblocked,$startblock,$endblock,
1183: \%setters));
1.1 albertel 1184: }
1185: }
1186:
1.65 raeburn 1187: sub blocked_in_folder {
1188: my ($numblocked,$startblock,$endblock,$setters) = @_;
1189: my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
1190: my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
1191: my $output = '<br /><br />'.
1192: &mt('[quant,_1,message is, messages are] not viewable because display of LON-CAPA messages sent to you by other students between [_2] and [_3] is currently being blocked because of online exams.',$numblocked,$beginblock,$finishblock);
1193: $output .= &Apache::loncommon::build_block_table($startblock,$endblock,
1194: $setters);
1195: return $output;
1196: }
1197:
1.1 albertel 1198: # ============================================================== Compose output
1199:
1200: sub compout {
1.53 raeburn 1201: my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode,
1202: $multiforward)=@_;
1.1 albertel 1203: my $suffix=&Apache::lonmsg::foldersuffix($folder);
1.38 raeburn 1204: my ($cdom,$cnum,$group,$refarg);
1205: if (exists($env{'form.group'})) {
1206: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1207: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1208: $group = $env{'form.group'};
1209: my $action = 'composing';
1210: $r->print(&groupmail_header($action,$group,$cdom,$cnum));
1211: } elsif ($broadcast eq 'individual') {
1.1 albertel 1212: &printheader($r,'/adm/email?compose=individual',
1213: 'Send a Message');
1214: } elsif ($broadcast) {
1215: &printheader($r,'/adm/email?compose=group',
1216: 'Broadcast Message');
1217: } elsif ($forwarding) {
1218: &Apache::lonhtmlcommon::add_breadcrumb
1.29 www 1219: ({href=>"/adm/email?display=".&escape($forwarding),
1.1 albertel 1220: text=>"Display Message"});
1.29 www 1221: &printheader($r,'/adm/email?forward='.&escape($forwarding),
1.1 albertel 1222: 'Forwarding a Message');
1223: } elsif ($replying) {
1224: &Apache::lonhtmlcommon::add_breadcrumb
1.29 www 1225: ({href=>"/adm/email?display=".&escape($replying),
1.1 albertel 1226: text=>"Display Message"});
1.29 www 1227: &printheader($r,'/adm/email?replyto='.&escape($replying),
1.1 albertel 1228: 'Replying to a Message');
1229: } elsif ($replycrit) {
1230: $r->print('<h3>'.&mt('Replying to a Critical Message').'</h3>');
1231: $replying=$replycrit;
1.53 raeburn 1232: } elsif ($multiforward) {
1233: &Apache::lonhtmlcommon::add_breadcrumb
1234: ({href=>"/adm/email?folder=".&escape($folder),
1235: text=>"Display All Messages"});
1236: &printheader($r,'/adm/email?compose=multiforward',
1237: 'Forwarding Multiple Messages');
1.70 raeburn 1238: if ($multiforward > 1) {
1.85 bisitz 1239: $r->print(&mt('Each of the <b>[quant,_1,message]</b> you checked'
1240: .' will be forwarded to the recipient(s) you select below.',$multiforward)
1241: .'<br />');
1.70 raeburn 1242: } else {
1243: $r->print(&mt('The message you checked will be forwarded to the recipient(s) you select below.').'<br />');
1244: }
1245:
1.1 albertel 1246: } else {
1247: &printheader($r,'/adm/email?compose=upload',
1248: 'Distribute from Uploaded File');
1249: }
1250:
1251: my $dispcrit='';
1252: my $dissub='';
1253: my $dismsg='';
1254: my $disbase='';
1.86 raeburn 1255: my $attachrow;
1.94 bisitz 1256: my $func1='Send'; # do not translate here!
1257: my %func2=( # do not translate here!
1258: 'ma' => 'Message',
1259: 'msg' => 'Messages',
1260: );
1.50 raeburn 1261: my %lt=&Apache::lonlocal::texthash('us' => 'Username',
1262: 'do' => 'Domain',
1263: 'ad' => 'Additional Recipients',
1.78 raeburn 1264: 'rt' => 'Reply to',
1265: 'ar' => 'Allow replies',
1.50 raeburn 1266: 'sb' => 'Subject',
1267: 'ca' => 'Cancel',
1268: 'gen' => 'Generate messages from a file',
1269: 'gmt' => 'General message text',
1270: 'tff' => 'The file format for the uploaded portion of the message is',
1271: 'uas' => 'Upload and Send',
1.86 raeburn 1272: 'atta' => 'Attachment',
1.95 ! raeburn 1273: 'to' => 'To:',
1.50 raeburn 1274: );
1.86 raeburn 1275: my %attachmax = (
1.93 bisitz 1276: text => &mt('(128 KB max size)'),
1.86 raeburn 1277: num => 131072,
1278: );
1279: if (!$forwarding && !$multiforward) {
1.95 ! raeburn 1280: $attachrow = '<tr><td colspan="3"><b>'.$lt{'atta'}.'</b> '.$attachmax{'text'}.': <input type="file" name="attachment" /></td></tr>';
1.86 raeburn 1281: }
1.1 albertel 1282: if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1283: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1284: '/'.$env{'request.course.sec'})) {
1285: my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
1286: $dispcrit=
1.95 ! raeburn 1287: '<span class="LC_nobreak"><label><input type="checkbox" name="critmsg" /> '.&mt('Send as critical message').'.</label>'.$crithelp.' '.&mt('Require return receipt?').'<label><input type="radio" name="sendbck" value="1" />'.&mt('Yes').'</label> <label><input type="radio" name="sendbck" value="" checked="checked" />'.&mt('No').'</label></span><br />'.
! 1288: '<label><input type="checkbox" name="permanent" /> '.
! 1289: &mt('Send copy to permanent email address (if known)').'</label><br />'.
! 1290: '<label><input type="checkbox" name="rsspost" /> '.
! 1291: &mt('Include in course RSS newsfeed').'</label><br />';
1.70 raeburn 1292: }
1.71 raeburn 1293: if ($broadcast ne 'group') {
1294: if (&Apache::lonnet::allowed('dff',$env{'request.course.id'}) ||
1295: &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
1296: '/'.$env{'request.course.sec'})) {
1297:
1.95 ! raeburn 1298: $dispcrit.='<label>'.
1.71 raeburn 1299: '<input type="checkbox" name="courserecord" value="1" /> '.
1300: &mt("Include in course's 'User records' for recipient(s)").
1.95 ! raeburn 1301: '</label><br />';
1.71 raeburn 1302: }
1.70 raeburn 1303: }
1304:
1.1 albertel 1305: my %message;
1306: my %content;
1.95 ! raeburn 1307: my ($hasfloat,$broadcast_js,$sendmode,$can_grp_broadcast);
1.1 albertel 1308: my $defdom=$env{'user.domain'};
1.95 ! raeburn 1309: if ($broadcast eq 'group') {
! 1310: my %access_status = (
! 1311: active => 0,
! 1312: previous => 0,
! 1313: future => 0,
! 1314: );
! 1315:
! 1316: if ($group eq '') {
! 1317: my $studentsel = &discourse(\%access_status);
! 1318: if ($studentsel) {
! 1319: $r->print('<div class="LC_left_float">'.$studentsel.'</div>');
! 1320: $hasfloat = 1;
! 1321: }
! 1322: } else {
! 1323: $can_grp_broadcast = &check_group_priv($group);
! 1324: if ($can_grp_broadcast) {
! 1325: $r->print('<div class="LC_left_float">'.
! 1326: &disgroup($cdom,$cnum,$group,\%access_status).
! 1327: '</div>');
! 1328: $hasfloat = 1;
! 1329: }
! 1330: }
! 1331: if ($hasfloat) {
! 1332: $sendmode = '<input type="hidden" name="sendmode" value="group" />'."\n";
! 1333: $broadcast_js = qq|
! 1334: <script type="text/javascript">
! 1335: function courseRecipients() {
! 1336: |;
! 1337: foreach my $type (keys(%access_status)) {
! 1338: if ($access_status{$type}) {
! 1339: my $formname = $type.'users';
! 1340: if ($type eq 'active' && $group ne '') {
! 1341: $broadcast_js .= qq|
! 1342: document.compemail.groupmail.value = document.$formname.groupmail[document.$formname.groupmail.selectedIndex].value;
! 1343: |;
! 1344: }
! 1345: $broadcast_js .= qq|
! 1346: if (typeof(document.$formname.selectedusers_forminput.length)=="undefined") {
! 1347: document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput.value;
! 1348: } else {
! 1349: for (var i=0; i<document.$formname.selectedusers_forminput.length; i++) {
! 1350: if (document.$formname.selectedusers_forminput[i].checked) {
! 1351: document.compemail.courserecips.value += '_&&&_'+document.$formname.selectedusers_forminput[i].value;
! 1352: }
! 1353: }
! 1354: }
! 1355: |;
! 1356: }
! 1357: }
! 1358: $broadcast_js .= qq|
! 1359: return;
! 1360: }
! 1361: </script>
! 1362:
! 1363: |;
! 1364: }
! 1365: }
1.1 albertel 1366: if ($forwarding) {
1367: %message=&Apache::lonnet::get('nohist_email'.$suffix,[$forwarding]);
1368: %content=&Apache::lonmsg::unpackagemsg($message{$forwarding},$folder);
1369: $dispcrit.='<input type="hidden" name="forwid" value="'.
1370: $forwarding.'" />';
1.94 bisitz 1371: $func1='Forward'; # do not translate here!
1.1 albertel 1372:
1373: $dissub=&mt('Forwarding').': '.$content{'subject'};
1374: $dismsg=&mt('Forwarded message from').' '.
1375: $content{'sendername'}.' '.&mt('at').' '.$content{'senderdomain'};
1376: if ($content{'baseurl'}) {
1.29 www 1377: $disbase='<input type="hidden" name="baseurl" value="'.&escape($content{'baseurl'}).'" />';
1.1 albertel 1378: }
1379: }
1380: if ($replying) {
1381: %message=&Apache::lonnet::get('nohist_email'.$suffix,[$replying]);
1382: %content=&Apache::lonmsg::unpackagemsg($message{$replying},$folder);
1383: $dispcrit.='<input type="hidden" name="replyid" value="'.
1384: $replying.'" />';
1.94 bisitz 1385: $func1='Send Reply to'; # do not translate here!
1.1 albertel 1386:
1387: $dissub=&mt('Reply').': '.$content{'subject'};
1388: $dismsg='> '.$content{'message'};
1389: $dismsg=~s/\r/\n/g;
1390: $dismsg=~s/\f/\n/g;
1391: $dismsg=~s/\n+/\n\> /g;
1392: if ($content{'baseurl'}) {
1.29 www 1393: $disbase='<input type="hidden" name="baseurl" value="'.&escape($content{'baseurl'}).'" />';
1.1 albertel 1394: if ($env{'user.adv'}) {
1.72 albertel 1395: $disbase.='<label><input type="checkbox" name="storebasecomment" />'.&mt('Save message for re-use').
1.1 albertel 1396: '</label> <a href="/adm/email?showcommentbaseurl='.
1.29 www 1397: &escape($content{'baseurl'}).'" target="comments">'.
1.1 albertel 1398: &mt('Show re-usable messages').'</a><br />';
1399: }
1400: }
1.73 raeburn 1401: my $jscript = &Apache::loncommon::check_uncheck_jscript();
1402: $r->print(<<"ENDREPSCRIPT");
1403: <script type="text/javascript">
1404: $jscript
1405: </script>
1406: ENDREPSCRIPT
1.1 albertel 1407: }
1408: my $citation=&displayresource(%content);
1.95 ! raeburn 1409: my $onsubmit;
1.1 albertel 1410: if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; }
1.23 www 1411: if ($env{'form.text'}) { $dismsg=$env{'form.text'}; }
1412: if ($env{'form.subject'}) { $dissub=$env{'form.subject'}; }
1.95 ! raeburn 1413: if ($hasfloat) {
! 1414: $r->print($broadcast_js.'<div class="LC_left_float">');
! 1415: $onsubmit = ' onsubmit="javascript:courseRecipients();" ';
! 1416: }
1.23 www 1417: $r->print(
1.1 albertel 1418: '<form action="/adm/email" name="compemail" method="post"'.
1.95 ! raeburn 1419: ' enctype="multipart/form-data"'.$onsubmit.'>'."\n".
! 1420: '<input type="hidden" name="sendmail" value="on" />'."\n".
! 1421: '<table>');
! 1422: if (($broadcast eq 'group') && ($group ne '') && (!$can_grp_broadcast)) {
1.38 raeburn 1423: $r->print(&recipient_input_row($cdom,%lt));
1.95 ! raeburn 1424: }
1.38 raeburn 1425: if (($broadcast ne 'group') && ($broadcast ne 'upload')) {
1.1 albertel 1426: if ($replying) {
1.78 raeburn 1427: if ($content{'noreplies'}) {
1428: $r->print('<tr><td>'.&mt('This message was designated by the sender not to allow replies.').'</td></tr></table></form>');
1429: return;
1430: }
1.95 ! raeburn 1431: $r->print('<tr><td colspan="3"><b>'.&mt('Replying to').'</b> ');
1.78 raeburn 1432: if ($content{'replytoaddr'}) {
1433: my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
1434: if ($replytoname ne '' && $replytodom ne '') {
1435: $r->print(&Apache::loncommon::plainname($replytoname,
1436: $replytodom).' ('.$replytoname.':'.
1437: $replytodom.')');
1438: $r->print('<input type="hidden" name="recuname" value="'.
1439: $replytoname.'" />'.
1440: '<input type="hidden" name="recdomain" value="'.
1441: $replytodom.'" /></td></tr>');
1442:
1443: } else {
1444: $r->print(&mt('The sender did not designate a reply to address for this message.').'</td></tr></table>');
1445: return;
1446: }
1447: } else {
1448: $r->print(&Apache::loncommon::aboutmewrapper(
1.1 albertel 1449: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('.
1.14 albertel 1450: $content{'sendername'}.':'.
1.78 raeburn 1451: $content{'senderdomain'}.')');
1452: $r->print('<input type="hidden" name="recuname" value="'.
1453: $content{'sendername'}.'" />'.
1454: '<input type="hidden" name="recdomain" value="'.
1455: $content{'senderdomain'}.'" /></td></tr>');
1456: }
1.73 raeburn 1457: if ($content{'recipid'}) {
1.95 ! raeburn 1458: my %recips;
! 1459: &retrieve_recips('replying',\%content,\%recips);
! 1460: if (ref($recips{'to'}) eq 'ARRAY') {
! 1461: if (@{$recips{'to'}} > 0) {
! 1462: my $replyall;
! 1463: if (@{$recips{'to'}} > 1) {
! 1464: $replyall = qq|
! 1465: <span class="LC_nobreak">
! 1466: <input type="button" value="check all"
! 1467: onclick="javascript:checkAll(document.compemail.replying_to)" />
! 1468:
! 1469: <input type="button" value="uncheck all"
! 1470: onclick="javascript:uncheckAll(document.compemail.replying_to)" />
! 1471: </span>
! 1472: |;
! 1473: }
! 1474: my $tolist = join(' ',@{$recips{'to'}});
! 1475: $r->print('<tr><td colspan="3"><table><tr><td>'.&mt('[_1]Send reply[_2] to other recipients','<b>','</b>').':<br />'.$replyall.'</td><td>'.$tolist.'</td></tr></table></td></tr>');
! 1476: }
! 1477: }
! 1478: if (ref($recips{'cc'}) eq 'ARRAY') {
! 1479: if (@{$recips{'cc'}} > 0) {
! 1480: my $replyall;
! 1481: if (@{$recips{'cc'}} > 1) {
! 1482: $replyall = qq|
1.73 raeburn 1483: <span class="LC_nobreak">
1484: <input type="button" value="check all"
1485: onclick="javascript:checkAll(document.compemail.replying_cc)" />
1486:
1487: <input type="button" value="uncheck all"
1488: onclick="javascript:uncheckAll(document.compemail.replying_cc)" />
1489: </span>
1490: |;
1.95 ! raeburn 1491: }
! 1492: my $cclist = join(' ',@{$recips{'cc'}});
! 1493: $r->print('<tr><td colspan="3"><table><tr><td>'.&mt('[_1]Cc[_2] to other copied recipients','<b>','</b>').':<br />'.$replyall.'</td><td>'.$cclist.'</td></tr></table></td></tr>');
! 1494: }
! 1495: }
! 1496: if ($content{'group'} ne '') {
! 1497: if (&check_group_priv($content{'group'})) {
! 1498: if (ref($recips{'group_cc_broadcast'}) eq 'ARRAY') {
! 1499: if (@{$recips{'group_cc_broadcast'}} > 0) {
! 1500: my $replyall;
! 1501: if (@{$recips{'group_cc_broadcast'}} > 1) {
! 1502: $replyall = qq|
! 1503: <span class="LC_nobreak">
! 1504: <input type="button" value="check all"
! 1505: onclick="javascript:checkAll(document.compemail.replying_groupcc)" />
! 1506:
! 1507: <input type="button" value="uncheck all"
! 1508: onclick="javascript:uncheckAll(document.compemail.replying_groupcc)" />
! 1509: </span>
! 1510: |;
! 1511: }
! 1512: my $groupcclist = join(' ',@{$recips{'group_cc_broadcast'}});
! 1513: $r->print('<tr><td colspan="3"><table><tr><td>'.&mt('[_1]Cc[_2] to other copied group members','<b>','</b>').':<br />'.$replyall.'</td><td>'.$groupcclist.'<input type="hidden" name="group" value="'.$content{'group'}.'" /><input type="hidden" name="sendmode" value="group" /><input type="hidden" name="groupmail" value="cc" /></td></tr></table></td></tr>');
! 1514: }
! 1515: }
! 1516: }
1.73 raeburn 1517: }
1518: }
1.1 albertel 1519: } else {
1.38 raeburn 1520: $r->print(&recipient_input_row($defdom,%lt));
1.1 albertel 1521: }
1522: }
1.95 ! raeburn 1523: my $latexHelp = &Apache::loncommon::helpLatexCheatsheet();
! 1524: my $wysiwyglink=&Apache::lonhtmlcommon::htmlareaselectactive('message').'<br />';
1.53 raeburn 1525: my $subj_size;
1526: if ($multiforward) {
1527: $r->print(&additional_rec_row(\%lt));
1528: $r->print('<tr><td colspan="2">'.
1529: &mt('Unless you choose otherwise:').'<ul><li>'.
1530: &mt("The subject in each forwarded message will be <i>'Forwarding:'</i> followed by the original subject.").'</li><li>'.
1531: &mt("The message itself will begin with a first line: <i>'Forwarded message from'</i> followed by the original sender's name.").'</li></ul></td></tr>');
1.94 bisitz 1532: $func1='Forward'; # do not translate here!
1.53 raeburn 1533: $dissub = &mt('Forwarding').': ';
1534: $subj_size = '10';
1535: my $extra = '<'.&mt('original subject').'> '.
1536: '<input type="radio" name="showorigsubj" value="1" checked="checked" />'.&mt('Yes').' <input type="radio" name="showorigsubj" value="0" />'.&mt('No');
1537: $dismsg = &mt('Forwarded message from ').' ';
1538: my $sender = &mt("sender's name");
1539: $r->print(&msg_subject_row($dissub,\%lt,$subj_size,$extra));
1540: $r->print('<tr><td>'.&mt('Message begins with:').'</td><td><input type="text" name="msgheader" value="'.$dismsg.'" /> '.$sender.' <input type="radio" name="showorigsender" value="1" checked="checked" />'.&mt('Yes').' <input type="radio" name="showorigsender" value="0" />'.&mt('No').'<input type="hidden" name="multiforward" value="'.$multiforward.'" /></td></tr>
1541: </table>
1.95 ! raeburn 1542: <br /><table>
! 1543: <tr><td align="left">'."\n".
! 1544: $latexHelp."<br />\n".
! 1545: &mt("Any new text to display before the text of the original messages:").'<br />'."\n".
! 1546: '<textarea name="message" id="message" cols="80" rows="5" wrap="hard"></textarea>'.
! 1547: $wysiwyglink);
1.53 raeburn 1548: my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
1549: foreach my $msg (@to_forward) {
1550: $r->print('<input type="hidden" name="delmark" value="'.$msg.'" />');
1551: }
1.94 bisitz 1552: $r->print(&submit_button_row($folder,$dismode,&mt($func1.' '.$func2{'msg'}),
1.53 raeburn 1553: \%lt));
1554: } elsif ($broadcast ne 'upload') {
1555: $subj_size = '50';
1556: $r->print(&additional_rec_row(\%lt));
1.78 raeburn 1557: if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
1558: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
1559: '/'.$env{'request.course.sec'})) {
1560: $r->print(&reply_to_row(\%lt));
1561: }
1.53 raeburn 1562: $r->print(&msg_subject_row($dissub,\%lt,$subj_size));
1563: $r->print(<<"ENDCOMP");
1.95 ! raeburn 1564: $attachrow
! 1565: </table><br />
1.1 albertel 1566: $latexHelp
1567: <textarea name="message" id="message" cols="80" rows="15" wrap="hard">$dismsg
1.95 ! raeburn 1568: </textarea>$wysiwyglink
! 1569: $sendmode
1.1 albertel 1570: $dispcrit
1571: $disbase
1572: ENDCOMP
1.94 bisitz 1573: $r->print(&submit_button_row($folder,$dismode,&mt($func1.' '.$func2{'ma'}),
1.95 ! raeburn 1574: \%lt,$hasfloat,$group));
1.53 raeburn 1575: $r->print($citation);
1.38 raeburn 1576: if (exists($env{'form.ref'})) {
1577: $r->print('<input type="hidden" name="ref" value="'.
1578: $env{'form.ref'}.'" />');
1579: }
1580: if (exists($env{'form.group'})) {
1581: $r->print('<input type="hidden" name="group" value="'.
1582: $env{'form.group'}.'" />');
1583: }
1.1 albertel 1584: } else { # $broadcast is 'upload'
1.50 raeburn 1585: $r->print(<<ENDBLOCK);
1.1 albertel 1586: <input type="hidden" name="sendmode" value="upload" />
1587: <input type="hidden" name="send" value="on" />
1.50 raeburn 1588: <h3>$lt{'gen'}</h3>
1.1 albertel 1589: <p>
1590: Subject: <input type="text" size="50" name="subject" />
1591: </p>
1.50 raeburn 1592: <p>$lt{'gmt'}:<br />
1.1 albertel 1593: <textarea name="message" id="message" cols="60" rows="10" wrap="hard">$dismsg
1.95 ! raeburn 1594: </textarea>$wysiwyglink</p>
1.1 albertel 1595: <p>
1.50 raeburn 1596: $lt{'tff'}:
1597: ENDBLOCK
1598: $r->print('
1599: <pre>'."\n".
1600: &mt('username1:domain1: text')."\n".
1601: &mt('username2:domain2: text')."\n".
1602: &mt('username3:domain1: text')."\n".
1603: '</pre>
1.1 albertel 1604: </p>
1605: <p>
1.50 raeburn 1606: '.&mt('The messages will be assembled from all lines with the respective'."\n".'<tt>username:domain</tt>, and appended to the general message text.'));
1607: $r->print(<<ENDUPLOAD);
1608: </p>
1.1 albertel 1609: <p>
1610: <input type="file" name="upfile" size="40" /></p><p>
1611: $dispcrit
1.50 raeburn 1612: <input type="submit" value="$lt{'uas'}" /></p>
1.1 albertel 1613: ENDUPLOAD
1614: }
1.36 albertel 1615: if ($env{'form.displayedcrit'}) {
1616: $r->print('<input type="hidden" name="displayedcrit" value="true" />');
1617: }
1.95 ! raeburn 1618: $r->print('</form>');
! 1619: if ($hasfloat) {
! 1620: $r->print('</div><div class="LC_clear_float_footer"></div>');
! 1621: }
! 1622: $r->print(&generate_preview_form);
! 1623: }
! 1624:
! 1625: sub check_group_priv {
! 1626: my ($group) = @_;
! 1627: my $cid = $env{'request.course.id'};
! 1628: my $sec = $env{'request.course.sec'};
! 1629: return if !$cid;
! 1630: my $can_broadcast = &Apache::lonnet::allowed('sgb',$cid.'/'.$group);
! 1631: my $viewgrps = &Apache::lonnet::allowed('vcg',$cid.($sec?'/'.$sec:''));
! 1632: my $editgrps = &Apache::lonnet::allowed('mdg',$cid.($sec?'/'.$sec:''));
! 1633: if ($viewgrps || $editgrps || $can_broadcast) {
! 1634: return 1;
! 1635: }
! 1636: return;
1.1 albertel 1637: }
1638:
1.38 raeburn 1639: sub recipient_input_row {
1640: my ($dom,%lt) = @_;
1641: my $domform = &Apache::loncommon::select_dom_form($dom,'recdomain');
1642: my $selectlink=
1643: &Apache::loncommon::selectstudent_link('compemail','recuname',
1644: 'recdomain');
1645: my $output = <<"ENDREC";
1.95 ! raeburn 1646: <tr><td colspan="3"><span class="LC_nobreak"><b>$lt{'to'}</b> $lt{'us'}: <input type="text" size="12" name="recuname" value="$env{'form.recname'}" /> $lt{'do'}: $domform $selectlink</span></td></tr>
1.38 raeburn 1647: ENDREC
1648: return $output;
1649: }
1650:
1.78 raeburn 1651: sub reply_to_row {
1652: my ($lt) = @_;
1653: my $radioyes = &mt('Yes');
1654: my $radiono = &mt('No');
1655: my $output = <<"ENDREP";
1.95 ! raeburn 1656: <tr><td colspan="3"><span class="LC_nobreak"><b>$lt->{'ar'}</b>:<label><input type="radio" name="can_reply" value="Y" checked="checked" />$radioyes</label> <label><input type="radio" name="can_reply" value="N" />$radiono</label></span> <span class="LC_nobreak">$lt->{'rt'}: <input type="text" size="25" name="reply_to_addr" value="$env{'user.name'}:$env{'user.domain'}" /></span></td></tr>
1.78 raeburn 1657: ENDREP
1658: return $output;
1659: }
1660:
1.53 raeburn 1661: sub additional_rec_row {
1662: my ($lt) = @_;
1.73 raeburn 1663: my $cc = &mt('Cc:');
1.85 bisitz 1664: my $bcc = &mt('Bcc:');
1665: my $exmpl = &mt('username:domain,username:domain,...');
1.53 raeburn 1666: my $output = <<"ENDADD";
1.95 ! raeburn 1667: <tr><td colspan="3"><fieldset id="LC_additionalrecips"><legend><b>$lt->{'ad'}</b> <tt>($exmpl)</tt>:</legend><table>
! 1668: <tr><td> </td><td>$lt->{'to'}</td><td><input type="text" size="50" name="additionalrec_to" /></td></tr>
! 1669: <tr><td> </td><td>$cc</td><td><input type="text" size="50" name="additionalrec_cc" /></td></tr>
! 1670: <tr><td> </td><td>$bcc</td><td><input type="text" size="50" name="additionalrec_bcc" /></td></tr></table></fieldset>
1.53 raeburn 1671: ENDADD
1672: return $output;
1673: }
1674:
1675: sub submit_button_row {
1.95 ! raeburn 1676: my ($folder,$dismode,$sendtext,$lt,$is_crsform,$group) = @_;
! 1677: my $pre=&mt("Show Preview and Check Spelling");
! 1678: my $prevbutton = '<input type="button" name="preview" value="'.$pre.'" onclick="if (typeof(document.compemail.onsubmit)=='."'function'".') {document.compemail.onsubmit();};document.preview.comment.value=document.compemail.message.value;document.preview.subject.value=document.compemail.subject.value;document.preview.submit();" />';
! 1679: my $output = qq|
1.53 raeburn 1680: <input type="hidden" name="folder" value="$folder" />
1.95 ! raeburn 1681: <input type="hidden" name="dismode" value="$dismode" />|;
! 1682: if ($is_crsform) {
! 1683: $output .= '<input type="hidden" name="courserecips" value="" />'."\n";
! 1684: if ($group ne '') {
! 1685: $output .= '<input type="hidden" name="groupmail" value="" />'."\n";
! 1686: }
! 1687: }
! 1688: $output .= qq|
! 1689: <table><tr><td align="left">
1.53 raeburn 1690: <input type="submit" name="send" value="$sendtext" />
1.95 ! raeburn 1691: <input type="submit" name="cancel" value="$lt->{'ca'}" />
! 1692: </td><td width="60"> </td><td align="right">$prevbutton</td></tr></table>
1.53 raeburn 1693: |;
1694: return $output;
1695: }
1696:
1697: sub msg_subject_row {
1698: my ($dissub,$lt,$subj_size,$extra) = @_;
1.95 ! raeburn 1699: my $output = '<tr><td colspan="3"><b>'.$lt->{'sb'}.'</b>: <input type="text" size="'.
1.53 raeburn 1700: $subj_size.'" name="subject" value="'.$dissub.'" />'.$extra.
1701: '</td></tr>';
1702: return $output;
1703: }
1704:
1.95 ! raeburn 1705: sub generate_preview_form {
! 1706: my $prevbutton = (<<ENDPREVIEW);
! 1707: <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
! 1708: <input type="hidden" name="subject" />
! 1709: <input type="hidden" name="comment" />
! 1710: </form>
! 1711: ENDPREVIEW
! 1712: }
! 1713:
! 1714: # ---------------------------------------------------- Display all face to face
! 1715:
1.1 albertel 1716: sub retrieve_instructor_comments {
1717: my ($user,$domain)=@_;
1718: my $target=$env{'form.grade_target'};
1719: if (! $env{'request.course.id'}) { return; }
1.49 albertel 1720: if (! &Apache::lonnet::allowed('dff',$env{'request.course.id'})
1721: && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
1.1 albertel 1722: '/'.$env{'request.course.sec'})) {
1723: return;
1724: }
1725: my %records=&Apache::lonnet::dump('nohist_email',
1726: $env{'course.'.$env{'request.course.id'}.'.domain'},
1727: $env{'course.'.$env{'request.course.id'}.'.num'},
1728: '%255b'.$user.'%253a'.$domain.'%255d');
1729: my $result='';
1.42 raeburn 1730: foreach my $key (sort(keys(%records))) {
1731: my %content=&Apache::lonmsg::unpackagemsg($records{$key});
1.1 albertel 1732: next if ($content{'senderdomain'} eq '');
1733: next if ($content{'subject'} !~ /^Record/);
1734: # &Apache::lonfeedback::newline_to_br(\$content{'message'});
1735: $result.='Recorded by '.
1.14 albertel 1736: $content{'sendername'}.':'.$content{'senderdomain'}."\n";
1.1 albertel 1737: $result.=
1738: &Apache::lontexconvert::msgtexconverted($content{'message'})."\n";
1739: }
1740: return $result;
1741: }
1742:
1743: sub disfacetoface {
1744: my ($r,$user,$domain)=@_;
1745: my $target=$env{'form.grade_target'};
1746: unless ($env{'request.course.id'}) { return; }
1.49 albertel 1747: if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'})
1748: && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
1.1 albertel 1749: '/'.$env{'request.course.sec'})) {
1.50 raeburn 1750: $r->print(&mt('Not allowed'));
1.1 albertel 1751: return;
1752: }
1753: my %records=&Apache::lonnet::dump('nohist_email',
1754: $env{'course.'.$env{'request.course.id'}.'.domain'},
1755: $env{'course.'.$env{'request.course.id'}.'.num'},
1756: '%255b'.$user.'%253a'.$domain.'%255d');
1757: my $result='';
1.42 raeburn 1758: foreach my $key (sort(keys(%records))) {
1759: my %content=&Apache::lonmsg::unpackagemsg($records{$key});
1.1 albertel 1760: next if ($content{'senderdomain'} eq '');
1761: &Apache::lonfeedback::newline_to_br(\$content{'message'});
1762: if ($content{'subject'}=~/^Record/) {
1763: $result.='<h3>'.&mt('Record').'</h3>';
1764: } elsif ($content{'subject'}=~/^Broadcast/) {
1765: $result .='<h3>'.&mt('Broadcast Message').'</h3>';
1766: if ($content{'subject'}=~/^Broadcast\./) {
1767: if (defined($content{'coursemsgid'})) {
1.29 www 1768: my $crsmsgid = &escape($content{'coursemsgid'});
1.1 albertel 1769: my $broadcast_message = &general_message($crsmsgid);
1770: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$broadcast_message;
1771: } else {
1772: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1773: $content{'message'} =
1774: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1775: $content{'message'};
1776: }
1.70 raeburn 1777: }
1778: } elsif ($content{'subject'}=~/^Archive/) {
1779: $result.='<h3>'.&mt('Archived Message').'</h3>';
1780: if (defined($content{'coursemsgid'})) {
1781: my $crsmsgid = &escape($content{'coursemsgid'});
1782: my $archive_message = &general_message($crsmsgid);
1783: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$archive_message;
1784: } else {
1785: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1786: $content{'message'} =
1787: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br
1788: '.
1789: $content{'message'};
1790: }
1.1 albertel 1791: } else {
1792: $result.='<h3>'.&mt('Critical Message').'</h3>';
1793: if (defined($content{'coursemsgid'})) {
1.29 www 1794: my $crsmsgid=&escape($content{'coursemsgid'});
1.1 albertel 1795: my $critical_message = &general_message($crsmsgid);
1796: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$critical_message;
1797: } else {
1798: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1799: $content{'message'}=
1800: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1801: $content{'message'};
1802: }
1803: }
1804: $result.=&mt('By').': <b>'.
1805: &Apache::loncommon::aboutmewrapper(
1806: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
1.14 albertel 1807: $content{'sendername'}.':'.
1.1 albertel 1808: $content{'senderdomain'}.') '.$content{'time'}.
1809: '<br /><pre>'.
1810: &Apache::lontexconvert::msgtexconverted($content{'message'}).
1811: '</pre>';
1812: }
1813: # Check to see if there were any messages.
1814: if ($result eq '') {
1.33 albertel 1815: my $lctype = lc(&Apache::loncommon::course_type());
1.1 albertel 1816: if ($target ne 'tex') {
1.30 raeburn 1817: $r->print("<p><b>".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."</b></p>");
1.1 albertel 1818: } else {
1.30 raeburn 1819: $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\');
1.1 albertel 1820: }
1821: } else {
1822: $r->print($result);
1823: }
1824: }
1825:
1826: sub general_message {
1827: my ($crsmsgid) = @_;
1828: my %general_content;
1829: if ($crsmsgid) {
1830: my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
1831: $env{'course.'.$env{'request.course.id'}.'.domain'},
1832: $env{'course.'.$env{'request.course.id'}.'.num'});
1833: %general_content = &Apache::lonmsg::unpackagemsg($course_content{$crsmsgid});
1834: }
1835: return $general_content{'message'};
1836: }
1837:
1838: # ---------------------------------------------------------------- Face to face
1839:
1840: sub facetoface {
1841: my ($r,$stage)=@_;
1.49 albertel 1842: if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'})
1843: && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
1.1 albertel 1844: '/'.$env{'request.course.sec'})) {
1.50 raeburn 1845: $r->print(&mt('Not allowed'));
1.1 albertel 1846: return;
1847: }
1.33 albertel 1848: my $crstype = &Apache::loncommon::course_type();
1849: my $leaders = ($crstype eq 'Group') ? 'coordinators and leaders'
1850: : 'faculty and staff';
1.1 albertel 1851: &printheader($r,
1852: '/adm/email?recordftf=query',
1.70 raeburn 1853: "User Notes, Face-to-Face, Critical Messages, Broadcast Messages, Archived Messages");
1.1 albertel 1854: # from query string
1855:
1856: if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
1857: if ($env{'form.recdom'}) { $env{'form.recdomain'}=$env{'form.recdom'}; }
1858:
1859: my $defdom=$env{'user.domain'};
1860: # already filled in
1861: if ($env{'form.recdomain'}) { $defdom=$env{'form.recdomain'}; }
1862: # generate output
1863: my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
1864: my $stdbrws = &Apache::loncommon::selectstudent_link
1865: ('stdselect','recuname','recdomain');
1866: my %lt=&Apache::lonlocal::texthash('user' => 'Username',
1867: 'dom' => 'Domain',
1.70 raeburn 1868: 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, Broadcast Messages and Archived Messages in $crstype",
1.1 albertel 1869: 'subm' => 'Retrieve discussion and message records',
1.30 raeburn 1870: 'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
1.1 albertel 1871: 'post' => 'Post this Record');
1872: $r->print(<<"ENDTREC");
1873: <h3>$lt{'head'}</h3>
1874: <form method="post" action="/adm/email" name="stdselect">
1875: <input type="hidden" name="recordftf" value="retrieve" />
1876: <table>
1877: <tr><td>$lt{'user'}:</td><td><input type="text" size="12" name="recuname" value="$env{'form.recuname'}" /></td>
1878: <td rowspan="2">
1879: $stdbrws
1880: <input type="submit" value="$lt{'subm'}" /></td>
1881: </tr>
1882: <tr><td>$lt{'dom'}:</td>
1883: <td>$domform</td></tr>
1884: </table>
1885: </form>
1886: ENDTREC
1887: if (($stage ne 'query') &&
1888: ($env{'form.recdomain'}) && ($env{'form.recuname'})) {
1889: chomp($env{'form.newrecord'});
1890: if ($env{'form.newrecord'}) {
1.31 albertel 1891: &Apache::lonmsg::store_instructor_comment($env{'form.newrecord'},
1892: $env{'form.recuname'},
1893: $env{'form.recdomain'});
1.1 albertel 1894: }
1895: $r->print('<h3>'.&Apache::loncommon::plainname($env{'form.recuname'},
1896: $env{'form.recdomain'}).'</h3>');
1897: &disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
1898: $r->print(<<ENDRHEAD);
1899: <form method="post" action="/adm/email">
1900: <input name="recdomain" value="$env{'form.recdomain'}" type="hidden" />
1901: <input name="recuname" value="$env{'form.recuname'}" type="hidden" />
1902: ENDRHEAD
1903: $r->print(<<ENDBFORM);
1904: <hr />$lt{'newr'}<br />
1905: <textarea name="newrecord" cols="80" rows="10" wrap="hard"></textarea>
1906: <br />
1907: <input type="hidden" name="recordftf" value="post" />
1908: <input type="submit" value="$lt{'post'}" />
1909: </form>
1910: ENDBFORM
1911: }
1912: }
1913:
1914: # ----------------------------------------------------------- Blocking during exams
1915:
1916: sub examblock {
1917: my ($r,$action) = @_;
1918: unless ($env{'request.course.id'}) { return;}
1.44 raeburn 1919: if (!&Apache::lonnet::allowed('dcm',$env{'request.course.id'})
1920: && ! &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
1.1 albertel 1921: '/'.$env{'request.course.sec'})) {
1922: $r->print('Not allowed');
1923: return;
1924: }
1.34 albertel 1925: my $usertype = (&Apache::loncommon::course_type() eq 'Group') ? 'members'
1.33 albertel 1926: : 'students';
1.1 albertel 1927: my %lt=&Apache::lonlocal::texthash(
1928: 'comb' => 'Communication Blocking',
1929: 'cbds' => 'Communication blocking during scheduled exams',
1.30 raeburn 1930: 'desc' => "You can use communication blocking to prevent $usertype enrolled in this course from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype 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.",
1.1 albertel 1931: 'mecb' => 'Modify existing communication blocking periods',
1.72 albertel 1932: 'ncbc' => 'No communication blocks currently saved',
1933: 'stor' => 'Save',
1.1 albertel 1934: );
1935:
1936: my %ltext = &Apache::lonlocal::texthash(
1937: 'dura' => 'Duration',
1938: 'setb' => 'Set by',
1939: 'even' => 'Event',
1.44 raeburn 1940: 'blck' => 'Blocked?',
1.1 albertel 1941: 'actn' => 'Action',
1942: 'star' => 'Start',
1943: 'endd' => 'End'
1944: );
1945:
1946: &printheader($r,'/adm/email?block=display',$lt{'comb'});
1947: $r->print('<h3>'.$lt{'cbds'}.'</h3>');
1948:
1949: if ($action eq 'store') {
1950: &blockstore($r);
1951: }
1952:
1953: $r->print($lt{'desc'}.'<br /><br />
1954: <form name="blockform" method="post" action="/adm/email?block=store">
1955: ');
1956:
1957: $r->print('<h4>'.$lt{'mecb'}.'</h4>');
1958: my %records = ();
1959: my $blockcount = 0;
1960: my $parmcount = 0;
1961: &get_blockdates(\%records,\$blockcount);
1962: if ($blockcount > 0) {
1963: $parmcount = &display_blocker_status($r,\%records,\%ltext);
1964: } else {
1965: $r->print($lt{'ncbc'}.'<br /><br />');
1966: }
1967: &display_addblocker_table($r,$parmcount,\%ltext);
1968: my $end_page=&Apache::loncommon::end_page();
1969: $r->print(<<"END");
1970: <br />
1971: <input type="hidden" name="blocktotal" value="$blockcount" />
1.50 raeburn 1972: <input type ="submit" value="$lt{'stor'}" />
1.1 albertel 1973: </form>
1974: $end_page
1975: END
1976: return;
1977: }
1978:
1979: sub blockstore {
1980: my $r = shift;
1981: my %lt=&Apache::lonlocal::texthash(
1982: 'tfcm' => 'The following changes were made',
1983: 'ncwm' => 'No changes were made.'
1984: );
1985: my %adds = ();
1986: my %removals = ();
1987: my %cancels = ();
1988: my $modtotal = 0;
1989: my $canceltotal = 0;
1990: my $addtotal = 0;
1991: my %blocking = ();
1992: $r->print('<h3>'.$lt{'head'}.'</h3>');
1.42 raeburn 1993: foreach my $envkey (keys(%env)) {
1.44 raeburn 1994: if ($envkey =~ m/^form\.modify_(\d+)$/) {
1.1 albertel 1995: $adds{$1} = $1;
1996: $removals{$1} = $1;
1997: $modtotal ++;
1.42 raeburn 1998: } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
1.1 albertel 1999: $cancels{$1} = $1;
2000: unless ( defined($removals{$1}) ) {
2001: $removals{$1} = $1;
2002: $canceltotal ++;
2003: }
1.42 raeburn 2004: } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
1.1 albertel 2005: $adds{$1} = $1;
2006: $addtotal ++;
1.44 raeburn 2007: }
1.1 albertel 2008: }
2009:
1.42 raeburn 2010: foreach my $key (keys(%removals)) {
2011: my $hashkey = $env{'form.key_'.$key};
1.1 albertel 2012: &Apache::lonnet::del('comm_block',["$hashkey"],
2013: $env{'course.'.$env{'request.course.id'}.'.domain'},
2014: $env{'course.'.$env{'request.course.id'}.'.num'}
2015: );
2016: }
1.42 raeburn 2017: foreach my $key (keys(%adds)) {
2018: unless ( defined($cancels{$key}) ) {
2019: my ($newstart,$newend) = &get_dates_from_form($key);
1.1 albertel 2020: my $newkey = $newstart.'____'.$newend;
1.44 raeburn 2021: my $blocktypes = &get_block_choices($key);
2022: $blocking{$newkey} = {
2023: setter => $env{'user.name'}.':'.$env{'user.domain'},
2024: event => &escape($env{'form.title_'.$key}),
2025: blocks => $blocktypes,
2026: };
1.1 albertel 2027: }
2028: }
2029: if ($addtotal + $modtotal > 0) {
2030: &Apache::lonnet::put('comm_block',\%blocking,
2031: $env{'course.'.$env{'request.course.id'}.'.domain'},
2032: $env{'course.'.$env{'request.course.id'}.'.num'}
2033: );
2034: }
2035: my $chgestotal = $canceltotal + $modtotal + $addtotal;
2036: if ($chgestotal > 0) {
2037: $r->print($lt{'tfcm'}.'<ul>');
2038: if ($canceltotal > 0) {
1.50 raeburn 2039: $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] removed.',$canceltotal).'</li>');
1.1 albertel 2040: }
2041: if ($modtotal > 0) {
1.50 raeburn 2042: $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] modified.',$modtotal).'</li>');
1.1 albertel 2043: }
2044: if ($addtotal > 0) {
1.50 raeburn 2045: $r->print('<li>'.&mt('[quant,_1,communication blocking period was,communication blocking periods were] added.',$addtotal).'</li>');
1.1 albertel 2046: }
2047: $r->print('</ul>');
2048: } else {
2049: $r->print($lt{'ncwm'});
2050: }
2051: $r->print('<br />');
2052: return;
2053: }
2054:
2055: sub get_dates_from_form {
2056: my $item = shift;
2057: my $startdate = &Apache::lonhtmlcommon::get_date_from_form('startdate_'.$item);
2058: my $enddate = &Apache::lonhtmlcommon::get_date_from_form('enddate_'.$item);
2059: return ($startdate,$enddate);
2060: }
2061:
2062: sub get_blockdates {
2063: my ($records,$blockcount) = @_;
2064: $$blockcount = 0;
2065: %{$records} = &Apache::lonnet::dump('comm_block',
2066: $env{'course.'.$env{'request.course.id'}.'.domain'},
2067: $env{'course.'.$env{'request.course.id'}.'.num'}
2068: );
1.15 albertel 2069: $$blockcount = keys(%{$records});
2070:
2071: if ((keys(%{$records}))[0] =~ /^error: 2 /) {
2072: $records = {};
2073: $$blockcount = 0;
1.1 albertel 2074: }
2075: }
2076:
1.44 raeburn 2077: sub get_block_choices {
2078: my $item = shift;
2079: my $blocklist;
2080: my ($typeorder,$types) = &blocktype_text();
2081: foreach my $type (@{$typeorder}) {
2082: if ($env{'form.'.$type.'_'.$item}) {
2083: $blocklist->{$type} = 'on';
2084: } else {
2085: $blocklist->{$type} = 'off';
2086: }
2087: }
2088: return $blocklist;
2089: }
2090:
1.1 albertel 2091: sub display_blocker_status {
2092: my ($r,$records,$ltext) = @_;
2093: my $parmcount = 0;
1.16 albertel 2094:
1.1 albertel 2095: my %lt = &Apache::lonlocal::texthash(
2096: 'modi' => 'Modify',
2097: 'canc' => 'Cancel',
2098: );
1.44 raeburn 2099: my ($typeorder,$types) = &blocktype_text();
1.18 albertel 2100: $r->print(&Apache::loncommon::start_data_table());
1.1 albertel 2101: $r->print(<<"END");
1.16 albertel 2102: <tr>
1.44 raeburn 2103: <th>$ltext->{'dura'}</th>
2104: <th>$ltext->{'setb'}</th>
2105: <th>$ltext->{'even'}</th>
2106: <th>$ltext->{'blck'}</th>
2107: <th>$ltext->{'actn'}?</th>
1.16 albertel 2108: </tr>
1.1 albertel 2109: END
1.18 albertel 2110: foreach my $record (sort(keys(%{$records}))) {
1.1 albertel 2111: my $onchange = 'onFocus="javascript:window.document.forms['.
2112: "'blockform'].elements['modify_".$parmcount."'].".
2113: 'checked=true;"';
1.18 albertel 2114: my ($start,$end) = split(/____/,$record);
1.1 albertel 2115: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
2116: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
1.15 albertel 2117:
1.44 raeburn 2118: my ($setuname,$setudom,$title,$blocks) =
2119: &Apache::loncommon::parse_block_record($$records{$record});
1.21 albertel 2120: $title = &HTML::Entities::encode($title,'"<>&');
1.44 raeburn 2121: my $settername =
2122: &Apache::loncommon::aboutmewrapper(
2123: &Apache::loncommon::plainname($setuname,$setudom),
2124: $setuname,$setudom);
1.18 albertel 2125: $r->print(&Apache::loncommon::start_data_table_row());
1.1 albertel 2126: $r->print(<<"END");
1.44 raeburn 2127: <td>$ltext->{'star'}: $startform<br/>$ltext->{'endd'}: $endform</td>
1.1 albertel 2128: <td>$settername</td>
1.18 albertel 2129: <td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td>
1.44 raeburn 2130: <td>
2131: END
2132: foreach my $block (@{$typeorder}) {
2133: my $blockstatus = '';
2134: if ($blocks->{$block} eq 'on') {
2135: $blockstatus = 'checked="true"';
2136: }
2137: $r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" '.$blockstatus.' value="1" />'.$types->{$block}.'</label><br />');
2138: }
2139: $r->print(<<"END");
2140: </td>
1.1 albertel 2141: <td><label>$lt{'modi'}? <input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}? <input type="checkbox" name="cancel_$parmcount" /></label>
2142: END
1.18 albertel 2143: $r->print(&Apache::loncommon::end_data_table_row());
2144: $parmcount++;
1.1 albertel 2145: }
2146: $r->print(<<"END");
2147: </table>
2148: <br />
2149: <br />
2150: END
2151: return $parmcount;
2152: }
2153:
2154: sub display_addblocker_table {
2155: my ($r,$parmcount,$ltext) = @_;
2156: my $start = time;
2157: my $end = $start + (60 * 60 * 2); #Default is an exam of 2 hours duration.
2158: my $onchange = 'onFocus="javascript:window.document.forms['.
2159: "'blockform'].elements['add_".$parmcount."'].".
2160: 'checked=true;"';
2161: my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
2162: my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
2163: my %lt = &Apache::lonlocal::texthash(
2164: 'addb' => 'Add block',
2165: 'exam' => 'e.g., Exam 1',
2166: 'addn' => 'Add new communication blocking periods'
2167: );
1.44 raeburn 2168: my ($typeorder,$types) = &blocktype_text();
1.1 albertel 2169: $r->print(<<"END");
2170: <h4>$lt{'addn'}</h4>
1.18 albertel 2171: END
2172: $r->print(&Apache::loncommon::start_data_table());
2173: $r->print(<<"END");
1.16 albertel 2174: <tr>
1.44 raeburn 2175: <th>$ltext->{'dura'}</th>
2176: <th>$ltext->{'even'} $lt{'exam'}</th>
2177: <th>$ltext->{'blck'}</th>
2178: <th>$ltext->{'actn'}?</th>
1.16 albertel 2179: </tr>
1.18 albertel 2180: END
1.44 raeburn 2181: $r->print(&Apache::loncommon::start_data_table_row());
1.18 albertel 2182: $r->print(<<"END");
1.44 raeburn 2183: <td>$ltext->{'star'}: $startform<br />$ltext->{'endd'}: $endform</td>
1.16 albertel 2184: <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
1.44 raeburn 2185: <td>
2186: END
2187: foreach my $block (@{$typeorder}) {
2188: $r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" value="1" />'.$types->{$block}.'</label><br />');
2189: }
2190: $r->print(<<"END");
2191: </td>
1.16 albertel 2192: <td><label>$lt{'addb'}? <input type="checkbox" name="add_$parmcount" value="1" /></label></td>
1.1 albertel 2193: END
1.18 albertel 2194: $r->print(&Apache::loncommon::end_data_table_row());
2195: $r->print(&Apache::loncommon::end_data_table());
1.1 albertel 2196: return;
2197: }
2198:
1.44 raeburn 2199: sub blocktype_text {
2200: my %types = &Apache::lonlocal::texthash(
2201: 'com' => 'Messaging',
2202: 'chat' => 'Chat',
2203: 'boards' => 'Discussion',
2204: 'port' => 'Portfolio',
1.45 raeburn 2205: 'groups' => 'Groups',
2206: 'blogs' => 'Blogs',
1.18 albertel 2207: );
1.45 raeburn 2208: my $typeorder = ['com','chat','boards','port','groups','blogs'];
1.44 raeburn 2209: return ($typeorder,\%types);
1.1 albertel 2210: }
2211:
2212: # ----------------------------------------------------------- Display a message
2213:
2214: sub displaymessage {
1.53 raeburn 2215: my ($r,$msgid,$folder,$msgstatus)=@_;
1.1 albertel 2216: my $suffix=&Apache::lonmsg::foldersuffix($folder);
2217: my %blocked = ();
2218: my %setters = ();
2219: my $numblocked = 0;
1.33 albertel 2220: my $crstype = &Apache::loncommon::course_type();
1.30 raeburn 2221:
1.1 albertel 2222: # info to generate "next" and "previous" buttons and check if message is blocked
1.44 raeburn 2223: my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
1.53 raeburn 2224: my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
1.1 albertel 2225: if ( $blocked{$msgid} eq 'ON' ) {
2226: &printheader($r,'/adm/email',&mt('Display a Message'));
2227: $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.'));
2228: &build_block_table($r,$startblock,$endblock,\%setters);
2229: return;
2230: }
1.59 raeburn 2231: if ($msgstatus eq '') {
2232: &statuschange($msgid,'read',$folder);
2233: }
1.1 albertel 2234: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
2235: my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
2236: my $counter=0;
1.29 www 2237: my $escmsgid=&escape($msgid);
1.1 albertel 2238: foreach (@messages) {
2239: if ($_->[5] eq $escmsgid){
2240: last;
2241: }
2242: $counter++;
2243: }
1.82 albertel 2244:
2245: my $see_anonymous;
2246: my $from_student = 0;
2247: if ($env{'request.course.id'} eq $content{'courseid'}) {
2248: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2249: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2250: my $username = $content{'sendername'}.':'.$content{'senderdomain'};
2251: my %classlist_entry =
2252: &Apache::lonnet::get('classlist',[$username],$cdom,$cnum);
2253: if (exists($classlist_entry{$username})) {
2254: $from_student = 1;
2255: $see_anonymous = &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
2256: }
2257: }
2258:
2259:
1.1 albertel 2260: my $number_of_messages = scalar(@messages); #subtract 1 for last index
2261: # start output
1.29 www 2262: &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
1.1 albertel 2263: my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
2264: # Functions
1.78 raeburn 2265: $r->print('<table border="2" width="100%"><tr bgcolor="#FFFFAA"><td>'.&mt('Functions').':</td>');
2266: if (!$content{'noreplies'}) {
2267: $r->print('<td><a href="/adm/email?replyto='.&escape($msgid).$sqs.
2268: '"><b>'.&mt('Reply').'</b></a></td>');
2269: }
2270: $r->print('<td><a href="/adm/email?forward='.&escape($msgid).$sqs.
1.1 albertel 2271: '"><b>'.&mt('Forward').'</b></a></td>'.
1.29 www 2272: '<td><a href="/adm/email?markunread='.&escape($msgid).$sqs.
1.1 albertel 2273: '"><b>'.&mt('Mark Unread').'</b></a></td>'.
1.29 www 2274: '<td><a href="/adm/email?markdel='.&escape($msgid).$sqs.
1.1 albertel 2275: '"><b>'.&mt('Delete').'</b></a></td>'.
2276: '<td><a href="/adm/email?'.$sqs.
2277: '"><b>'.&mt('Back to Folder Display').'</b></a></td>');
2278: if ($counter > 0){
2279: $r->print('<td><a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.
2280: '"><b>'.&mt('Previous').'</b></a></td>');
2281: }
2282: if ($counter < $number_of_messages - 1){
2283: $r->print('<td><a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.
2284: '"><b>'.&mt('Next').'</b></a></td>');
2285: }
2286: $r->print('</tr></table>');
1.59 raeburn 2287: my $symb;
2288: if (defined($content{'symb'})) {
2289: $symb = $content{'symb'};
2290: } elsif (defined($content{'baseurl'})) {
2291: $symb=&Apache::lonnet::symbread($content{'baseurl'});
2292: }
1.1 albertel 2293: if ($env{'user.adv'}) {
1.90 bisitz 2294: my $actionlist='';
1.1 albertel 2295: if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
1.90 bisitz 2296: $actionlist.='<td><b>'
2297: .&Apache::loncommon::track_student_link(
2298: &mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check')
2299: .'</b></td>';
2300: }
1.1 albertel 2301: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) {
1.90 bisitz 2302: $actionlist.='<td><b>'
2303: .&Apache::loncommon::pprmlink(
2304: &mt('Set/Change parameters'),$content{'sendername'},$content{'senderdomain'},$symb,'check')
2305: .'</b></td>';
1.1 albertel 2306: }
2307: if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) {
1.90 bisitz 2308: $actionlist.='<td><b>'
2309: .&Apache::loncommon::pgrdlink(
2310: &mt('Set/Change grades'),$content{'sendername'},$content{'senderdomain'},$symb,'check')
2311: .'</b></td>';
2312: }
2313: if ($actionlist) {
2314: $r->print('<table border="2" width="100%">'
2315: .'<tr bgcolor="#FFAAAA"><td>'
2316: .&mt('Currently available actions (will open extra window):')
2317: .'</td>'
2318: .$actionlist
2319: .'</tr></table>');
2320: }
1.1 albertel 2321: }
1.95 ! raeburn 2322: my ($tonum,$tolist,$cclist,$bcclist,$groupcclist,%recipients);
! 2323: if ($content{'recipid'}) {
! 2324: $tonum = &retrieve_recips('display',\%content,\%recipients);
! 2325: if (ref($recipients{'cc'}) eq 'ARRAY') {
! 2326: $cclist = join(', ',@{$recipients{'cc'}});
! 2327: }
! 2328: if (ref($recipients{'to'}) eq 'ARRAY') {
! 2329: $tolist = join(', ',@{$recipients{'to'}});
! 2330: }
! 2331: if (ref($recipients{'bcc'}) eq 'ARRAY') {
! 2332: $bcclist = join(', ',@{$recipients{'bcc'}});
! 2333: }
! 2334: }
! 2335: if (!$tolist && ref($content{'recuser'}) eq 'ARRAY') {
! 2336: my @recipients;
1.73 raeburn 2337: for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
2338: $recipients[$i] = &Apache::loncommon::aboutmewrapper(
2339: &Apache::loncommon::plainname($content{'recuser'}[$i],
1.1 albertel 2340: $content{'recdomain'}[$i]),
1.73 raeburn 2341: $content{'recuser'}[$i],$content{'recdomain'}[$i]).
1.95 ! raeburn 2342: ' ('.$content{'recuser'}[$i].':'.$content{'recdomain'}[$i].') ';
1.73 raeburn 2343: }
1.95 ! raeburn 2344: $tolist = join(', ',@recipients);
1.73 raeburn 2345: }
1.59 raeburn 2346: my ($restitle,$baseurl,$refers_to);
2347: if (defined($content{'resource_title'})) {
2348: $restitle = $content{'resource_title'};
2349: } else {
2350: if (defined($content{'baseurl'})) {
2351: $restitle = &Apache::lonnet::gettitle($content{'baseurl'});
2352: }
2353: }
2354: if (defined($content{'baseurl'})) {
2355: $baseurl = &Apache::lonenc::check_encrypt($content{'baseurl'});
2356: }
1.82 albertel 2357: if ($from_student && $see_anonymous ) {
2358: $r->print(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}));
2359: }
2360:
1.95 ! raeburn 2361: my $broadcast_link;
! 2362: if (($content{'courseid'}) && ($content{'recipid'} &&
! 2363: (ref($recipients{'course_broadcast'}) eq 'ARRAY') ||
! 2364: (ref($recipients{'group_cc_broadcast'}) eq 'ARRAY') ||
! 2365: (ref($recipients{'group_bcc_broadcast'}) eq 'ARRAY'))) {
! 2366: $broadcast_link = &recipients_link($r,\%content,\%recipients);
! 2367: }
! 2368:
1.91 bisitz 2369: # Display LON-CAPA Message (Start)
2370: # Subject
2371: $r->print('<br />'
2372: .&Apache::lonhtmlcommon::start_pick_box()
2373: .&Apache::lonhtmlcommon::row_title(&mt('Subject'))
2374: .$content{'subject'}
2375: .&Apache::lonhtmlcommon::row_closure()
2376: );
1.73 raeburn 2377: if ($folder eq 'sent') {
1.91 bisitz 2378: # To
2379: $r->print(&Apache::lonhtmlcommon::row_title(&mt('To'))
2380: .$tolist
2381: .&Apache::lonhtmlcommon::row_closure()
2382: );
1.95 ! raeburn 2383: if ($cclist) {
! 2384: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
! 2385: .$cclist
! 2386: .&Apache::lonhtmlcommon::row_closure()
! 2387: );
! 2388: }
! 2389: if ($bcclist) {
! 2390: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Bcc'))
! 2391: .$bcclist
! 2392: .&Apache::lonhtmlcommon::row_closure()
! 2393: );
! 2394: }
! 2395: if (($content{'courseid'}) && ($content{'recipid'})) {
! 2396: my %broadcast_types =
! 2397: &Apache::lonlocal::texthash (
! 2398: course_broadcast => 'Broadcast to',
! 2399: group_cc_broadcast => 'Cc to group',
! 2400: group_bcc_broadcast => 'Bcc to group',
! 2401: );
! 2402: foreach my $type (sort(keys(%broadcast_types))) {
! 2403: if (ref($recipients{$type}) eq 'ARRAY') {
! 2404: my $num = @{$recipients{$type}};
! 2405: my $broadcastlist = join(', ',@{$recipients{$type}});
! 2406: if ($broadcastlist && $broadcast_link) {
! 2407: if ($type eq 'group_cc_broadcast') {
! 2408: $groupcclist = $broadcastlist;
! 2409: }
! 2410: $r->print(&Apache::lonhtmlcommon::row_title(
! 2411: $broadcast_types{$type})
! 2412: .&mt('[quant,_1,recipient]',$num)
! 2413: .' <a href="javascript:showBroadcastList();">['
! 2414: .&mt('Show').']</a>'
! 2415: .&Apache::lonhtmlcommon::row_closure());
! 2416: }
! 2417: }
! 2418: }
! 2419: }
1.78 raeburn 2420: if ($content{'replytoaddr'}) {
2421: my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
2422: if ($replytoname ne '' && $replytodom ne '') {
1.91 bisitz 2423: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
1.95 ! raeburn 2424: .$replytoname.':'.$replytodom
1.91 bisitz 2425: .&Apache::lonhtmlcommon::row_closure()
2426: );
1.78 raeburn 2427: }
2428: }
1.73 raeburn 2429: } else {
1.91 bisitz 2430: # From, Reply
2431: $r->print(&Apache::lonhtmlcommon::row_title(&mt('From'))
2432: .&Apache::loncommon::aboutmewrapper(
2433: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
2434: $content{'sendername'},$content{'senderdomain'})
2435: );
1.78 raeburn 2436: if ($content{'noreplies'}) {
1.91 bisitz 2437: $r->print(' ('.&mt('No replies to sender').')'
2438: .&Apache::lonhtmlcommon::row_closure()
1.95 ! raeburn 2439: );
1.78 raeburn 2440: } else {
2441: if ($content{'replytoaddr'}) {
2442: my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
2443: if ($replytoname ne '' && $replytodom ne '') {
1.91 bisitz 2444: $r->print(&Apache::lonhtmlcommon::row_closure()
2445: .&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
1.95 ! raeburn 2446: .$replytoname.':'.$replytodom
1.91 bisitz 2447: .&Apache::lonhtmlcommon::row_closure()
2448: );
2449: } else {
2450: $r->print(&Apache::lonhtmlcommon::row_closure());
1.78 raeburn 2451: }
2452: } else {
1.95 ! raeburn 2453: $r->print(' ('.$content{'sendername'}.':'.$content{'senderdomain'}.') '
1.91 bisitz 2454: .&Apache::lonhtmlcommon::row_closure()
2455: );
1.78 raeburn 2456: }
1.95 ! raeburn 2457: if ($tonum && $tolist) {
! 2458: $r->print(&Apache::lonhtmlcommon::row_title(&mt('To'))
! 2459: .$tolist
! 2460: .&Apache::lonhtmlcommon::row_closure()
! 2461: );
! 2462: }
! 2463: if ($cclist) {
1.91 bisitz 2464: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
2465: .$cclist
2466: .&Apache::lonhtmlcommon::row_closure()
2467: );
1.95 ! raeburn 2468: }
! 2469: if ($content{'group'} ne '') {
! 2470: if (&check_group_priv($content{'group'})) {
! 2471: $groupcclist = join(', ',@{$recipients{'group_cc_broadcast'}});
! 2472: if ($groupcclist) {
! 2473: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Group Cc'))
! 2474: .$groupcclist
! 2475: .&Apache::lonhtmlcommon::row_closure()
! 2476: );
! 2477: }
! 2478: }
1.78 raeburn 2479: }
1.91 bisitz 2480: }
1.73 raeburn 2481: }
1.91 bisitz 2482:
2483: # Course
1.73 raeburn 2484: if ($content{'courseid'}) {
1.91 bisitz 2485: $r->print(&Apache::lonhtmlcommon::row_title(&mt($crstype))
2486: .$courseinfo{'description'}
2487: );
1.73 raeburn 2488: if ($content{'coursesec'}) {
2489: $r->print(' ('.&mt('Section').': '.$content{'coursesec'}.')');
2490: }
1.91 bisitz 2491: $r->print(&Apache::lonhtmlcommon::row_closure());
1.73 raeburn 2492: }
1.91 bisitz 2493: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Time'))
2494: .$content{'time'}
2495: .&Apache::lonhtmlcommon::row_closure()
2496: );
2497:
2498: # Refers to
1.59 raeburn 2499: if ($baseurl) {
2500: if (defined($content{'courseid'}) && defined($env{'request.course.id'})) {
2501: if ($content{'courseid'} eq $env{'request.course.id'}) {
2502: my $symblink;
1.62 raeburn 2503: my $showsymb = &Apache::lonenc::check_decrypt($symb);
2504: my $showurl = &Apache::lonenc::check_decrypt($baseurl);
2505: my $encrypturl = &Apache::lonnet::EXT('resource.0.encrypturl',
2506: $showsymb,$env{'user.domain'},$env{'user.name'});
1.59 raeburn 2507: if ($symb) {
1.62 raeburn 2508: if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
2509: $showsymb = &Apache::lonenc::check_encrypt($symb);
2510: }
2511: $symblink = '?symb='.$showsymb;
2512: }
2513: if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
2514: $showurl = $baseurl;
1.59 raeburn 2515: }
1.91 bisitz 2516: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2517: .'<a href="'.$showurl.$symblink.'">'.$restitle.'</a>'
2518: .&Apache::lonhtmlcommon::row_closure()
2519: );
1.59 raeburn 2520: $refers_to = 1;
2521: }
2522: }
2523: if (!$refers_to) {
2524: if ($baseurl =~ m-^/enc/-) {
2525: if (defined($content{'courseid'})) {
1.62 raeburn 2526: if (!$env{'request.course.id'}) {
2527: my $unencurl =
2528: &Apache::lonenc::unencrypted($baseurl,
2529: $content{'courseid'});
2530: if ($unencurl ne '') {
2531: if (&Apache::lonnet::allowed('bre',$unencurl)) {
1.91 bisitz 2532: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2533: .'<a href="'.$unencurl.'">'.$restitle.'</a>'
2534: .&Apache::lonhtmlcommon::row_closure()
2535: );
1.62 raeburn 2536: }
1.59 raeburn 2537: }
2538: }
2539: }
2540: } else {
2541: if (&Apache::lonnet::allowed('bre',$baseurl)) {
1.91 bisitz 2542: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2543: .'<a href="'.$baseurl.'">'.$restitle.'</a>'
2544: .&Apache::lonhtmlcommon::row_closure()
2545: );
2546:
1.59 raeburn 2547: }
2548: }
2549: }
2550: }
1.91 bisitz 2551:
2552: # Message
2553: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message'))
2554: .'<pre>'
2555: .&Apache::lontexconvert::msgtexconverted($content{'message'},1)
2556: .'</pre>'
2557: );
2558: if (&displayresource(%content)) {
2559: $r->print(&Apache::lonhtmlcommon::row_closure()
2560: .&Apache::lonhtmlcommon::row_title(&mt('Resource Details'))
2561: .&displayresource(%content)
2562: );
2563: }
1.92 raeburn 2564: $r->print(&Apache::lonhtmlcommon::row_closure(1).
2565: &Apache::lonhtmlcommon::end_pick_box());
1.91 bisitz 2566: # Display LON-CAPA Message (End)
1.59 raeburn 2567: return;
1.1 albertel 2568: }
2569:
1.95 ! raeburn 2570: sub retrieve_recips {
! 2571: my ($context,$content,$recips)= @_;
! 2572: my $tonum = 0;
! 2573: if (ref($content) eq 'HASH') {
! 2574: my %reciphash =
! 2575: &Apache::lonnet::get('nohist_emailrecip',[$content->{'recipid'}],
! 2576: $content->{'senderdomain'},$content->{'sendername'});
! 2577: my $recipinfo = $reciphash{$content->{'recipid'}};
! 2578: if (ref($recipinfo) eq 'HASH') {
! 2579: foreach my $type ('to','cc','course_broadcast','group_cc_broadcast','group_bcc_broadcast') {
! 2580: if (ref($recipinfo->{$type}) eq 'HASH') {
! 2581: if ($type eq 'to') {
! 2582: $tonum = keys(%{$recipinfo->{$type}});
! 2583: }
! 2584: foreach my $user (sort(keys(%{$recipinfo->{$type}}))) {
! 2585: my ($uname,$udom) = split(/:/,$user);
! 2586: next if (($context eq 'replying') && ($uname eq $env{'user.name'})
! 2587: && ($udom eq $env{'user.domain'}));
! 2588: my $showuser ='<span class="LC_nobreak">';
! 2589: if ($context eq 'replying') {
! 2590: if (($type eq 'to') || ($type eq 'cc')) {
! 2591: $showuser = '<label><input type="checkbox" name="replying_'.$type.'" value="'.$user.'" />';
! 2592: } elsif ($type eq 'group_cc_broadcast') {
! 2593: $showuser = '<label><input type="checkbox" name="replying_groupcc" value="'.$user.'" />';
! 2594: }
! 2595: }
! 2596: $showuser .= &Apache::loncommon::aboutmewrapper(
! 2597: &Apache::loncommon::plainname($uname,
! 2598: $udom),$uname,$udom);
! 2599: if ($context eq 'replying') {
! 2600: $showuser .='</label>';
! 2601: }
! 2602: $showuser .= '</span>';
! 2603: if (ref($recips) eq 'HASH') {
! 2604: push(@{$recips->{$type}},$showuser);
! 2605: }
! 2606: }
1.73 raeburn 2607: }
2608: }
2609: }
2610: }
1.95 ! raeburn 2611: return $tonum;
! 2612: }
! 2613:
! 2614: sub recipients_link {
! 2615: my ($r,$content,$recipients) = @_;
! 2616: my ($broadcast_link,$show);
! 2617: if ((ref($content) eq 'HASH') && (ref($recipients) eq 'HASH')) {
! 2618: if (ref($recipients->{'course_broadcast'}) eq 'ARRAY') {
! 2619: if (@{$recipients->{'course_broadcast'}} > 0) {
! 2620: $show = 'course';
! 2621: }
! 2622: } elsif (ref($recipients->{'group_cc_broadcast'}) eq 'ARRAY') {
! 2623: if (@{$recipients->{'group_cc_broadcast'}} > 0) {
! 2624: $show = 'group_cc';
! 2625: }
! 2626: } elsif (ref($recipients->{'group_bcc_broadcast'}) eq 'ARRAY') {
! 2627: if (@{$recipients->{'group_bcc_broadcast'}} > 0) {
! 2628: $show = 'group_bcc';
! 2629: }
! 2630: }
! 2631: if ($show) {
! 2632: my ($nothing,$height,$width,$start_page,$end_page,$body);
! 2633: $nothing=&Apache::lonhtmlcommon::javascript_nothing();
! 2634: $height = 400;
! 2635: $width = 600;
! 2636: my $start_page =
! 2637: &Apache::loncommon::start_page('Broadcast List', undef,
! 2638: {only_body => 1,
! 2639: js_ready => 1,});
! 2640: my $end_page = &Apache::loncommon::end_page({js_ready => 1,});
! 2641: my $body = '<h3>'.&mt("Recipients of broadcast message").'</h3>'.
! 2642: &Apache::loncommon::start_data_table();
! 2643: my $cell = 0;
! 2644: $body .= &Apache::loncommon::start_data_table_row();
! 2645: foreach my $item (@{$recipients->{$show.'_broadcast'}}) {
! 2646: $item =~ s/'/\\'/g;
! 2647: if (!($cell%2) && $cell > 0) {
! 2648: $body .= &Apache::loncommon::end_data_table_row().
! 2649: &Apache::loncommon::start_data_table_row();
! 2650: }
! 2651: $cell ++;
! 2652: $body .= '<td>'.$cell.' '.$item.' </td>';
! 2653: }
! 2654: if ($cell%2) {
! 2655: $body .= '<td> </td>';
! 2656: }
! 2657: $body .= &Apache::loncommon::end_data_table_row().
! 2658: &Apache::loncommon::end_data_table();
! 2659: $body =~ s{</}{<\\/}g;
! 2660: $body =~ s{\n}{}g;
! 2661: $r->print(<<ENDJS);
! 2662: <script type="text/javascript">
! 2663: function showBroadcastList() {
! 2664: var caller = this;
! 2665: var newWindow = null;
! 2666: try {
! 2667: newWindow = window.open($nothing,"broadcast","HEIGHT=$height,WIDTH=$width,resizable=yes,scrollbars=yes" );
! 2668: }
! 2669: catch(error) {
! 2670: writeWin(caller);
! 2671: return;
! 2672: }
! 2673: if (newWindow) {
! 2674: caller = newWindow;
! 2675: }
! 2676: writeWin(caller);
! 2677: return;
! 2678: }
! 2679:
! 2680: function writeWin(caller) {
! 2681: caller.document.writeln('$start_page $body $end_page');
! 2682: caller.document.close();
! 2683: caller.focus();
! 2684: }
! 2685:
! 2686: </script>
! 2687:
! 2688: ENDJS
! 2689: $broadcast_link = 1;
! 2690: }
! 2691: }
! 2692: return $broadcast_link;
1.73 raeburn 2693: }
2694:
1.1 albertel 2695: # =========================================================== Show the citation
2696:
2697: sub displayresource {
2698: my %content=@_;
2699: #
2700: # If the recipient is in the same course that the message was sent from and
2701: # has sufficient privileges, show "all details," else show citation
2702: #
2703: if (($env{'request.course.id'} eq $content{'courseid'})
2704: && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
1.59 raeburn 2705: my $symb;
2706: if (defined($content{'symb'})) {
2707: $symb = $content{'symb'};
2708: } else {
2709: $symb=&Apache::lonnet::symbread($content{'baseurl'});
2710: }
1.1 albertel 2711: # Could not get a symb, give up
2712: unless ($symb) { return $content{'citation'}; }
2713: # Have a symb, can render
2714: return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'.
2715: &Apache::loncommon::get_previous_attempt($symb,
2716: $content{'sendername'},
2717: $content{'senderdomain'},
2718: $content{'courseid'}).
2719: '<hr /><h2>'.&mt('Current screen output (if applicable)').'</h2>'.
2720: &Apache::loncommon::get_student_view($symb,
2721: $content{'sendername'},
2722: $content{'senderdomain'},
2723: $content{'courseid'}).
2724: '<h2>'.&mt('Correct Answer(s) (if applicable)').'</h2>'.
2725: &Apache::loncommon::get_student_answers($symb,
2726: $content{'sendername'},
2727: $content{'senderdomain'},
2728: $content{'courseid'});
2729: } elsif ($env{'user.adv'}) {
2730: return $content{'citation'};
2731: }
2732: return '';
2733: }
2734:
2735: # ================================================================== The Header
2736:
2737: sub header {
2738: my ($r,$title,$baseurl)=@_;
2739:
2740: my $extra = &Apache::loncommon::studentbrowser_javascript();
2741: if ($baseurl) {
1.41 albertel 2742: $extra .= "<base href=\"".&Apache::lonnet::absolute_url()."/$baseurl\" />";
1.1 albertel 2743: }
2744: $r->print(&Apache::loncommon::start_page('Communication and Messages',
1.38 raeburn 2745: $extra));
1.1 albertel 2746: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.38 raeburn 2747: (($title?$title:'Communication and Messages')));
1.1 albertel 2748: }
2749:
2750: # ---------------------------------------------------------------- Print header
2751:
2752: sub printheader {
2753: my ($r,$url,$desc,$title,$baseurl)=@_;
2754: &Apache::lonhtmlcommon::add_breadcrumb
2755: ({href=>$url,
2756: text=>$desc});
2757: &header($r,$title,$baseurl);
2758: }
2759:
2760: # ------------------------------------------------------------ Store the comment
2761:
2762: sub storecomment {
2763: my ($r)=@_;
2764: my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
2765: my $cleanmsgtxt='';
1.42 raeburn 2766: foreach my $line (split(/[\n\r]/,$msgtxt)) {
2767: unless ($line=~/^\s*(\>|\>\;)/) {
2768: $cleanmsgtxt.=$line."\n";
1.1 albertel 2769: }
2770: }
1.29 www 2771: my $key=&escape($env{'form.baseurl'}).'___'.time;
1.1 albertel 2772: &Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
2773: }
2774:
2775: sub storedcommentlisting {
2776: my ($r)=@_;
2777: my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
1.29 www 2778: '^'.&escape(&escape($env{'form.showcommentbaseurl'})));
1.72 albertel 2779: $r->print(&Apache::loncommon::start_page('Saved Comment Listing',undef,
1.1 albertel 2780: {'onlybody' => 1}));
2781: if ((keys %msgs)[0]=~/^error\:/) {
1.72 albertel 2782: $r->print(&mt('No saved comments yet.'));
1.1 albertel 2783: } else {
2784: my $found=0;
1.42 raeburn 2785: foreach my $key (sort(keys(%msgs))) {
2786: $r->print("\n".$msgs{$key}."<hr />");
1.1 albertel 2787: $found=1;
2788: }
2789: unless ($found) {
1.72 albertel 2790: $r->print(&mt('No saved comments yet for this resource.'));
1.1 albertel 2791: }
2792: }
2793: }
2794:
2795: # ---------------------------------------------------------------- Send an email
2796:
2797: sub sendoffmail {
2798: my ($r,$folder)=@_;
2799: my $suffix=&Apache::lonmsg::foldersuffix($folder);
2800: my $sendstatus='';
1.71 raeburn 2801: my %msg_status;
2802: my $numsent = 0;
2803: my $nosentstore = 1;
1.86 raeburn 2804: my $attachmenturl;
2805: my $now = time;
1.38 raeburn 2806: my ($cdom,$cnum,$group);
2807: if (exists($env{'form.group'})) {
2808: $group = $env{'form.group'};
2809: }
2810: if (exists($env{'request.course.id'})) {
2811: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2812: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2813: }
1.1 albertel 2814: if ($env{'form.send'}) {
1.53 raeburn 2815: if (!$env{'form.multiforward'}) {
2816: if ($group eq '') {
2817: &printheader($r,'','Messages being sent.');
2818: } else {
2819: $r->print(&groupmail_header('sending',$group));
2820: }
1.38 raeburn 2821: }
1.1 albertel 2822: $r->rflush();
2823: my %content=();
2824: undef %content;
2825: if ($env{'form.forwid'}) {
2826: my $msgid=$env{'form.forwid'};
2827: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1.86 raeburn 2828: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1);
1.1 albertel 2829: &statuschange($msgid,'forwarded',$folder);
1.86 raeburn 2830: if ($content{'attachmenturl'} ne '') {
2831: $attachmenturl = $content{'attachmenturl'};
2832: }
2833: $env{'form.message'} .= "\n\n-- Forwarded message --\n\n".
2834: $content{'message'};
1.1 albertel 2835: }
2836: if ($env{'form.replyid'}) {
2837: my $msgid=$env{'form.replyid'};
2838: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
2839: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
2840: &statuschange($msgid,'replied',$folder);
2841: }
1.13 albertel 2842:
1.25 foxr 2843: my $mode = $env{'form.sendmode'};
1.95 ! raeburn 2844: my (%toaddr,$tos,$cc,$bcc,$broadcast);
1.25 foxr 2845:
1.95 ! raeburn 2846: if ($mode eq 'group') {
! 2847: if (defined($env{'form.courserecips'})) {
! 2848: my $courseusers = $env{'form.courserecips'};
! 2849: $courseusers =~ s/^_\&\&\&_//;
! 2850: my @to = split('_&&&_',$courseusers);
! 2851: foreach my $dest (@to) {
! 2852: my ($user,$domain) = split(/:/, $dest);
! 2853: if (($user ne '') && ($domain ne '')) {
! 2854: my $rec = $user.":".$domain;
! 2855: $toaddr{$rec} = '';
! 2856: $broadcast->{$rec} = '';
! 2857: }
! 2858: }
! 2859: }
! 2860: } elsif ($mode eq 'upload') {
1.71 raeburn 2861: $nosentstore = 0;
1.13 albertel 2862: foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
1.43 raeburn 2863: my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
1.1 albertel 2864: if ($txt) {
1.43 raeburn 2865: $rec =~ s/^\s+//;
1.44 raeburn 2866: $rec =~ s/\s+$//;
1.1 albertel 2867: $toaddr{$rec}.=$txt."\n";
1.95 ! raeburn 2868: $broadcast->{$rec} = '';
1.1 albertel 2869: }
2870: }
2871: } else {
1.25 foxr 2872: if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {
2873: $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
1.95 ! raeburn 2874: $tos->{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
1.25 foxr 2875: }
1.1 albertel 2876: }
1.95 ! raeburn 2877: if ($env{'form.additionalrec_to'}) {
! 2878: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_to'})) {
! 2879: my ($auname,$audom)=split(/:/,$rec);
! 2880: if (($auname ne "") && ($audom ne "")) {
! 2881: $toaddr{$auname.':'.$audom}='';
! 2882: $tos->{$auname.':'.$audom}='';
! 2883: }
! 2884: }
! 2885: }
! 2886: if ($env{'form.replying_to'}) {
! 2887: my @toreplies =
! 2888: &Apache::loncommon::get_env_multiple('form.replying_to');
! 2889: foreach my $rec (@toreplies) {
! 2890: my ($auname,$audom)=split(/:/,$rec);
! 2891: if (($auname ne "") && ($audom ne "")) {
! 2892: $toaddr{$auname.':'.$audom}='';
! 2893: $tos->{$auname.':'.$audom}='';
! 2894: }
! 2895: }
! 2896: }
1.73 raeburn 2897: if ($env{'form.additionalrec_cc'}) {
2898: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_cc'})) {
1.43 raeburn 2899: my ($auname,$audom)=split(/:/,$rec);
1.25 foxr 2900: if (($auname ne "") && ($audom ne "")) {
1.73 raeburn 2901: $toaddr{$auname.':'.$audom}='';
1.95 ! raeburn 2902: if (!defined($tos->{$auname.':'.$audom})) {
! 2903: $cc->{$auname.':'.$audom}='';
! 2904: }
1.25 foxr 2905: }
1.1 albertel 2906: }
2907: }
1.95 ! raeburn 2908: if ($env{'form.replying_cc'}) {
! 2909: my @ccreplies =
! 2910: &Apache::loncommon::get_env_multiple('form.replying_cc');
! 2911: foreach my $rec (@ccreplies) {
! 2912: my ($auname,$audom)=split(/:/,$rec);
! 2913: if (($auname ne "") && ($audom ne "")) {
! 2914: $toaddr{$auname.':'.$audom}='';
! 2915: if (!defined($tos->{$auname.':'.$audom})) {
! 2916: $cc->{$auname.':'.$audom}='';
! 2917: }
! 2918: }
! 2919: }
! 2920: }
! 2921: if ($env{'form.replying_groupcc'}) {
! 2922: my @groupreplies =
! 2923: &Apache::loncommon::get_env_multiple('form.replying_groupcc');
! 2924: foreach my $rec (@groupreplies) {
1.73 raeburn 2925: my ($auname,$audom)=split(/:/,$rec);
2926: if (($auname ne "") && ($audom ne "")) {
2927: $toaddr{$auname.':'.$audom}='';
1.95 ! raeburn 2928: if (!defined($tos->{$auname.':'.$audom})) {
! 2929: $broadcast->{$auname.':'.$audom}='';
! 2930: }
1.73 raeburn 2931: }
2932: }
2933: }
1.95 ! raeburn 2934: if ($env{'form.additionalrec_bcc'}) {
! 2935: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_bcc'})) {
1.73 raeburn 2936: my ($auname,$audom)=split(/:/,$rec);
2937: if (($auname ne "") && ($audom ne "")) {
2938: $toaddr{$auname.':'.$audom}='';
1.95 ! raeburn 2939: if ((!defined($tos->{$auname.':'.$audom})) &&
! 2940: (!defined($cc->{$auname.':'.$audom}))) {
! 2941: $bcc->{$auname.':'.$audom}='';
! 2942: }
1.73 raeburn 2943: }
2944: }
2945: }
1.1 albertel 2946: my $savemsg;
2947: my $msgtype;
2948: my %sentmessage;
1.7 albertel 2949: my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'},
2950: undef,1);
1.1 albertel 2951: if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
2952: (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
2953: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
2954: '/'.$env{'request.course.sec'})
2955: )) {
2956: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1);
2957: $msgtype = 'critical';
2958: } else {
2959: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
2960: }
1.73 raeburn 2961: my %reciphash = (
1.95 ! raeburn 2962: to => $tos,
1.73 raeburn 2963: cc => $cc,
2964: bcc => $bcc,
1.95 ! raeburn 2965: );
! 2966: if ($mode eq 'group') {
! 2967: if ($group eq '') {
! 2968: $reciphash{'course_broadcast'} = $broadcast;
! 2969: } else {
! 2970: if ($env{'form.groupmail'} eq 'cc') {
! 2971: $reciphash{'group_cc_broadcast'} = $broadcast;
! 2972: } else {
! 2973: $reciphash{'group_bcc_broadcast'} = $broadcast;
! 2974: }
! 2975: }
! 2976: }
1.73 raeburn 2977: my ($recipid,$recipstatus) =
2978: &Apache::lonmsg::store_recipients($msgsubj,$env{'user.name'},
2979: $env{'user.domain'},\%reciphash);
2980: if ($recipstatus ne 'ok') {
1.95 ! raeburn 2981: &Apache::lonnet::logthis('Failed to store To, Bcc and Cc recipients for '.$env{'user.name'}.':'.$env{'user.domain'});
1.86 raeburn 2982: }
2983: if ($env{'form.attachment'}) {
2984: if (length($env{'form.attachment'})<131072) {
2985: $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback/'.$now);
2986: } else {
2987: $r->print('<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>');
2988: }
2989: } elsif ($env{'form.multiforward'}) {
2990: if ($env{'form.attachmenturl'} ne '') {
2991: $attachmenturl = $env{'form.attachmenturl'};
2992: }
2993: }
1.71 raeburn 2994: my @recusers;
2995: my @recudoms;
1.13 albertel 2996: foreach my $address (sort(keys(%toaddr))) {
2997: my ($recuname,$recdomain)=split(/\:/,$address);
1.1 albertel 2998: my $msgtxt = $savemsg;
1.73 raeburn 2999: if ($toaddr{$address}) {
3000: $msgtxt.='<hr />'.$toaddr{$address};
3001: }
1.12 albertel 3002: my @thismsg;
1.60 raeburn 3003: if ($msgtype eq 'critical') {
3004: $r->print(&mt('Sending critical message').' '.
3005: $recuname.':'.$recdomain.': ');
1.13 albertel 3006: @thismsg=
3007: &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
3008: $msgsubj,$msgtxt,
3009: $env{'form.sendbck'},
3010: $env{'form.permanent'},
1.71 raeburn 3011: \$sentmessage{$address},
1.73 raeburn 3012: $nosentstore,$recipid);
1.1 albertel 3013: } else {
1.14 albertel 3014: $r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': ');
1.13 albertel 3015: @thismsg=
3016: &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
3017: $msgsubj,$msgtxt,
3018: $content{'citation'},
1.86 raeburn 3019: undef,$attachmenturl,
1.13 albertel 3020: $env{'form.permanent'},
1.71 raeburn 3021: \$sentmessage{$address},
3022: undef,undef,undef,
1.73 raeburn 3023: $nosentstore,$recipid);
1.71 raeburn 3024: }
3025: $msg_status{$recuname.':'.$recdomain}=join(' ',@thismsg);
3026: if ($msg_status{$recuname.':'.$recdomain} =~ /(ok|con_delayed)/) {
3027: $numsent++;
3028: push(@recusers,$recuname);
3029: push(@recudoms,$recdomain);
1.1 albertel 3030: }
1.12 albertel 3031: $sendstatus.=' '.join(' ',@thismsg);
1.1 albertel 3032: }
1.71 raeburn 3033: my $subj_prefix;
3034: if ($numsent > 0) {
3035: if (($env{'request.course.id'}) &&
1.95 ! raeburn 3036: (($mode eq 'group') ||
1.71 raeburn 3037: ($env{'form.courserecord'}) ||
1.95 ! raeburn 3038: ($msgtype eq 'critical')) ||
! 3039: ($env{'form.replyid'} &&
! 3040: (($content{'courseid'} ne '') &&
! 3041: ($mode eq 'group')))) {
1.71 raeburn 3042: if ($msgtype eq 'critical') {
3043: $subj_prefix = 'Critical.';
1.95 ! raeburn 3044: } elsif ($mode eq 'group') {
1.71 raeburn 3045: $subj_prefix = 'Broadcast.';
3046: } else {
3047: $subj_prefix = 'Archive';
3048: }
3049: my ($specialmsgid,$specialresult);
1.95 ! raeburn 3050: my $course_str;
! 3051: if ($env{'form.replyid'}) {
! 3052: if ($content{'courseid'} ne '') {
! 3053: my %crsdesc =
! 3054: &Apache::lonnet::coursedescription($content{'courseid'},
! 3055: {'one_time' => 1});
! 3056: $course_str = &escape('['.$crsdesc{'num'}.':'.$crsdesc{'domain'}.']');
! 3057: }
! 3058: } elsif ($env{'request.course.id'}) {
! 3059: $course_str = &escape('['.$cnum.':'.$cdom.']');
! 3060: }
1.71 raeburn 3061: $specialresult =
3062: &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
3063: $subj_prefix.' '.$course_str,$savemsg,undef,undef,
1.86 raeburn 3064: $attachmenturl,undef,undef,\$specialmsgid,undef,undef,undef,
1.71 raeburn 3065: undef,undef,1);
1.29 www 3066: $specialmsgid = &unescape($specialmsgid);
1.71 raeburn 3067: if ($specialresult eq 'ok') {
3068: my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
3069: split(/\:/,&unescape($specialmsgid));
3070:
3071: foreach my $recipient (sort(keys(%toaddr))) {
3072: if ($msg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) {
3073: my $usersubj = $subj_prefix.'['.$recipient.']';
3074: my $usermsgid =
3075: &Apache::lonmsg::buildmsgid($stamp,$usersubj,
3076: $msgname,$msgdom,
3077: $msgcount,$context,
3078: $pid);
3079: &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
3080: $subj_prefix.' ['.$recipient.']',$msgsubj,
1.86 raeburn 3081: undef,undef,$attachmenturl,undef,$usermsgid,undef,
1.71 raeburn 3082: undef,$specialmsgid,undef,undef,undef,1);
3083: }
3084: }
1.95 ! raeburn 3085: if (($mode ne 'upload') && (@recusers > 0)) {
1.71 raeburn 3086: &Apache::lonmsg::process_sent_mail($msgsubj,
3087: $subj_prefix,$numsent,$stamp,$msgname,$msgdom,
3088: $msgcount,$context,$pid,$savemsg,\@recusers,
1.95 ! raeburn 3089: \@recudoms,undef,$attachmenturl,'','','','',$recipid);
1.1 albertel 3090: }
1.71 raeburn 3091: } else {
1.78 raeburn 3092: &Apache::lonnet::logthis('Failed to create record of critical, broadcast or archived message in '.$env{'course.'.$env{'request.course.id'}.'.num'}.' '&mt('at').' '.$env{'course.'.$env{'request.course.id'}.'.domain'}.' - no msgid generated');
1.1 albertel 3093: }
3094: } else {
1.71 raeburn 3095: my $stamp = time;
3096: my $msgcount = &Apache::lonmsg::get_uniq();
3097: my $context = &Apache::lonmsg::get_course_context();
3098: &Apache::lonmsg::process_sent_mail($msgsubj,$subj_prefix,
3099: $numsent,$stamp,$env{'user.name'},
3100: $env{'user.domain'},$msgcount,$context,
1.95 ! raeburn 3101: $$,$savemsg,\@recusers,\@recudoms,undef,$attachmenturl,
! 3102: '','','','',$recipid);
1.1 albertel 3103: }
3104: }
1.71 raeburn 3105: if (!$env{'form.multiforward'}) {
3106: if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
3107: $r->print('<br /><span class="LC_success">'.&mt('Completed.').
3108: '</span>');
3109: if ($env{'form.displayedcrit'}) {
3110: &discrit($r);
3111: }
3112: if ($group ne '') {
3113: $r->print(&groupmail_sent($group,$cdom,$cnum));
3114: } else {
3115: &Apache::loncommunicate::menu($r);
3116: }
3117: } else {
3118: $r->print('<p><span class="LC_error">'.&mt('Could not deliver message').'</span> '.
1.85 bisitz 3119: &mt('Please use the browser "Back" button and correct the recipient addresses ([_1]).',$sendstatus).'</p>');
1.53 raeburn 3120: }
1.38 raeburn 3121: }
1.1 albertel 3122: }
1.53 raeburn 3123: return $sendstatus;
1.1 albertel 3124: }
3125:
3126: # ===================================================================== Handler
3127:
3128: sub handler {
3129: my $r=shift;
3130:
3131: # ----------------------------------------------------------- Set document type
3132:
3133: &Apache::loncommon::content_type($r,'text/html');
3134: $r->send_http_header;
3135:
3136: return OK if $r->header_only;
3137:
3138: # --------------------------- Get query string for limited number of parameters
3139: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
3140: ['display','replyto','forward','markread','markdel','markunread',
3141: 'sendreply','compose','sendmail','critical','recname','recdom',
3142: 'recordftf','sortedby','block','folder','startdis','interdis',
1.53 raeburn 3143: 'showcommentbaseurl','dismode','group','subject','text','ref',
3144: 'msgstatus']);
1.1 albertel 3145: $sqs='&sortedby='.$env{'form.sortedby'};
3146:
3147: # ------------------------------------------------------ They checked for email
3148: unless ($env{'form.block'}) {
3149: &Apache::lonnet::put('email_status',{'recnewemail'=>0});
3150: }
3151:
3152: # ----------------------------------------------------------------- Breadcrumbs
3153:
3154: &Apache::lonhtmlcommon::clear_breadcrumbs();
3155: &Apache::lonhtmlcommon::add_breadcrumb
3156: ({href=>"/adm/communicate",
3157: text=>"Communication/Messages",
3158: faq=>12,bug=>'Communication Tools',});
3159:
3160: # ------------------------------------------------------------------ Get Folder
3161:
3162: my $folder=$env{'form.folder'};
3163: unless ($folder) {
3164: $folder='';
3165: } else {
1.29 www 3166: $sqs.='&folder='.&escape($folder);
1.1 albertel 3167: }
3168: # ------------------------------------------------------------ Get Display Mode
3169:
3170: my $dismode=$env{'form.dismode'};
3171: unless ($dismode) {
3172: $dismode='';
3173: } else {
1.48 albertel 3174: $sqs.='&dismode='.&escape($dismode);
1.1 albertel 3175: }
3176:
3177: # --------------------------------------------------------------------- Display
1.53 raeburn 3178: my $msgstatus = $env{'form.msgstatus'};
1.1 albertel 3179: $startdis=$env{'form.startdis'};
1.53 raeburn 3180: if ($startdis ne '') {
3181: $startdis--;
3182: }
1.1 albertel 3183: unless ($startdis) { $startdis=0; }
3184:
3185: if ($env{'form.firstview'}) {
3186: $startdis=0;
3187: }
3188: if ($env{'form.lastview'}) {
3189: $startdis=-1;
3190: }
3191: if ($env{'form.prevview'}) {
3192: $startdis--;
3193: }
3194: if ($env{'form.nextview'}) {
3195: $startdis++;
3196: }
3197: my $postedstartdis=$startdis+1;
3198: $sqs.='&startdis='.$postedstartdis;
3199:
3200: # --------------------------------------------------------------- Render Output
3201:
3202: if ($env{'form.display'}) {
1.53 raeburn 3203: &displaymessage($r,$env{'form.display'},$folder,$msgstatus);
1.1 albertel 3204: } elsif ($env{'form.replyto'}) {
3205: &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
3206: } elsif ($env{'form.confirm'}) {
3207: &printheader($r,'','Confirmed Receipt');
1.36 albertel 3208: my $replying = 0;
1.42 raeburn 3209: foreach my $envkey (keys(%env)) {
1.75 raeburn 3210: if ($envkey=~/^form\.(rep)?rec\_(.*)$/) {
1.77 raeburn 3211: my $repchk = $1;
1.75 raeburn 3212: my $msgid = $2;
3213: $r->print('<b>'.&mt('Confirming Receipt').':</b> ');
3214: my $result = &Apache::lonmsg::user_crit_received($msgid);
3215: if ($result =~ /trans:\s+ok/) {
3216: &statuschange($msgid,'read');
3217: }
1.76 albertel 3218: $r->print($result.'<br />');
1.77 raeburn 3219: if ($repchk eq 'rep') {
1.75 raeburn 3220: &compout($r,'','','',$msgid);
3221: $replying = 1;
3222: }
1.1 albertel 3223: }
3224: }
1.36 albertel 3225: if (!$replying) {
3226: &discrit($r);
3227: }
1.1 albertel 3228: } elsif ($env{'form.critical'}) {
3229: &printheader($r,'','Displaying Critical Messages');
3230: &discrit($r);
3231: } elsif ($env{'form.forward'}) {
3232: &compout($r,$env{'form.forward'},undef,undef,undef,$folder);
3233: } elsif ($env{'form.markdel'}) {
3234: &printheader($r,'','Deleted Message');
1.9 albertel 3235: my ($result,$msg) =
3236: &statuschange($env{'form.markdel'},'deleted',$folder);
3237: if (!$result) {
1.10 albertel 3238: $r->print('<p class="LC_error">'.
3239: &mt('Failed to delete the message.').'</p>'.
1.9 albertel 3240: '<p class="LC_error">'.$msg."</p>\n");
3241: }
1.1 albertel 3242: &Apache::loncommunicate::menu($r);
1.53 raeburn 3243: &disall($r,($folder?$folder:$dismode),$msgstatus);
3244: } elsif ($env{'form.markedaction'} eq 'markedforward') {
3245: my $total = 0;
3246: my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
3247: foreach my $msgid (@to_forward) {
3248: &statuschange(&unescape($msgid),'forwarded',$folder);
3249: $total ++;
3250: }
3251: if ($total > 0) {
3252: &compout($r,undef,undef,undef,undef,$folder,$dismode,$total);
3253: }
3254: } elsif ($env{'form.markedaction'} eq 'markedread') {
3255: my $total = 0;
3256: my @to_markread = &Apache::loncommon::get_env_multiple('form.delmark');
3257: foreach my $msgid (@to_markread) {
3258: &statuschange(&unescape($msgid),'read',$folder);
3259: $total ++;
3260: }
3261: &printheader($r,'','Marked Messages Read');
3262: $r->print(&mt('Marked [_1] message(s) read',$total).'<p>');
3263: &Apache::loncommunicate::menu($r);
3264: &disall($r,($folder?$folder:$dismode),$msgstatus);
3265: } elsif ($env{'form.markedaction'} eq 'markedunread') {
3266: my $total = 0;
3267: my @to_markunread = &Apache::loncommon::get_env_multiple('form.delmark');
3268: foreach my $msgid (@to_markunread) {
3269: &statuschange(&unescape($msgid),'new',$folder);
3270: $total ++;
3271: }
3272: &printheader($r,'','Marked Messages Unread');
3273: $r->print(&mt('Marked [_1] message(s) unread',$total).'<p>');
3274: &Apache::loncommunicate::menu($r);
3275: &disall($r,($folder?$folder:$dismode),$msgstatus);
3276: } elsif ($env{'form.markedaction'} eq 'markedmove') {
3277: my $destfolder = $env{'form.movetofolder'};
3278: my %gotfolders = &Apache::lonmsg::get_user_folders();
3279: &printheader($r,'','Moved Messages');
3280: if (!defined($gotfolders{$destfolder})) {
3281: $r->print(&mt('Destination folder [_1] is not a valid folder',
3282: $destfolder));
3283: } else {
3284: my ($total,$failed,@failed_msg)=(0,0);
3285: my @to_move = &Apache::loncommon::get_env_multiple('form.delmark');
3286: foreach my $msgid (@to_move) {
3287: my ($result,$msg) = &movemsg(&unescape($msgid),$folder,
3288: $env{'form.movetofolder'});
3289: if ($result) {
1.9 albertel 3290: $total++;
1.53 raeburn 3291: } else {
1.9 albertel 3292: $failed++;
3293: push(@failed_msg,$msg);
1.53 raeburn 3294: }
1.1 albertel 3295: }
1.53 raeburn 3296: if ($failed) {
3297: $r->print('<p class="LC_error">
1.10 albertel 3298: '.&mt('Failed to move [_1] message(s)',$failed).
3299: '</p>');
1.53 raeburn 3300: $r->print('<p class="LC_error">'.
3301: join("</p>\n<p class=\"LC_error\">",@failed_msg).
3302: "</p>\n");
3303: }
3304: $r->print(&mt('Moved [_1] message(s)',$total).'<p>');
3305: }
1.1 albertel 3306: &Apache::loncommunicate::menu($r);
1.53 raeburn 3307: &disall($r,($folder?$folder:$dismode),$msgstatus);
3308: } elsif ($env{'form.markedaction'} eq 'markeddel') {
1.9 albertel 3309: my ($total,$failed,@failed_msg)=(0,0);
1.53 raeburn 3310: my @to_delete = &Apache::loncommon::get_env_multiple('form.delmark');
3311: foreach my $msgid (@to_delete) {
3312: my ($result,$msg) = &statuschange(&unescape($msgid),'deleted',
3313: $folder);
3314: if ($result) {
3315: $total++;
3316: } else {
3317: $failed++;
3318: push(@failed_msg,$msg);
1.1 albertel 3319: }
3320: }
3321: &printheader($r,'','Deleted Messages');
1.9 albertel 3322: if ($failed) {
3323: $r->print('<p class="LC_error">
1.10 albertel 3324: '.&mt('Failed to delete [_1] message(s)',$failed).
3325: '</p>');
1.9 albertel 3326: $r->print('<p class="LC_error">'.
3327: join("</p>\n<p class=\"LC_error\">",@failed_msg).
3328: "</p>\n");
3329: }
1.10 albertel 3330: $r->print(&mt('Deleted [_1] message(s)',$total).'<p>');
1.1 albertel 3331: &Apache::loncommunicate::menu($r);
1.53 raeburn 3332: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3333: } elsif ($env{'form.markunread'}) {
3334: &printheader($r,'','Marked Message as Unread');
3335: &statuschange($env{'form.markunread'},'new');
3336: &Apache::loncommunicate::menu($r);
1.53 raeburn 3337: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3338: } elsif ($env{'form.compose'}) {
3339: &compout($r,'','',$env{'form.compose'});
3340: } elsif ($env{'form.recordftf'}) {
3341: &facetoface($r,$env{'form.recordftf'});
3342: } elsif ($env{'form.block'}) {
3343: &examblock($r,$env{'form.block'});
3344: } elsif ($env{'form.sendmail'}) {
1.53 raeburn 3345: if ($env{'form.multiforward'}) {
3346: &printheader($r,'','Messages being sent.');
3347: my $fixed_subj = $env{'form.subject'};
3348: my $suffix=&Apache::lonmsg::foldersuffix($folder);
3349: my (%sendresult,%forwardok,%forwardfail,$fwdcount);
3350: my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
3351: foreach my $item (@to_forward) {
3352: my $msgid=&unescape($item);
3353: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1.86 raeburn 3354: my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1);
1.53 raeburn 3355: if ($env{'form.showorigsubj'}) {
3356: $env{'form.subject'} = $fixed_subj.$content{'subject'};
3357: } else {
3358: $env{'form.subject'} = '';
3359: }
3360: my $uname = $content{'sendername'};
3361: my $udom = $content{'senderdomain'};
3362: &statuschange($msgid,'forwarded',$folder);
3363: if ($env{'form.showorigsender'}) {
3364: $env{'form.message'} = $env{'form.msgheader'}.' '.
3365: &Apache::loncommon::plainname($uname,$udom).' ('.
3366: $uname.':'.$udom.')';
3367: }
1.86 raeburn 3368: $env{'form.message'}.="\n\n-- Forwarded message --\n\n".
3369: $content{'message'};
3370: $env{'form.attachmenturl'} = $content{'attachmenturl'};
3371: $env{'form.multiforwid'} = $item;
1.53 raeburn 3372: $fwdcount ++;
3373: $r->print($fwdcount.': ');
3374: $sendresult{$msgid} = &sendoffmail($r,$folder);
3375: $r->print('<br />');
3376: }
3377: foreach my $key (keys(%sendresult)) {
3378: if ($sendresult{$key} =~/^(\s*(?:ok|con_delayed)\s*)*$/) {
3379: $forwardok{$key} = $sendresult{$key};
3380: } else {
3381: $forwardfail{$key} = $sendresult{$key};
3382: }
3383: }
3384: if (keys(%forwardok) > 0) {
3385: my $count = keys(%forwardok);
3386: $r->print('<br /><span class="LC_success">'.
3387: &mt('[quant,_1,message] forwarded.',$count).
3388: '</span>');
3389: }
3390: if (keys(%forwardfail) > 0) {
3391: my $count = keys(%forwardfail);
3392: $r->print('<p><span class="LC_error">'.
3393: &mt('Could not forward [quant,_1,message].',$count).
3394: '</span> ');
3395: foreach my $key (keys(%forwardfail)) {
3396: $r->print(&mt('Could not deliver forwarded message.').'</span> '.
3397: &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.').<br /><br />');
3398: }
3399: }
3400: &Apache::loncommunicate::menu($r);
3401: } else {
3402: &sendoffmail($r,$folder);
3403: }
1.1 albertel 3404: if ($env{'form.storebasecomment'}) {
3405: &storecomment($r);
1.38 raeburn 3406: }
1.1 albertel 3407: if (($env{'form.rsspost'}) && ($env{'request.course.id'})) {
1.38 raeburn 3408: &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
1.1 albertel 3409: $env{'course.'.$env{'request.course.id'}.'.domain'},
3410: 'Course_Announcements',
3411: $env{'form.subject'},
3412: $env{'form.message'},'/adm/communicate','public');
3413: }
1.38 raeburn 3414: if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) {
1.53 raeburn 3415: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.36 albertel 3416: }
1.1 albertel 3417: } elsif ($env{'form.newfolder'}) {
3418: &printheader($r,'','New Folder');
1.46 raeburn 3419: my $showfolder = $env{'form.newfolder'};
3420: my ($makeresult,$warning) = &makefolder($env{'form.newfolder'});
3421: if ($makeresult eq 'ok') {
3422: $r->print(&mt('Mail folder "[_1]" created.',$showfolder).'<br />');
3423: } else {
3424: $r->print(&mt('Creation failed.').' '.$makeresult.'<br />'.
3425: $warning);
3426: $showfolder = $folder;
3427: }
3428: &Apache::loncommunicate::menu($r);
1.53 raeburn 3429: &disall($r,$showfolder,$msgstatus);
1.1 albertel 3430: } elsif ($env{'form.showcommentbaseurl'}) {
3431: &storedcommentlisting($r);
1.46 raeburn 3432: } elsif ($env{'form.folderaction'} eq 'delete') {
3433: &printheader($r,'','Deleted Folder');
3434: my $showfolder = '';
3435: my $delresult = &deletefolder($folder);
3436: if ($delresult eq 'ok') {
3437: $r->print(&mt('Mail folder "[_1]" deleted.',$folder).'<br />');
1.65 raeburn 3438: $env{'form.folder'} = '';
1.46 raeburn 3439: } else {
3440: $r->print(&mt('Deletion failed.').' '.$delresult.'<br />');
3441: $showfolder = $folder;
3442: }
3443: &Apache::loncommunicate::menu($r);
1.53 raeburn 3444: &disall($r,$showfolder,$msgstatus);
1.46 raeburn 3445: } elsif ($env{'form.folderaction'} eq 'rename') {
3446: &printheader($r,'','Renamed Folder');
3447: my $showfolder = $env{'form.renamed'};
3448: my $renresult = &renamefolder($folder);
3449: if ($renresult eq 'ok') {
3450: $r->print(&mt('Mail folder "[_1]" renamed "[_2]".',$folder,$showfolder).'<br />');
3451: } else {
3452: $r->print(&mt('Renaming failed.').' '.$renresult.'<br />');
3453: $showfolder = $folder;
3454: }
3455: &Apache::loncommunicate::menu($r);
1.53 raeburn 3456: &disall($r,$showfolder,$msgstatus);
1.1 albertel 3457: } else {
3458: &printheader($r,'','Display All Messages');
1.44 raeburn 3459: &Apache::loncommunicate::menu($r);
1.53 raeburn 3460: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3461: }
3462: $r->print(&Apache::loncommon::end_page());
3463: return OK;
3464: }
3465: # ================================================= Main program, reset counter
3466:
3467: =pod
3468:
3469: =cut
3470:
3471: 1;
3472:
3473: __END__
3474:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>