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: list_keys.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $
10 UserTag list-keys Order table
11 UserTag list-keys addAttr
12 UserTag list-keys Version $Revision: 1.5 $
13 UserTag list-keys Routine <<EOR
16 #::logDebug("list-keys $table");
17 $table = $::Values->{mv_data_table}
19 #::logDebug("list-keys $table");
22 if(! ($record = $Vend::UI_entry) ) {
23 $record = ui_acl_enabled();
29 #::logDebug("list_keys: record=$record");
30 $acl = get_ui_table_acl($table);
31 #::logDebug("list_keys table=$table: acl=$acl");
32 if($acl and $acl->{yes_keys}) {
33 #::logDebug("list_keys table=$table: yes.keys enabled");
34 @keys = grep /\S/, split /\s+/, $acl->{yes_keys};
38 my $db = Vend::Data::database_exists_ref($table);
40 $db = $db->ref() unless $Vend::Interpolate::Db{$table};
41 my $keyname = $db->config('KEY');
42 if($db->config('LARGE')) {
43 return ::errmsg('--not listed, too large--');
45 my $query = "select $keyname from $table order by $keyname";
46 #::logDebug("list_keys: query=$query");
50 ml => $::Variable->{UI_ACCESS_KEY_LIMIT} || 500,
55 @keys = map {$_->[0]} @$keys;
59 while (($k) = $db->each_record()) {
62 if( $db->numeric($db->config('KEY')) ) {
63 @keys = sort { $a <=> $b } @keys;
69 #::logDebug("list_keys: query=returned " . ::uneval(\@keys));
72 #::logDebug("list_keys acl: ". ::uneval($acl));
73 @keys = UI::Primitive::ui_acl_grep( $acl, 'keys', @keys);
75 return @keys if wantarray;
76 return join("\n", @keys);