Closed (fixed)
Project:
Role Expire
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
26 Jan 2013 at 12:46 UTC
Updated:
24 Jun 2020 at 21:13 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pere orgaBased on code from #831232: Problem working with role delegation module for non admin/uid 1, here there's a small javascript-only patch.
It works properly on both admin/non-admin users, and doesn't interfere when Role Delegation is not used.
I tested it, and should apply cleanly to current git.
Comment #2
daniel wentsch commentedThanks a lot for this patch, works as expected!
Comment #3
OliverColeman commentedHere's a new patch that works with the latest versions of role_expire and role_delegation.
Comment #4
sgdev commentedI've made some updates to this patch to provide better support, and be in closer alignment with the current 7.x-1.x-dev branch. Updates are as follows:
role_expire.js
* Replaced use of
parent()withclosest()to add the role_expire fields. Theparent()function will not work with modules such as Bootstrap that wrap the role checkbox with a<label>tag.closest()makes it more generic.* Replaced use of
attr("checked")withis(":checked"). Theattr("checked")function no longer works with jQuery 1.6+, and theis()function will work in all cases.role_expire.module
* Added check for
module_exists('role_delegation'). The$roles_keyvalue needs this for sites that do *not* have the role_delegation module enabled.* Attached class and js file as a new array item rather than an override. This ensures it properly supports any existing class or js file already added to the field.
* Use the
#attachedoption to add JavaScript instead ofdrupal_add_js. Using#attachedis the right way to include js files in almost every situation.Comment #5
sgdev commentedBased on some further testing, have another update for this patch.
We are using Role Delegation with the Contextual Admin module, and had previously uncovered an issue that causes the two to not work together: https://www.drupal.org/node/2700759
This same type of problem exists when using Role Expire, Role Delegation and Contextual Admin, if the "Create user" process has been taken over by Contextual Admin.
The attached patch adds an extra
form_alterto account for using the three of these modules together.Comment #6
sgdev commentedAlso noticed that expiration dates are not set when creating a new user, and fails with errors using this patch (https://www.drupal.org/project/role_expire/issues/2401985) because some modifications are needed to support Role Delegation.
I've created a new patch on that thread that works. Please review both of them, thanks.
Comment #7
sgdev commentedUpdated patch that includes the extra code from #2401985.
Also removed some extra line breaks so
role_expire_user_updateandrole_expire_user_insertare more consistent.Comment #8
sgdev commentedPer this comment (https://www.drupal.org/project/role_expire/issues/2076363#comment-12727650), I've created a new patch that incorporates code from the #2076363 patch.
This is now a patch for supporting role assignment modules (both Role Delegation and Role Assign).
Please test, but I think all that is necessary to get this to work is the following addition I've made to the JavaScript file:
Comment #9
liam morlandA coding standards note:
else ifshould beelseif.Comment #10
sgdev commentedNo, not in JavaScript. That would cause an error.
https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...
Comment #11
liam morlandRight you are.
Comment #13
rcodinaThanks to all! I will not create a new release yet. I have only tested it without role assignment modules.
@Liam Morland Can you check out latest dev version and tell me if all it's fine? Thanks!
Comment #15
kpaxman commentedRole expiries now show up with Role Expire and Role Assign enabled - however, they all show up at the beginning, separate from the roles themselves; additionally, all roles appear and are therefore can be set to expire, not just the ones the user has access to through Role Assign. I'm fiddling now to see if I can modify my patch from this queue: https://www.drupal.org/project/role_expire/issues/2076363.
Comment #16
kpaxman commentedIt looks like this patch doesn't *quite* work as expected with Role Assign - I've created https://www.drupal.org/project/role_expire/issues/3154642 for this issue and will have a patch there shortly.