[Bps-public-commit] rt-extension-rightsdebugger branch, master, updated. bed0df30df49898fb5ebfc205b694be6f1184971
Shawn Moore
shawn at bestpractical.com
Tue Feb 28 14:25:58 EST 2017
The branch, master has been updated
via bed0df30df49898fb5ebfc205b694be6f1184971 (commit)
via 3825d524f7cf0e9c2ba97f3fe0fee211066c226e (commit)
via 942e4357b15aede626d8b2e5b36e99a2033c6ee3 (commit)
via 94006a2b90ac8d676bebbae9fa9b6f0c685b3566 (commit)
via 9d51187cd1f4a2047b49860479c6717f22631d8d (commit)
from dc5e61d18d7757e3e8e7197cb6834647ef280ad2 (commit)
Summary of changes:
html/Admin/RightsDebugger/index.html | 9 +---
lib/RT/Extension/RightsDebugger.pm | 83 +++++++++++++++++++++++++-----------
2 files changed, 58 insertions(+), 34 deletions(-)
- Log -----------------------------------------------------------------
commit 9d51187cd1f4a2047b49860479c6717f22631d8d
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Feb 28 19:09:54 2017 +0000
Canonicalize groups into custom roles, obviating need to call ->Label
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index 2ad153c..5edd800 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -33,6 +33,14 @@ sub SerializeRecord {
$principal->Load($record->Instance);
$record = $principal->Object;
}
+ elsif ($record->Domain =~ /-Role$/) {
+ my ($id) = $record->Name =~ /^RT::CustomRole-(\d+)$/;
+ if ($id) {
+ my $role = RT::CustomRole->new($record->CurrentUser);
+ $role->Load($id);
+ $record = $role;
+ }
+ }
}
my $type = ref($record);
@@ -59,10 +67,6 @@ sub LabelForRecord {
my $self = shift;
my $object = shift;
- if ($object->isa('RT::Group')) {
- return $object->Label;
- }
-
return $object->Name;
}
commit 94006a2b90ac8d676bebbae9fa9b6f0c685b3566
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Feb 28 19:11:26 2017 +0000
The only groups that should be linkified are user-defined
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index 5edd800..c3c5de2 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -85,7 +85,7 @@ sub URLForRecord {
return RT->Config->Get('WebURL') . 'Admin/Users/Modify.html?id=' . $id;
}
elsif ($object->isa('RT::Group')) {
- return undef if $object->Domain eq 'SystemInternal';
+ return undef unless $object->Domain eq 'UserDefined';
return RT->Config->Get('WebURL') . 'Admin/Groups/Modify.html?id=' . $id;
}
elsif ($object->isa('RT::CustomField')) {
commit 942e4357b15aede626d8b2e5b36e99a2033c6ee3
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Feb 28 19:15:15 2017 +0000
object -> record
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index c3c5de2..ec545bc 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -65,39 +65,39 @@ sub SerializeRecord {
sub LabelForRecord {
my $self = shift;
- my $object = shift;
+ my $record = shift;
- return $object->Name;
+ return $record->Name;
}
sub URLForRecord {
my $self = shift;
- my $object = shift;
- my $id = $object->id;
+ my $record = shift;
+ my $id = $record->id;
- if ($object->isa('RT::Queue')) {
+ if ($record->isa('RT::Queue')) {
return RT->Config->Get('WebURL') . 'Admin/Queues/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::User')) {
+ elsif ($record->isa('RT::User')) {
return undef if $id == RT->SystemUser->id
|| $id == RT->Nobody->id;
return RT->Config->Get('WebURL') . 'Admin/Users/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::Group')) {
- return undef unless $object->Domain eq 'UserDefined';
+ elsif ($record->isa('RT::Group')) {
+ return undef unless $record->Domain eq 'UserDefined';
return RT->Config->Get('WebURL') . 'Admin/Groups/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::CustomField')) {
+ elsif ($record->isa('RT::CustomField')) {
return RT->Config->Get('WebURL') . 'Admin/CustomFields/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::Class')) {
+ elsif ($record->isa('RT::Class')) {
return RT->Config->Get('WebURL') . 'Admin/Articles/Classes/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::Catalog')) {
+ elsif ($record->isa('RT::Catalog')) {
return RT->Config->Get('WebURL') . 'Admin/Assets/Catalogs/Modify.html?id=' . $id;
}
- elsif ($object->isa('RT::CustomRole')) {
+ elsif ($record->isa('RT::CustomRole')) {
return RT->Config->Get('WebURL') . 'Admin/CustomRoles/Modify.html?id=' . $id;
}
commit 3825d524f7cf0e9c2ba97f3fe0fee211066c226e
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Feb 28 19:17:27 2017 +0000
Factor detail rendering into lib/
diff --git a/html/Admin/RightsDebugger/index.html b/html/Admin/RightsDebugger/index.html
index b5bd0bc..95a72b7 100644
--- a/html/Admin/RightsDebugger/index.html
+++ b/html/Admin/RightsDebugger/index.html
@@ -18,14 +18,7 @@
{{label}}
{{/if}}
- {{#if show_detail}}
- <span class="detail">
- {{type}}
- {{#if show_id}}
- #{{id}}
- {{/if}}
- </span>
- {{/if}}
+ <span class="detail">{{detail}}</span>
</script>
<script type="text/x-template" id="debugger-result-template">
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index ec545bc..96f3111 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -43,23 +43,12 @@ sub SerializeRecord {
}
}
- my $type = ref($record);
- $type =~ s/^RT:://;
-
- my $show_detail = 1;
- $show_detail = 0 if $record->isa('RT::System');
-
- my $show_id = 1;
- $show_id = 0 if $record->isa('RT::Group') && $record->Domain eq 'SystemInternal';
-
return {
class => ref($record),
id => $record->id,
label => $self->LabelForRecord($record),
+ detail => $self->DetailForRecord($record),
url => $self->URLForRecord($record),
- type => $type,
- show_detail => $show_detail,
- show_id => $show_id,
};
}
@@ -70,6 +59,20 @@ sub LabelForRecord {
return $record->Name;
}
+sub DetailForRecord {
+ my $self = shift;
+ my $record = shift;
+
+ return undef if $record->isa('RT::System');
+
+ my $type = ref($record);
+ $type =~ s/^RT:://;
+
+ return $type if $record->isa('RT::Group') && $record->Domain eq 'SystemInternal';
+
+ return $type . ' #' . $record->id;
+}
+
sub URLForRecord {
my $self = shift;
my $record = shift;
commit bed0df30df49898fb5ebfc205b694be6f1184971
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Feb 28 19:25:46 2017 +0000
Improve detail descriptions of groups, roles, etc
diff --git a/lib/RT/Extension/RightsDebugger.pm b/lib/RT/Extension/RightsDebugger.pm
index 96f3111..d8b4326 100644
--- a/lib/RT/Extension/RightsDebugger.pm
+++ b/lib/RT/Extension/RightsDebugger.pm
@@ -63,14 +63,38 @@ sub DetailForRecord {
my $self = shift;
my $record = shift;
- return undef if $record->isa('RT::System');
+ my $id = $record->Id;
+
+ return 'Global System' if $record->isa('RT::System');
+
+ return 'System User' if $record->isa('RT::User')
+ && ($id == RT->SystemUser->Id || $id == RT->Nobody->Id);
+
+ # like RT::Group->SelfDescription but without the redundant labels
+ if ($record->isa('RT::Group')) {
+ if ($record->Domain eq 'RT::System-Role') {
+ return "System Role";
+ }
+ elsif ($record->Domain eq 'RT::Queue-Role') {
+ return "Queue Role";
+ }
+ elsif ($record->Domain eq 'RT::Ticket-Role') {
+ return "Ticket Role";
+ }
+ elsif ($record->RoleClass) {
+ my $class = $record->RoleClass;
+ $class =~ s/^RT:://i;
+ return "$class Role";
+ }
+ elsif ($record->Domain eq 'SystemInternal') {
+ return "System Group";
+ }
+ }
my $type = ref($record);
$type =~ s/^RT:://;
- return $type if $record->isa('RT::Group') && $record->Domain eq 'SystemInternal';
-
- return $type . ' #' . $record->id;
+ return $type . ' #' . $id;
}
sub URLForRecord {
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list