package II3562149e53818b6637b38680e87ba918::checkboxForPriv; use strict; use Zen; use Zen::PerlHandler; sub get { my ($form, $f) = @_; my $block = ''; my $object = $form->getDecorated; $block = $1 if $f =~ /^priv_([a-z]+)/; if ($object->{enhanced_mode} && $block eq 'master') { return Zen::PerlHandler->get('II3562149e53818b6637b38680e87ba918::goth' . '::get(/master/users/roles/form_priv.html,main)')->do($form, $f); } else { my $pf = $form->pfx . $f; my $checked = $object->{$f} ? 'checked' : ''; my $disabled = ''; unless (_has_priv($f)) { $checked = ''; $disabled = 'disabled'; } return qq(<input type="checkbox" name="$pf" value="1" $checked $disabled><input type="hidden" name="$pf" value="">); } } sub set { my ($form, $f, $v) = @_; my $block = ''; my $in = $form->getInput; my $object = $form->getDecorated; $block = $1 if $f =~ /^priv_([a-z]+)/; $object->{$f} = ($v && _has_priv($f)) ? 1 : 0; if ($block eq 'master') { $object->{$f} = $v ? 'all' : ''; if ($object->{enhanced_mode}) { $object->{$f} = 'all'; unless ($in->{"$f\_all"}) { my @options; for my $opt (qw/seaonly add edit delete/) { push @options, $opt if $in->{"$f\_$opt"}; } push @options, 'limit' . $in->{"$f\_limit"} if $in->{"$f\_limit"}; $object->{$f} = join ':', @options; } } $object->{$f} = '' unless _has_priv($f); } return; } sub _has_priv { my $f = shift; my $user = Zen->getRequest->getCtx->{UserObj}; my ($priv) = $f =~ /^priv_(\w+)/; $user->getPrivHandler->hasPriv($priv); } 1; 