Ignore:
Timestamp:
07/06/10 17:23:27 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint, email notice management. See #21.
Completed: add new notice group.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/admin.cgi

    r422 r423  
    535535  }
    536536  print "</table>\n";
     537
     538# add new entries from this tangle:
     539  print "Add new notification:<br>\n";
     540
     541  print qq(<table border=1><form action=admin.cgi method="POST">
     542<input type=hidden name=action value=addnotice>
     543<tr>
     544<td>Recipients</td><td colspan=3><textarea name=reciplist cols=50 rows=5></textarea></td></tr>
     545<tr><td>Action</td><td>
     546        <input type=radio name=msgaction value=a>Add &nbsp;
     547        <input type=radio name=msgaction value=u>Update &nbsp;
     548        <input type=radio name=msgaction value=d>Delete
     549</td>
     550<td>Failure?</td><td><input type=checkbox name=onfail></td></tr>
     551<tr><td>Allocation type:</td><td colspan=3>
     552        <table>
     553        <tr>
     554                <td><input type=radio name=alloctype value=a>All allocations</td>
     555                <td><input type=radio name=alloctype value=.i>All static IPs</td>
     556        </tr>
     557        <tr>
     558);
     559
     560  $sth = $ip_dbh->prepare("SELECT type,dispname FROM alloctypes WHERE listorder < 500 ".
     561        "ORDER BY listorder");
     562  $sth->execute;
     563  my $i=0;
     564  while (my ($type,$disp) = $sth->fetchrow_array) {
     565    print "             <td><input type=radio name=alloctype value=$type>$disp</td>";
     566    $i++;
     567    print "     </tr>\n\t<tr>"
     568        if ($i % 4 == 0);
     569  }
     570
     571  print qq(     </tr>
     572        </table>
     573</tr>
     574<tr><td colspan=4 align=center><input type=submit value="Add notice"></td></tr>
     575</table>
     576</form>
     577);
     578  ## done spitting out add-new-spam-me-now table
     579
     580} elsif ($webvar{action} eq 'addnotice') {
     581##work
     582  $webvar{reciplist} =~ s/[\r\n]+/,/g;
     583  print "Adding notice to $webvar{reciplist} for ".dispNoticeCode($webvar{msgaction}.$webvar{alloctype}).":\n";
     584  $sth = $ip_dbh->prepare("INSERT INTO notify (action, reciplist) VALUES (?,?)");
     585##fixme:  automagically merge reciplists iff action already exists
     586  $webvar{msgaction} = "f:$webvar{msgaction}" if $webvar{onfail};
     587  $sth->execute($webvar{msgaction}.$webvar{alloctype}, $webvar{reciplist});
     588  if ($sth->err) {
     589    print "Failed:  DB error: ".$sth->errstr."\n";
     590  } else {
     591    print "OK!<br>\n"
     592  }
     593  print qq(<a href="admin.cgi?action=emailnotice">Back to email notice list</a>\n);
     594
    537595} elsif ($webvar{action} eq 'ednotice') {
    538596  print "<h4>Editing recipient list for '".dispNoticeCode($webvar{code})."':</h4>\n";
    539 ##work
    540597  $sth = $ip_dbh->prepare("SELECT reciplist FROM notify WHERE action=?");
    541598  $sth->execute($webvar{code});
     
    731788    elsif ($action eq 'd')   { $action_out .= 'Delete '; }
    732789##fixme:  what if we get something funky?
     790# What about the eleventy-billion odd combinations possible?
     791# this should give an idea of the structure tho
    733792    if ($target eq 'a') { $action_out .= "all"; }
     793    elsif ($target =~ /^\.i$/) {
     794      $action_out .= "all static IPs";
     795    }
    734796    else { $action_out .= $disp_alloctypes{$target}; }
    735797  }
Note: See TracChangeset for help on using the changeset viewer.