Closed (won't fix)
Project:
Role Expire
Version:
6.x-1.11
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Dec 2009 at 18:51 UTC
Updated:
9 Jan 2018 at 19:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chrispeat commentedYes that seems very logical and valuable to me. I am looking for a way to set users as expired and would be bulk uploading users, its seems sensible to have it this way round.
Would give it a virtual thumbs up from my end, for what its worth!
Chris
Comment #2
stewsnoozeI would of course commit it after standard style checks and testing. I'd love simpletests but I am a realistic human.
I am on holiday until 21 dec so take your time and thank you so much
Comment #3
kentr commented@chrispeat: I think I saw somewhere that someone created an addition for user import that incorporates role expire.
Comment #4
kentr commentedSorry, my need for this has decreased, so I'm not working on a patch.
Comment #5
stewsnoozeI think this should be a feature. Setting back to active
Comment #6
OliverColeman commentedI've made a patch for this. It works for users created by administrators and self-registrations.
It should probably display a notice for administrators to let them know that the role(s) will expire (maybe this should happen whenever the default expiration time has been applied). And in fact the instructions under the text fields in user add/edit form aren't entirely accurate: they always indicate that leaving the field blank will mean the role won't expire, but if they've just enabled the role it will be set to the default duration period. But these should probably be files as different bug reports. :)
Comment #7
inductor commentedOliverColeman, thanks a lot for the patch! Works perfectly for new users. Any chance for this to get committed? Maybe somebody else will test it too so we can set the status to RTBC?
Comment #8
sharplesa commentedCreated a patch that will serve as the candidate for 6.x-1.12. This patch addresses the following issues:
This patch features cleaner help text (from a UX perspective).
Files affected:
I propose to leave this in patch form for a few weeks so you can test it. Please test that Views works correctly and that the default value behavior works as advertised (and is actually an improvement). If I don't hear anything by Christmas, I'll roll a new version of role_expire with this patch incorporated.
Comment #9
Gareth10 commentedIs the patch (role_expire.module.diff) that was Posted by OliverColeman on July 2, 2010 at 6:31am which allows it to work for users created by administrators and self-registrations, included in the patch that you released on November 26, 2011 at 12:12am that "will serve as the candidate for 6.x-1.12"?
If it is not included, is it safe to run OliverColeman's path after already running the role_expire-649256-08.patch, or should it be done in order of release?
Thanks to both contributors for the work done here.
Comment #10
sharplesa commented@Gareth10 - Yes, the OliverColeman stuff is included in the patch I wrote. Note that this patch will not apply to the D7 version of role_expire. A separate patch will have to be made for it.
Comment #11
Gareth10 commentedsharplesa - fantastic, thanks for getting back to me so quickly. I will be conducting extensive testing with this module over the next week so I will feedback my findings so you can roll out the new version of role_expire with this patch incorporated.
Many thanks once again - G
Comment #12
Gareth10 commentedIs this module compatible with Auto assign role (http://drupal.org/project/autoassignrole ) ?
I am using Auto assign role to assign a reg-trial role to all users that sign up to the site, this aspect is working fine.
I am then attempting to use role expire to auto remove this role (back to authenticated user) after a period of time. I have now run several tests but the role is not being automatically removed when the given time period expires. Is what i am trying to achieve not possible with the Role Expire module or am missing something?
Any thoughts / suggestions are greatly welcomed
Many thanks
Comment #13
sharplesa commentedSorry, I don't know anything about auto-assign role. If it uses standard mechanisms, there's a chance it's compatible. Did you give it a try? Did it work?
Comment #14
sharplesa commentedRolled patch at http://drupal.org/node/649256#comment-5291110 into new version 6.x-1.12.
Comment #15
stewsnoozeThere are multiple problems with the code in the patch from http://drupal.org/files/role_expire-649256-08.patch
For instance.
We have comments that are TODO's
We should instead create issues for those and remove them from code.
We have entire functions that are commented out. We are using git. Surely that work if it is in progress should simply be in a branch rather than in the released code?
The tab size seems wrong to me in places. It should be 2, inserted as spaces
Tab size again.
Comment #16
sharplesa commentedMerry Christmas, Stew! Long time no hear! I figured that you had tacitly approved of the patch since it had been out for testing for over a month.
role_expire_menuwas left in just in case. I wasn't sure whether it was needed when I saw it in a previous release so I just left it.You're right that I need to get smart about branching in git. As it is now, I have two different repositories, one for D6 and one for D7. Nevertheless, I think it's good functional code. Suggest you close and throw new issues to clean up the comments.
Comment #17
dianacastillo commentedI have the same problem, I am using "auto assign role" to automatically assign users the role of "registered_user" and "trial_user" which works fine , when they register they have those roles. But I also set the role "trial_user" to have a default expiration of "30 days" and when they register they have no default expiration set up.
can this be fixed ? thank you
Comment #18
dianacastillo commentedI dont understand if the patch on comment # 8 was put into the last version of "Role Expire" why when I just installed the latest role expire 6.x-1.x-dev tar.gz (14.37 KB) | zip (17.26 KB) 2012-Aug-30
and ran update.php, i still do not get an automatically generated expiration date when new users register. Can someone clarify if I have to run the patch seperately to get this to work?
Comment #19
dianacastillo commentedi just made the changes in this patch and I still do not get an expiration date when someone registers themselves and their role is automatically assigned.
Comment #20
dianacastillo commentedI made a cron script to update users with correct expiration date once a day:
http://drupal.org/node/1420070#comment-6635516
Comment #21
dianacastillo commentedI modified the cron within the role expire module and added two functions and now everytime cron runs the new users who have had the role of "trial user" auto assigned to them get the expiration date assigned: here is the modified cron and the two api functions I added to role_expire.module . I made a patch, but I don't have permissions to attach it.
/**
* Implementation of hook_cron().
*/
function role_expire_cron() {
if ($expires = role_expire_get_expired()) {
$roles = _role_expire_get_role();
foreach ($expires as $expire) {
// Remove the role from the user.
$account = user_load($expire['uid']);
$edit = $account->roles;
unset($edit[$expire['rid']]);
// In the documentation for the role_expire implementation of hook_user we
// state to use $category = 'account'. We don't do that here because
// that would cause the delete to occur twice.
user_save($account, array('roles' => $edit), NULL);
// Remove the role expiration record.
role_expire_delete_record($expire['uid'], $expire['rid']);
watchdog('role expire', 'Remove role @role from user @account.', array('@role' => $roles[$expire['rid']], '@account' => $account->name));
}
}
// now look for users that dont have expiration dates but should and add them
$rid=get_role_id_by_name("trial_user");
// now get the default duration for this role in days
$duration=role_expire_get_default_duration($rid);
$pieces = explode(" ", $duration);
$currentTimestamp = time();// current date
$expiration_date=strtotime("+$pieces[0] $pieces[1]", $currentTimestamp);
// get the users that have the trial user rold but dont have an expiration date yet.
$results=get_users_without_expiration_date($rid);
if (count($results)){
foreach ($results as $uid){
role_expire_write_record($uid,$rid,$expiration_date);
}
}
}
/**
* API function; Get the users that dont have an expiration time for a specific role id.
* // added by diana
* @param $rid
* Role ID.
* @return
* Array with user ids.
*/
function get_users_without_expiration_date($rid){
$result = db_query("SELECT users . uid , users_roles.rid, role_expire . expiry_timestamp
FROM users
JOIN users_roles ON users.uid = users_roles.uid
LEFT OUTER JOIN role_expire ON users.uid = role_expire.uid
WHERE users_roles.rid =$rid AND ISNULL(role_expire.expiry_timestamp)");
while ($row = db_fetch_array($result)) {
$return[] = $row['uid'];
}
return $return;
}
/**
* API function; Get the role id by the name of the role.
* // added by diana
* @param $role_name
* @return $rid
* Role ID
*/
function get_role_id_by_name($role_name){
$result = db_fetch_array(db_query("SELECT rid FROM role WHERE name='$role_name'"));
return (!empty($result)) ? $result['rid'] : '';
}
Comment #22
stewsnoozeCould you at least paste the patch? You can wrap it in code < code > < /code >
Comment #23
dianacastillo commentedHere it is, the only thing is I made it specifically for the user with role "trial_user" , this should probably be administrable on the admin page, i havent done that
Comment #25
rcodinaDrupal 6 version is unsupported!