Only administrator can send invitations on multilingual installation.

zio - October 17, 2008 - 18:22
Project:Invite
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

The "registered user" role always have a "Sorry, you've reached the maximum number of invitations" message when attempting to send invitation. (Even with "unlimited" number option enabled for this role). What is this?

#1

THOOR - October 23, 2008 - 14:01

Subscribe ... because I have exactly the same Problem

#2

gatonero - October 26, 2008 - 09:09

Me too. Even deactivating, uninstalling and reanstalling doesn't solve it.

#3

zio - October 27, 2008 - 16:48

I don't understand: in invite.install there is function for schema update - invite_maxnum_ should be in permissions table. But there are no such entry in permissions. Reinstalling and update.php don't help. What else?

#4

Excaliber - November 2, 2008 - 17:36

same problem here.. doenst work with normal users

#5

Popolo - November 9, 2008 - 22:45

I got the same issue and found a way around (the issue could be linked to a translation matter).
I have a site in French and therefore the 2 following strings are translated as follow.
- 'anonymous user' --> 'visiteur anonyme'
- 'authenticated user' --> 'visiteur identifié'.

I had to translate these 2 strings back in English over the translation interface:
- 'visiteur anonyme' --> 'anonymous user'
- 'visiteur identifié' --> 'authenticated user'
and this solved the issue.

I am using D6 and module Invite 6.x-2.x-dev

#6

zio - November 10, 2008 - 19:26

very interesting! How this trick can work? In db schema roles are coded in two different tables and there are no relations to translation.

But.... it's work for me also.
I hope that somebody can find and fix this tiny bug.

#7

gatonero - November 19, 2008 - 08:35
Priority:normal» critical

This workes for me too. Now I'm using this modul again because I like, that's possible to personalize the invitation. Because I didn't use the modul before this workarround and I'm using it now with this provisorium I set priority to critical.

#8

edalcin - November 23, 2008 - 10:57

Is it in English? Works with me if the Default language is "English"..... Which brings another issue, already reported.

#9

lillywolf - December 14, 2008 - 00:33

So this can also be fixed by creating a new role, giving that role the appropriate invite permissions, and then assigning that role to your users. For some reason, though, just giving authenticated users the right invite permissions isn't working.

#10

ij - January 15, 2009 - 16:08

same here, subscribing...

#11

tpohlsch - January 19, 2009 - 13:00

The roles array in the $account object is not (fully) localized (since the default "registered" role is manually added to the array, it's always called "authenticated user"). So simple localization of the roles in $account->roles does the trick.

Disclaimer: While this works well for me on a site with German localization, and IMHO should (tm) work on "real" multi-lingual sites, I have not thoroughly tested this. The bit of code below is exactly what it says it is: a QUICK fix.

Quick fix:

.../modules/invite/invite.module, line 655+

<?php
function invite_get_role_limit($account) {
  if (!isset(
$account->roles)) {
   
$account = user_load(array('uid' => $account->uid));
  }
 
 
// localize roles
 
$roles_loc = array();
  foreach(
$account->roles as $role) {
       
$roles_loc[] = t($role);
  }
   
 
$role_limit = 0;
  foreach (
user_roles(0, 'send invitations') as $role) {
   
$role_no_space = str_replace(' ', '_', $role);
    if (
in_array($role, $roles_loc)) {

...
?>

#12

tpohlsch - January 19, 2009 - 13:38
Status:active» needs review

Changes suggested in #11 (so I'm not accused of being lazy, correct as that may be... :) )

AttachmentSize
invite.module.322748.diff 747 bytes

#13

geraldito - January 20, 2009 - 21:39

patch fixed that error for me and users with role "registered user" can send invitations. thanx

#14

guldi - January 21, 2009 - 11:42

thanks mates, fixed it also for me.
now also possible to send invitations as guest.

#15

kalbun - January 25, 2009 - 18:33

Great! Thank you, I fixed the problem in my site too (Italian/Romanian/English)

-- Kalbun

#16

tpohlsch - January 30, 2009 - 12:18

Sure, no problem! :)

#17

EzS - February 2, 2009 - 01:02

Thanks a lot for patch! It works for my project: Drupal 6.9 (English, Russian)

#18

setvik - February 23, 2009 - 13:29
Title:only administrator can send invitations» Only administrator can send invitations on multilingual installation.

Building on tpohlsch's patch above, I think we can simplify the code a bit by comparing the role IDs instead of the role names which has the added bonus of avoiding the translation issue altogether.

References:
sess_read() in session.inc
user_roles() in user.module
invite_get_role_limit() in invite.module

AttachmentSize
invite.role_limit.patch 608 bytes

#19

sebzur - March 11, 2009 - 08:53

Thanks! Now Invite works perfect!

#20

Slobodan - May 27, 2009 - 20:01

Thanks! Now Invite works perfect:D

#21

invi - June 2, 2009 - 21:55

Great patch! It also fixes problem with no showing invite block for logged user.

#22

aexl_konzepto.net - June 23, 2009 - 13:45

patch #11 does the job for me.

@setvik, the direction you go "feels better" for me.
but if i review your patch right, the result uses the $role_no_space variable, without setting it. which gives "unlimited" for all inviters.

#23

jsmm - July 2, 2009 - 22:39

Same problem in Spanish, both for authenticated and anonymous user, not for admin. Will the patch be included in a new version? Thanks,

jmm

#24

pal_ur - July 5, 2009 - 11:23

subscribe

#25

ckng - July 13, 2009 - 13:00

Patch #18 is incomplete though, as the $role_no_space was not defined, thus giving the default INVITE_UNLIMITED.

Updated the patch.

AttachmentSize
322748-invite.role_limit.patch 688 bytes

#26

andypost - July 25, 2009 - 02:14

Suppose better to change variable format to store role_id against role_name which is always translatable for $rid=2.

Marked as duplicate http://drupal.org/node/338005#comment-1849252 - read this comments

Limit is not only one place where this used so here patch with upgrade path and different variable names

AttachmentSize
invite_role_0.patch 4.98 KB

#27

andypost - July 25, 2009 - 02:36
Status:needs review» reviewed & tested by the community

Patch from author is the same so rtbc

http://drupal.org/node/443916#comment-1554810

#28

andypost - July 25, 2009 - 02:46
Status:reviewed & tested by the community» duplicate

Better mark this duplicate of #443916: Using role-names instead of ids caused problems with other languages

#29

andypost - July 25, 2009 - 02:50
Status:duplicate» reviewed & tested by the community

This patch more complex so I add upgrade path and mark as duplicate #443916: Using role-names instead of ids caused problems with other languages

Sorry for buzz of my comments...

AttachmentSize
invite_role-ids.patch 6.21 KB

#30

smk-ka - October 4, 2009 - 12:35
Status:reviewed & tested by the community» fixed

Thanks, committed a slightly enhanced version that also takes care of upgraded D5 installations.

#31

System Message - October 18, 2009 - 12:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.