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