Active
Project:
Auto Assign Role
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
29 Jan 2012 at 01:04 UTC
Updated:
21 Mar 2013 at 17:59 UTC
I've made this change on the autoassignrole.module
// Sort the roles
if (variable_get('autoassignrole_user_sort', 'SORT_ASC') == 'SORT_ASC') {
asort($roles);
} else if (variable_get('autoassignrole_user_sort', 'SORT_DESC') == 'SORT_DESC') {
arsort($roles);
} else {
drupal_sort_weight($roles, $roles);
}I've added one more IF and the ELSE
then got to autoassignrole.admin.inc and changed variable
$form['autoassignrole_user_sort'] = array(
'#type' => 'radios',
'#title' => t('Sorting'),
'#default_value' => variable_get('autoassignrole_user_sort', 'SORT_ASC'),
'#description' => t('Default sort order of roles the user will see.'),
'#options' => array(
'SORT_ASC' => t('Ascending'),
'SORT_DESC' => t('Descending'),
'SORT_WEIGHT' => t('Weight of field'),
),
);
This will make the roles being ordered by the weight defined on the Roles admin screen.
Now the question is, how can i do this using hook instead of hack the module?
kind regards
Comments
Comment #1
dianacastillo commentedI made a cron tu update the expiration date once a day as a solution, here is the code, (havent run it yet so may have some bug)
<?
// update users expiration date if they have just registered as trial users
//
//Get all user who are trail users and have no expiration
// first get the role id for trial users
$return = array();
$result = db_query("SELECT rid FROM role WHERE name='trial_user'");
while ($row = db_fetch_array($result)) {
$rid = $row['rid'];
}
// now get the default duration for this role
$result = db_query("SELECT duration FROM role_expire_length WHERE rid=$rid");
while ($row = db_fetch_array($result)) {
$duration = $row['duration'];
}
if ($duration=="30 days"){
$days_to_add=30;
}
$currentTimestamp = time();// current date
$expiration_date=strtotime("+$days_to_add days", $currentTimestamp);
$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 =3 AND ISNULL(role_expire.expiry_timestamp)");
while ($row = db_fetch_array($result)) {
$uid = $row['uid'];
mysql_query="INSERT INTO role_expire (uid,rid,expiry_timestamp) Values ($uid,$rid,$expiration_date)";
}
}
?>
Comment #2
dianacastillo commentedI modified the module and put this functionality into the role_expire_module so now it adds the expiration date for the role that has been auto assigned everytime the cron runs
http://drupal.org/node/649256#comment-6640094
Comment #3
damienmckennaThis needs a patch before it can be reviewed.
Comment #3.0
damienmckennaMore readable