--- loncom/interface/lonmsg.pm 2002/09/16 20:06:12 1.39 +++ loncom/interface/lonmsg.pm 2002/12/30 14:10:58 1.46 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging # -# $Id: lonmsg.pm,v 1.39 2002/09/16 20:06:12 albertel Exp $ +# $Id: lonmsg.pm,v 1.46 2002/12/30 14:10:58 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -119,6 +119,17 @@ sub unpackmsgid { return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid}); } +# ============================================================= Check for email + +sub newmail { + if ((time-$ENV{'user.mailcheck.time'})>300) { + my %what=&Apache::lonnet::get('email_status',['recnewemail']); + &Apache::lonnet::appenv('user.mailcheck.time'=>time); + if ($what{'recnewemail'}>0) { return 1; } + } + return 0; +} + # =============================== Automated message to the author of a resource sub author_res_msg { @@ -155,6 +166,13 @@ sub user_crit_msg_raw { 'put:'.$domain.':'.$user.':critical:'. &Apache::lonnet::escape($msgid).'='. &Apache::lonnet::escape($message),$homeserver); + if ($ENV{'request.course.id'}) { + &user_normal_msg_raw( + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + 'Critical ['.$user.':'.$domain.']', + $message); + } } else { $status='no_host'; } @@ -199,9 +217,10 @@ sub user_crit_received { &user_normal_msg($contents{'sendername'},$contents{'senderdomain'}, 'Receipt: '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}, 'User '.$ENV{'user.name'}.' at '.$ENV{'user.domain'}. - ' acknowledged receipt of message "'. - $contents{'subject'}.'" dated '.$contents{'time'}.".\n\n" - .'Message ID: '.$contents{'msgid'}):'no msg req'); + ' acknowledged receipt of message'."\n".' "'. + $contents{'subject'}.'"'."\n".'dated '. + $contents{'time'}.".\n" + ):'no msg req'); $status.=' trans: '. &Apache::lonnet::put( 'nohist_email',{$contents{'msgid'} => $message{$msgid}}); @@ -229,6 +248,8 @@ sub user_normal_msg_raw { 'put:'.$domain.':'.$user.':nohist_email:'. &Apache::lonnet::escape($msgid).'='. &Apache::lonnet::escape($message),$homeserver); + &Apache::lonnet::put + ('email_status',{'recnewemail'=>time},$domain,$user); } else { $status='no_host'; } @@ -512,10 +533,11 @@ sub compout { ''); unless (($broadcast eq 'group') || ($broadcast eq 'upload')) { my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); - + my $selectlink=&Apache::loncommon::selectstudent_link + ('compemail','recuname','recdomain'); $r->print(<<"ENDREC");
- + ENDREC @@ -565,6 +587,111 @@ ENDUPLOAD $r->print(''); } +# ---------------------------------------------------- Display all face to face + +sub disfacetoface { + my ($r,$user,$domain)=@_; + unless ($ENV{'request.course.id'}) { return; } + unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { + return; + } + my %records=&Apache::lonnet::dump('nohist_email', + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, + '%255b'.$user.'%253a'.$domain.'%255d'); + my $result=''; + foreach (sort keys %records) { + my %content=&unpackagemsg($records{$_}); + next if ($content{'senderdomain'} eq ''); + $content{'message'}=~s/\n/\/g; + if ($content{'subject'}=~/^Record/) { + $result.='

Record

'; + } else { + $result.='

Sent Message

'; + %content=&unpackagemsg($content{'message'}); + $content{'message'}= + 'Subject: '.$content{'subject'}.'
'. + $content{'message'}; + } + $result.='By: '. +&Apache::loncommon::aboutmewrapper( + &Apache::loncommon::plainname($content{'sendername'},$content{'senderdomain'}),$content{'sendername'},$content{'senderdomain'}).' ('. +$content{'sendername'}.'@'. + $content{'senderdomain'}.') '.$content{'time'}. + '
'. + &Apache::lontexconvert::msgtexconverted($content{'message'}). + '
'; + } + # Check to see if there were any messages. + if ($result eq '') { + $r->print("

No notes, face-to-face discussion records, or critical messages in this course.

"); + } else { + $r->print($result); + } +} + +# ---------------------------------------------------------------- Face to face + +sub facetoface { + my ($r,$stage)=@_; + unless (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'})) { + return; + } +# from query string + if ($ENV{'form.recname'}) { $ENV{'form.recuname'}=$ENV{'form.recname'}; } + if ($ENV{'form.recdom'}) { $ENV{'form.recdomain'}=$ENV{'form.recdom'}; } + + my $defdom=$ENV{'user.domain'}; +# already filled in + if ($ENV{'form.recdomain'}) { $defdom=$ENV{'form.recdomain'}; } +# generate output + my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); + my $stdbrws = &Apache::loncommon::selectstudent_link + ('stdselect','recuname','recdomain'); + $r->print(<<"ENDTREC"); +

User Notes, Records of Face-To-Face Discussions, and Critical Messages in Course

+
+ +
Username:
Username:$selectlink
Domain: $domform
+ + + + + +
Username: +$stdbrws +
Domain:$domform
+ +ENDTREC + if (($stage ne 'query') && + ($ENV{'form.recdomain'}) && ($ENV{'form.recuname'})) { + chomp($ENV{'form.newrecord'}); + if ($ENV{'form.newrecord'}) { + &user_normal_msg_raw( + $ENV{'course.'.$ENV{'request.course.id'}.'.num'}, + $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, + 'Record ['.$ENV{'form.recuname'}.':'.$ENV{'form.recdomain'}.']', + $ENV{'form.newrecord'}); + } + $r->print('

'.&Apache::loncommon::plainname($ENV{'form.recuname'}, + $ENV{'form.recdomain'}).'

'); + &disfacetoface($r,$ENV{'form.recuname'},$ENV{'form.recdomain'}); + $r->print(< + + +ENDRHEAD + $r->print(<New Record (record is visible to course faculty and staff)
+ +
+ + + +ENDBFORM + } +} + # ===================================================================== Handler sub handler { @@ -580,11 +707,15 @@ sub handler { # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['display','replyto','forward','markread','markdel','markunread', - 'sendreply','compose','sendmail','critical','recname','recdom']); + 'sendreply','compose','sendmail','critical','recname','recdom', + 'recordftf']); +# ------------------------------------------------------ They checked for email + &Apache::lonnet::put('email_status',{'recnewemail'=>0}); # --------------------------------------------------------------- Render Output - $r->print('EMail and Messaging'. + $r->print('EMail and Messaging'. + &Apache::loncommon::studentbrowser_javascript().''. &Apache::loncommon::bodytag('EMail and Messages')); if ($ENV{'form.display'}) { my $msgid=$ENV{'form.display'}; @@ -606,6 +737,8 @@ $content{'sendername'},$content{'senderd '">Forward'. 'Mark Unread'. + 'Delete'. 'Display all Messages'. '

'.
              &Apache::lontexconvert::msgtexconverted($content{'message'}).
@@ -673,6 +806,8 @@ $content{'sendername'},$content{'senderd
       &disall($r);
   } elsif ($ENV{'form.compose'}) {
       &compout($r,'',$ENV{'form.compose'});
+  } elsif ($ENV{'form.recordftf'}) {
+      &facetoface($r,$ENV{'form.recordftf'});
   } elsif ($ENV{'form.sendmail'}) {
       my %content=();
       undef %content;