Diff for /loncom/interface/lonmsgdisplay.pm between versions 1.35.2.4 and 1.44

version 1.35.2.4, 2006/07/19 16:01:45 version 1.44, 2006/11/29 07:46:39
Line 270  sub discourse { Line 270  sub discourse {
     &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'});      &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'});
     unshift @$current_members, (@$course_personnel);      unshift @$current_members, (@$course_personnel);
     my %defaultUsers;      my %defaultUsers;
       
       $result .= '<input type="hidden" name="sendmode" value="group" />'."\n";
   
     $result = &Apache::lonselstudent::render_student_list($current_members,      $result .= &Apache::lonselstudent::render_student_list($current_members,
   "compemail",     "compemail",
   "current",     "current",
   \%defaultUsers,     \%defaultUsers,
   1,"selectedusers",1);     1,"selectedusers",1);
   
     $result .= &Apache::lonselstudent::render_student_list($expired_members,      $result .= &Apache::lonselstudent::render_student_list($expired_members,
    "compemail",     "compemail",
Line 484  sub discrit { Line 486  sub discrit {
         '<input type="hidden" name="confirm" value="true" />';          '<input type="hidden" name="confirm" value="true" />';
     my %what=&Apache::lonnet::dump('critical');      my %what=&Apache::lonnet::dump('critical');
     my $result = '';      my $result = '';
     foreach (sort keys %what) {      foreach my $key (sort(keys(%what))) {
         my %content=&Apache::lonmsg::unpackagemsg($what{$_});          my %content=&Apache::lonmsg::unpackagemsg($what{$key});
         next if ($content{'senderdomain'} eq '');          next if ($content{'senderdomain'} eq '');
         $result.='<hr />'.&mt('From').': <b>'.          $result.='<hr />'.&mt('From').': <b>'.
 &Apache::loncommon::aboutmewrapper(  &Apache::loncommon::aboutmewrapper(
Line 498  $content{'sendername'}.':'. Line 500  $content{'sendername'}.':'.
             '</pre><small>'.              '</pre><small>'.
 &mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').  &mt('You have to confirm that you received this message. After confirmation, this message will be moved to your regular inbox').
             '</small><br />'.              '</small><br />'.
             '<input type="submit" name="rec_'.$_.'" value="'.&mt('Confirm Receipt').'" />'.              '<input type="submit" name="rec_'.$key.'" value="'.&mt('Confirm Receipt').'" />'.
             '<input type="submit" name="reprec_'.$_.'" '.              '<input type="submit" name="reprec_'.$key.'" '.
                   'value="'.&mt('Confirm Receipt and Reply').'" />';                    'value="'.&mt('Confirm Receipt and Reply').'" />';
     }      }
     # Check to see if there were any messages.      # Check to see if there were any messages.
Line 638  sub disnew { Line 640  sub disnew {
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
        'nm' => 'New Messages',         'nm' => 'New Messages',
        'su' => 'Subject',         'su' => 'Subject',
                                        'co' => 'Course',                                         'co' => 'Course/Group',
        'da' => 'Date',         'da' => 'Date',
        'us' => 'Username',         'us' => 'Username',
        'op' => 'Open',         'op' => 'Open',
Line 647  sub disnew { Line 649  sub disnew {
     my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));      my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
     my @newmsgs;      my @newmsgs;
     my %setters = ();      my %setters = ();
     my $startblock = 0;  
     my $endblock = 0;  
     my %blocked = ();      my %blocked = ();
     my $numblocked = 0;      my $numblocked = 0;
     # Check for blocking of display because of scheduled online exams.      # Check for blocking of display because of scheduled online exams.
     &blockcheck(\%setters,\$startblock,\$endblock);      my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
     my %status_cache =       my %status_cache = 
  &Apache::lonnet::get('email_status',\@msgids);   &Apache::lonnet::get('email_status',\@msgids);
     my %descriptions;      my %descriptions;
     foreach (@msgids) {      foreach my $id (@msgids) {
  my $msgid=&escape($_);   my $msgid=&escape($id);
         my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=          my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
     &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);      &Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
         if (defined($sendtime) && $sendtime!~/error/) {          if (defined($sendtime) && $sendtime!~/error/) {
Line 666  sub disnew { Line 666  sub disnew {
             $sendtime = &Apache::lonlocal::locallocaltime($sendtime);              $sendtime = &Apache::lonlocal::locallocaltime($sendtime);
             if ($status eq 'new') {              if ($status eq 'new') {
                 if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {                  if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
                     $blocked{$_} = 'ON';                      $blocked{$id} = 'ON';
                     $numblocked ++;                      $numblocked ++;
                 } else {                  } else {
                     push @newmsgs, {                       push @newmsgs, { 
Line 692  TABLEHEAD Line 692  TABLEHEAD
 <tr class="LC_mail_new">  <tr class="LC_mail_new">
 <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>  <td><a href="/adm/email?dismode=new&display=$msg->{'msgid'}">$lt{'op'}</a></td>
 ENDLINK  ENDLINK
             foreach ('sendtime','from','fromdom','shortsub','course') {              foreach my $item ('sendtime','from','fromdom','shortsub','course') {
                 $r->print("<td>$msg->{$_}</td>");                  $r->print("<td>$msg->{$item}</td>");
             }              }
             $r->print("</td></tr>");              $r->print("</td></tr>");
         }          }
Line 713  ENDLINK Line 713  ENDLINK
         }          }
         $r->print(          $r->print(
 &mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');  &mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
         &build_block_table($r,$startblock,$endblock,\%setters);          $r->print(&Apache::loncommon::build_block_table($startblock,$endblock,
                                                           \%setters));
     }      }
 }  }
   
Line 738  sub disfolder { Line 739  sub disfolder {
     my ($r,$folder)=@_;      my ($r,$folder)=@_;
     my %blocked = ();      my %blocked = ();
     my %setters = ();      my %setters = ();
     my $startblock;  
     my $endblock;  
     my $numblocked = 0;      my $numblocked = 0;
     &blockcheck(\%setters,\$startblock,\$endblock);      my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
     $r->print(<<ENDDISHEADER);      $r->print(<<ENDDISHEADER);
 <script type="text/javascript">  <script type="text/javascript">
     function checkall() {      function checkall() {
Line 764  sub disfolder { Line 763  sub disfolder {
 </script>  </script>
 ENDDISHEADER  ENDDISHEADER
     my $fsqs='&folder='.$folder;      my $fsqs='&folder='.$folder;
     my @temp=sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);      my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
     my $totalnumber=$#temp+1;      my $totalnumber=$#temp+1;
     unless ($totalnumber>0) {      unless ($totalnumber>0) {
  $r->print('<h2>'.&mt('Empty Folder').'</h2>');   $r->print('<h2>'.&mt('Empty Folder').'</h2>');
Line 807  ENDDISHEADER Line 806  ENDDISHEADER
     }      }
     $r->print('</th><th>');      $r->print('</th><th>');
     if ($env{'form.sortedby'} eq "revcourse") {      if ($env{'form.sortedby'} eq "revcourse") {
         $r->print('<a href = "?sortedby=course'.$fsqs.'">'.&mt('Course').'</a>');          $r->print('<a href = "?sortedby=course'.$fsqs.'">'.&mt('Course/Group').'</a>');
     } else {      } else {
         $r->print('<a href = "?sortedby=revcourse'.$fsqs.'">'.&mt('Course').'</a>');          $r->print('<a href = "?sortedby=revcourse'.$fsqs.'">'.&mt('Course/Group').'</a>');
     }      }
     $r->print('</th><th>');      $r->print('</th><th>');
     if ($env{'form.sortedby'} eq "revstatus") {      if ($env{'form.sortedby'} eq "revstatus") {
Line 885  ENDDISHEADER Line 884  ENDDISHEADER
         my $finishblock = &Apache::lonlocal::locallocaltime($endblock);          my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
         $r->print('<br /><br />'.          $r->print('<br /><br />'.
                   $numblocked.' '.&mt('message(s) is/are not viewable because display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams.'));                    $numblocked.' '.&mt('message(s) is/are not viewable because display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams.'));
         &build_block_table($r,$startblock,$endblock,\%setters);          $r->print(&Apache::loncommon::build_block_table($startblock,$endblock,
                                                           \%setters));
     }      }
 }  }
   
Line 1037  sub compout { Line 1037  sub compout {
     my $latexHelp = Apache::loncommon::helpLatexCheatsheet();      my $latexHelp = Apache::loncommon::helpLatexCheatsheet();
     if ($broadcast ne 'upload') {      if ($broadcast ne 'upload') {
        $r->print(<<"ENDCOMP");         $r->print(<<"ENDCOMP");
 <tr><td>$lt{'ad'}<br /><tt>username\@domain,username\@domain, ...  <tr><td>$lt{'ad'}<br /><tt>username:domain,username:domain, ...
 </tt></td><td>  </tt></td><td>
 <input type="text" size="50" name="additionalrec" /></td></tr>  <input type="text" size="50" name="additionalrec" /></td></tr>
 <tr><td>$lt{'sb'}:</td><td><input type="text" size="50" name="subject" value="$dissub" />  <tr><td>$lt{'sb'}:</td><td><input type="text" size="50" name="subject" value="$dissub" />
Line 1075  Subject: <input type="text" size="50" na Line 1075  Subject: <input type="text" size="50" na
 <p>  <p>
 The file format for the uploaded portion of the message is:  The file format for the uploaded portion of the message is:
 <pre>  <pre>
 username1\@domain1: text  username1:domain1: text
 username2\@domain2: text  username2:domain2: text
 username3\@domain1: text  username3:domain1: text
 </pre>  </pre>
 </p>  </p>
 <p>  <p>
 The messages will be assembled from all lines with the respective   The messages will be assembled from all lines with the respective 
 <tt>username\@domain</tt>, and appended to the general message text.</p>  <tt>username:domain</tt>, and appended to the general message text.</p>
 <p>  <p>
 <input type="file" name="upfile" size="40" /></p><p>  <input type="file" name="upfile" size="40" /></p><p>
 $dispcrit  $dispcrit
Line 1133  sub retrieve_instructor_comments { Line 1133  sub retrieve_instructor_comments {
  $env{'course.'.$env{'request.course.id'}.'.num'},   $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');                           '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';      my $result='';
     foreach (sort(keys(%records))) {      foreach my $key (sort(keys(%records))) {
         my %content=&Apache::lonmsg::unpackagemsg($records{$_});          my %content=&Apache::lonmsg::unpackagemsg($records{$key});
         next if ($content{'senderdomain'} eq '');          next if ($content{'senderdomain'} eq '');
         next if ($content{'subject'} !~ /^Record/);          next if ($content{'subject'} !~ /^Record/);
  # &Apache::lonfeedback::newline_to_br(\$content{'message'});   # &Apache::lonfeedback::newline_to_br(\$content{'message'});
Line 1161  sub disfacetoface { Line 1161  sub disfacetoface {
  $env{'course.'.$env{'request.course.id'}.'.num'},   $env{'course.'.$env{'request.course.id'}.'.num'},
                          '%255b'.$user.'%253a'.$domain.'%255d');                           '%255b'.$user.'%253a'.$domain.'%255d');
     my $result='';      my $result='';
     foreach (sort keys %records) {      foreach my $key (sort(keys(%records))) {
         my %content=&Apache::lonmsg::unpackagemsg($records{$_});          my %content=&Apache::lonmsg::unpackagemsg($records{$key});
         next if ($content{'senderdomain'} eq '');          next if ($content{'senderdomain'} eq '');
  &Apache::lonfeedback::newline_to_br(\$content{'message'});   &Apache::lonfeedback::newline_to_br(\$content{'message'});
         if ($content{'subject'}=~/^Record/) {          if ($content{'subject'}=~/^Record/) {
Line 1309  ENDBFORM Line 1309  ENDBFORM
 sub examblock {  sub examblock {
     my ($r,$action) = @_;      my ($r,$action) = @_;
     unless ($env{'request.course.id'}) { return;}      unless ($env{'request.course.id'}) { return;}
     if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})      if (!&Apache::lonnet::allowed('dcm',$env{'request.course.id'})
  && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}.   && ! &Apache::lonnet::allowed('dcm',$env{'request.course.id'}.
       '/'.$env{'request.course.sec'})) {        '/'.$env{'request.course.sec'})) {
  $r->print('Not allowed');   $r->print('Not allowed');
  return;   return;
Line 1329  sub examblock { Line 1329  sub examblock {
             'dura' => 'Duration',              'dura' => 'Duration',
             'setb' => 'Set by',              'setb' => 'Set by',
             'even' => 'Event',              'even' => 'Event',
               'blck' => 'Blocked?',
             'actn' => 'Action',              'actn' => 'Action',
             'star' => 'Start',              'star' => 'Start',
             'endd' => 'End'              'endd' => 'End'
Line 1385  sub blockstore { Line 1386  sub blockstore {
     my $addtotal = 0;      my $addtotal = 0;
     my %blocking = ();      my %blocking = ();
     $r->print('<h3>'.$lt{'head'}.'</h3>');      $r->print('<h3>'.$lt{'head'}.'</h3>');
     foreach (keys %env) {      foreach my $envkey (keys(%env)) {
         if ($_ =~ m/^form\.modify_(\w+)$/) {          if ($envkey =~ m/^form\.modify_(\d+)$/) {
             $adds{$1} = $1;              $adds{$1} = $1;
             $removals{$1} = $1;              $removals{$1} = $1;
             $modtotal ++;              $modtotal ++;
         } elsif ($_ =~ m/^form\.cancel_(\d+)$/) {          } elsif ($envkey =~ m/^form\.cancel_(\d+)$/) {
             $cancels{$1} = $1;              $cancels{$1} = $1;
             unless ( defined($removals{$1}) ) {              unless ( defined($removals{$1}) ) {
                 $removals{$1} = $1;                  $removals{$1} = $1;
                 $canceltotal ++;                  $canceltotal ++;
             }              }
         } elsif ($_ =~ m/^form\.add_(\d+)$/) {          } elsif ($envkey =~ m/^form\.add_(\d+)$/) {
             $adds{$1} = $1;              $adds{$1} = $1;
             $addtotal ++;              $addtotal ++;
         }          } 
     }      }
   
     foreach (keys %removals) {      foreach my $key (keys(%removals)) {
         my $hashkey = $env{'form.key_'.$_};          my $hashkey = $env{'form.key_'.$key};
         &Apache::lonnet::del('comm_block',["$hashkey"],          &Apache::lonnet::del('comm_block',["$hashkey"],
                          $env{'course.'.$env{'request.course.id'}.'.domain'},                           $env{'course.'.$env{'request.course.id'}.'.domain'},
                          $env{'course.'.$env{'request.course.id'}.'.num'}                           $env{'course.'.$env{'request.course.id'}.'.num'}
                          );                           );
     }      }
     foreach (keys %adds) {      foreach my $key (keys(%adds)) {
         unless ( defined($cancels{$_}) ) {          unless ( defined($cancels{$key}) ) {
             my ($newstart,$newend) = &get_dates_from_form($_);              my ($newstart,$newend) = &get_dates_from_form($key);
             my $newkey = $newstart.'____'.$newend;              my $newkey = $newstart.'____'.$newend;
             $blocking{$newkey} = $env{'user.name'}.':'.$env{'user.domain'}.':'.$env{'form.title_'.$_};              my $blocktypes = &get_block_choices($key);
               $blocking{$newkey} = {
                             setter => $env{'user.name'}.':'.$env{'user.domain'},
                             event  => &escape($env{'form.title_'.$key}),
                             blocks => $blocktypes,
                           };
         }          }
     }      }
     if ($addtotal + $modtotal > 0) {      if ($addtotal + $modtotal > 0) {
Line 1464  sub get_blockdates { Line 1470  sub get_blockdates {
     }      }
 }  }
   
   sub get_block_choices {
       my $item = shift;
       my $blocklist;
       my ($typeorder,$types) = &blocktype_text();
       foreach my $type (@{$typeorder}) {
           if ($env{'form.'.$type.'_'.$item}) {
               $blocklist->{$type} = 'on'; 
           } else {
               $blocklist->{$type} = 'off';
           }
       }
       return $blocklist;
   }
   
 sub display_blocker_status {  sub display_blocker_status {
     my ($r,$records,$ltext) = @_;      my ($r,$records,$ltext) = @_;
     my $parmcount = 0;      my $parmcount = 0;
Line 1472  sub display_blocker_status { Line 1492  sub display_blocker_status {
         'modi' => 'Modify',          'modi' => 'Modify',
         'canc' => 'Cancel',          'canc' => 'Cancel',
     );      );
       my ($typeorder,$types) = &blocktype_text();
     $r->print(&Apache::loncommon::start_data_table());      $r->print(&Apache::loncommon::start_data_table());
     $r->print(<<"END");      $r->print(<<"END");
   <tr>    <tr>
     <th>$$ltext{'dura'}</th>      <th>$ltext->{'dura'}</th>
     <th>$$ltext{'setb'}</th>      <th>$ltext->{'setb'}</th>
     <th>$$ltext{'even'}</th>      <th>$ltext->{'even'}</th>
     <th>$$ltext{'actn'}?</th>      <th>$ltext->{'blck'}</th>
       <th>$ltext->{'actn'}?</th>
   </tr>    </tr>
 END  END
     foreach my $record (sort(keys(%{$records}))) {      foreach my $record (sort(keys(%{$records}))) {
Line 1489  END Line 1511  END
         my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);          my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
         my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);          my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
   
  my ($setuname,$setudom,$title) =    my ($setuname,$setudom,$title,$blocks) = 
     &parse_block_record($$records{$record});      &Apache::loncommon::parse_block_record($$records{$record});
  $title = &HTML::Entities::encode($title,'"<>&');   $title = &HTML::Entities::encode($title,'"<>&');
         my $settername = &Apache::loncommon::plainname($setuname,$setudom);          my $settername = 
              &Apache::loncommon::aboutmewrapper(
                              &Apache::loncommon::plainname($setuname,$setudom),
                              $setuname,$setudom);
         $r->print(&Apache::loncommon::start_data_table_row());          $r->print(&Apache::loncommon::start_data_table_row());
         $r->print(<<"END");          $r->print(<<"END");
         <td>$$ltext{'star'}:&nbsp;$startform<br/>$$ltext{'endd'}:&nbsp;&nbsp;$endform</td>          <td>$ltext->{'star'}:&nbsp;$startform<br/>$ltext->{'endd'}:&nbsp;&nbsp;$endform</td>
         <td>$settername</td>          <td>$settername</td>
         <td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td>          <td><input type="text" name="title_$parmcount" size="15" value="$title" /><input type="hidden" name="key_$parmcount" value="$record" /></td>
           <td>
   END
           foreach my $block (@{$typeorder}) {
               my $blockstatus = '';
               if ($blocks->{$block} eq 'on') {
                   $blockstatus = 'checked="true"';
               }
               $r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" '.$blockstatus.' value="1" />'.$types->{$block}.'</label><br />');
           }
           $r->print(<<"END");
           </td>      
         <td><label>$lt{'modi'}?&nbsp;<input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}?&nbsp;&nbsp;<input type="checkbox" name="cancel_$parmcount" /></label>          <td><label>$lt{'modi'}?&nbsp;<input type="checkbox" name="modify_$parmcount" /></label><br /><label>$lt{'canc'}?&nbsp;&nbsp;<input type="checkbox" name="cancel_$parmcount" /></label>
 END  END
         $r->print(&Apache::loncommon::end_data_table_row());          $r->print(&Apache::loncommon::end_data_table_row());
Line 1511  END Line 1547  END
     return $parmcount;      return $parmcount;
 }  }
   
 sub parse_block_record {  
     my ($record) = @_;  
     my ($setuname,$setudom,$title);  
     my @data = split(/:/,$record,3);  
     if (scalar(@data) eq 2) {  
  $title = $data[1];  
  ($setuname,$setudom) = split(/@/,$data[0]);  
     } else {  
  ($setuname,$setudom,$title) = @data;  
     }  
     return ($setuname,$setudom,$title);  
 }  
   
 sub display_addblocker_table {  sub display_addblocker_table {
     my ($r,$parmcount,$ltext) = @_;      my ($r,$parmcount,$ltext) = @_;
     my $start = time;      my $start = time;
Line 1538  sub display_addblocker_table { Line 1561  sub display_addblocker_table {
         'exam' => 'e.g., Exam 1',          'exam' => 'e.g., Exam 1',
         'addn' => 'Add new communication blocking periods'          'addn' => 'Add new communication blocking periods'
     );      );
       my ($typeorder,$types) = &blocktype_text();
     $r->print(<<"END");      $r->print(<<"END");
 <h4>$lt{'addn'}</h4>   <h4>$lt{'addn'}</h4> 
 END  END
     $r->print(&Apache::loncommon::start_data_table());      $r->print(&Apache::loncommon::start_data_table());
     $r->print(<<"END");      $r->print(<<"END");
    <tr>     <tr>
      <th>$$ltext{'dura'}</th>       <th>$ltext->{'dura'}</th>
      <th>$$ltext{'even'} $lt{'exam'}</th>       <th>$ltext->{'even'} $lt{'exam'}</th>
      <th>$$ltext{'actn'}?</th>       <th>$ltext->{'blck'}</th>
        <th>$ltext->{'actn'}?</th>
    </tr>     </tr>
 END  END
    $r->print(&Apache::loncommon::start_data_table_row());      $r->print(&Apache::loncommon::start_data_table_row());
     $r->print(<<"END");      $r->print(<<"END");
      <td>$$ltext{'star'}:&nbsp;$startform<br />$$ltext{'endd'}:&nbsp;&nbsp;$endform</td>       <td>$ltext->{'star'}:&nbsp;$startform<br />$ltext->{'endd'}:&nbsp;&nbsp;$endform</td>
      <td><input type="text" name="title_$parmcount" size="15" value="" /></td>       <td><input type="text" name="title_$parmcount" size="15" value="" /></td>
        <td>
   END
       foreach my $block (@{$typeorder}) {
           $r->print('<label><input type="checkbox" name="'.$block.'_'.$parmcount.'" value="1" />'.$types->{$block}.'</label><br />');
        }
        $r->print(<<"END");
        </td> 
      <td><label>$lt{'addb'}?&nbsp;<input type="checkbox" name="add_$parmcount" value="1" /></label></td>       <td><label>$lt{'addb'}?&nbsp;<input type="checkbox" name="add_$parmcount" value="1" /></label></td>
 END  END
     $r->print(&Apache::loncommon::end_data_table_row());      $r->print(&Apache::loncommon::end_data_table_row());
Line 1560  END Line 1592  END
     return;      return;
 }  }
   
 sub blockcheck {  sub blocktype_text {
     my ($setters,$startblock,$endblock) = @_;      my %types = &Apache::lonlocal::texthash(
     # Retrieve active student roles and active course coordinator/instructor roles          'com' => 'Messaging',
     my %live_courses =          'chat' => 'Chat',
  map { $_ => 1} &Apache::loncommon::findallcourses();          'boards' => 'Discussion',
     # FIXME should really probe for apriv, but ::allowed can only probe the           'port' => 'Portfolio',
     #       currently active role          'groups' => 'Groups'
     my %staff_of =  
  map { $_ => 1} &Apache::loncommon::findallcourses(['cc','in']);  
   
     # Retrieve blocking times and identity of blocker for active courses  
     # for students.  
     return if (!%live_courses);  
   
     foreach my $course (keys(%live_courses)) {  
  my $cdom = $env{'course.'.$course.'.domain'};  
  my $cnum = $env{'course.'.$course.'.num'};  
   
  # if they are a staff member and are currently not playing student  
  next if ( $staff_of{$course}   
   && ($env{'request.role'} !~ m{^st\./$cdom/$cnum}));  
   
  $setters->{$course} = {};  
  $setters->{$course}{'staff'} = [];  
  $setters->{$course}{'times'} = [];  
  my %records = &Apache::lonnet::dump('comm_block',$cdom,$cnum);  
  foreach my $record (keys %records) {  
     my ($start,$end) = ($record =~ m/^(\d+)____(\d+)$/);  
     if ($start <= time && $end >= time) {  
  my ($staff_name,$staff_dom,$title) =   
     &parse_block_record($records{$record});  
  push(@{$$setters{$course}{'staff'}}, [$staff_name,$staff_dom]);  
  push(@{$$setters{$course}{'times'}}, [$start,$end]);  
  if ( ($$startblock == 0) || ($$startblock > $1) ) {  
     $$startblock = $1;  
  }  
  if ( ($$endblock == 0) || ($$endblock < $2) ) {  
     $$endblock = $2;  
  }  
     }  
  }  
     }  
 }  
   
 sub build_block_table {  
     my ($r,$startblock,$endblock,$setters) = @_;  
     my %lt = &Apache::lonlocal::texthash(  
         'cacb' => 'Currently active communication blocks',  
         'cour' => 'Course',  
         'dura' => 'Duration',  
         'blse' => 'Block set by'  
     );      );
     $r->print(<<"END");      my $typeorder = ['com','chat','boards','port','groups'];
 <br /><br />$lt{'cacb'}:<br /><br />      return ($typeorder,\%types);
 END  
     $r->print(&Apache::loncommon::start_data_table());  
     $r->print(<<"END");  
 <tr>  
  <th>$lt{'cour'}</th>  
  <th>$lt{'dura'}</th>  
  <th>$lt{'blse'}</th>  
 </tr>  
 END  
     foreach my $course (keys(%{$setters})) {  
         my %courseinfo=&Apache::lonnet::coursedescription($course);  
         for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {  
             my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};  
             my $fullname = &Apache::loncommon::plainname($uname,$udom);  
             my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};  
             $openblock = &Apache::lonlocal::locallocaltime($openblock);  
             $closeblock= &Apache::lonlocal::locallocaltime($closeblock);  
             $r->print(&Apache::loncommon::start_data_table_row().  
       '<td>'.$courseinfo{'description'}.'</td>'.  
                       '<td>'.$openblock.' to '.$closeblock.'</td>'.  
                       '<td>'.$fullname.' ('.$uname.':'.$udom.  
                       ')</td>'.  
        &Apache::loncommon::end_data_table_row());  
         }  
     }  
     $r->print(&Apache::loncommon::end_data_table());  
 }  }
   
 # ----------------------------------------------------------- Display a message  # ----------------------------------------------------------- Display a message
Line 1649  sub displaymessage { Line 1611  sub displaymessage {
     my $suffix=&Apache::lonmsg::foldersuffix($folder);      my $suffix=&Apache::lonmsg::foldersuffix($folder);
     my %blocked = ();      my %blocked = ();
     my %setters = ();      my %setters = ();
     my $startblock = 0;  
     my $endblock = 0;  
     my $numblocked = 0;      my $numblocked = 0;
     my $crstype = &Apache::loncommon::course_type();      my $crstype = &Apache::loncommon::course_type();
   
 # info to generate "next" and "previous" buttons and check if message is blocked  # info to generate "next" and "previous" buttons and check if message is blocked
     &blockcheck(\%setters,\$startblock,\$endblock);      my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
     my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);      my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
     if ( $blocked{$msgid} eq 'ON' ) {      if ( $blocked{$msgid} eq 'ON' ) {
         &printheader($r,'/adm/email',&mt('Display a Message'));          &printheader($r,'/adm/email',&mt('Display a Message'));
Line 1788  sub header { Line 1748  sub header {
           
     my $extra = &Apache::loncommon::studentbrowser_javascript();      my $extra = &Apache::loncommon::studentbrowser_javascript();
     if ($baseurl) {      if ($baseurl) {
  $extra .= "<base href=\"http://$ENV{'SERVER_NAME'}/$baseurl\" />";   $extra .= "<base href=\"".&Apache::lonnet::absolute_url()."/$baseurl\" />";
     }      }
     $r->print(&Apache::loncommon::start_page('Communication and Messages',      $r->print(&Apache::loncommon::start_page('Communication and Messages',
   $extra));    $extra));
Line 1812  sub storecomment { Line 1772  sub storecomment {
     my ($r)=@_;      my ($r)=@_;
     my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});      my $msgtxt=&Apache::lonfeedback::clear_out_html($env{'form.message'});
     my $cleanmsgtxt='';      my $cleanmsgtxt='';
     foreach (split(/[\n\r]/,$msgtxt)) {      foreach my $line (split(/[\n\r]/,$msgtxt)) {
  unless ($_=~/^\s*(\>|\&gt\;)/) {   unless ($line=~/^\s*(\>|\&gt\;)/) {
     $cleanmsgtxt.=$_."\n";      $cleanmsgtxt.=$line."\n";
  }   }
     }      }
     my $key=&escape($env{'form.baseurl'}).'___'.time;      my $key=&escape($env{'form.baseurl'}).'___'.time;
Line 1831  sub storedcommentlisting { Line 1791  sub storedcommentlisting {
  $r->print(&mt('No stored comments yet.'));   $r->print(&mt('No stored comments yet.'));
     } else {      } else {
  my $found=0;   my $found=0;
  foreach (sort keys %msgs) {   foreach my $key (sort(keys(%msgs))) {
     $r->print("\n".$msgs{$_}."<hr />");      $r->print("\n".$msgs{$key}."<hr />");
     $found=1;      $found=1;
  }   }
  unless ($found) {   unless ($found) {
Line 1904  sub sendoffmail { Line 1864  sub sendoffmail {
     }      }
  } elsif ($env{'form.sendmode'} eq 'upload') {   } elsif ($env{'form.sendmode'} eq 'upload') {
     foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {      foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) {
  my ($rec,$txt)=split(/\s*\:\s*/,$line);                  my ($rec,$txt) = ($line =~ /^([^:]+:[^:]+):(.*)$/);
  if ($txt) {   if ($txt) {
     $rec=~s/\@/\:/;                      $rec =~ s/^\s+//;
                       $rec =~ s/\s+$//;
     $toaddr{$rec}.=$txt."\n";      $toaddr{$rec}.=$txt."\n";
  }   }
     }      }
Line 1916  sub sendoffmail { Line 1877  sub sendoffmail {
     }      }
  }   }
  if ($env{'form.additionalrec'}) {   if ($env{'form.additionalrec'}) {
     foreach (split(/\,/,$env{'form.additionalrec'})) {      foreach my $rec (split(/\,/,$env{'form.additionalrec'})) {
  my ($auname,$audom)=split(/\@/,$_);   my ($auname,$audom)=split(/:/,$rec);
  if (($auname ne "") && ($audom ne "")) {   if (($auname ne "") && ($audom ne "")) {
     $toaddr{$auname.':'.$audom}='';      $toaddr{$auname.':'.$audom}='';
  }   }
Line 2138  sub handler { Line 2099  sub handler {
     } elsif ($env{'form.confirm'}) {      } elsif ($env{'form.confirm'}) {
  &printheader($r,'','Confirmed Receipt');   &printheader($r,'','Confirmed Receipt');
  my $replying = 0;   my $replying = 0;
  foreach (keys %env) {   foreach my $envkey (keys(%env)) {
     if ($_=~/^form\.rec\_(.*)$/) {      if ($envkey=~/^form\.rec\_(.*)$/) {
  $r->print('<b>'.&mt('Confirming Receipt').':</b> '.   $r->print('<b>'.&mt('Confirming Receipt').':</b> '.
   &Apache::lonmsg::user_crit_received($1).'<br>');    &Apache::lonmsg::user_crit_received($1).'<br>');
     }      }
     if ($_=~/^form\.reprec\_(.*)$/) {      if ($envkey=~/^form\.reprec\_(.*)$/) {
  my $msgid=$1;   my $msgid=$1;
  $r->print('<b>'.&mt('Confirming Receipt').':</b> '.   $r->print('<b>'.&mt('Confirming Receipt').':</b> '.
   &Apache::lonmsg::user_crit_received($msgid).'<br>');    &Apache::lonmsg::user_crit_received($msgid).'<br>');
Line 2259  sub handler { Line 2220  sub handler {
  &storedcommentlisting($r);   &storedcommentlisting($r);
     } else {      } else {
  &printheader($r,'','Display All Messages');   &printheader($r,'','Display All Messages');
  &Apache::loncommunicate::menu($r);    &Apache::loncommunicate::menu($r);
  &disall($r,($folder?$folder:$dismode));   &disall($r,($folder?$folder:$dismode));
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());

Removed from v.1.35.2.4  
changed lines
  Added in v.1.44


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>