Changeset 22 for trunk/DNSDB.pm


Ignore:
Timestamp:
10/15/09 17:50:22 (15 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint - basic group management should be complete

  • fiddled HTML so that group-delete and domain-delete errors don't sit on top of the menu column
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r20 r22  
    2323@ISA            = qw(Exporter);
    2424@EXPORT_OK      = qw(
    25         &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren &groupName
    26         &getSOA &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus
     25        &initGlobals &connectDB &finish
     26        &addDomain &delDomain &domainName
     27        &addGroup &delGroup &getChildren &groupName
     28        &getSOA &getRecLine &getDomRecs
     29        &addRec &updateRec &delRec
     30        &domStatus
    2731        %typemap %reverse_typemap
    2832        );
     
    3034@EXPORT         = (); # Export nothing by default.
    3135%EXPORT_TAGS    = ( ALL => [qw(
    32                 &initGlobals &connectDB &finish &addDomain &delDomain &domainName &addGroup &getChildren
    33                 &groupName &getSOA &getRecLine &getDomRecs &addRec &updateRec &delRec &domStatus
     36                &initGlobals &connectDB &finish
     37                &addDomain &delDomain &domainName
     38                &addGroup &delGroup &getChildren &groupName
     39                &getSOA &getRecLine &getDomRecs
     40                &addRec &updateRec &delRec
     41                &domStatus
    3442                %typemap %reverse_typemap
    3543                )]
     
    225233    $sth->execute($domid);
    226234
     235#die "full of fail\n";
    227236    # once we get here, we should have suceeded.
    228     $dbh->commit;
     237#    $dbh->commit;
    229238  }; # end eval
    230239
     
    302311    }
    303312
    304 die "epic FAIL..  hahahah, just testing!\n";
    305313    # once we get here, we should have suceeded.
    306314    $dbh->commit;
     
    316324
    317325} # end addGroup()
     326
     327
     328## DNSDB::delGroup()
     329# Delete a group.
     330# Takes a group ID
     331# Returns a status code and message
     332sub delGroup {
     333  my $dbh = shift;
     334  my $groupid = shift;
     335
     336  # Allow transactions, and raise an exception on errors so we can catch it later.
     337  # Use local to make sure these get "reset" properly on exiting this block
     338  local $dbh->{AutoCommit} = 0;
     339  local $dbh->{RaiseError} = 1;
     340
     341##fixme:  locate "knowable" error conditions and deal with them before the eval
     342# -> domains still exist in group
     343# -> ...
     344
     345  # Wrap all the SQL in a transaction
     346  eval {
     347    my $sth = $dbh->prepare("delete from default_records where group_id=?");
     348    $sth->execute($groupid);
     349    $sth = $dbh->prepare("delete from groups where group_id=?");
     350    $sth->execute($groupid);
     351
     352die "epic group fail FTW!\n";
     353    # once we get here, we should have suceeded.
     354    $dbh->commit;
     355  }; # end eval
     356
     357  if ($@) {
     358    my $msg = $@;
     359    eval { $dbh->rollback; };
     360    return ('FAIL',$msg);
     361  } else {
     362    return ('OK','OK');
     363  }
     364} # end delGroup()
    318365
    319366
Note: See TracChangeset for help on using the changeset viewer.