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