Comments

pere orga’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

Based 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.

daniel wentsch’s picture

Thanks a lot for this patch, works as expected!

OliverColeman’s picture

Version: 7.x-1.x-dev » 7.x-1.0-beta2
Issue summary: View changes
StatusFileSize
new3.94 KB

Here's a new patch that works with the latest versions of role_expire and role_delegation.

sgdev’s picture

Title: Role Expire doesn't play well with Role Delegation » Support Role Delegation module
Version: 7.x-1.0-beta2 » 7.x-1.x-dev
StatusFileSize
new5.17 KB

I'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() with closest() to add the role_expire fields. The parent() 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") with is(":checked"). The attr("checked") function no longer works with jQuery 1.6+, and the is() function will work in all cases.

role_expire.module

* Added check for module_exists('role_delegation'). The $roles_key value 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 #attached option to add JavaScript instead of drupal_add_js. Using #attached is the right way to include js files in almost every situation.

sgdev’s picture

Related issues: +#2700759: Support Contextual Admin module
StatusFileSize
new5.46 KB

Based 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_alter to account for using the three of these modules together.

sgdev’s picture

Also 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.

sgdev’s picture

Updated patch that includes the extra code from #2401985.

Also removed some extra line breaks so role_expire_user_update and role_expire_user_insert are more consistent.

sgdev’s picture

Title: Support Role Delegation module » Support role assignment modules
Related issues: +#2076363: Role Assign integration
StatusFileSize
new9.39 KB

Per 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:

      // Change rolesKey if Role Delegation or Role Assign modules are used.
      if ($('#edit-roles-change').length > 0) {
        var rolesKey = 'roles-change';
      }
      else if ($('#edit-roleassign-roles').length > 0) {
        rolesKey = 'roleassign-roles';
      }
      else {
        rolesKey = 'roles';
      }
liam morland’s picture

A coding standards note: else if should be elseif.

sgdev’s picture

No, not in JavaScript. That would cause an error.

https://www.drupal.org/docs/develop/standards/javascript/javascript-codi...

liam morland’s picture

Right you are.

  • rcodina committed 90a4a7f on 7.x-1.x authored by ron_s
    Issue #1899606 by ron_s, Pere Orga, OliverColeman, Liam Morland: Support...
rcodina’s picture

Status: Needs review » Fixed

Thanks 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kpaxman’s picture

Role 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.

kpaxman’s picture

It 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.