* Don't autovifivy @fields array entries.
[interchange.git] / code / UI_Tag / mm_value.coretag
1 # Copyright 2002-2007 Interchange Development Group and others
2
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.
7
8 # $Id: mm_value.coretag,v 1.4 2007-03-30 23:40:54 pajamian Exp $
9
10 UserTag mm-value Order     field table
11 UserTag mm-value addAttr
12 UserTag mm-value Version   $Revision: 1.4 $
13 UserTag mm-value Routine   <<EOR
14 sub {
15         my($field, $table, $opt, $text) = @_;
16
17         my $record;
18         my $status;
19         my $reverse;
20         my $uid = $opt->{user};
21         unless ($record = $Vend::UI_entry) {
22                 return '' unless ref($record = ui_acl_enabled());
23         }
24 #::logDebug("mm-value record: " . ::uneval($record));
25         $table = $opt->{table} || $::Scratch->{ui_data_table};
26
27         if($field eq 'user') {
28                 return $Vend::Session->{ui_username} || $Vend::Session->{username} || $CGI::user;
29         }
30
31         my %hash_field = qw/
32                                                 acl_keys      1
33                                                 no_fields     1
34                                                 yes_fields    1
35                                                 no_keys       1
36                                                 yes_keys      1
37                                                 owner_field   1
38                                         /;
39         
40         my $acl;
41         my $check;
42         if($check = $hash_field{$field}) {
43                 if ($field eq 'acl_keys') {
44                         return join "\n", get_ui_table_acl($table, $uid, 1);
45                 }
46                 else {
47                         $acl = get_ui_table_acl($table, $uid);
48                         return $acl->{$field};
49                 }
50         }
51         else {
52                 return $record->{$field};
53         }
54 }
55 EOR