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