[Bps-public-commit] rt-extension-rightsdebugger branch, master, updated. 1c6a2de6faf1ebf7835aa9a9a8713dd8fb57a0ce
Shawn Moore
shawn at bestpractical.com
Tue Mar 7 14:50:44 EST 2017
The branch, master has been updated
via 1c6a2de6faf1ebf7835aa9a9a8713dd8fb57a0ce (commit)
from 223d23cfd1b0d5707b2f5731425bd51c48630fdc (commit)
Summary of changes:
lib/RT/Extension/RightsDebugger.pm | 44 ++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 1c6a2de6faf1ebf7835aa9a9a8713dd8fb57a0ce
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Mar 7 19:50:33 2017 +0000
Object specs and URLs for many more types of record
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index c6a2fc4..a54b3f0 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -79,7 +79,7 @@ sub _PrincipalForSpec {
my $type = shift;
my $identifier = shift;
- if ($type =~ /^g/i) {
+ if ($type =~ /^(g|group)$/i) {
my $group = RT::Group->new($self->CurrentUser);
if ( $identifier =~ /^\d+$/ ) {
$group->LoadByCols(
@@ -94,11 +94,14 @@ sub _PrincipalForSpec {
return $group->PrincipalObj if $group->Id;
}
- else {
+ elsif ($type =~ /^(u|user)$/i) {
my $user = RT::User->new($self->CurrentUser);
$user->Load($identifier);
return $user->PrincipalObj if $user->Id;
}
+ else {
+ RT->Logger->debug("Unexpected type '$type'");
+ }
return undef;
}
@@ -108,14 +111,37 @@ sub _ObjectForSpec {
my $type = shift;
my $identifier = shift;
+ my $record;
+
if ($type =~ /^(t|ticket)$/i) {
- my $ticket = RT::Ticket->new($self->CurrentUser);
- $ticket->Load($identifier);
- return $ticket if $ticket->Id;
+ $record = RT::Ticket->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^(q|queue)$/i) {
+ $record = RT::Queue->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^asset$/i) {
+ $record = RT::Asset->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^catalog$/i) {
+ $record = RT::Catalog->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^(a|article)$/i) {
+ $record = RT::Article->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^class$/i) {
+ $record = RT::Class->new($self->CurrentUser);
+ }
+ elsif ($type =~ /^(g|group)$/i) {
+ return $self->_PrincipalForSpec($type, $identifier);
}
else {
+ RT->Logger->debug("Unexpected type '$type'");
+ return undef;
}
+ $record->Load($identifier);
+ return $record if $record->Id;
+
return undef;
}
@@ -146,7 +172,7 @@ sub Search {
if (my ($type, $identifier) = $args{object} =~ m{
^
\s*
- (t|ticket|asset)
+ (t|ticket|q|queue|asset|catalog|a|article|class|g|group)
\s*
[:#]
\s*
@@ -469,6 +495,12 @@ sub URLForRecord {
elsif ($record->isa('RT::Ticket')) {
return RT->Config->Get('WebURL') . 'Ticket/Display.html?id=' . $id;
}
+ elsif ($record->isa('RT::Asset')) {
+ return RT->Config->Get('WebURL') . 'Asset/Display.html?id=' . $id;
+ }
+ elsif ($record->isa('RT::Article')) {
+ return RT->Config->Get('WebURL') . 'Articles/Article/Display.html?id=' . $id;
+ }
return undef;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list