[freeside-commits] freeside/httemplate/edit/process part_pkg.cgi, 1.37, 1.38

Ivan,,, ivan at wavetail.420.am
Sat Feb 7 18:05:27 PST 2009


Update of /home/cvs/cvsroot/freeside/httemplate/edit/process
In directory wavetail.420.am:/tmp/cvs-serv1782/httemplate/edit/process

Modified Files:
	part_pkg.cgi 
Log Message:
further work on agents editing own packages: allow them to see (but not edit) global packages for their type, RT#1331

Index: part_pkg.cgi
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/part_pkg.cgi,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- part_pkg.cgi	30 Aug 2008 02:10:09 -0000	1.37
+++ part_pkg.cgi	8 Feb 2009 02:05:25 -0000	1.38
@@ -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 @@
     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 '';
 



More information about the freeside-commits mailing list