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