[calc] $CGI->{no_dbmenu} = 1; $CGI->{access_menu} = 1; $CGI->{mv_data_table} = $Values->{mv_data_table} = '__UI_ACCESS_TABLE__'; $CGI->{user_id} = $Values->{user_id} if ! $CGI->{user_id}; return; [/calc] [if !cgi user_id] [bounce page="__UI_BASE__/access"] [/if] [seti page_title][L]Edit Permissions[/L]: [cgi user_id][/seti] [set ui_class]Admin[/set] [set page_perm]access=v[/set] [set help_name]access.permissions[/set] [set icon_name]icon_config.gif[/set] [set process_perm] [flag type=write table="__UI_ACCESS_TABLE__"] [db-hash table="__UI_ACCESS_TABLE__" column="table_control" key="[cgi user_id]" scratch=ui_owner] [perl] $tc = $Scratch->{ui_owner}; my @filters = grep /^ui_filter:/, keys %$CGI; foreach my $key (@filters) { my $val = delete $CGI->{$key}; $key =~ s/ui_filter://; next unless $val; next unless defined $CGI->{$key}; $CGI->{$key} = $Tag->filter($val, $CGI->{$key}, $key); $CGI->{$key} = s/=$//; } $CGI->{yes_functions} =~ s/\0//g; $CGI->{yes_functions} =~ s/,/ /g; $CGI->{yes_functions} =~ s/\w+=(?:\s+|$)//g; $CGI->{yes_tables} =~ s/\0//g; $CGI->{yes_tables} =~ s/,/ /g; $CGI->{yes_tables} =~ s/\w+=(?:\s+|$)//g; $CGI->{yes_tables} =~ s/(\w+)=vecdix(\s+|$)/$1$2/g; $CGI->{owner_field} =~ s/\0//g; $CGI->{owner_field} =~ s/,$//; my (%of) = split /[=,]/, $CGI->{owner_field}; for(keys %of) { if($of{$_} !~ /\S/) { next unless defined $tc->{$_}; delete $tc->{$_}{owner_field}; } else { $tc->{$_}{owner_field} = $of{$_}; } } $CGI->{table_control} = $Tag->uneval( { ref => $tc } ); $CGI->{owner_field} =~ s/\w+=(?:\s+|$)//g; $CGI->{owner_field} =~ s/(\w+)=vecdix(\s+|$)/$1$2/g; $CGI->{no_tables} =~ s/\0/ /g; $CGI->{mv_todo} = 'set'; return; [/perl] [/set] @_UI_STD_HEAD_@
[seti tables][list-databases][/seti] [db-hash table="__UI_ACCESS_TABLE__" column="table_control" key="[cgi user_id]" scratch="ui_owner"] [perl tables="__UI_META_TABLE__ __UI_ACCESS_TABLE__"] my @permissions = ( item => '[L]Item editor[/L]', page => '[L]Page editor[/L]', cat => '[L]Category editor[/L]', tax => '[L]Tax editor[/L]', shipping => '[L]Shipping editor[/L]', payment => '[L]Payment editor[/L]', affiliate => '[L]Affiliates editor[/L]', itemtype => '[L]Item type editor[/L]', pagetype => '[L]Page type editor[/L]', grouptype => '[L]Group type editor[/L]', matrix => '[L]Matrix editor[/L]', knar => '[L]Knar editor[/L]', access => '[L]Administrator Permissions[/L]', group => '[L]Access Group editor[/L]', perm => '[L]Permission editor[/L]', layout => '[L]Layout editor[/L]', ); my %extra = qw/userdb 1 order 1/; my $current = tag_data('__UI_ACCESS_TABLE__', 'yes_functions', $CGI->{user_id}); my $out = ''; my @ary = grep /\S/, split /[\s,\0]+/, $current; my @some = qw/l v c e d/; my @more = qw/a u p/; my @all = (@some, @more); my %all; @all{@some, @more} = (@some, @more); $permref = {}; foreach $one (@ary) { $one =~ s/=(.*)//; my $sub = $1 || undef; my $ref = $permref->{$one} = {}; my @set; if ($sub) { @set = grep $all{$_}, split //, $sub; } else { @set = $extra{$one} ? @all : @some; } for(@set) { $ref->{$_} = ' CHECKED'; } } my $string = $Tag->uneval( {ref=>$permref} ); #DEBUG # $out .= < # #EOF my $perm; my $title; while( $perm = shift @permissions) { $title = shift @permissions; my $ref = $permref->{$perm} || {}; $out .= < EOF for(@some) { $out .= < {$_}> EOF } $out =~ s!(<.td>\s*)$!$1!; } my $ref = $permref->{order}; $out .= <
  [L]View list[/L] [L]View detail[/L] [L]Create[/L] [L]Edit[/L] [L]Delete[/L]
#$string # $title

EOF return $out; [/perl]
[L]Order manager[/L]:
  • {l}> [L]View list[/L]
  • {v}> [L]View single[/L]
  • {d}> [L]Delete[/L]
  • {e}> [L]Edit[/L]
  • {c}> [L]Input new[/L]
  • {a}> [L]Archive[/L]
  • {u}> [L]Un-archive[/L]

  • EOF @permissions = ( orderstats => 'Order statistics utility', trafficstats => 'Traffic statistics utility', env_vars => 'Environment variables utility', stats => 'Stats menu', techadmin => 'Technical Admin menu', sitedesign => 'Site Design menu', config => 'Apply changes', delete_files => 'Delete owned files', dbupload => 'Database importer', dbdownload => 'Database exporter', layupload => 'Layout importer', laydownload => 'Layout exporter', gentable => 'List tables', gensql => 'Direct SQL utility', dbconfig => 'Database configuration', files => 'Modify Files', ); while($perm = shift @permissions ) { $title = errmsg(shift @permissions); my $on = defined $permref->{$perm} ? ' CHECKED' : ''; $out .= < $title EOF } $ref = $permref->{userdb}; $out .= <
    [L]Customer Edit Permissions[/L]:
  • {l}> [L]View list[/L]
  • {v}> [L]View single[/L]
  • {d}> [L]Delete[/L]
  • {e}> [L]Edit[/L]
  • {c}> [L]Input new[/L]
  • {p}> [L]Mail password[/L]

  • [db-hash table="__UI_ACCESS_TABLE__" column="table_control" key="[cgi user_id]" scratch="ui_owner"] [perl] my $current = tag_data('__UI_ACCESS_TABLE__', 'yes_tables', $CGI->{user_id}) || $Scratch->{tables}; $current =~ s/\s+/ /g; my $no = tag_data('__UI_ACCESS_TABLE__', 'no_tables', $CGI->{user_id}); $no =~ s/\s+/ /g; #Log("no = $no"); my (@no) = split /\s+/, $no; my %no; for(@no) { $no{$_} = ' CHECKED' } my $out = ''; my @ary = split /[\s,\0]+/, $current; #Log("ary = " . join ",", @ary); #Log("no = " . join ",", @no); my (@all) = qw/v e c d i x/; my %all; @all{@all} = @all; my $permref = {}; my $one; foreach $one (@ary) { $one =~ s/=(.*)//; my $sub = $1 || undef; next if $no{$one}; my $ref = $permref->{$one} = {}; my @set; if ($sub) { @set = grep $all{$_}, split //, $sub; } else { @set = (@all); } for(@set) { $ref->{$_} = ' CHECKED'; } } #my $string = "all=@all ". $Tag->uneval( { ref=> $permref } ); my @tables = split /\s+/, $Scratch->{tables}; for(@tables) { push @permissions, $_, tag_data('__UI_META_TABLE__', 'label', $_) || $_; } my $perm; my $title; $tc = $Scratch->{ui_owner}; while( $perm = shift @permissions) { $title = shift @permissions; my $ref = $permref->{$perm} || {}; $out .= < EOF for(@all) { $out .= < {$_}> EOF } my $of = ''; if($tc->{$perm}) { $of = $tc->{$perm}{owner_field}; } $out .= < EOF $out =~ s!(<.td>\s*)$!$1!; } #$Scratch->{string} = $string; return $out; [/perl]
    [L]Table Permissions[/L]
      [L]HIDE[/L] [L]View[/L] [L]Edit[/L] [L]Create[/L] [L]Delete[/L] [L]Import[/L] [L]Export[/L] [L]Owner field[/L]
    $title

    @_UI_STD_FOOTER_@