Closed (fixed)
Project:
Role Expire
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 May 2012 at 20:27 UTC
Updated:
10 Jul 2017 at 17:59 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dchaffin commentedOops ... found an error with the above patch ...
role_expire.module, line 590
$role_day_period is now an array; therefore, the line needs to change from:
role_expire_write_record($uid, $role_id, mktime(0, 0, 0, date("m"), date("d") + $role_day_period, date("Y")));... to:
role_expire_write_record($uid, $role_id, mktime(0, 0, 0, date("m"), date("d") + $role_day_period['duration'], date("Y")));Comment #2
carrierawks commentedHow would you do this with D6 though?
Comment #3
stewsnoozeHave you tried doing it with Rules?
Comment #4
phrankle commentedI get this error when implementing the patch and after making the $role_day_period change:
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'new_role' in 'field list': SELECT duration, new_role FROM {role_expire_length} WHERE rid = :rid; Array ( [:rid] => 16 ) in role_expire_get_default_duration() (line 115 of /blah/public_html/blah/sites/all/modules/role_expire/role_expire.module).
Comment #5
phrankle commentedI've got a few issues with this, so I must be doing something wrong. Whenever I try to apply the patch it fails:
[user@web role_expire]$ patch < role-expire-module-new-role.patch
(Stripping trailing CRs from patch.)
patching file role_expire.module
Reversed (or previously applied) patch detected! Assume -R? [n] y
Hunk #2 FAILED at 125.
Hunk #4 FAILED at 255.
Hunk #5 FAILED at 296.
Hunk #6 succeeded at 421 (offset -11 lines).
3 out of 7 hunks FAILED -- saving rejects to file role_expire.module.rej
[user@web role_expire]$ patch < role-expire-install-new-role.patch
(Stripping trailing CRs from patch.)
patching file role_expire.install
Hunk #1 FAILED at 51.
1 out of 1 hunk FAILED -- saving rejects to file role_expire.install.rej
I can make all of the changes manually (copying and pasting from the patch to the files) except for this (from the patch):
That bit of code doesn't exist starting at line 247 in the original role_expire.module for beta1. In fact, it's not in the file at all. These are lines 230-250:
Any idea how I can get this patch working? It looks like it might be incomplete as it doesn't actually add a form where you can select the new role as you have in your screenshot.
Comment #6
kaduwall commentedThis patch would've been VERY NICE. It didn't work for me but I got a solution and wanted to share it with you.
I needed to give a new role to the user when any of the other roles expired.
Besides the anonymous and authenticated user, I have these 3 roles on my website:
- Basic User
- Premium User
- Premium Plus User
Whenever "Premium" or "Premium Plus" expired, I wanted to remove this role and give him the "Basic User" role.
After some hours of banging my head against the wall I managed to get it working.
On line 423 of the "role_expire.module" we have this:
Then after the "user_save" line I added this:
And that's it, it's working! You'll just have to change the 'basic user' to the name of the role you want.
THIS CODE IS PROBABLY UGLY and there are 2 "user_save"'s. This happens because I AM NO PHP or DRUPAL GURU, I just managed to get it working!
So, please, if you can make this code better, I'm all ears (or fingers for that matter, heh).
FULL CODE of this part:
I hope this helps!
Comment #7
rcodinaI attach a patch with a new approach. It creates a new module configuration page where you can globally define which new roles should be assign given expired ones.
Comment #8
rcodinaIf while applying the patch on #7, the hunk on file role_expire.info fails, just add this line to it:
configure = admin/config/people/role_expireThis is the URL of the new administration options for this module.
Comment #9
rcodinaI upload a new patch which solves a bug of patch on #7. I enclose an interdiff with that patch.
Comment #10
rcodinaI add an screenshot of the new configuration form.
Comment #11
stewsnooze@rcodina I've added you as a maintainer
Comment #12
rcodina@stewsnooze Ok, thanks!
Comment #14
rcodina