Index: invite.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite.module,v
retrieving revision 1.25.2.6
diff -u -p -r1.25.2.6 invite.module
--- invite.module 27 Apr 2009 17:24:44 -0000 1.25.2.6
+++ invite.module 5 May 2009 12:09:54 -0000
@@ -470,20 +470,19 @@ function _invite_accept($invite, $accoun
* The user object of the invitee.
*/
function _invite_escalate_role($account) {
- // Default target role.
- $roles = array('default');
+ // Add a dummy entry to retrieve the default target role setting.
+ $roles = array('default' => 'default');
// Add roles of inviter.
$inviter_uid = db_result(db_query("SELECT uid FROM {invite} WHERE invitee = %d", $account->uid));
if ($inviter_uid && $inviter = user_load(array('uid' => $inviter_uid))) {
- $roles = array_merge($roles, array_intersect($inviter->roles, user_roles(0, 'send invitations')));
+ $roles = array_merge($roles, array_intersect($inviter->roles, user_roles(FALSE, 'send invitations')));
}
// Map to configured target roles.
$targets = array();
- foreach ($roles as $role) {
- $role_no_space = str_replace(' ', '_', $role);
- $target = variable_get('invite_target_role_'. $role_no_space, DRUPAL_AUTHENTICATED_RID);
+ foreach ($roles as $rid => $role) {
+ $target = variable_get('invite_target_role_'. $rid, DRUPAL_AUTHENTICATED_RID);
if ($target != DRUPAL_AUTHENTICATED_RID) {
$targets[$target] = $target;
}
@@ -629,7 +628,6 @@ function invite_get_remaining_invites($a
}
else {
$remaining = invite_get_role_limit($account);
-
if ($remaining > 0) {
// Legacy support.
$sent = db_result(db_query("SELECT COUNT(*) FROM {invite} WHERE uid = %d", $account->uid));
@@ -658,10 +656,9 @@ function invite_get_role_limit($account)
}
$role_limit = 0;
- foreach (user_roles(0, 'send invitations') as $role) {
- $role_no_space = str_replace(' ', '_', $role);
- if (in_array($role, $account->roles)) {
- $role_max = variable_get('invite_maxnum_'. $role_no_space, INVITE_UNLIMITED);
+ foreach (user_roles(FALSE, 'send invitations') as $rid => $role) {
+ if (array_key_exists($rid, $account->roles)) {
+ $role_max = variable_get('invite_maxnum_'. $rid, INVITE_UNLIMITED);
if ($role_max == INVITE_UNLIMITED) {
return INVITE_UNLIMITED;
}
Index: invite_admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/invite/invite_admin.inc,v
retrieving revision 1.3.2.2
diff -u -p -r1.3.2.2 invite_admin.inc
--- invite_admin.inc 19 Apr 2009 21:26:01 -0000 1.3.2.2
+++ invite_admin.inc 5 May 2009 12:05:44 -0000
@@ -10,11 +10,11 @@
* Menu callback; display invite settings form.
*/
function invite_settings() {
- $roles = user_roles(0, 'send invitations');
+ $roles = user_roles(FALSE, 'send invitations');
if (count($roles) == 0) {
drupal_set_message(t('Please enable the send invitations permission for at least one role. This can be done on the Permissions page.', array('!permissions-url' => url('admin/user/permissions'))));
}
- $target_roles = user_roles(1);
+ $target_roles = user_roles(TRUE);
// General settings.
$form['general'] = array(
@@ -50,26 +50,25 @@ function invite_settings() {
'#collapsed' => TRUE,
);
- foreach ($roles as $role) {
- $role_no_space = str_replace(' ', '_', $role);
- $form['role'][$role_no_space] = array(
+ foreach ($roles as $rid => $role) {
+ $form['role'][$rid] = array(
'#type' => 'fieldset',
'#title' => t('@role settings', array('@role' => drupal_ucfirst($role))),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
- $form['role'][$role_no_space]['invite_target_role_'. $role_no_space] = array(
+ $form['role'][$rid]['invite_target_role_'. $rid] = array(
'#type' => 'select',
'#title' => t('Target role'),
- '#default_value' => variable_get('invite_target_role_'. $role_no_space, DRUPAL_AUTHENTICATED_RID),
+ '#default_value' => variable_get('invite_target_role_'. $rid, DRUPAL_AUTHENTICATED_RID),
'#options' => $target_roles,
'#description' => t('You may choose to add invited users to another role (in addition to the default role set in the general section) when they have been invited by a member of %role.', array('%role' => $role)),
'#required' => TRUE,
);
- $form['role'][$role_no_space]['invite_maxnum_'. $role_no_space] = array(
+ $form['role'][$rid]['invite_maxnum_'. $rid] = array(
'#type' => 'select',
'#title' => t('Invitation limit'),
- '#default_value' => variable_get('invite_maxnum_'. $role_no_space, INVITE_UNLIMITED),
+ '#default_value' => variable_get('invite_maxnum_'. $rid, INVITE_UNLIMITED),
'#options' => array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100, 500 => 500, 1000 => 1000, INVITE_UNLIMITED => t('unlimited')),
'#description' => t('Allows to limit the total number of invitations members of %role can send.', array('%role' => $role)),
'#multiple' => FALSE,