[Koha-patches] [PATCH] Bug 3706 Part 2: Label templates/layouts do not save properly

Chris Nighswonger cnighswonger at foundations.edu
Thu Oct 15 19:37:26 CEST 2009


This completes adding checks for profile id passed in by the layout edit template.
---
 labels/label-edit-template.pl |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/labels/label-edit-template.pl b/labels/label-edit-template.pl
index cc539c5..ec80f3d 100755
--- a/labels/label-edit-template.pl
+++ b/labels/label-edit-template.pl
@@ -41,7 +41,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
 );
 
 my $op = $cgi->param('op');
-warn "operation = $op\n";
 my $template_id = $cgi->param('template_id') || $cgi->param('element_id');
 my $label_template = undef;
 my $profile_list = undef;
@@ -72,13 +71,15 @@ elsif ($op eq 'save') {
                         );
     if ($template_id) {   # if a label_id was passed in, this is an update to an existing layout
         $label_template = C4::Labels::Template->retrieve(template_id => $template_id);
-        my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id'));
-        my $new_profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id'));
-        if ($label_template->get_attr('template_id') != $new_profile->get_attr('template_id')) {
-            $new_profile->set_attr(template_id => $label_template->get_attr('template_id'));
-            $old_profile->set_attr(template_id => 0);
-            $new_profile->save();
-            $old_profile->save();
+        if ($cgi->param('profile_id')) {
+            my $old_profile = C4::Labels::Profile->retrieve(profile_id => $label_template->get_attr('profile_id'));
+            my $new_profile = C4::Labels::Profile->retrieve(profile_id => $cgi->param('profile_id'));
+            if ($label_template->get_attr('template_id') != $new_profile->get_attr('template_id')) {
+                $new_profile->set_attr(template_id => $label_template->get_attr('template_id'));
+                $old_profile->set_attr(template_id => 0);
+                $new_profile->save();
+                $old_profile->save();
+            }
         }
         $label_template->set_attr(@params);
         $label_template->save();
@@ -100,7 +101,7 @@ else {  # if we get here, this is a new layout
 }
 if ($template_id) {
     foreach my $profile (@$profile_list) {
-        if ($profile->{'profile_id'} == $label_template->get_attr('profile_id')) {
+        if ($cgi->param('profile_id') && $profile->{'profile_id'} == $label_template->get_attr('profile_id')) {
             $profile->{'selected'} = 1;
         }
         else {
-- 
1.6.0.4




More information about the Koha-patches mailing list