Changeset 426 for trunk


Ignore:
Timestamp:
07/08/10 13:16:24 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

Tweak mailNotify call on SWIP-is-on
Note "special" notification option for SWIP-is-on
Fix add-special-notice so that the special flag content gets inserted
Complain if any of reciplist, section, and target/alloctype are missing while

adding a new notification

Fix mailNotify to actually iterate over all of the combinations it's supposed

to instead of just looking up the passed action code

Closes #21

Location:
trunk/cgi-bin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r422 r426  
    847847  my @reciplist;
    848848  foreach (@actionsets) {
    849     $sth->execute($action);
     849    $sth->execute($_);
    850850##fixme - need to handle db errors
    851851    my ($recipsub) = $sth->fetchrow_array;
  • trunk/cgi-bin/admin.cgi

    r424 r426  
    534534        qq(<td><a href="admin.cgi?action=delnotice&code=$notice_code">Delete</a></tr>\n);
    535535  }
    536   print "</table>\n";
     536  print qq(<tr><td colspan=2>Known "special" codes:<br>
     537<ul style="margin-top: 0px; margin-bottom: 0px;">
     538        <li>swi: Notify if block being updated has SWIP flag set</li>
     539</ul></td></tr>
     540</table>
     541);
    537542
    538543# add new entries from this tangle:
     
    581586
    582587} elsif ($webvar{action} eq 'addnotice') {
    583   $webvar{reciplist} =~ s/[\r\n]+/,/g;
    584   print "Adding notice to $webvar{reciplist} for ".dispNoticeCode($webvar{msgaction}.$webvar{alloctype}).":\n";
    585   $sth = $ip_dbh->prepare("INSERT INTO notify (action, reciplist) VALUES (?,?)");
     588  $webvar{alloctype} = $webvar{special} if $webvar{msgaction} eq 's:';
     589  if ($webvar{msgaction} && $webvar{alloctype} && $webvar{reciplist}) {
     590    $webvar{reciplist} =~ s/[\r\n]+/,/g;
     591    print "Adding notice to $webvar{reciplist} for ".dispNoticeCode($webvar{msgaction}.$webvar{alloctype}).":\n";
     592    $sth = $ip_dbh->prepare("INSERT INTO notify (action, reciplist) VALUES (?,?)");
    586593##fixme:  automagically merge reciplists iff action already exists
    587   $webvar{msgaction} = "f:$webvar{msgaction}" if $webvar{onfail};
    588   $sth->execute($webvar{msgaction}.$webvar{alloctype}, $webvar{reciplist});
    589   if ($sth->err) {
    590     print "Failed:  DB error: ".$sth->errstr."\n";
     594    $webvar{msgaction} = "f:$webvar{msgaction}" if $webvar{onfail};
     595    $sth->execute($webvar{msgaction}.$webvar{alloctype}, $webvar{reciplist});
     596    if ($sth->err) {
     597      print "Failed:  DB error: ".$sth->errstr."\n";
     598    } else {
     599      print "OK!<br>\n"
     600    }
    591601  } else {
    592     print "OK!<br>\n"
     602    print "Need to specify at least one recipient, an action, and an allocation type. ".
     603        qq{("Special" content is considered an allocation type).  Hit the Back button and try again.<br>\n};
    593604  }
    594605  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
     
    784795  my $code = shift;
    785796  my $action_out = '';
    786 #    my $code = $notice_code;
     797
     798  if ($code =~ /^s:/) {
     799    $code =~ s/^s:/Special: /;
     800    return $code;
     801  }
    787802  if ($code =~ /^f:(.+)$/) {
    788803    $code =~ s/^f://;
  • trunk/cgi-bin/main.cgi

    r420 r426  
    12301230##fixme:  need to wedge something in to allow "update:field" notifications
    12311231## hmm.  how to tell what changed?  O_o
    1232 mailNotify($ip_dbh, 'ua', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
     1232mailNotify($ip_dbh, 's:swi', "SWIPed: $disp_alloctypes{$webvar{alloctype}} $webvar{block}",
    12331233        "$webvar{block} had SWIP status changed to \"Yes\" by $authuser") if $webvar{swip} eq 'on';
    12341234  open (HTML, "../updated.html")
Note: See TracChangeset for help on using the changeset viewer.