further work on agents editing own packages: fix fallout on package customization...
[freeside.git] / httemplate / edit / elements / edit.html
index f4e4195..d18a37d 100644 (file)
@@ -91,8 +91,12 @@ Example:
     'menubar'     => '', #menubar arrayref
 
     #agent virtualization
-    'agent_virt'       => 1,
-    'agent_null_right' => 'Access Right Name',
+    'agent_virt'            => 1,
+    'agent_null_right'      => 'Access Right Name',
+    'agent_clone_extra_sql' => '', #if provided, this overrides the extra_sql
+                                   #implementing agent virt, for clone
+                                   #operations.  i.e. pass "1=1" to allow
+                                   #cloning anything
 
     'viewall_dir' => '', #'search' or 'browse', defaults to 'search'
 
@@ -106,6 +110,8 @@ Example:
     # HTML callbacks
     ###
 
+    'body_etc' => '', # Additional BODY attributes, i.e. onLoad=""
+
     'html_init'   => '', #after the header/menubar
 
     #string or coderef of additional HTML to add before </TABLE>
@@ -172,7 +178,8 @@ Example:
 
 <% include('/elements/header'. ( $opt{popup} ? '-popup' : '' ). '.html',
               $title,
-              include( '/elements/menubar.html', @menubar )
+              include( '/elements/menubar.html', @menubar ),
+              $opt{'body_etc'},
            )
 %>
 
@@ -254,7 +261,7 @@ Example:
 %     'layer_values'  => $layer_values,
 %     'html_between'  => $f->{'html_between'},
 %
-%     #umm.
+%     #umm.  for select-agent_types at least
 %     'disabled'      => $f->{'disabled'},
 %   );
 %
@@ -620,6 +627,9 @@ if ( $cgi->param('error') ) {
 
   $clone = $1;
 
+  $qsearch{'extra_sql'} = ' AND '. $opt{'agent_clone_extra_sql'}
+    if $opt{'agent_clone_extra_sql'};
+
   $object = qsearchs({ %qsearch, 'hashref' => { $pkey => $clone } });
 
   &{$opt{'clone_callback'}}($cgi, $object, $fields, \%opt )
@@ -641,7 +651,8 @@ if ( $cgi->param('error') ) {
     $value = $query;
   }
   $value =~ /^(\d+)$/ or die "unparsable $pkey";
-  $object = qsearchs({ %qsearch, 'hashref' => { $pkey => $1 } });
+  $object = qsearchs({ %qsearch, 'hashref' => { $pkey => $1 } })
+    or die "$pkey $1 not found in $table";
   
   warn "$table $pkey => $1"
     if $opt{'debug'};