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