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: if_mm.coretag,v 1.6 2007-03-30 23:40:54 pajamian Exp $
10 UserTag if-mm Order function name
12 UserTag if-mm attrAlias key name
13 UserTag if-mm hasEndTag
14 UserTag if-mm Version $Revision: 1.6 $
15 UserTag if-mm Routine <<EOR
17 my($func, $field, $opt, $text) = @_;
23 $reverse = $func =~ s/^\s*!\s*//;
26 $extended = $1 if $field =~ s/(=.*)//;
31 if ($group or ! ($record = $Vend::UI_entry) ) {
32 $record = ui_acl_enabled($group);
38 ($status = 0, last CHECKIT) if ! UI::Primitive::is_logged();
39 ($status = 1, last CHECKIT) if $record->{super};
41 ($status = 1, last CHECKIT) if $func eq 'logged_in';
53 owner_field owner_field
88 my $table = $CGI::values{mv_data_table} || $::Values->{mv_data_table};
90 if($yesno_func{$func} eq 'tables') {
91 $opt->{table} = $field if ! $opt->{table};
92 $opt->{table} =~ s/^=/$table/;
94 elsif($yesno_func{$func} eq 'functions') {
95 $opt->{table} = $field;
98 $table = $opt->{table} || $table;
102 $status = 0, last CHECKIT if $func eq 'super';
103 if($check = $file_func{$func}) {
104 $status = 1, last CHECKIT unless $record->{$check};
105 my $file = $field || $Global::Variable->{MV_PAGE};
106 # strip trailing slashes for checks on directories
108 #::logDebug("check=$check file=$file record=$record->{$check} prefix=$opt->{prefix}");
109 my @files = UI::Primitive::list_glob($record->{$check}, $opt->{prefix});
110 #::logDebug("check yielded files=" . join(",", @files));
115 $status = ui_check_acl("$file$extended", join(" ", @files));
116 #::logDebug("check status=$status");
119 if($check = $prefix_func{$func}) {
120 $status = '', last CHECKIT unless $record->{$check};
122 # strip trailing slashes for checks on directories
123 #::logDebug("check=$check file=$file record=$record->{$check}");
124 my @allow = split /\s+/, $record->{$check};
127 #::logDebug("check file=$file against allow=$_");
129 if ($file =~ /^$_/) {
130 #::logDebug("denied based on $_");
136 next unless $file =~ /^$_\b/;
140 #::logDebug("check Yielded status=$status");
143 if($bool_func{$func} ) {
144 $status = $record->{$func};
147 if($check = $yesno_func{$func} ) {
149 if($v = $record->{"yes_$check"}) {
150 $status = ui_check_acl("$table$extended", $v);
155 if($v = $record->{"no_$check"}) {
156 $status &&= ! ui_check_acl("$table$extended", $v);
160 if(! ($check = $acl_func{$func}) ) {
161 my $default = $func =~ /^no_/ ? 0 : 1;
162 $status = $default, last CHECKIT unless $record->{$func};
163 $status = ui_check_acl("$table$extended", $record->{$func});
167 # Now it is definitely a job for table_control;
168 $acl = UI::Primitive::get_ui_table_acl($table);
170 $status = 1, last CHECKIT unless $acl;
172 if($acl->{owner_field} and $check eq 'keys') {
173 $status = ::tag_data($table, $acl->{owner_field}, $field)
177 elsif ($check eq 'owner_field') {
178 $status = length $acl->{owner_field};
181 $status = UI::Primitive::ui_acl_atom($acl, $check, $field);
183 if(! $status and $record and (@groups or $record->{groups}) ) {
184 goto CHECKIT if $group = shift @groups;
185 (@groups) = grep /\S/, split /[\0,\s]+/, $record->{groups};
186 ($group, @groups) = map { s/^/:/; $_ } @groups;
191 Vend::Interpolate::pull_if($text, $reverse)
193 : Vend::Interpolate::pull_else($text, $reverse);