Annotation of loncom/interface/lonmsgdisplay.pm, revision 1.171
1.158 raeburn 1: # The LearningOnline Network with CAPA
1.1 albertel 2: # Routines for messaging display
3: #
1.171 ! bisitz 4: # $Id: lonmsgdisplay.pm,v 1.170 2013/09/04 14:51:00 bisitz Exp $
1.1 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29:
30: package Apache::lonmsgdisplay;
31:
32: =pod
33:
34: =head1 NAME
35:
1.69 raeburn 36: Apache::lonmsgdisplay: supports internal messaging
1.1 albertel 37:
38: =head1 SYNOPSIS
39:
1.69 raeburn 40: lonmsgdisplay provides a handler to allow users to read, send,
41: and delete messages, and to create and delete message folders,
42: and to move messages between folders.
1.1 albertel 43:
44: =head1 OVERVIEW
45:
46: =head2 Messaging Overview
47:
48: X<messages>LON-CAPA provides an internal messaging system similar to
49: email, but customized for LON-CAPA's usage. LON-CAPA implements its
50: own messaging system, rather then building on top of email, because of
51: the features LON-CAPA messages can offer that conventional e-mail can
52: not:
53:
54: =over 4
55:
56: =item * B<Critical messages>: A message the recipient B<must>
57: acknowlegde receipt of before they are allowed to continue using the
58: system, preventing a user from claiming they never got a message
59:
60: =item * B<Receipts>: LON-CAPA can reliably send reciepts informing the
61: sender that it has been read; again, useful for preventing students
62: from claiming they did not see a message. (While conventional e-mail
63: has some reciept support, it's sporadic, e-mail client-specific, and
64: generally the receiver can opt to not send one, making it useless in
65: this case.)
66:
67: =item * B<Context>: LON-CAPA knows about the sender, such as where
68: they are in a course. When a student mails an instructor asking for
69: help on the problem, the instructor receives not just the student's
70: question, but all submissions the student has made up to that point,
71: the user's rendering of the problem, and the complete view the student
72: saw of the resource, including discussion up to that point. Finally,
73: the instructor is reading all of this inside of LON-CAPA, not their
74: email program, so they have full access to LON-CAPA's grading
75: interface, or other features they may wish to use in response to the
76: student's query.
77:
1.50 raeburn 78: =item * B<Blocking>: LON-CAPA can block selected communication
79: features for students during an online exam. A course coordinator or
1.1 albertel 80: instructor can set an open and close date/time for scheduled online
81: exams in a course. If a user uses the LON-CAPA internal messaging
82: system to display e-mails during the scheduled blocking event,
83: display of all e-mail sent during the blocking period will be
84: suppressed, and a message of explanation, including details of the
85: currently active blocking periods will be displayed instead. A user
86: who has a course coordinator or instructor role in a course will be
87: unaffected by any blocking periods for the course, unless the user
88: also has a student role in the course, AND has selected the student role.
89:
90: =back
91:
92: Users can ask LON-CAPA to forward messages to conventional e-mail
93: addresses on their B<PREF> screen, but generally, LON-CAPA messages
94: are much more useful than traditional email can be made to be, even
95: with HTML support.
96:
97: =cut
98:
99: use strict;
100: use Apache::lonnet;
101: use HTML::TokeParser();
102: use Apache::Constants qw(:common);
103: use Apache::loncommon();
1.67 www 104: use Apache::lonhtmlcommon();
1.1 albertel 105: use Apache::lontexconvert();
106: use HTML::Entities();
107: use Apache::lonlocal;
108: use Apache::loncommunicate;
109: use Apache::lonfeedback;
110: use Apache::lonrss();
1.27 albertel 111: use Apache::lonselstudent();
1.29 www 112: use lib '/home/httpd/lib/perl/';
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.170 bisitz 1207: $item.'</a>'.(($status eq 'new')?'</b>':'').'</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') {
1.170 bisitz 1257: $r->print(' <option value="markedread">'.&mt('Mark Read').'</option>'."\n");
1.53 raeburn 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'} =
1.170 bisitz 1927: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1.70 raeburn 1928: $content{'message'};
1929: }
1.1 albertel 1930: } else {
1931: $result.='<h3>'.&mt('Critical Message').'</h3>';
1932: if (defined($content{'coursemsgid'})) {
1.29 www 1933: my $crsmsgid=&escape($content{'coursemsgid'});
1.1 albertel 1934: my $critical_message = &general_message($crsmsgid);
1935: $content{'message'} = '<b>'.&mt('Subject').': '.$content{'message'}.'</b><br />'.$critical_message;
1936: } else {
1937: %content=&Apache::lonmsg::unpackagemsg($content{'message'});
1938: $content{'message'}=
1939: '<b>'.&mt('Subject').': '.$content{'subject'}.'</b><br />'.
1940: $content{'message'};
1941: }
1942: }
1943: $result.=&mt('By').': <b>'.
1944: &Apache::loncommon::aboutmewrapper(
1945: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).'</b> ('.
1.14 albertel 1946: $content{'sendername'}.':'.
1.1 albertel 1947: $content{'senderdomain'}.') '.$content{'time'}.
1948: '<br /><pre>'.
1949: &Apache::lontexconvert::msgtexconverted($content{'message'}).
1950: '</pre>';
1951: }
1952: # Check to see if there were any messages.
1953: if ($result eq '') {
1.106 riegler 1954: my $lctype = &mt(lc(&Apache::loncommon::course_type()));
1.1 albertel 1955: if ($target ne 'tex') {
1.30 raeburn 1956: $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 1957: } else {
1.30 raeburn 1958: $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\');
1.1 albertel 1959: }
1.136 amueller 1960: } elsif ($target ne 'tex') {
1961: $r->print($result.'</div>');
1.1 albertel 1962: } else {
1.136 amueller 1963: $r->print(&Apache::lonxml::xmlparse($r, 'tex', $result));
1964: }
1.1 albertel 1965: }
1966:
1967: sub general_message {
1968: my ($crsmsgid) = @_;
1969: my %general_content;
1970: if ($crsmsgid) {
1971: my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid],
1972: $env{'course.'.$env{'request.course.id'}.'.domain'},
1973: $env{'course.'.$env{'request.course.id'}.'.num'});
1974: %general_content = &Apache::lonmsg::unpackagemsg($course_content{$crsmsgid});
1975: }
1976: return $general_content{'message'};
1977: }
1978:
1979: # ---------------------------------------------------------------- Face to face
1980:
1981: sub facetoface {
1982: my ($r,$stage)=@_;
1.49 albertel 1983: if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'})
1984: && ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
1.1 albertel 1985: '/'.$env{'request.course.sec'})) {
1.50 raeburn 1986: $r->print(&mt('Not allowed'));
1.1 albertel 1987: return;
1988: }
1.33 albertel 1989: my $crstype = &Apache::loncommon::course_type();
1.128 raeburn 1990: my $leaders = ($crstype eq 'Community') ? 'coordinators and leaders'
1991: : 'faculty and staff';
1.1 albertel 1992: &printheader($r,
1993: '/adm/email?recordftf=query',
1.70 raeburn 1994: "User Notes, Face-to-Face, Critical Messages, Broadcast Messages, Archived Messages");
1.1 albertel 1995: # from query string
1996:
1997: if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
1998: if ($env{'form.recdom'}) { $env{'form.recdomain'}=$env{'form.recdom'}; }
1999:
2000: my $defdom=$env{'user.domain'};
2001: # already filled in
2002: if ($env{'form.recdomain'}) { $defdom=$env{'form.recdomain'}; }
2003: # generate output
2004: my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain');
2005: my $stdbrws = &Apache::loncommon::selectstudent_link
2006: ('stdselect','recuname','recdomain');
2007: my %lt=&Apache::lonlocal::texthash('user' => 'Username',
2008: 'dom' => 'Domain',
1.70 raeburn 2009: 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, Broadcast Messages and Archived Messages in $crstype",
1.1 albertel 2010: 'subm' => 'Retrieve discussion and message records',
1.30 raeburn 2011: 'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
1.1 albertel 2012: 'post' => 'Post this Record');
1.123 bisitz 2013:
2014: $r->print('<h2>'.$lt{'head'}.'</h2>'
2015: .'<form method="post" action="/adm/email" name="stdselect">'
2016: .'<input type="hidden" name="recordftf" value="retrieve" />'
2017: .&Apache::lonhtmlcommon::start_pick_box()
2018: .&Apache::lonhtmlcommon::row_title($lt{'user'})
2019: .'<input type="text" size="12" name="recuname" value="'.$env{'form.recuname'}.'" />'
2020: .' '.$stdbrws
2021: .&Apache::lonhtmlcommon::row_closure()
2022: .&Apache::lonhtmlcommon::row_title($lt{'dom'})
2023: .$domform
2024: .&Apache::lonhtmlcommon::row_closure(1)
2025: .&Apache::lonhtmlcommon::end_pick_box()
2026: .'<br />'
2027: .'<input type="submit" value="'.$lt{'subm'}.'" />'
1.150 raeburn 2028: .'</form>'
1.123 bisitz 2029: );
2030:
1.1 albertel 2031: if (($stage ne 'query') &&
2032: ($env{'form.recdomain'}) && ($env{'form.recuname'})) {
2033: chomp($env{'form.newrecord'});
2034: if ($env{'form.newrecord'}) {
1.31 albertel 2035: &Apache::lonmsg::store_instructor_comment($env{'form.newrecord'},
2036: $env{'form.recuname'},
2037: $env{'form.recdomain'});
1.1 albertel 2038: }
1.123 bisitz 2039: my $aboutmelink=&Apache::loncommon::aboutmewrapper(
2040: &Apache::loncommon::plainname($env{'form.recuname'}
2041: ,$env{'form.recdomain'})
2042: ,$env{'form.recuname'},$env{'form.recdomain'});
2043: $r->print('<hr />'
2044: .'<h2>'
2045: .&mt('Discussion and message records for [_1] ([_2])'
2046: ,$aboutmelink
2047: ,$env{'form.recuname'}.':'.$env{'form.recdomain'})
1.161 bisitz 2048: .'</h2>'
1.123 bisitz 2049: );
1.1 albertel 2050: &disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
2051: $r->print(<<ENDRHEAD);
2052: <form method="post" action="/adm/email">
2053: <input name="recdomain" value="$env{'form.recdomain'}" type="hidden" />
2054: <input name="recuname" value="$env{'form.recuname'}" type="hidden" />
2055: ENDRHEAD
2056: $r->print(<<ENDBFORM);
2057: <hr />$lt{'newr'}<br />
2058: <textarea name="newrecord" cols="80" rows="10" wrap="hard"></textarea>
2059: <br />
2060: <input type="hidden" name="recordftf" value="post" />
2061: <input type="submit" value="$lt{'post'}" />
2062: </form>
2063: ENDBFORM
2064: }
2065: }
2066:
2067: # ----------------------------------------------------------- Display a message
2068:
2069: sub displaymessage {
1.53 raeburn 2070: my ($r,$msgid,$folder,$msgstatus)=@_;
1.1 albertel 2071: my $suffix=&Apache::lonmsg::foldersuffix($folder);
2072: my %blocked = ();
2073: my %setters = ();
2074: my $numblocked = 0;
1.33 albertel 2075: my $crstype = &Apache::loncommon::course_type();
1.30 raeburn 2076:
1.1 albertel 2077: # info to generate "next" and "previous" buttons and check if message is blocked
1.44 raeburn 2078: my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
1.53 raeburn 2079: my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
1.1 albertel 2080: if ( $blocked{$msgid} eq 'ON' ) {
2081: &printheader($r,'/adm/email',&mt('Display a Message'));
1.129 kalberla 2082: #$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 2083: my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
1.129 kalberla 2084: $r->print("<br />".$blocktext);
1.1 albertel 2085: return;
2086: }
1.59 raeburn 2087: if ($msgstatus eq '') {
2088: &statuschange($msgid,'read',$folder);
2089: }
1.1 albertel 2090: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
2091: my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
2092: my $counter=0;
1.29 www 2093: my $escmsgid=&escape($msgid);
1.1 albertel 2094: foreach (@messages) {
2095: if ($_->[5] eq $escmsgid){
2096: last;
2097: }
2098: $counter++;
2099: }
1.82 albertel 2100:
2101: my $see_anonymous;
2102: my $from_student = 0;
2103: if ($env{'request.course.id'} eq $content{'courseid'}) {
2104: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2105: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2106: my $username = $content{'sendername'}.':'.$content{'senderdomain'};
2107: my %classlist_entry =
2108: &Apache::lonnet::get('classlist',[$username],$cdom,$cnum);
2109: if (exists($classlist_entry{$username})) {
2110: $from_student = 1;
2111: $see_anonymous = &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
2112: }
2113: }
2114:
2115:
1.1 albertel 2116: my $number_of_messages = scalar(@messages); #subtract 1 for last index
2117: # start output
1.29 www 2118: &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
1.101 bisitz 2119:
2120: # Prepare available functions
1.119 bisitz 2121: my @functionlist;
1.78 raeburn 2122: if (!$content{'noreplies'}) {
1.119 bisitz 2123: push(@functionlist,'<a href="/adm/email?replyto='.&escape($msgid).$sqs.'">'
1.101 bisitz 2124: .&mt('Reply')
1.119 bisitz 2125: .'</a>');
1.101 bisitz 2126: }
1.119 bisitz 2127: push(@functionlist,'<a href="/adm/email?forward='.&escape($msgid).$sqs.'">'
1.101 bisitz 2128: .&mt('Forward')
1.119 bisitz 2129: .'</a>');
2130: push(@functionlist,'<a href="/adm/email?markunread='.&escape($msgid).$sqs.'">'
1.101 bisitz 2131: .&mt('Mark Unread')
1.119 bisitz 2132: .'</a>');
2133: push(@functionlist,'<a href="/adm/email?markdel='.&escape($msgid).$sqs.'">'
1.101 bisitz 2134: .&mt('Delete')
1.119 bisitz 2135: .'</a>');
1.162 bisitz 2136:
2137: # Prepare available navigation
2138: my @navigationlist;
1.1 albertel 2139: if ($counter > 0){
1.162 bisitz 2140: push(@navigationlist,'<a href="/adm/email?display='.$messages[$counter-1]->[5].$sqs.'">'
1.119 bisitz 2141: .&mt('Previous')
2142: .'</a>');
1.1 albertel 2143: }
2144: if ($counter < $number_of_messages - 1){
1.162 bisitz 2145: push(@navigationlist,'<a href="/adm/email?display='.$messages[$counter+1]->[5].$sqs.'">'
1.119 bisitz 2146: .&mt('Next')
2147: .'</a>');
1.101 bisitz 2148: }
1.162 bisitz 2149: push(@navigationlist,'<a href="/adm/email?'.$sqs.'">'
2150: .&mt('Back to Folder Display')
2151: .'</a>');
1.101 bisitz 2152:
2153: # Prepare available actions
1.59 raeburn 2154: my $symb;
2155: if (defined($content{'symb'})) {
2156: $symb = $content{'symb'};
2157: } elsif (defined($content{'baseurl'})) {
2158: $symb=&Apache::lonnet::symbread($content{'baseurl'});
2159: }
1.162 bisitz 2160: my @actionlist;
1.1 albertel 2161: if ($env{'user.adv'}) {
1.101 bisitz 2162:
1.1 albertel 2163: if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) {
1.119 bisitz 2164: push(@actionlist,&Apache::loncommon::track_student_link(
1.171 ! bisitz 2165: 'View recent activity'
1.119 bisitz 2166: ,$content{'sendername'}
2167: ,$content{'senderdomain'}
2168: ,'check'));
1.90 bisitz 2169: }
1.1 albertel 2170: if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) {
1.119 bisitz 2171: push(@actionlist,&Apache::loncommon::pprmlink(
2172: &mt('Set/Change parameters')
2173: ,$content{'sendername'}
2174: ,$content{'senderdomain'}
2175: ,$symb
2176: ,'check'));
1.1 albertel 2177: }
2178: if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) {
1.119 bisitz 2179: push(@actionlist,&Apache::loncommon::pgrdlink(
2180: &mt('Set/Change grades')
2181: ,$content{'sendername'}
2182: ,$content{'senderdomain'}
2183: ,$symb
2184: ,'check'));
1.90 bisitz 2185: }
1.126 bisitz 2186: }
2187:
1.162 bisitz 2188: # Print functionlist, navigationlist, and actionlist in page header
1.126 bisitz 2189: my $functions='<div class="LC_columnSection">';
1.101 bisitz 2190:
1.126 bisitz 2191: # Functionlist
2192: $functions.=&Apache::lonhtmlcommon::start_funclist();
2193: foreach my $item (@functionlist) {
2194: $functions.=&Apache::lonhtmlcommon::add_item_funclist($item);
2195: }
2196: $functions .= &Apache::lonhtmlcommon::end_funclist();
2197:
1.162 bisitz 2198: # Navigationlist
2199: $functions.=&Apache::lonhtmlcommon::start_funclist(
2200: &mt('Navigation'));
2201: foreach my $item (@navigationlist) {
2202: $functions.=&Apache::lonhtmlcommon::add_item_funclist($item);
2203: }
2204: $functions .= &Apache::lonhtmlcommon::end_funclist();
2205:
1.126 bisitz 2206: # Actionlist
1.119 bisitz 2207: if (@actionlist) {
1.162 bisitz 2208: $functions.=&Apache::lonhtmlcommon::start_funclist(
2209: &mt('Currently available actions (will open extra window)'));
1.119 bisitz 2210: foreach my $item (@actionlist) {
1.126 bisitz 2211: $functions.=&Apache::lonhtmlcommon::add_item_funclist($item);
1.119 bisitz 2212: }
1.126 bisitz 2213: $functions.=&Apache::lonhtmlcommon::end_funclist();
1.90 bisitz 2214: }
1.126 bisitz 2215:
2216: $functions.='</div>';
2217: $r->print(&Apache::loncommon::head_subbox($functions));
2218:
1.101 bisitz 2219:
1.95 raeburn 2220: my ($tonum,$tolist,$cclist,$bcclist,$groupcclist,%recipients);
2221: if ($content{'recipid'}) {
2222: $tonum = &retrieve_recips('display',\%content,\%recipients);
2223: if (ref($recipients{'cc'}) eq 'ARRAY') {
2224: $cclist = join(', ',@{$recipients{'cc'}});
2225: }
2226: if (ref($recipients{'to'}) eq 'ARRAY') {
2227: $tolist = join(', ',@{$recipients{'to'}});
2228: }
2229: if (ref($recipients{'bcc'}) eq 'ARRAY') {
2230: $bcclist = join(', ',@{$recipients{'bcc'}});
2231: }
2232: }
1.107 raeburn 2233:
2234: my $broadcast_link;
2235: if (($content{'courseid'}) && ($content{'recipid'} &&
2236: (ref($recipients{'course_broadcast'}) eq 'ARRAY') ||
2237: (ref($recipients{'group_cc_broadcast'}) eq 'ARRAY') ||
2238: (ref($recipients{'group_bcc_broadcast'}) eq 'ARRAY'))) {
2239: $broadcast_link = &recipients_link($r,\%content,\%recipients);
2240: }
2241:
2242: if (((!$tolist) && (!$broadcast_link)) && ref($content{'recuser'}) eq 'ARRAY') {
1.95 raeburn 2243: my @recipients;
1.73 raeburn 2244: for (my $i=0; $i<@{$content{'recuser'}}; $i++) {
2245: $recipients[$i] = &Apache::loncommon::aboutmewrapper(
2246: &Apache::loncommon::plainname($content{'recuser'}[$i],
1.1 albertel 2247: $content{'recdomain'}[$i]),
1.73 raeburn 2248: $content{'recuser'}[$i],$content{'recdomain'}[$i]).
1.95 raeburn 2249: ' ('.$content{'recuser'}[$i].':'.$content{'recdomain'}[$i].') ';
1.73 raeburn 2250: }
1.95 raeburn 2251: $tolist = join(', ',@recipients);
1.73 raeburn 2252: }
1.59 raeburn 2253: my ($restitle,$baseurl,$refers_to);
2254: if (defined($content{'resource_title'})) {
2255: $restitle = $content{'resource_title'};
2256: } else {
2257: if (defined($content{'baseurl'})) {
2258: $restitle = &Apache::lonnet::gettitle($content{'baseurl'});
2259: }
2260: }
2261: if (defined($content{'baseurl'})) {
2262: $baseurl = &Apache::lonenc::check_encrypt($content{'baseurl'});
2263: }
1.104 raeburn 2264: $r->print('<div class="LC_clear_float_footer">');
1.82 albertel 2265: if ($from_student && $see_anonymous ) {
1.104 raeburn 2266: $r->print(&Apache::loncommon::student_image_tag($content{'senderdomain'},$content{'sendername'}).'</br>');
1.82 albertel 2267: }
2268:
1.91 bisitz 2269: # Display LON-CAPA Message (Start)
2270: # Subject
1.104 raeburn 2271: $r->print('</div>'
1.91 bisitz 2272: .&Apache::lonhtmlcommon::start_pick_box()
2273: .&Apache::lonhtmlcommon::row_title(&mt('Subject'))
2274: .$content{'subject'}
2275: .&Apache::lonhtmlcommon::row_closure()
2276: );
1.73 raeburn 2277: if ($folder eq 'sent') {
1.91 bisitz 2278: # To
1.107 raeburn 2279: if ($tolist) {
2280: $r->print(&Apache::lonhtmlcommon::row_title(&mt('To'))
2281: .$tolist
2282: .&Apache::lonhtmlcommon::row_closure()
2283: );
2284: }
1.95 raeburn 2285: if ($cclist) {
2286: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
2287: .$cclist
2288: .&Apache::lonhtmlcommon::row_closure()
2289: );
2290: }
2291: if ($bcclist) {
2292: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Bcc'))
2293: .$bcclist
2294: .&Apache::lonhtmlcommon::row_closure()
2295: );
2296: }
2297: if (($content{'courseid'}) && ($content{'recipid'})) {
2298: my %broadcast_types =
2299: &Apache::lonlocal::texthash (
2300: course_broadcast => 'Broadcast to',
2301: group_cc_broadcast => 'Cc to group',
2302: group_bcc_broadcast => 'Bcc to group',
2303: );
2304: foreach my $type (sort(keys(%broadcast_types))) {
2305: if (ref($recipients{$type}) eq 'ARRAY') {
2306: my $num = @{$recipients{$type}};
2307: my $broadcastlist = join(', ',@{$recipients{$type}});
2308: if ($broadcastlist && $broadcast_link) {
2309: if ($type eq 'group_cc_broadcast') {
2310: $groupcclist = $broadcastlist;
2311: }
2312: $r->print(&Apache::lonhtmlcommon::row_title(
2313: $broadcast_types{$type})
2314: .&mt('[quant,_1,recipient]',$num)
2315: .' <a href="javascript:showBroadcastList();">['
2316: .&mt('Show').']</a>'
2317: .&Apache::lonhtmlcommon::row_closure());
2318: }
2319: }
2320: }
2321: }
1.78 raeburn 2322: if ($content{'replytoaddr'}) {
2323: my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
2324: if ($replytoname ne '' && $replytodom ne '') {
1.91 bisitz 2325: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
1.95 raeburn 2326: .$replytoname.':'.$replytodom
1.91 bisitz 2327: .&Apache::lonhtmlcommon::row_closure()
2328: );
1.78 raeburn 2329: }
2330: }
1.73 raeburn 2331: } else {
1.91 bisitz 2332: # From, Reply
2333: $r->print(&Apache::lonhtmlcommon::row_title(&mt('From'))
2334: .&Apache::loncommon::aboutmewrapper(
2335: &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),
2336: $content{'sendername'},$content{'senderdomain'})
2337: );
1.78 raeburn 2338: if ($content{'noreplies'}) {
1.91 bisitz 2339: $r->print(' ('.&mt('No replies to sender').')'
2340: .&Apache::lonhtmlcommon::row_closure()
1.95 raeburn 2341: );
1.78 raeburn 2342: } else {
2343: if ($content{'replytoaddr'}) {
2344: my ($replytoname,$replytodom) = split(/:/,$content{'replytoaddr'});
2345: if ($replytoname ne '' && $replytodom ne '') {
1.91 bisitz 2346: $r->print(&Apache::lonhtmlcommon::row_closure()
2347: .&Apache::lonhtmlcommon::row_title(&mt('Reply To'))
1.95 raeburn 2348: .$replytoname.':'.$replytodom
1.91 bisitz 2349: .&Apache::lonhtmlcommon::row_closure()
2350: );
2351: } else {
2352: $r->print(&Apache::lonhtmlcommon::row_closure());
1.78 raeburn 2353: }
2354: } else {
1.95 raeburn 2355: $r->print(' ('.$content{'sendername'}.':'.$content{'senderdomain'}.') '
1.91 bisitz 2356: .&Apache::lonhtmlcommon::row_closure()
2357: );
1.78 raeburn 2358: }
1.95 raeburn 2359: if ($tonum && $tolist) {
2360: $r->print(&Apache::lonhtmlcommon::row_title(&mt('To'))
2361: .$tolist
2362: .&Apache::lonhtmlcommon::row_closure()
2363: );
2364: }
2365: if ($cclist) {
1.91 bisitz 2366: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Cc'))
2367: .$cclist
2368: .&Apache::lonhtmlcommon::row_closure()
2369: );
1.95 raeburn 2370: }
2371: if ($content{'group'} ne '') {
2372: if (&check_group_priv($content{'group'})) {
1.155 raeburn 2373: if (ref($recipients{'group_cc_broadcast'}) eq 'ARRAY') {
2374: $groupcclist = join(', ',@{$recipients{'group_cc_broadcast'}});
2375: if ($groupcclist) {
2376: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Group Cc'))
2377: .$groupcclist
2378: .&Apache::lonhtmlcommon::row_closure()
2379: );
2380: }
1.95 raeburn 2381: }
2382: }
1.78 raeburn 2383: }
1.91 bisitz 2384: }
1.73 raeburn 2385: }
1.91 bisitz 2386:
2387: # Course
1.157 raeburn 2388: if ($content{'courseid'} ne '') {
2389: if ($content{'courseid'} =~ m{^$match_domain\_$match_courseid$}) {
2390: my %courseinfo;
2391: %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'},
2392: {'one_time' => 1});
2393: my $description = $courseinfo{'description'};
2394: if ($description ne '') {
2395: $r->print(&Apache::lonhtmlcommon::row_title(&mt($crstype))
2396: .$description
2397: );
2398: if ($content{'coursesec'}) {
2399: $r->print(' ('.&mt('Section').': '.$content{'coursesec'}.')');
2400: }
2401: $r->print(&Apache::lonhtmlcommon::row_closure());
2402: }
1.73 raeburn 2403: }
2404: }
1.91 bisitz 2405: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Time'))
2406: .$content{'time'}
2407: .&Apache::lonhtmlcommon::row_closure()
2408: );
2409:
2410: # Refers to
1.59 raeburn 2411: if ($baseurl) {
2412: if (defined($content{'courseid'}) && defined($env{'request.course.id'})) {
2413: if ($content{'courseid'} eq $env{'request.course.id'}) {
2414: my $symblink;
1.62 raeburn 2415: my $showsymb = &Apache::lonenc::check_decrypt($symb);
2416: my $showurl = &Apache::lonenc::check_decrypt($baseurl);
2417: my $encrypturl = &Apache::lonnet::EXT('resource.0.encrypturl',
2418: $showsymb,$env{'user.domain'},$env{'user.name'});
1.59 raeburn 2419: if ($symb) {
1.62 raeburn 2420: if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
2421: $showsymb = &Apache::lonenc::check_encrypt($symb);
2422: }
2423: $symblink = '?symb='.$showsymb;
2424: }
2425: if ($encrypturl =~ /^yes$/i && !$env{'request.role.adv'}) {
2426: $showurl = $baseurl;
1.59 raeburn 2427: }
1.91 bisitz 2428: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2429: .'<a href="'.$showurl.$symblink.'">'.$restitle.'</a>'
2430: .&Apache::lonhtmlcommon::row_closure()
2431: );
1.59 raeburn 2432: $refers_to = 1;
2433: }
2434: }
2435: if (!$refers_to) {
2436: if ($baseurl =~ m-^/enc/-) {
2437: if (defined($content{'courseid'})) {
1.62 raeburn 2438: if (!$env{'request.course.id'}) {
2439: my $unencurl =
2440: &Apache::lonenc::unencrypted($baseurl,
2441: $content{'courseid'});
2442: if ($unencurl ne '') {
2443: if (&Apache::lonnet::allowed('bre',$unencurl)) {
1.91 bisitz 2444: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2445: .'<a href="'.$unencurl.'">'.$restitle.'</a>'
2446: .&Apache::lonhtmlcommon::row_closure()
2447: );
1.62 raeburn 2448: }
1.59 raeburn 2449: }
2450: }
2451: }
2452: } else {
2453: if (&Apache::lonnet::allowed('bre',$baseurl)) {
1.91 bisitz 2454: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Refers to'))
2455: .'<a href="'.$baseurl.'">'.$restitle.'</a>'
2456: .&Apache::lonhtmlcommon::row_closure()
2457: );
2458:
1.59 raeburn 2459: }
2460: }
2461: }
2462: }
1.91 bisitz 2463:
2464: # Message
2465: $r->print(&Apache::lonhtmlcommon::row_title(&mt('Message'))
2466: .'<pre>'
2467: .&Apache::lontexconvert::msgtexconverted($content{'message'},1)
2468: .'</pre>'
2469: );
2470: if (&displayresource(%content)) {
2471: $r->print(&Apache::lonhtmlcommon::row_closure()
2472: .&Apache::lonhtmlcommon::row_title(&mt('Resource Details'))
2473: .&displayresource(%content)
2474: );
2475: }
1.92 raeburn 2476: $r->print(&Apache::lonhtmlcommon::row_closure(1).
2477: &Apache::lonhtmlcommon::end_pick_box());
1.91 bisitz 2478: # Display LON-CAPA Message (End)
1.59 raeburn 2479: return;
1.1 albertel 2480: }
2481:
1.95 raeburn 2482: sub retrieve_recips {
2483: my ($context,$content,$recips)= @_;
2484: my $tonum = 0;
2485: if (ref($content) eq 'HASH') {
2486: my %reciphash =
2487: &Apache::lonnet::get('nohist_emailrecip',[$content->{'recipid'}],
2488: $content->{'senderdomain'},$content->{'sendername'});
2489: my $recipinfo = $reciphash{$content->{'recipid'}};
2490: if (ref($recipinfo) eq 'HASH') {
2491: foreach my $type ('to','cc','course_broadcast','group_cc_broadcast','group_bcc_broadcast') {
2492: if (ref($recipinfo->{$type}) eq 'HASH') {
2493: if ($type eq 'to') {
2494: $tonum = keys(%{$recipinfo->{$type}});
2495: }
2496: foreach my $user (sort(keys(%{$recipinfo->{$type}}))) {
2497: my ($uname,$udom) = split(/:/,$user);
2498: next if (($context eq 'replying') && ($uname eq $env{'user.name'})
2499: && ($udom eq $env{'user.domain'}));
2500: my $showuser ='<span class="LC_nobreak">';
2501: if ($context eq 'replying') {
2502: if (($type eq 'to') || ($type eq 'cc')) {
2503: $showuser = '<label><input type="checkbox" name="replying_'.$type.'" value="'.$user.'" />';
2504: } elsif ($type eq 'group_cc_broadcast') {
2505: $showuser = '<label><input type="checkbox" name="replying_groupcc" value="'.$user.'" />';
2506: }
2507: }
2508: $showuser .= &Apache::loncommon::aboutmewrapper(
2509: &Apache::loncommon::plainname($uname,
2510: $udom),$uname,$udom);
2511: if ($context eq 'replying') {
2512: $showuser .='</label>';
2513: }
2514: $showuser .= '</span>';
2515: if (ref($recips) eq 'HASH') {
2516: push(@{$recips->{$type}},$showuser);
2517: }
2518: }
1.73 raeburn 2519: }
2520: }
2521: }
2522: }
1.95 raeburn 2523: return $tonum;
2524: }
2525:
2526: sub recipients_link {
2527: my ($r,$content,$recipients) = @_;
2528: my ($broadcast_link,$show);
2529: if ((ref($content) eq 'HASH') && (ref($recipients) eq 'HASH')) {
2530: if (ref($recipients->{'course_broadcast'}) eq 'ARRAY') {
2531: if (@{$recipients->{'course_broadcast'}} > 0) {
2532: $show = 'course';
2533: }
2534: } elsif (ref($recipients->{'group_cc_broadcast'}) eq 'ARRAY') {
2535: if (@{$recipients->{'group_cc_broadcast'}} > 0) {
2536: $show = 'group_cc';
2537: }
2538: } elsif (ref($recipients->{'group_bcc_broadcast'}) eq 'ARRAY') {
2539: if (@{$recipients->{'group_bcc_broadcast'}} > 0) {
2540: $show = 'group_bcc';
2541: }
2542: }
2543: if ($show) {
2544: my ($nothing,$height,$width,$start_page,$end_page,$body);
2545: $nothing=&Apache::lonhtmlcommon::javascript_nothing();
2546: $height = 400;
2547: $width = 600;
1.108 raeburn 2548: $start_page =
2549: &Apache::loncommon::start_page('Broadcast List', undef,
2550: {only_body => 1,
2551: js_ready => 1,});
2552: $end_page = &Apache::loncommon::end_page({js_ready => 1,});
2553: $body = '<h3>'.&mt("Recipients of broadcast message").'</h3>'.
2554: &Apache::loncommon::start_data_table();
1.95 raeburn 2555: my $cell = 0;
2556: $body .= &Apache::loncommon::start_data_table_row();
2557: foreach my $item (@{$recipients->{$show.'_broadcast'}}) {
2558: $item =~ s/'/\\'/g;
2559: if (!($cell%2) && $cell > 0) {
2560: $body .= &Apache::loncommon::end_data_table_row().
2561: &Apache::loncommon::start_data_table_row();
2562: }
2563: $cell ++;
2564: $body .= '<td>'.$cell.' '.$item.' </td>';
2565: }
2566: if ($cell%2) {
2567: $body .= '<td> </td>';
2568: }
2569: $body .= &Apache::loncommon::end_data_table_row().
2570: &Apache::loncommon::end_data_table();
2571: $body =~ s{</}{<\\/}g;
2572: $body =~ s{\n}{}g;
2573: $r->print(<<ENDJS);
2574: <script type="text/javascript">
1.127 bisitz 2575: // <![CDATA[
1.95 raeburn 2576: function showBroadcastList() {
2577: var caller = this;
2578: var newWindow = null;
2579: try {
2580: newWindow = window.open($nothing,"broadcast","HEIGHT=$height,WIDTH=$width,resizable=yes,scrollbars=yes" );
2581: }
2582: catch(error) {
2583: writeWin(caller);
2584: return;
2585: }
2586: if (newWindow) {
2587: caller = newWindow;
2588: }
2589: writeWin(caller);
2590: return;
2591: }
2592:
2593: function writeWin(caller) {
2594: caller.document.writeln('$start_page $body $end_page');
2595: caller.document.close();
2596: caller.focus();
2597: }
1.127 bisitz 2598: // ]]>
1.95 raeburn 2599: </script>
2600:
2601: ENDJS
2602: $broadcast_link = 1;
2603: }
2604: }
2605: return $broadcast_link;
1.73 raeburn 2606: }
2607:
1.1 albertel 2608: # =========================================================== Show the citation
2609:
2610: sub displayresource {
2611: my %content=@_;
2612: #
2613: # If the recipient is in the same course that the message was sent from and
2614: # has sufficient privileges, show "all details," else show citation
2615: #
2616: if (($env{'request.course.id'} eq $content{'courseid'})
2617: && (&Apache::lonnet::allowed('vgr',$content{'courseid'}))) {
1.59 raeburn 2618: my $symb;
2619: if (defined($content{'symb'})) {
2620: $symb = $content{'symb'};
2621: } else {
2622: $symb=&Apache::lonnet::symbread($content{'baseurl'});
2623: }
1.1 albertel 2624: # Could not get a symb, give up
2625: unless ($symb) { return $content{'citation'}; }
2626: # Have a symb, can render
2627: return '<h2>'.&mt('Current attempts of student (if applicable)').'</h2>'.
2628: &Apache::loncommon::get_previous_attempt($symb,
2629: $content{'sendername'},
2630: $content{'senderdomain'},
2631: $content{'courseid'}).
2632: '<hr /><h2>'.&mt('Current screen output (if applicable)').'</h2>'.
2633: &Apache::loncommon::get_student_view($symb,
2634: $content{'sendername'},
2635: $content{'senderdomain'},
2636: $content{'courseid'}).
2637: '<h2>'.&mt('Correct Answer(s) (if applicable)').'</h2>'.
2638: &Apache::loncommon::get_student_answers($symb,
2639: $content{'sendername'},
2640: $content{'senderdomain'},
2641: $content{'courseid'});
2642: } elsif ($env{'user.adv'}) {
2643: return $content{'citation'};
2644: }
2645: return '';
2646: }
2647:
2648: # ================================================================== The Header
2649:
2650: sub header {
2651: my ($r,$title,$baseurl)=@_;
2652: my $extra = &Apache::loncommon::studentbrowser_javascript();
2653: if ($baseurl) {
1.41 albertel 2654: $extra .= "<base href=\"".&Apache::lonnet::absolute_url()."/$baseurl\" />";
1.1 albertel 2655: }
1.138 raeburn 2656: $r->print(&Apache::loncommon::start_page('Messages',
1.38 raeburn 2657: $extra));
1.1 albertel 2658: $r->print(&Apache::lonhtmlcommon::breadcrumbs
1.138 raeburn 2659: (($title?$title:'Send and display messages')));
1.1 albertel 2660: }
2661:
2662: # ---------------------------------------------------------------- Print header
2663:
2664: sub printheader {
2665: my ($r,$url,$desc,$title,$baseurl)=@_;
2666: &Apache::lonhtmlcommon::add_breadcrumb
2667: ({href=>$url,
2668: text=>$desc});
2669: &header($r,$title,$baseurl);
2670: }
2671:
2672: # ------------------------------------------------------------ Store the comment
2673:
2674: sub storecomment {
2675: my ($r)=@_;
2676: my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
2677: my $cleanmsgtxt='';
1.42 raeburn 2678: foreach my $line (split(/[\n\r]/,$msgtxt)) {
2679: unless ($line=~/^\s*(\>|\>\;)/) {
2680: $cleanmsgtxt.=$line."\n";
1.1 albertel 2681: }
2682: }
1.29 www 2683: my $key=&escape($env{'form.baseurl'}).'___'.time;
1.1 albertel 2684: &Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
2685: }
2686:
2687: sub storedcommentlisting {
2688: my ($r)=@_;
2689: my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
1.29 www 2690: '^'.&escape(&escape($env{'form.showcommentbaseurl'})));
1.72 albertel 2691: $r->print(&Apache::loncommon::start_page('Saved Comment Listing',undef,
1.1 albertel 2692: {'onlybody' => 1}));
2693: if ((keys %msgs)[0]=~/^error\:/) {
1.72 albertel 2694: $r->print(&mt('No saved comments yet.'));
1.1 albertel 2695: } else {
2696: my $found=0;
1.42 raeburn 2697: foreach my $key (sort(keys(%msgs))) {
2698: $r->print("\n".$msgs{$key}."<hr />");
1.1 albertel 2699: $found=1;
2700: }
2701: unless ($found) {
1.72 albertel 2702: $r->print(&mt('No saved comments yet for this resource.'));
1.1 albertel 2703: }
2704: }
2705: }
2706:
2707: # ---------------------------------------------------------------- Send an email
2708:
2709: sub sendoffmail {
2710: my ($r,$folder)=@_;
2711: my $suffix=&Apache::lonmsg::foldersuffix($folder);
2712: my $sendstatus='';
1.71 raeburn 2713: my %msg_status;
2714: my $numsent = 0;
2715: my $nosentstore = 1;
1.86 raeburn 2716: my $attachmenturl;
2717: my $now = time;
1.38 raeburn 2718: my ($cdom,$cnum,$group);
2719: if (exists($env{'form.group'})) {
2720: $group = $env{'form.group'};
2721: }
2722: if (exists($env{'request.course.id'})) {
2723: $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
2724: $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
2725: }
1.1 albertel 2726: if ($env{'form.send'}) {
1.53 raeburn 2727: if (!$env{'form.multiforward'}) {
2728: if ($group eq '') {
2729: &printheader($r,'','Messages being sent.');
2730: } else {
2731: $r->print(&groupmail_header('sending',$group));
2732: }
1.38 raeburn 2733: }
1.1 albertel 2734: $r->rflush();
2735: my %content=();
2736: undef %content;
2737: if ($env{'form.forwid'}) {
2738: my $msgid=$env{'form.forwid'};
2739: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1.86 raeburn 2740: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1);
1.1 albertel 2741: &statuschange($msgid,'forwarded',$folder);
1.86 raeburn 2742: if ($content{'attachmenturl'} ne '') {
2743: $attachmenturl = $content{'attachmenturl'};
2744: }
2745: $env{'form.message'} .= "\n\n-- Forwarded message --\n\n".
2746: $content{'message'};
1.1 albertel 2747: }
2748: if ($env{'form.replyid'}) {
2749: my $msgid=$env{'form.replyid'};
2750: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
2751: %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1);
2752: &statuschange($msgid,'replied',$folder);
2753: }
1.13 albertel 2754:
1.25 foxr 2755: my $mode = $env{'form.sendmode'};
1.95 raeburn 2756: my (%toaddr,$tos,$cc,$bcc,$broadcast);
1.25 foxr 2757:
1.95 raeburn 2758: if ($mode eq 'group') {
2759: if (defined($env{'form.courserecips'})) {
2760: my $courseusers = $env{'form.courserecips'};
2761: $courseusers =~ s/^_\&\&\&_//;
2762: my @to = split('_&&&_',$courseusers);
2763: foreach my $dest (@to) {
2764: my ($user,$domain) = split(/:/, $dest);
2765: if (($user ne '') && ($domain ne '')) {
2766: my $rec = $user.":".$domain;
2767: $toaddr{$rec} = '';
2768: $broadcast->{$rec} = '';
2769: }
2770: }
2771: }
2772: } elsif ($mode eq 'upload') {
1.71 raeburn 2773: $nosentstore = 0;
1.13 albertel 2774: foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
1.43 raeburn 2775: my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
1.1 albertel 2776: if ($txt) {
1.43 raeburn 2777: $rec =~ s/^\s+//;
1.44 raeburn 2778: $rec =~ s/\s+$//;
1.1 albertel 2779: $toaddr{$rec}.=$txt."\n";
1.95 raeburn 2780: $broadcast->{$rec} = '';
1.1 albertel 2781: }
2782: }
2783: } else {
1.25 foxr 2784: if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) {
2785: $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
1.95 raeburn 2786: $tos->{$env{'form.recuname'}.':'.$env{'form.recdomain'}}='';
1.25 foxr 2787: }
1.1 albertel 2788: }
1.95 raeburn 2789: if ($env{'form.additionalrec_to'}) {
2790: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_to'})) {
2791: my ($auname,$audom)=split(/:/,$rec);
2792: if (($auname ne "") && ($audom ne "")) {
2793: $toaddr{$auname.':'.$audom}='';
2794: $tos->{$auname.':'.$audom}='';
2795: }
2796: }
2797: }
2798: if ($env{'form.replying_to'}) {
2799: my @toreplies =
2800: &Apache::loncommon::get_env_multiple('form.replying_to');
2801: foreach my $rec (@toreplies) {
2802: my ($auname,$audom)=split(/:/,$rec);
2803: if (($auname ne "") && ($audom ne "")) {
2804: $toaddr{$auname.':'.$audom}='';
2805: $tos->{$auname.':'.$audom}='';
2806: }
2807: }
2808: }
1.73 raeburn 2809: if ($env{'form.additionalrec_cc'}) {
2810: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_cc'})) {
1.43 raeburn 2811: my ($auname,$audom)=split(/:/,$rec);
1.25 foxr 2812: if (($auname ne "") && ($audom ne "")) {
1.73 raeburn 2813: $toaddr{$auname.':'.$audom}='';
1.95 raeburn 2814: if (!defined($tos->{$auname.':'.$audom})) {
2815: $cc->{$auname.':'.$audom}='';
2816: }
1.25 foxr 2817: }
1.1 albertel 2818: }
2819: }
1.95 raeburn 2820: if ($env{'form.replying_cc'}) {
2821: my @ccreplies =
2822: &Apache::loncommon::get_env_multiple('form.replying_cc');
2823: foreach my $rec (@ccreplies) {
2824: my ($auname,$audom)=split(/:/,$rec);
2825: if (($auname ne "") && ($audom ne "")) {
2826: $toaddr{$auname.':'.$audom}='';
2827: if (!defined($tos->{$auname.':'.$audom})) {
2828: $cc->{$auname.':'.$audom}='';
2829: }
2830: }
2831: }
2832: }
2833: if ($env{'form.replying_groupcc'}) {
2834: my @groupreplies =
2835: &Apache::loncommon::get_env_multiple('form.replying_groupcc');
2836: foreach my $rec (@groupreplies) {
1.73 raeburn 2837: my ($auname,$audom)=split(/:/,$rec);
2838: if (($auname ne "") && ($audom ne "")) {
2839: $toaddr{$auname.':'.$audom}='';
1.95 raeburn 2840: if (!defined($tos->{$auname.':'.$audom})) {
2841: $broadcast->{$auname.':'.$audom}='';
2842: }
1.73 raeburn 2843: }
2844: }
2845: }
1.95 raeburn 2846: if ($env{'form.additionalrec_bcc'}) {
2847: foreach my $rec (split(/\s*,\s*/,$env{'form.additionalrec_bcc'})) {
1.73 raeburn 2848: my ($auname,$audom)=split(/:/,$rec);
2849: if (($auname ne "") && ($audom ne "")) {
2850: $toaddr{$auname.':'.$audom}='';
1.95 raeburn 2851: if ((!defined($tos->{$auname.':'.$audom})) &&
2852: (!defined($cc->{$auname.':'.$audom}))) {
2853: $bcc->{$auname.':'.$audom}='';
2854: }
1.73 raeburn 2855: }
2856: }
2857: }
1.1 albertel 2858: my $savemsg;
2859: my $msgtype;
2860: my %sentmessage;
1.7 albertel 2861: my $msgsubj=&Apache::lonfeedback::clear_out_html($env{'form.subject'},
2862: undef,1);
1.1 albertel 2863: if ((($env{'form.critmsg'}) || ($env{'form.sendbck'})) &&
2864: (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
2865: || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
2866: '/'.$env{'request.course.sec'})
2867: )) {
2868: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'},1);
2869: $msgtype = 'critical';
2870: } else {
2871: $savemsg=&Apache::lonfeedback::clear_out_html($env{'form.message'});
2872: }
1.73 raeburn 2873: my %reciphash = (
1.95 raeburn 2874: to => $tos,
1.73 raeburn 2875: cc => $cc,
2876: bcc => $bcc,
1.95 raeburn 2877: );
2878: if ($mode eq 'group') {
2879: if ($group eq '') {
2880: $reciphash{'course_broadcast'} = $broadcast;
2881: } else {
2882: if ($env{'form.groupmail'} eq 'cc') {
2883: $reciphash{'group_cc_broadcast'} = $broadcast;
2884: } else {
2885: $reciphash{'group_bcc_broadcast'} = $broadcast;
2886: }
2887: }
2888: }
1.73 raeburn 2889: my ($recipid,$recipstatus) =
2890: &Apache::lonmsg::store_recipients($msgsubj,$env{'user.name'},
2891: $env{'user.domain'},\%reciphash);
2892: if ($recipstatus ne 'ok') {
1.95 raeburn 2893: &Apache::lonnet::logthis('Failed to store To, Bcc and Cc recipients for '.$env{'user.name'}.':'.$env{'user.domain'});
1.86 raeburn 2894: }
2895: if ($env{'form.attachment'}) {
2896: if (length($env{'form.attachment'})<131072) {
2897: $attachmenturl=&Apache::lonnet::userfileupload('attachment',undef,'feedback/'.$now);
2898: } else {
2899: $r->print('<p><span class="LC_warning">'.&mt('Attachment not included - exceeded permitted length').'</span><br /></p>');
2900: }
2901: } elsif ($env{'form.multiforward'}) {
2902: if ($env{'form.attachmenturl'} ne '') {
2903: $attachmenturl = $env{'form.attachmenturl'};
2904: }
2905: }
1.71 raeburn 2906: my @recusers;
2907: my @recudoms;
1.13 albertel 2908: foreach my $address (sort(keys(%toaddr))) {
2909: my ($recuname,$recdomain)=split(/\:/,$address);
1.1 albertel 2910: my $msgtxt = $savemsg;
1.73 raeburn 2911: if ($toaddr{$address}) {
1.151 raeburn 2912: $msgtxt.="\n".'<hr />'."\n".$toaddr{$address};
1.73 raeburn 2913: }
1.12 albertel 2914: my @thismsg;
1.60 raeburn 2915: if ($msgtype eq 'critical') {
2916: $r->print(&mt('Sending critical message').' '.
2917: $recuname.':'.$recdomain.': ');
1.13 albertel 2918: @thismsg=
2919: &Apache::lonmsg::user_crit_msg($recuname,$recdomain,
2920: $msgsubj,$msgtxt,
2921: $env{'form.sendbck'},
2922: $env{'form.permanent'},
1.71 raeburn 2923: \$sentmessage{$address},
1.73 raeburn 2924: $nosentstore,$recipid);
1.1 albertel 2925: } else {
1.14 albertel 2926: $r->print(&mt('Sending').' '.$recuname.':'.$recdomain.': ');
1.13 albertel 2927: @thismsg=
2928: &Apache::lonmsg::user_normal_msg($recuname,$recdomain,
2929: $msgsubj,$msgtxt,
2930: $content{'citation'},
1.86 raeburn 2931: undef,$attachmenturl,
1.13 albertel 2932: $env{'form.permanent'},
1.71 raeburn 2933: \$sentmessage{$address},
2934: undef,undef,undef,
1.73 raeburn 2935: $nosentstore,$recipid);
1.71 raeburn 2936: }
2937: $msg_status{$recuname.':'.$recdomain}=join(' ',@thismsg);
2938: if ($msg_status{$recuname.':'.$recdomain} =~ /(ok|con_delayed)/) {
2939: $numsent++;
2940: push(@recusers,$recuname);
2941: push(@recudoms,$recdomain);
1.1 albertel 2942: }
1.12 albertel 2943: $sendstatus.=' '.join(' ',@thismsg);
1.1 albertel 2944: }
1.71 raeburn 2945: my $subj_prefix;
2946: if ($numsent > 0) {
2947: if (($env{'request.course.id'}) &&
1.95 raeburn 2948: (($mode eq 'group') ||
1.71 raeburn 2949: ($env{'form.courserecord'}) ||
1.95 raeburn 2950: ($msgtype eq 'critical')) ||
2951: ($env{'form.replyid'} &&
2952: (($content{'courseid'} ne '') &&
2953: ($mode eq 'group')))) {
1.71 raeburn 2954: if ($msgtype eq 'critical') {
2955: $subj_prefix = 'Critical.';
1.95 raeburn 2956: } elsif ($mode eq 'group') {
1.71 raeburn 2957: $subj_prefix = 'Broadcast.';
2958: } else {
2959: $subj_prefix = 'Archive';
2960: }
2961: my ($specialmsgid,$specialresult);
1.95 raeburn 2962: my $course_str;
2963: if ($env{'form.replyid'}) {
2964: if ($content{'courseid'} ne '') {
2965: my %crsdesc =
2966: &Apache::lonnet::coursedescription($content{'courseid'},
2967: {'one_time' => 1});
2968: $course_str = &escape('['.$crsdesc{'num'}.':'.$crsdesc{'domain'}.']');
2969: }
2970: } elsif ($env{'request.course.id'}) {
2971: $course_str = &escape('['.$cnum.':'.$cdom.']');
2972: }
1.71 raeburn 2973: $specialresult =
2974: &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
2975: $subj_prefix.' '.$course_str,$savemsg,undef,undef,
1.86 raeburn 2976: $attachmenturl,undef,undef,\$specialmsgid,undef,undef,undef,
1.71 raeburn 2977: undef,undef,1);
1.29 www 2978: $specialmsgid = &unescape($specialmsgid);
1.71 raeburn 2979: if ($specialresult eq 'ok') {
2980: my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
2981: split(/\:/,&unescape($specialmsgid));
2982:
2983: foreach my $recipient (sort(keys(%toaddr))) {
2984: if ($msg_status{$recipient} =~ /\s*(ok|con_delayed)\s*/) {
2985: my $usersubj = $subj_prefix.'['.$recipient.']';
2986: my $usermsgid =
2987: &Apache::lonmsg::buildmsgid($stamp,$usersubj,
2988: $msgname,$msgdom,
2989: $msgcount,$context,
2990: $pid);
2991: &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,
2992: $subj_prefix.' ['.$recipient.']',$msgsubj,
1.86 raeburn 2993: undef,undef,$attachmenturl,undef,$usermsgid,undef,
1.71 raeburn 2994: undef,$specialmsgid,undef,undef,undef,1);
2995: }
2996: }
1.95 raeburn 2997: if (($mode ne 'upload') && (@recusers > 0)) {
1.71 raeburn 2998: &Apache::lonmsg::process_sent_mail($msgsubj,
2999: $subj_prefix,$numsent,$stamp,$msgname,$msgdom,
3000: $msgcount,$context,$pid,$savemsg,\@recusers,
1.95 raeburn 3001: \@recudoms,undef,$attachmenturl,'','','','',$recipid);
1.1 albertel 3002: }
1.71 raeburn 3003: } else {
1.78 raeburn 3004: &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 3005: }
3006: } else {
1.71 raeburn 3007: my $stamp = time;
3008: my $msgcount = &Apache::lonmsg::get_uniq();
3009: my $context = &Apache::lonmsg::get_course_context();
3010: &Apache::lonmsg::process_sent_mail($msgsubj,$subj_prefix,
3011: $numsent,$stamp,$env{'user.name'},
3012: $env{'user.domain'},$msgcount,$context,
1.95 raeburn 3013: $$,$savemsg,\@recusers,\@recudoms,undef,$attachmenturl,
3014: '','','','',$recipid);
1.1 albertel 3015: }
3016: }
1.143 wenzelju 3017: if (!$env{'form.multiforward'}) {
1.71 raeburn 3018: if ($sendstatus=~/^(\s*(?:ok|con_delayed)\s*)*$/) {
1.143 wenzelju 3019: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Completed.'));
3020: $message = &Apache::loncommon::confirmwrapper($message);
3021: $r->print($message);
1.71 raeburn 3022: if ($env{'form.displayedcrit'}) {
3023: &discrit($r);
3024: }
3025: if ($group ne '') {
3026: $r->print(&groupmail_sent($group,$cdom,$cnum));
3027: } else {
3028: &Apache::loncommunicate::menu($r);
3029: }
3030: } else {
1.143 wenzelju 3031: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not deliver message'),1);
1.145 raeburn 3032: $message .= '<br />'.&mt('Please use the browser "Back" button and correct the recipient addresses ([_1]).',$sendstatus);
1.143 wenzelju 3033: $message = &Apache::loncommon::confirmwrapper($message);
3034: $r->print($message);
1.53 raeburn 3035: }
1.38 raeburn 3036: }
1.152 www 3037: } else {
3038: &printheader($r,'','Messages cancelled.');
3039: return 'cancelled';
1.1 albertel 3040: }
1.53 raeburn 3041: return $sendstatus;
1.1 albertel 3042: }
3043:
3044: # ===================================================================== Handler
3045:
3046: sub handler {
3047: my $r=shift;
3048:
3049: # ----------------------------------------------------------- Set document type
3050:
3051: &Apache::loncommon::content_type($r,'text/html');
3052: $r->send_http_header;
3053:
3054: return OK if $r->header_only;
3055:
3056: # --------------------------- Get query string for limited number of parameters
3057: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
3058: ['display','replyto','forward','markread','markdel','markunread',
3059: 'sendreply','compose','sendmail','critical','recname','recdom',
1.159 raeburn 3060: 'recordftf','sortedby','folder','startdis','interdis',
1.53 raeburn 3061: 'showcommentbaseurl','dismode','group','subject','text','ref',
3062: 'msgstatus']);
1.127 bisitz 3063: $sqs='&sortedby='.$env{'form.sortedby'};
1.1 albertel 3064:
3065: # ------------------------------------------------------ They checked for email
1.159 raeburn 3066: &Apache::lonnet::put('email_status',{'recnewemail'=>0});
1.1 albertel 3067:
3068: # ----------------------------------------------------------------- Breadcrumbs
3069:
3070: &Apache::lonhtmlcommon::clear_breadcrumbs();
3071: &Apache::lonhtmlcommon::add_breadcrumb
3072: ({href=>"/adm/communicate",
1.138 raeburn 3073: text=>"Messages",
1.1 albertel 3074: faq=>12,bug=>'Communication Tools',});
3075:
3076: # ------------------------------------------------------------------ Get Folder
3077:
3078: my $folder=$env{'form.folder'};
3079: unless ($folder) {
3080: $folder='';
3081: } else {
1.127 bisitz 3082: $sqs.='&folder='.&escape($folder);
1.1 albertel 3083: }
3084: # ------------------------------------------------------------ Get Display Mode
3085:
3086: my $dismode=$env{'form.dismode'};
3087: unless ($dismode) {
3088: $dismode='';
3089: } else {
1.48 albertel 3090: $sqs.='&dismode='.&escape($dismode);
1.1 albertel 3091: }
3092:
3093: # --------------------------------------------------------------------- Display
1.53 raeburn 3094: my $msgstatus = $env{'form.msgstatus'};
1.1 albertel 3095: $startdis=$env{'form.startdis'};
1.53 raeburn 3096: if ($startdis ne '') {
3097: $startdis--;
3098: }
1.1 albertel 3099: unless ($startdis) { $startdis=0; }
3100:
3101: if ($env{'form.firstview'}) {
3102: $startdis=0;
3103: }
3104: if ($env{'form.lastview'}) {
3105: $startdis=-1;
3106: }
3107: if ($env{'form.prevview'}) {
3108: $startdis--;
3109: }
3110: if ($env{'form.nextview'}) {
3111: $startdis++;
3112: }
3113: my $postedstartdis=$startdis+1;
1.127 bisitz 3114: $sqs.='&startdis='.$postedstartdis;
1.1 albertel 3115:
3116: # --------------------------------------------------------------- Render Output
3117:
3118: if ($env{'form.display'}) {
1.53 raeburn 3119: &displaymessage($r,$env{'form.display'},$folder,$msgstatus);
1.1 albertel 3120: } elsif ($env{'form.replyto'}) {
3121: &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
3122: } elsif ($env{'form.confirm'}) {
3123: &printheader($r,'','Confirmed Receipt');
1.36 albertel 3124: my $replying = 0;
1.42 raeburn 3125: foreach my $envkey (keys(%env)) {
1.75 raeburn 3126: if ($envkey=~/^form\.(rep)?rec\_(.*)$/) {
1.77 raeburn 3127: my $repchk = $1;
1.75 raeburn 3128: my $msgid = $2;
3129: $r->print('<b>'.&mt('Confirming Receipt').':</b> ');
3130: my $result = &Apache::lonmsg::user_crit_received($msgid);
3131: if ($result =~ /trans:\s+ok/) {
3132: &statuschange($msgid,'read');
3133: }
1.76 albertel 3134: $r->print($result.'<br />');
1.77 raeburn 3135: if ($repchk eq 'rep') {
1.75 raeburn 3136: &compout($r,'','','',$msgid);
3137: $replying = 1;
3138: }
1.1 albertel 3139: }
3140: }
1.36 albertel 3141: if (!$replying) {
3142: &discrit($r);
3143: }
1.1 albertel 3144: } elsif ($env{'form.critical'}) {
3145: &printheader($r,'','Displaying Critical Messages');
3146: &discrit($r);
3147: } elsif ($env{'form.forward'}) {
3148: &compout($r,$env{'form.forward'},undef,undef,undef,$folder);
3149: } elsif ($env{'form.markdel'}) {
3150: &printheader($r,'','Deleted Message');
1.9 albertel 3151: my ($result,$msg) =
3152: &statuschange($env{'form.markdel'},'deleted',$folder);
3153: if (!$result) {
1.143 wenzelju 3154: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Failed to delete the message.'),1);
1.147 wenzelju 3155: $message .= '<p class="LC_error" style="font-size: inherit;">'.$msg.'</p>';
1.143 wenzelju 3156: $message = &Apache::loncommon::confirmwrapper($message);
3157: $r->print($message);
1.9 albertel 3158: }
1.1 albertel 3159: &Apache::loncommunicate::menu($r);
1.53 raeburn 3160: &disall($r,($folder?$folder:$dismode),$msgstatus);
3161: } elsif ($env{'form.markedaction'} eq 'markedforward') {
3162: my $total = 0;
3163: my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
3164: foreach my $msgid (@to_forward) {
3165: &statuschange(&unescape($msgid),'forwarded',$folder);
3166: $total ++;
3167: }
3168: if ($total > 0) {
3169: &compout($r,undef,undef,undef,undef,$folder,$dismode,$total);
3170: }
3171: } elsif ($env{'form.markedaction'} eq 'markedread') {
3172: my $total = 0;
3173: my @to_markread = &Apache::loncommon::get_env_multiple('form.delmark');
3174: foreach my $msgid (@to_markread) {
3175: &statuschange(&unescape($msgid),'read',$folder);
3176: $total ++;
3177: }
3178: &printheader($r,'','Marked Messages Read');
1.143 wenzelju 3179: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Marked [quant,_1,message] read',$total));
3180: $message = &Apache::loncommon::confirmwrapper($message);
3181: $r->print($message);
3182: # $r->print('<p>');
1.53 raeburn 3183: &Apache::loncommunicate::menu($r);
3184: &disall($r,($folder?$folder:$dismode),$msgstatus);
3185: } elsif ($env{'form.markedaction'} eq 'markedunread') {
3186: my $total = 0;
3187: my @to_markunread = &Apache::loncommon::get_env_multiple('form.delmark');
3188: foreach my $msgid (@to_markunread) {
3189: &statuschange(&unescape($msgid),'new',$folder);
3190: $total ++;
3191: }
3192: &printheader($r,'','Marked Messages Unread');
1.143 wenzelju 3193: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Marked [quant,_1,message] unread',$total));
3194: $message = &Apache::loncommon::confirmwrapper($message);
3195: $r->print($message);
3196: # $r->print('<p>');
1.53 raeburn 3197: &Apache::loncommunicate::menu($r);
3198: &disall($r,($folder?$folder:$dismode),$msgstatus);
3199: } elsif ($env{'form.markedaction'} eq 'markedmove') {
3200: my $destfolder = $env{'form.movetofolder'};
3201: my %gotfolders = &Apache::lonmsg::get_user_folders();
3202: &printheader($r,'','Moved Messages');
3203: if (!defined($gotfolders{$destfolder})) {
3204: $r->print(&mt('Destination folder [_1] is not a valid folder',
1.148 bisitz 3205: '<span class="LC_filename">'.$destfolder.'</span>'));
1.53 raeburn 3206: } else {
3207: my ($total,$failed,@failed_msg)=(0,0);
3208: my @to_move = &Apache::loncommon::get_env_multiple('form.delmark');
3209: foreach my $msgid (@to_move) {
3210: my ($result,$msg) = &movemsg(&unescape($msgid),$folder,
3211: $env{'form.movetofolder'});
3212: if ($result) {
1.9 albertel 3213: $total++;
1.53 raeburn 3214: } else {
1.9 albertel 3215: $failed++;
3216: push(@failed_msg,$msg);
1.53 raeburn 3217: }
1.1 albertel 3218: }
1.143 wenzelju 3219: my $message = '';
3220: if ($failed) {
3221: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Failed to move [quant,_1,message]',$failed),1);
1.147 wenzelju 3222: $message .= '<p class="LC_error" style="font-size: inherit;">'.
3223: join("</p>\n<p class=\"LC_error\" style=\"font-size: inherit;\">",@failed_msg).
1.143 wenzelju 3224: "</p>\n";
3225: }
3226: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Moved [quant,_1,message]',$total));
3227: $message = &Apache::loncommon::confirmwrapper($message);
3228: $r->print($message);
3229: # $r->print('<p>');
1.53 raeburn 3230: }
1.1 albertel 3231: &Apache::loncommunicate::menu($r);
1.53 raeburn 3232: &disall($r,($folder?$folder:$dismode),$msgstatus);
3233: } elsif ($env{'form.markedaction'} eq 'markeddel') {
1.9 albertel 3234: my ($total,$failed,@failed_msg)=(0,0);
1.53 raeburn 3235: my @to_delete = &Apache::loncommon::get_env_multiple('form.delmark');
3236: foreach my $msgid (@to_delete) {
3237: my ($result,$msg) = &statuschange(&unescape($msgid),'deleted',
3238: $folder);
3239: if ($result) {
3240: $total++;
3241: } else {
3242: $failed++;
3243: push(@failed_msg,$msg);
1.1 albertel 3244: }
3245: }
3246: &printheader($r,'','Deleted Messages');
1.143 wenzelju 3247: my $message = '';
1.9 albertel 3248: if ($failed) {
1.143 wenzelju 3249: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Failed to delete [quant,_1,message]',$failed),1);
1.147 wenzelju 3250: $message .= '<p class="LC_error" style="font-size: inherit;">'.
3251: join("</p>\n<p class=\"LC_error\" style=\"font-size: inherit;\">",@failed_msg).
1.143 wenzelju 3252: "</p>\n";
1.9 albertel 3253: }
1.143 wenzelju 3254: $message .= &Apache::lonhtmlcommon::confirm_success(&mt('Deleted [quant,_1,message]',$total));
3255: $message = &Apache::loncommon::confirmwrapper($message);
3256: $r->print($message);
3257: # $r->print('<p>');
1.1 albertel 3258: &Apache::loncommunicate::menu($r);
1.53 raeburn 3259: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3260: } elsif ($env{'form.markunread'}) {
3261: &printheader($r,'','Marked Message as Unread');
3262: &statuschange($env{'form.markunread'},'new');
3263: &Apache::loncommunicate::menu($r);
1.53 raeburn 3264: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3265: } elsif ($env{'form.compose'}) {
3266: &compout($r,'','',$env{'form.compose'});
3267: } elsif ($env{'form.recordftf'}) {
3268: &facetoface($r,$env{'form.recordftf'});
3269: } elsif ($env{'form.sendmail'}) {
1.53 raeburn 3270: if ($env{'form.multiforward'}) {
3271: &printheader($r,'','Messages being sent.');
3272: my $fixed_subj = $env{'form.subject'};
3273: my $suffix=&Apache::lonmsg::foldersuffix($folder);
3274: my (%sendresult,%forwardok,%forwardfail,$fwdcount);
3275: my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
3276: foreach my $item (@to_forward) {
3277: my $msgid=&unescape($item);
3278: my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
1.86 raeburn 3279: my %content=&Apache::lonmsg::unpackagemsg($message{$msgid},1,1);
1.53 raeburn 3280: if ($env{'form.showorigsubj'}) {
3281: $env{'form.subject'} = $fixed_subj.$content{'subject'};
3282: } else {
3283: $env{'form.subject'} = '';
3284: }
3285: my $uname = $content{'sendername'};
3286: my $udom = $content{'senderdomain'};
3287: &statuschange($msgid,'forwarded',$folder);
3288: if ($env{'form.showorigsender'}) {
3289: $env{'form.message'} = $env{'form.msgheader'}.' '.
3290: &Apache::loncommon::plainname($uname,$udom).' ('.
3291: $uname.':'.$udom.')';
3292: }
1.86 raeburn 3293: $env{'form.message'}.="\n\n-- Forwarded message --\n\n".
3294: $content{'message'};
3295: $env{'form.attachmenturl'} = $content{'attachmenturl'};
3296: $env{'form.multiforwid'} = $item;
1.53 raeburn 3297: $fwdcount ++;
3298: $r->print($fwdcount.': ');
3299: $sendresult{$msgid} = &sendoffmail($r,$folder);
3300: $r->print('<br />');
3301: }
3302: foreach my $key (keys(%sendresult)) {
3303: if ($sendresult{$key} =~/^(\s*(?:ok|con_delayed)\s*)*$/) {
3304: $forwardok{$key} = $sendresult{$key};
3305: } else {
3306: $forwardfail{$key} = $sendresult{$key};
3307: }
3308: }
3309: if (keys(%forwardok) > 0) {
3310: my $count = keys(%forwardok);
1.143 wenzelju 3311: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('[quant,_1,message] forwarded.',$count));
3312: $message = &Apache::loncommon::confirmwrapper($message);
3313: $r->print($message);
1.53 raeburn 3314: }
3315: if (keys(%forwardfail) > 0) {
3316: my $count = keys(%forwardfail);
1.143 wenzelju 3317: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Could not forward [quant,_1,message].',$count),1);
1.53 raeburn 3318: foreach my $key (keys(%forwardfail)) {
1.145 raeburn 3319: $message .= '<br />'.&mt('Could not deliver forwarded message.').'</span> '.
1.143 wenzelju 3320: &mt('The recipient addresses may need to be corrected').' ('.$forwardfail{$key}.')';
1.53 raeburn 3321: }
1.143 wenzelju 3322: $message = &Apache::loncommon::confirmwrapper($message);
3323: $r->print($message);
1.53 raeburn 3324: }
3325: &Apache::loncommunicate::menu($r);
3326: } else {
3327: &sendoffmail($r,$folder);
3328: }
1.1 albertel 3329: if ($env{'form.storebasecomment'}) {
3330: &storecomment($r);
1.38 raeburn 3331: }
1.1 albertel 3332: if (($env{'form.rsspost'}) && ($env{'request.course.id'})) {
1.38 raeburn 3333: &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'},
1.1 albertel 3334: $env{'course.'.$env{'request.course.id'}.'.domain'},
3335: 'Course_Announcements',
3336: $env{'form.subject'},
3337: $env{'form.message'},'/adm/communicate','public');
3338: }
1.38 raeburn 3339: if ((!exists($env{'form.group'})) && (!$env{'form.displayedcrit'})) {
1.53 raeburn 3340: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.36 albertel 3341: }
1.1 albertel 3342: } elsif ($env{'form.newfolder'}) {
3343: &printheader($r,'','New Folder');
1.46 raeburn 3344: my $showfolder = $env{'form.newfolder'};
3345: my ($makeresult,$warning) = &makefolder($env{'form.newfolder'});
3346: if ($makeresult eq 'ok') {
1.143 wenzelju 3347: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" created.',$showfolder));
3348: $message = &Apache::loncommon::confirmwrapper($message);
3349: $r->print($message);
1.46 raeburn 3350: } else {
1.143 wenzelju 3351: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Creation failed.').' '.$makeresult.'<br />'.$warning,1);
3352: $message = &Apache::loncommon::confirmwrapper($message);
3353: $r->print($message);
1.46 raeburn 3354: $showfolder = $folder;
3355: }
3356: &Apache::loncommunicate::menu($r);
1.53 raeburn 3357: &disall($r,$showfolder,$msgstatus);
1.1 albertel 3358: } elsif ($env{'form.showcommentbaseurl'}) {
3359: &storedcommentlisting($r);
1.46 raeburn 3360: } elsif ($env{'form.folderaction'} eq 'delete') {
3361: &printheader($r,'','Deleted Folder');
3362: my $showfolder = '';
3363: my $delresult = &deletefolder($folder);
3364: if ($delresult eq 'ok') {
1.143 wenzelju 3365: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" deleted.',$folder));
3366: $message = &Apache::loncommon::confirmwrapper($message);
3367: $r->print($message);
1.65 raeburn 3368: $env{'form.folder'} = '';
1.46 raeburn 3369: } else {
1.143 wenzelju 3370: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Deletion failed.').' '.$delresult,1);
3371: $message = &Apache::loncommon::confirmwrapper($message);
3372: $r->print($message);
1.46 raeburn 3373: $showfolder = $folder;
3374: }
3375: &Apache::loncommunicate::menu($r);
1.53 raeburn 3376: &disall($r,$showfolder,$msgstatus);
1.46 raeburn 3377: } elsif ($env{'form.folderaction'} eq 'rename') {
3378: &printheader($r,'','Renamed Folder');
3379: my $showfolder = $env{'form.renamed'};
3380: my $renresult = &renamefolder($folder);
3381: if ($renresult eq 'ok') {
1.143 wenzelju 3382: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Folder "[_1]" renamed to "[_2]".',$folder,$showfolder));
3383: $message = &Apache::loncommon::confirmwrapper($message);
3384: $r->print($message);
1.46 raeburn 3385: } else {
1.143 wenzelju 3386: my $message = &Apache::lonhtmlcommon::confirm_success(&mt('Renaming failed.').' '.$renresult,1);
3387: $message = &Apache::loncommon::confirmwrapper($message);
3388: $r->print($message);
1.46 raeburn 3389: $showfolder = $folder;
3390: }
3391: &Apache::loncommunicate::menu($r);
1.53 raeburn 3392: &disall($r,$showfolder,$msgstatus);
1.1 albertel 3393: } else {
1.112 weissno 3394: &printheader($r,'','Display All Messages');
1.44 raeburn 3395: &Apache::loncommunicate::menu($r);
1.53 raeburn 3396: &disall($r,($folder?$folder:$dismode),$msgstatus);
1.1 albertel 3397: }
3398: $r->print(&Apache::loncommon::end_page());
3399: return OK;
3400: }
3401: # ================================================= Main program, reset counter
3402:
3403: =pod
3404:
3405: =cut
3406:
3407: 1;
3408:
3409: __END__
3410:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>