Changeset 370 for trunk/DNSDB.pm
- Timestamp:
- 07/29/12 22:02:48 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r368 r370 47 47 &addUser &updateUser &delUser &userFullName &userStatus &getUserData 48 48 &getUserCount &getUserList &getUserDropdown 49 &addLoc &updateLoc &delLoc 50 &getLocCount &getLocList &getLocDropdown 49 51 &getSOA &updateSOA &getRecLine &getDomRecs &getRecCount 50 52 &addRec &updateRec &delRec … … 72 74 &addUser &updateUser &delUser &userFullName &userStatus &getUserData 73 75 &getUserCount &getUserList &getUserDropdown 76 &addLoc &updateLoc &delLoc 77 &getLocCount &getLocList &getLocDropdown 74 78 &getSOA &updateSOA &getRecLine &getDomRecs &getRecCount 75 79 &addRec &updateRec &delRec … … 106 110 107 111 # Arguably defined wholly in the db, but little reason to change without supporting code changes 112 # group_view, user_view permissions? separate rDNS permission(s)? 108 113 our @permtypes = qw ( 109 114 group_edit group_create group_delete … … 111 116 domain_edit domain_create domain_delete 112 117 record_edit record_create record_delete 118 location_edit location_create location_delete location_view 113 119 self_edit admin 114 120 ); … … 2891 2897 2892 2898 } # end getUserData() 2899 2900 2901 ## DNSDB::addLoc() 2902 sub addLoc {} 2903 2904 ## DNSDB::updateLoc() 2905 sub updateLoc {} 2906 2907 ## DNSDB::delLoc() 2908 sub delLoc {} 2909 2910 2911 ## DNSDB::getLocCount() 2912 # Get count of locations/views 2913 # Takes a database handle and hash containing at least the current group, and optionally: 2914 # - a reference list of secondary groups 2915 # - a filter string 2916 # - a "Starts with" string 2917 sub getLocCount { 2918 my $dbh = shift; 2919 2920 my %args = @_; 2921 2922 my @filterargs; 2923 2924 $args{startwith} = undef if $args{startwith} && $args{startwith} !~ /^(?:[a-z]|0-9)$/; 2925 push @filterargs, "^$args{startwith}" if $args{startwith}; 2926 push @filterargs, $args{filter} if $args{filter}; 2927 2928 2929 my $sql = "SELECT count(*) FROM locations ". 2930 "WHERE group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 2931 ($args{startwith} ? " AND description ~* ?" : ''). 2932 ($args{filter} ? " AND description ~* ?" : ''); 2933 my ($count) = $dbh->selectrow_array($sql, undef, (@filterargs) ); 2934 $errstr = $dbh->errstr if !$count; 2935 return $count; 2936 } # end getLocCount() 2937 2938 2939 ## DNSDB::getLocList() 2940 sub getLocList { 2941 my $dbh = shift; 2942 2943 my %args = @_; 2944 2945 my @filterargs; 2946 2947 $args{startwith} = undef if $args{startwith} && $args{startwith} !~ /^(?:[a-z]|0-9)$/; 2948 push @filterargs, "^$args{startwith}" if $args{startwith}; 2949 push @filterargs, $args{filter} if $args{filter}; 2950 2951 # better to request sorts on "simple" names, but it means we need to map it to real columns 2952 # my %sortmap = (user => 'u.username', type => 'u.type', group => 'g.group_name', status => 'u.status', 2953 # fname => 'fname'); 2954 # $args{sortby} = $sortmap{$args{sortby}}; 2955 2956 # protection against bad or missing arguments 2957 $args{sortorder} = 'ASC' if !$args{sortorder}; 2958 $args{sortby} = 'l.description' if !$args{sortby}; 2959 $args{offset} = 0 if !$args{offset}; 2960 2961 my $sql = "SELECT l.location, l.description, l.iplist, g.group_name ". 2962 "FROM locations l ". 2963 "INNER JOIN groups g ON l.group_id=g.group_id ". 2964 "WHERE l.group_id IN ($args{curgroup}".($args{childlist} ? ",$args{childlist}" : '').")". 2965 ($args{startwith} ? " AND l.description ~* ?" : ''). 2966 ($args{filter} ? " AND l.description ~* ?" : ''). 2967 " ORDER BY $args{sortby} $args{sortorder} ". 2968 ($args{offset} eq 'all' ? '' : " LIMIT $config{perpage} OFFSET ".$args{offset}*$config{perpage}); 2969 my $ulist = $dbh->selectall_arrayref($sql, { Slice => {} }, (@filterargs) ); 2970 $errstr = $dbh->errstr if !$ulist; 2971 return $ulist; 2972 } # end getLocList() 2973 2974 2975 ## DNSDB::getLocDropdown() 2893 2976 2894 2977
Note:
See TracChangeset
for help on using the changeset viewer.