Diff for /loncom/interface/lonnotify.pm between versions 1.36 and 1.43

version 1.36, 2010/05/14 18:29:52 version 1.43, 2019/07/23 13:58:53
Line 220  sub print_display_option_form { Line 220  sub print_display_option_form {
     $output .= &Apache::lonhtmlcommon::row_title(&mt('Choose sender(s)'));      $output .= &Apache::lonhtmlcommon::row_title(&mt('Choose sender(s)'));
     my %personnel = &Apache::lonnet::get_domain_roles($cdom,\@roles);      my %personnel = &Apache::lonnet::get_domain_roles($cdom,\@roles);
     my @domcc = ();      my @domcc = ();
     foreach my $server (keys %personnel) {      foreach my $server (keys(%personnel)) {
         foreach my $user (sort(keys %{$personnel{$server}})) {          foreach my $user (sort(keys(%{$personnel{$server}}))) {
             my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);              my ($trole,$uname,$udom,$runame,$rudom,$rsec) = split(/:/,$user);
             unless (grep/^$uname:$udom$/,@domcc) {              unless (grep/^$uname:$udom$/,@domcc) {
                 my %userinfo = &Apache::lonnet::get('environment',['lastname','firstname'],$udom,$uname);                  my %userinfo = &Apache::lonnet::get('environment',['lastname','firstname'],$udom,$uname);
Line 286  ENDSCRIPT Line 286  ENDSCRIPT
     $output .= &Apache::loncommon::start_data_table();      $output .= &Apache::loncommon::start_data_table();
     if ($msgcount > 0) {      if ($msgcount > 0) {
         $output .= &Apache::loncommon::start_data_table_header_row().          $output .= &Apache::loncommon::start_data_table_header_row().
     '<th><a href="javascript:changeSort(\'date\')">Date</a></th>'.      '<th><a href="javascript:changeSort(\'date\')">'.&mt('Date').'</a></th>'.
     '<th><a href="javascript:changeSort(\'subject\')">Subject</a></th>'.      '<th><a href="javascript:changeSort(\'subject\')">'.&mt('Subject').'</a></th>'.
     '<th><a href="javascript:changeSort(\'sender\')">Sender</a></th>'.      '<th><a href="javascript:changeSort(\'sender\')">'.&mt('Sender').'</a></th>'.
     '<th><a href="javascript:changeSort(\'message\')">Message</a></th>'.      '<th><a href="javascript:changeSort(\'message\')">'.&mt('Message').'</a></th>'.
     '<th><a href="javascript:changeSort(\'recipients\')">Recipients</a></th>'.      '<th><a href="javascript:changeSort(\'recipients\')">'.&mt('Recipients').'</a></th>'.
     &Apache::loncommon::end_data_table_header_row();      &Apache::loncommon::end_data_table_header_row();
   
         if (($env{'form.sortby'} eq 'date') || ($env{'form.sortby'} eq '') || (!defined($env{'form.sortby'})) || (($env{'form.sortby'} eq 'sender') && (@senders <= 1))) {          if (($env{'form.sortby'} eq 'date') || ($env{'form.sortby'} eq '') || (!defined($env{'form.sortby'})) || (($env{'form.sortby'} eq 'sender') && (@senders <= 1))) {
Line 357  ENDSCRIPT Line 357  ENDSCRIPT
         }          }
     } else {      } else {
         $output .= &Apache::loncommon::start_data_table_empty_row().          $output .= &Apache::loncommon::start_data_table_empty_row().
     '<td>No mail sent matching supplied criteria</td>'.      '<td>'.&mt('No mail sent matching supplied criteria').'</td>'.
     &Apache::loncommon::end_data_table_empty_row();      &Apache::loncommon::end_data_table_empty_row();
     }      }
     $output .= &Apache::loncommon::end_data_table();      $output .= &Apache::loncommon::end_data_table();
Line 378  ENDSCRIPT Line 378  ENDSCRIPT
   
 sub print_selection_form {  sub print_selection_form {
     my ($r,$formname,$cdom) = @_;      my ($r,$formname,$cdom) = @_;
     my %coursecodes = ();  
     my %codes = ();      my %codes = ();
     my @codetitles = ();      my @codetitles = ();
     my %cat_titles = ();      my %cat_titles = ();
Line 386  sub print_selection_form { Line 385  sub print_selection_form {
     my %idlist = ();      my %idlist = ();
     my %idnums = ();      my %idnums = ();
     my %idlist_titles = ();      my %idlist_titles = ();
     my $caller = 'global';  
     my $totcodes = 0;      my $totcodes = 0;
     my $format_reply;  
     my $jscript = '';      my $jscript = '';
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
                'buil' => 'Building valid e-mail address from username, if missing from preferences:',                 'buil' => 'Building valid e-mail address from username, if missing from preferences:',
Line 399  sub print_selection_form { Line 396  sub print_selection_form {
     &Apache::lonhtmlcommon::add_breadcrumb      &Apache::lonhtmlcommon::add_breadcrumb
           ({text=>"Select Audience"});            ({text=>"Select Audience"});
   
     $totcodes = &Apache::courseclassifier::retrieve_instcodes(\%coursecodes,$cdom,$totcodes);      my $instcats = &Apache::lonnet::get_dom_instcats($cdom);
     if ($totcodes > 0) {      if (ref($instcats) eq 'HASH') {
         $format_reply = &Apache::lonnet::auto_instcode_format($caller,$cdom,\%coursecodes,\%codes,\@codetitles,\%cat_titles,\%cat_order);          if ((ref($instcats->{'codetitles'}) eq 'ARRAY') && (ref($instcats->{'codes'}) eq 'HASH') &&
         if ($format_reply eq 'ok') {              (ref($instcats->{'cat_titles'}) eq 'HASH') && (ref($instcats->{'cat_order'}) eq 'HASH')) {
               %codes = %{$instcats->{'codes'}};
               @codetitles = @{$instcats->{'codetitles'}};
               %cat_titles = %{$instcats->{'cat_titles'}};
               %cat_order = %{$instcats->{'cat_order'}};
               $totcodes = scalar(keys(%codes));
             my $numtypes = @codetitles;              my $numtypes = @codetitles;
             &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);              &Apache::courseclassifier::build_code_selections(\%codes,\@codetitles,\%cat_titles,\%cat_order,\%idlist,\%idnums,\%idlist_titles);
             my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);              my ($scripttext,$longtitles) = &Apache::courseclassifier::javascript_definitions(\@codetitles,\%idlist,\%idlist_titles,\%idnums,\%cat_titles);
Line 410  sub print_selection_form { Line 412  sub print_selection_form {
             my $allidlist = $idlist{$codetitles[0]};              my $allidlist = $idlist{$codetitles[0]};
             $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);              $jscript .= &Apache::courseclassifier::courseset_js_start($formname,$longtitles_str,$allidlist);
             $jscript .= $scripttext;              $jscript .= $scripttext;
             $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,@codetitles);              $jscript .= &Apache::courseclassifier::javascript_code_selections($formname,\@codetitles);
         }          }
     }      }
       my @standardnames = &Apache::loncommon::get_standard_codeitems();
   
     my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom);      my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($cdom);
   
Line 436  function setCourseCat(formname) { Line 439  function setCourseCat(formname) {
     if (formname.Year.options[formname.Year.selectedIndex].value == -1) {      if (formname.Year.options[formname.Year.selectedIndex].value == -1) {
         return;          return;
     }      }
     courseSet('Year');      courseSet('$codetitles[0]');
     for (var j=0; j<formname.Semester.length; j++) {      for (var j=0; j<formname.Semester.length; j++) {
         if (formname.Semester.options[j].value == "$env{'form.Semester'}") {          if (formname.Semester.options[j].value == "$env{'form.Semester'}") {
             formname.Semester.options[j].selected = true;              formname.Semester.options[j].selected = true;
Line 445  function setCourseCat(formname) { Line 448  function setCourseCat(formname) {
     if (formname.Semester.options[formname.Semester.selectedIndex].value == -1) {      if (formname.Semester.options[formname.Semester.selectedIndex].value == -1) {
         return;          return;
     }      }
     courseSet('Semester');      courseSet('$codetitles[1]');
     for (var j=0; j<formname.Department.length; j++) {      for (var j=0; j<formname.Department.length; j++) {
         if (formname.Department.options[j].value == "$env{'form.Department'}") {          if (formname.Department.options[j].value == "$env{'form.Department'}") {
             formname.Department.options[j].selected = true;              formname.Department.options[j].selected = true;
Line 454  function setCourseCat(formname) { Line 457  function setCourseCat(formname) {
     if (formname.Department.options[formname.Department.selectedIndex].value == -1) {      if (formname.Department.options[formname.Department.selectedIndex].value == -1) {
         return;          return;
     }      }
     courseSet('Department');      courseSet('$codetitles[2]');
     for (var j=0; j<formname.Number.length; j++) {      for (var j=0; j<formname.Number.length; j++) {
         if (formname.Number.options[j].value == "$env{'form.Number'}") {          if (formname.Number.options[j].value == "$env{'form.Number'}") {
             formname.Number.options[j].selected = true;              formname.Number.options[j].selected = true;
Line 481  function setCourseCat(formname) { Line 484  function setCourseCat(formname) {
     my $submit_text = $lt{'comp'};      my $submit_text = $lt{'comp'};
     my $cmd = 'compose';      my $cmd = 'compose';
     $output .= &Apache::lonhtmlcommon::role_select_row(\@roles,&mt('Roles'));      $output .= &Apache::lonhtmlcommon::role_select_row(\@roles,&mt('Roles'));
     $output .= &Apache::lonhtmlcommon::course_select_row(&mt('Courses'),$formname,$totcodes,\@codetitles,\%idlist,\%idlist_titles);      $output .= &Apache::lonhtmlcommon::course_select_row(&mt('Courses'),$formname,$totcodes,\@codetitles,\%idlist,\%idlist_titles,undef,undef,\@standardnames);
     $output .= &Apache::lonhtmlcommon::status_select_row(\%longtypes,&mt('Access status'));      $output .= &Apache::lonhtmlcommon::status_select_row(\%longtypes,&mt('Access status'));
     $output .= &Apache::lonhtmlcommon::email_default_row(\%authtypes,&mt('Username -> E-mail conversion'),$descrip);      $output .= &Apache::lonhtmlcommon::email_default_row(\%authtypes,&mt('Username -> E-mail conversion'),$descrip);
     $output .= &Apache::lonhtmlcommon::submit_row(&mt('Submit'),$cmd,$submit_text);      $output .= &Apache::lonhtmlcommon::submit_row(&mt('Submit'),$cmd,$submit_text);
Line 526  function goBack(target) { Line 529  function goBack(target) {
         %courses = &Apache::lonnet::courseiddump($cdom,'.','.','.','.','.',          %courses = &Apache::lonnet::courseiddump($cdom,'.','.','.','.','.',
                                                  undef,undef,'Course');                                                   undef,undef,'Course');
     } elsif ($coursefilter eq 'category') {      } elsif ($coursefilter eq 'category') {
         my $instcode = '';          my $instcode = &Apache::courseclassifier::instcode_from_selectors($cdom);
         my @cats = ('Semester','Year','Department','Number');          my $regexp = '';
         foreach my $category (@cats) {  
             if (defined($env{'form.'.$category})) {  
                 unless ($env{'form.'.$category} eq '-1') {  
                     $instcode .= $env{'form.'.$category};  
                 }  
             }  
         }  
         if ($instcode eq '') {          if ($instcode eq '') {
             $instcode = '.';              $instcode = '.';
           } else {
               $regexp = 1;
         }          }
         %courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.',          %courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.',
                                                  undef,undef,'Course');                                                   undef,undef,'Course',$regexp);
     } elsif ($coursefilter eq 'specific') {      } elsif ($coursefilter eq 'specific') {
         if ($env{'form.coursetotal'} > 1) {          if ($env{'form.coursetotal'} > 1) {
             my @course_ids = split(/&&/,$env{'form.courselist'});              my @course_ids = split(/&&/,$env{'form.courselist'});
Line 649  function goBack(target) { Line 647  function goBack(target) {
         $output .= &Apache::loncommon::end_data_table();          $output .= &Apache::loncommon::end_data_table();
         if (@unmatched) {          if (@unmatched) {
             $output .= '<br /><br />'.&mt('Could not determine e-mail addresses for the following users:').'<ul>';              $output .= '<br /><br />'.&mt('Could not determine e-mail addresses for the following users:').'<ul>';
             foreach my $username (sort @unmatched) {              foreach my $username (sort(@unmatched)) {
                 $output .= '<li>'.$username.'</li>';                  $output .= '<li>'.$username.'</li>';
             }              }
             $output .= '</ul>';              $output .= '</ul>';
Line 709  ENDSCRIPT Line 707  ENDSCRIPT
     '<th>'.&mt('Status').'</th>'.      '<th>'.&mt('Status').'</th>'.
     '<th>'.&mt('Subject').'</th>'.      '<th>'.&mt('Subject').'</th>'.
     '<th>'.&mt('Message').'</th>'.      '<th>'.&mt('Message').'</th>'.
     '<th>'.&mt('Recipents').'</th>'.      '<th>'.&mt('Recipients').'</th>'.
     &Apache::loncommon::end_data_table_header_row();      &Apache::loncommon::end_data_table_header_row();
  $output .= &Apache::loncommon::start_data_table_row().   $output .= &Apache::loncommon::start_data_table_row().
     '<td valign="middle">'.&mt('Sent').'</td>'.      '<td valign="middle">'.&mt('Sent').'</td>'.
Line 724  ENDSCRIPT Line 722  ENDSCRIPT
     &Apache::loncommon::end_data_table_row().      &Apache::loncommon::end_data_table_row().
     &Apache::loncommon::end_data_table();      &Apache::loncommon::end_data_table();
     } else {      } else {
         $output .= 'No mail sent - no recipients identified';           $output .= &mt('No mail sent - no recipients identified'); 
     }      }
     $output .= '<br /><a href="/adm/notify">'.&mt('Send another e-mail').'</a>'."\n";      $output .= '<br /><a href="/adm/notify">'.&mt('Send another e-mail').'</a>'."\n";
     $output .= '<input type="hidden" name="command" />'."\n".      $output .= '<input type="hidden" name="command" />'."\n".
Line 746  sub broadcast_email { Line 744  sub broadcast_email {
         $msg->to($to);          $msg->to($to);
         $msg->subject($subject);          $msg->subject($subject);
         $msg->add('From',"$from");          $msg->add('From',"$from");
           $msg->add('Content-type','text/plain; charset=UTF-8');
         if (my $fh = $msg->open()) {          if (my $fh = $msg->open()) {
             print $fh $message;              print $fh $message;
             $fh->close;              $fh->close;

Removed from v.1.36  
changed lines
  Added in v.1.43


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