]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Object.pm
Nicht mehr benötigte Felder beim Speichern von Usern weglassen
[mfinanz.git] / SL / DB / Object.pm
index 3cf670d55c31d7a29b010082d918c5747af1e748..8b86e97111a9942d2b0e422a30026d9557f571ff 100755 (executable)
@@ -60,9 +60,10 @@ sub _assign_attributes {
 
   my %types      = map { $_->name => $_->type } ref($self)->meta->columns;
 
 
   my %types      = map { $_->name => $_->type } ref($self)->meta->columns;
 
-  # Special case for *_as_man_days/*_as_man_days_unit: the _unit
-  # variation must always be called after the non-unit method.
-  my @man_days_attributes = grep { m/_as_man_days$/ } keys %attributes;
+  # Special case for *_as_man_days / *_as_man_days_string /
+  # *_as_man_days_unit: the _unit variation must always be called
+  # after the non-unit methods.
+  my @man_days_attributes = grep { m/_as_man_days(?:_string)?$/ } keys %attributes;
   foreach my $attribute (@man_days_attributes) {
     my $value = delete $attributes{$attribute};
     $self->$attribute(defined($value) && ($value eq '') ? undef : $value);
   foreach my $attribute (@man_days_attributes) {
     my $value = delete $attributes{$attribute};
     $self->$attribute(defined($value) && ($value eq '') ? undef : $value);
@@ -133,12 +134,12 @@ sub save {
 
   my ($result, $exception);
   my $worker = sub {
 
   my ($result, $exception);
   my $worker = sub {
-    SL::DB::Object::Hooks::run_hooks($self, 'before_save');
     $exception = $EVAL_ERROR unless eval {
     $exception = $EVAL_ERROR unless eval {
+      SL::DB::Object::Hooks::run_hooks($self, 'before_save');
       $result = $self->SUPER::save(@args);
       $result = $self->SUPER::save(@args);
+      SL::DB::Object::Hooks::run_hooks($self, 'after_save', $result);
       1;
     };
       1;
     };
-    SL::DB::Object::Hooks::run_hooks($self, 'after_save', $result);
 
     return $result;
   };
 
     return $result;
   };
@@ -155,12 +156,12 @@ sub delete {
 
   my ($result, $exception);
   my $worker = sub {
 
   my ($result, $exception);
   my $worker = sub {
-    SL::DB::Object::Hooks::run_hooks($self, 'before_delete');
     $exception = $EVAL_ERROR unless eval {
     $exception = $EVAL_ERROR unless eval {
+      SL::DB::Object::Hooks::run_hooks($self, 'before_delete');
       $result = $self->SUPER::delete(@args);
       $result = $self->SUPER::delete(@args);
+      SL::DB::Object::Hooks::run_hooks($self, 'after_delete', $result);
       1;
     };
       1;
     };
-    SL::DB::Object::Hooks::run_hooks($self, 'after_delete', $result);
 
     return $result;
   };
 
     return $result;
   };