[Rt-commit] rt branch, 4.0/validate-dashboard-args, updated. rt-4.0.0rc6-123-g0a02665
Shawn Moore
sartak at bestpractical.com
Wed Mar 9 11:33:29 EST 2011
The branch, 4.0/validate-dashboard-args has been updated
via 0a02665e0ca686a8083dc7c02a5b558bf118ec83 (commit)
from 511e2d4d278bf2be2bd30b461eb84cdd2287849b (commit)
Summary of changes:
lib/RT/Dashboard.pm | 13 +++++++++++++
lib/RT/SharedSetting.pm | 15 +++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit 0a02665e0ca686a8083dc7c02a5b558bf118ec83
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Wed Mar 9 11:32:48 2011 -0500
Use new PostLoadValidate to ensure what you loaded is actually a dashboard
See http://issues.bestpractical.com/Ticket/Display.html?id=16796
diff --git a/lib/RT/Dashboard.pm b/lib/RT/Dashboard.pm
index 431eb9b..a840ec1 100644
--- a/lib/RT/Dashboard.pm
+++ b/lib/RT/Dashboard.pm
@@ -156,6 +156,19 @@ sub UpdateAttribute {
return ($status, $msg);
}
+=head2 PostLoadValidate
+
+Ensure that the ID corresponds to an actual dashboard object, since it's all
+attributes under the hood.
+
+=cut
+
+sub PostLoadValidate {
+ my $self = shift;
+ return (0, "Invalid object type") unless $self->Name eq 'Dashboard';
+ return 1;
+}
+
=head2 Panes
Returns a hashref of pane name to portlets
diff --git a/lib/RT/SharedSetting.pm b/lib/RT/SharedSetting.pm
index fa58f2f..283fc19 100644
--- a/lib/RT/SharedSetting.pm
+++ b/lib/RT/SharedSetting.pm
@@ -112,6 +112,9 @@ sub Load {
return (0, $self->loc("Permission denied"))
unless $self->CurrentUserCanSee;
+ my ($ok, $msg) = $self->PostLoadValidate;
+ return ($ok, $msg) if !$ok;
+
return (1, $self->loc("Loaded [_1] [_2]", $self->ObjectName, $self->Name));
} else {
$RT::Logger->error("Could not load attribute " . $id
@@ -158,6 +161,18 @@ Called after after successful L</Load>.
sub PostLoad { }
+=head2 PostLoadValidate
+
+Called just before returning success from L</Load>; may be used to validate
+that the record is correct. This method is expected to return a (ok, msg)
+pair.
+
+=cut
+
+sub PostLoadValidate {
+ return 1;
+}
+
=head2 Save
Creates a new shared setting. Takes a privacy, a name, and any other arguments.
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list