[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 0.04-4-g448c74d
Shawn Moore
sartak at bestpractical.com
Thu Feb 24 16:10:51 EST 2011
The branch, master has been updated
via 448c74d12781d58791630b66f200af2360571d5f (commit)
from e2593c457ddf6904d57a7a59b239b262d47225e8 (commit)
Summary of changes:
.../RecordHistory/Mixin/Model/RecordHistory.pm | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit 448c74d12781d58791630b66f200af2360571d5f
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Thu Feb 24 16:08:29 2011 -0500
Create all changes as superuser to avoid permissions problems
Otherwise you could "lose" permission to update a record by updating
one of its fields (such as by changing who owns the record) and thus
can't create the audit trail
This also enables you to lock down the audit trail effectively,
since if anyone can create a Change without updating the record,
they lose value
diff --git a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
index 537d229..bd15f2d 100644
--- a/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
+++ b/lib/Jifty/Plugin/RecordHistory/Mixin/Model/RecordHistory.pm
@@ -27,8 +27,9 @@ sub import {
return if !$id; # the actual create failed
- my $change = Jifty::Plugin::RecordHistory::Model::Change->new;
+ my $change = Jifty::Plugin::RecordHistory::Model::Change->new(current_user => Jifty::CurrentUser->superuser);
$change->create(
+ created_by => $self->current_user->id,
record_class => ref($self),
record_id => $id,
type => 'create',
@@ -45,8 +46,9 @@ sub import {
);
my $change = $self->current_change || do {
- my $change = Jifty::Plugin::RecordHistory::Model::Change->new;
+ my $change = Jifty::Plugin::RecordHistory::Model::Change->new(current_user => Jifty::CurrentUser->superuser);
$change->create(
+ created_by => $self->current_user->id,
record_class => ref($self),
record_id => $self->id,
type => 'update',
@@ -84,7 +86,7 @@ sub import {
$caller->add_trigger(before_delete => sub {
my $self = shift;
- my $change = Jifty::Plugin::RecordHistory::Model::Change->new;
+ my $change = Jifty::Plugin::RecordHistory::Model::Change->new(current_user => Jifty::CurrentUser->superuser);
$change->create(
record_class => ref($self),
record_id => $self->id,
@@ -132,13 +134,14 @@ sub start_change {
my $type = shift || 'update';
my %args = (
+ created_by => $self->current_user->id,
record_class => ref($self),
record_id => $self->id,
type => $type,
@_,
);
- my $change = Jifty::Plugin::RecordHistory::Model::Change->new;
+ my $change = Jifty::Plugin::RecordHistory::Model::Change->new(current_user => Jifty::CurrentUser->superuser);
if ($type eq 'update') {
$change->deferred_create(%args);
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list