1 # Copyright 2002-2007 Interchange Development Group and others
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version. See the LICENSE file for details.
8 # $Id: db_columns.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $
10 UserTag db_columns Order name columns joiner passed_order
11 UserTag db_columns AttrAlias table name
12 UserTag db_columns AttrAlias fields columns
13 UserTag db_columns Version $Revision: 1.5 $
14 UserTag db_columns Routine <<EOR
16 my ($table,$columns, $joiner, $passed_order) = @_;
17 $table = $Values->{mv_data_table}
19 my $db = Vend::Data::database_exists_ref($table)
21 my $acl = UI::Primitive::get_ui_table_acl($table);
22 $db = $db->ref() unless $Vend::Interpolate::Db{$table};
23 my $key = $db->config('KEY');
25 $joiner = "\n" unless defined $joiner;
28 if(! $columns || $columns =~ /^[\s,\0]*$/) {
29 @cols = $db->columns();
32 @cols = grep /\S/, split /[\s,\0]+/, $columns;
33 my (@allcols) = $db->columns();
37 @col{@allcols} = @allcols;
41 next unless $_ eq $key;
45 unshift (@allcols, $key) if ! $found;
51 $col{$key} = $key if ! defined $col{$key};
53 @cols = grep defined $col{$_}, @cols;
57 @cols = UI::Primitive::ui_acl_grep( $acl, 'fields', @cols);
60 return @cols if wantarray;
61 return join $joiner, @cols;