Changeset 479 for trunk


Ignore:
Timestamp:
03/13/13 17:39:28 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Object conversion of DNSDB.pm, 12 of <mumble>. See #11.

  • user subs addUser(), getUserCount(), getUserList(), getUserDropdown(), updateUser(), delUser(), userStatus(), and getUserData() and callers
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r478 r479  
    26682668sub addUser {
    26692669  $errstr = '';
    2670   my $dbh = shift;
     2670  my $self = shift;
     2671  my $dbh = $self->{dbh};
    26712672  my $username = shift;
    26722673  my $group = shift;
     
    27822783# - a "Starts with" string
    27832784sub getUserCount {
    2784   my $dbh = shift;
     2785  my $self = shift;
     2786  my $dbh = $self->{dbh};
    27852787
    27862788  my %args = @_;
     
    28102812# - offset/return-all-everything flag (defaults to $perpage records)
    28112813sub getUserList {
    2812   my $dbh = shift;
     2814  my $self = shift;
     2815  my $dbh = $self->{dbh};
    28132816
    28142817  my %args = @_;
     
    28502853# Returns a reference to a list of hashrefs suitable to feeding to HTML::Template
    28512854sub getUserDropdown {
    2852   my $dbh = shift;
     2855  my $self = shift;
     2856  my $dbh = $self->{dbh};
    28532857  my $grp = shift;
    28542858  my $sel = shift || 0;
     
    28732877# Update general data about user
    28742878sub updateUser {
    2875   my $dbh = shift;
     2879  my $self = shift;
     2880  my $dbh = $self->{dbh};
    28762881
    28772882##fixme:  tweak calling convention so that we can update any given bit of data
     
    29352940# Returns a success/failure code and matching message
    29362941sub delUser {
    2937   my $dbh = shift;
     2942  my $self = shift;
     2943  my $dbh = $self->{dbh};
    29382944  my $userid = shift;
    29392945
    29402946  return ('FAIL',"Bad userid") if !defined($userid);
    29412947
    2942   my $userdata = getUserData($dbh, $userid);
     2948  my $userdata = $self->getUserData($userid);
    29432949
    29442950  # Allow transactions, and raise an exception on errors so we can catch it later.
     
    30013007# Returns undef on errors.
    30023008sub userStatus {
    3003   my $dbh = shift;
     3009  my $self = shift;
     3010  my $dbh = $self->{dbh};
    30043011  my $id = shift;
    30053012  my $newstatus = shift || 'mu';
     
    30073014  return undef if $id !~ /^\d+$/;
    30083015
    3009   my $userdata = getUserData($dbh, $id);
     3016  my $userdata = $self->getUserData($id);
    30103017
    30113018  # Allow transactions, and raise an exception on errors so we can catch it later.
     
    30493056# Get misc user data for display
    30503057sub getUserData {
    3051   my $dbh = shift;
     3058  my $self = shift;
     3059  my $dbh = $self->{dbh};
    30523060  my $uid = shift;
    30533061
  • trunk/dns-rpc.cgi

    r477 r479  
    245245    push @userargs, $args{$argname};
    246246  }
    247   my ($code,$msg) = DNSDB::addUser($dbh, @userargs);
     247  my ($code,$msg) = $dnsdb->addUser(@userargs);
    248248  die $msg if $code eq 'FAIL';
    249249  return $msg;
     
    271271##fixme:  also underlying in DNSDB::updateUser():  no way to just update this or that attribute;
    272272#         have to pass them all in to be overwritten
    273   my ($code,$msg) = DNSDB::updateUser($dbh, @userargs);
     273  my ($code,$msg) = $dnsdb->updateUser(@userargs);
    274274  die $msg if $code eq 'FAIL';
    275275  return $msg;
     
    282282
    283283  die "Missing UID\n" if !$args{uid};
    284   my ($code,$msg) = DNSDB::delUser($dbh, $args{uid});
     284  my ($code,$msg) = $dnsdb->delUser($args{uid});
    285285  die $msg if $code eq 'FAIL';
    286286  return $msg;
  • trunk/dns.cgi

    r477 r479  
    10961096    if ($flag && ($permissions{admin} || $permissions{user_edit} ||
    10971097        ($permissions{self_edit} && $webvar{id} == $session->param('uid')) )) {
    1098       my $stat = userStatus($dbh,$webvar{id},$webvar{userstatus});
     1098      my $stat = $dnsdb->userStatus($webvar{id}, $webvar{userstatus});
    10991099      $page->param(resultmsg => $DNSDB::resultstr);
    11001100    } else {
     
    11991199                unless $permissions{admin} || $permissions{user_create};
    12001200        # no scope check;  user is created in the current group
    1201         ($code,$msg) = addUser($dbh, $webvar{uname}, $curgroup, $webvar{pass1},
     1201        ($code,$msg) = $dnsdb->addUser($webvar{uname}, $curgroup, $webvar{pass1},
    12021202                ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype}, $permstring,
    12031203                $webvar{fname}, $webvar{lname}, $webvar{phone});
     
    12141214# or self-torture trying to not commit the transaction until we're really done.
    12151215        # Allowing for changing group, but not coding web support just yet.
    1216         ($code,$msg) = updateUser($dbh, $webvar{uid}, $webvar{uname}, $webvar{gid}, $webvar{pass1},
     1216        ($code,$msg) = $dnsdb->updateUser($webvar{uid}, $webvar{uname}, $webvar{gid}, $webvar{pass1},
    12171217                ($webvar{makeactive} eq 'on' ? 1 : 0), $webvar{accttype},
    12181218                $webvar{fname}, $webvar{lname}, $webvar{phone});
     
    12751275    fill_clonemelist();
    12761276
    1277     my $userinfo = getUserData($dbh,$webvar{user});
     1277    my $userinfo = $dnsdb->getUserData($webvar{user});
    12781278    fill_actypelist($userinfo->{type});
    12791279    # not using this yet, but adding it now means we can *much* more easily do so later.
     
    13191319    $page->param(user => $dnsdb->userFullName($webvar{id}));
    13201320  } elsif ($webvar{del} eq 'ok') {
    1321     my ($code,$msg) = delUser($dbh, $webvar{id});
     1321    my ($code,$msg) = $dnsdb->delUser($webvar{id});
    13221322    if ($code eq 'OK') {
    13231323      # success.  go back to the user list, do not pass "GO"
     
    19651965  local $webvar{clonesrc} = 0 if !defined($webvar{clonesrc});
    19661966
    1967   my $clones = getUserDropdown($dbh, $curgroup, $webvar{clonesrc});
     1967  my $clones = $dnsdb->getUserDropdown($curgroup, $webvar{clonesrc});
    19681968  $page->param(clonesrc => $clones);
    19691969}
     
    21902190  my $childlist = join(',',@childgroups);
    21912191
    2192   my $count = getUserCount($dbh, (childlist => $childlist, curgroup => $curgroup,
    2193         filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) ) );
     2192  my $count = $dnsdb->getUserCount(childlist => $childlist, curgroup => $curgroup,
     2193        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef) );
    21942194
    21952195# fill page count and first-previous-next-last-all bits
     
    22162216  $page->param(searchsubs => $searchsubs) if $searchsubs;
    22172217
    2218   my $ulist = getUserList($dbh, (childlist => $childlist, curgroup => $curgroup,
     2218  my $ulist = $dnsdb->getUserList(childlist => $childlist, curgroup => $curgroup,
    22192219        filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef),
    2220         offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder) );
     2220        offset => $webvar{offset}, sortby => $sortby, sortorder => $sortorder);
    22212221  # Some UI things need to be done to the list (unlike other lists)
    22222222  foreach my $u (@{$ulist}) {
Note: See TracChangeset for help on using the changeset viewer.