Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal support for custom permission levels in Accounts Manager which are not provided in the userRoles hash #2629

Conversation

taniwallach
Copy link
Member

A minimal fix for #2625.

This only prevents the error and allows the Accounts Manager to load. A fake permission level name "PermLevelN" will appear in the table. It is not a value which can be selected, and editing a user with such a value will force selecting a defined permission level.

the active %userRoles hash. Will prevent Accounts Manager from failing.
See openwebwork#2625
but when editing a user with such a value, will only allow choosing
a defined level.
@@ -51,7 +51,7 @@
id => $fieldName . '_id', class => 'form-select form-select-sm w-auto flex-grow-0',
'aria-labelledby' => 'permission_header' =%>
% } else {
<%= maketext((grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0]) %>
<%= maketext((grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0] // "PermLevel$value") %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be

Suggested change
<%= maketext((grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0] // "PermLevel$value") %>
% if (my $roleName = (grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0]) {
<%= maketext($roleName) %>
% } else {
<%= maketext("Permission Level [_1]", $value) %>
% }

With this "Permission Level [_1]" will get translated. With your code it will not. I also don't like abbreviations shown in the user interface, so I would rather have "Permission Level" rather than "PermLevel".

Although, I was alternately thinking that maybe "Permission Level" in any form isn't needed. This is the "Permission Level" column in the table. So maybe instead just show the unknown permission level numerically? So perhaps this should be

Suggested change
<%= maketext((grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0] // "PermLevel$value") %>
% if (my $roleName = (grep { $ce->{userRoles}{$_} eq $value } keys %{ $ce->{userRoles} })[0]) {
<%= maketext($roleName) %>
% } else {
<%= $value %>
% }

Or maybe use maketext('Unknown: [_1]', $value)?

Alex-Jordan added a commit that referenced this pull request Feb 1, 2025
Support for custom permission levels not in the userRoles hash (replacement of #2629)
@drgrice1
Copy link
Member

drgrice1 commented Feb 2, 2025

I am closing this as it is contained in #2660.

@drgrice1 drgrice1 closed this Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants