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