Changeset 927 for trunk/cgi-bin
- Timestamp:
- 07/12/19 16:13:35 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cgi-bin/search-rpc.cgi
r925 r927 256 256 } 257 257 258 my $cols = "s.cidr, s.custid, s.type, s.city, s.description, s.id, s.parent_id, s.available, s.vrf, a.dispname"; 259 my $sql = qq(SELECT $cols FROM searchme s JOIN alloctypes a ON s.type = a.type); 258 my $cols = "s.cidr, s.custid, s.type, s.city, s.description, s.id, s.parent_id, s.available, a.vrf, at.dispname"; 259 260 # Validation and SQL field name mapping all in one! 261 my %validcols = (cidr => 's.cidr', custid => 's.custid', oldcustid => 's.oldcustid', type => 's.type', city => 's.city', 262 description => 's.description', notes => 's.notes', circuitid => 's.circuitid', vrf => 'a.vrf', vlan => 's.vlan', 263 id => 's.id', parent_id => 's.parent_id', master_id => 's.master_id', available => 's.available'); 264 my @usercols; 265 266 if ($args{retfields}) { 267 # caller wants a custom set of returned fields 268 if (ref($args{retfields}) eq ref([])) { 269 # field list passed as list/array 270 foreach (@{$args{retfields}}) { 271 push @usercols, $validcols{$_} if $validcols{$_}; 272 } 273 } elsif (not ref $args{retfields}) { 274 # field list passed as simple string 275 foreach (split /\s+/, $args{retfields}) { 276 push @usercols, $validcols{$_} if $validcols{$_}; 277 } 278 } else { 279 # nonfatal fail. only accepts array or string. fall back to default list 280 } 281 } 282 283 # only replace the default set if a custom set was passed in 284 $cols = join ', ', @usercols if @usercols; 285 286 my $sql = qq(SELECT $cols FROM searchme s JOIN alloctypes at ON s.type = at.type JOIN allocations a ON s.master_id=a.id); 260 287 my @sqlcriteria; 261 288 for (my $i = 0; $i <= $#fields; $i++) { … … 436 463 city, and description. 437 464 465 =item fields 466 467 Specify the fields to return from the search. By default, these are returned: 468 469 =over 4 470 471 cidr 472 custid 473 type 474 city 475 description 476 id 477 parent_id 478 available 479 vrf 480 dispname (the "display name" for the type) 481 438 482 =back 439 483 484 The following are available from this interface: 485 486 =over 4 487 488 cidr 489 custid 490 oldcustid 491 type 492 city 493 description 494 notes 495 circuitid 496 vrf 497 vlan 498 id 499 parent_id 500 master_id 501 available 502 503 =back 504 505 The list may be sent as a space-separated string or as an array. Unknown field names will be ignored. 506 507 =back
Note:
See TracChangeset
for help on using the changeset viewer.