diff options
| author | ivan <ivan> | 2009-02-08 02:05:48 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2009-02-08 02:05:48 +0000 | 
| commit | 24533a22a23e211888fcc36a5177c0def5c77de3 (patch) | |
| tree | 09887e29cf74dc4e50ab03e23514acc0d69e59b2 /httemplate/edit/process/part_pkg.cgi | |
| parent | 8b72ad2a4d67f46e4bda36179e992d82d069689f (diff) | |
further work on agents editing own packages: allow them to see (but not edit) global packages for their type, RT#1331
Diffstat (limited to 'httemplate/edit/process/part_pkg.cgi')
| -rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 19 | 
1 files changed, 15 insertions, 4 deletions
| diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 669b75946..96c5b36b7 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -1,11 +1,12 @@  <% include( 'elements/process.html',                #'debug'             => 1,                'table'             => 'part_pkg', +              'agent_virt'        => 1, +              'agent_null_right'  => \@agent_null_right,                'redirect'          => $redirect_callback,                'viewall_dir'       => 'browse',                'viewall_ext'       => 'cgi',                'edit_ext'          => 'cgi', -              #XXX usable with cloning? #'agent_null_right'  => 'Edit global package definitions',                'precheck_callback' => $precheck_callback,                'args_callback'     => $args_callback,                'process_m2m'       => \@process_m2m, @@ -13,12 +14,21 @@  %>  <%init> +my $customizing = ( ! $cgi->param('pkgpart') && $cgi->param('pkgnum') ); +  my $curuser = $FS::CurrentUser::CurrentUser; +my $edit_global = 'Edit global package definitions'; +my $customize   = 'Customize customer package'; +  die "access denied"    unless $curuser->access_right('Edit package definitions') -      || $curuser->access_right('Edit global package definitions') -      || ( ! $cgi->param('pkgpart') && $cgi->param('pkgnum') && $curuser->access_right('Customize customer package') ); +      || $curuser->access_right($edit_global) +      || ( $customizing && $curuser->access_right($customize) ); + +my @agent_null_right = ( $edit_global ); +push @agent_null_right, $customize if $customizing; +  my $precheck_callback = sub {    my( $cgi ) = @_; @@ -41,7 +51,8 @@ my $precheck_callback = sub {      unless scalar(@agents)             || ( $cgi->param('clone') && $cgi->param('clone') =~ /^\d+$/ )             || ( !$cgi->param('pkgpart') && $conf->exists('agent-defaultpkg') ) -           || $cgi->param('disabled'); +           || $cgi->param('disabled') +           || $cgi->param('agentnum');    return ''; | 
