PDA

View Full Version : merging members of two VBs


izz
10-05-2002, 11:03 AM
I have a bi-lingual website for which I have baught two licences of VB.
My problem is that I want users who register in one of the two forums, to be automatically in submitte to both.
In other words, I want the two VB installations to use a single membership table.
What are the files need to be modified. I have the latest VB version.

Logician
10-05-2002, 08:14 PM
I would say it may be easier to use 1 vb for your site instead of trying to merge 2 vb databases.

I recall I give this solution before but basically it's how it works:
Create 2 usergroups for each language. Set forum permissions so that each usergroup will access to the forums that is in its language. Then put a small link in the header named "Change Language" or smt. and create a one line hack which will change the usergroup of the user when clicked. So their languages and the boards they access changes either..

Just a thought..

izz
10-06-2002, 06:01 AM
But I need not to change user permissions in each language version. I want all members to have the same privilages in both versions. But both versions will have different forums names and so.

Logician
10-06-2002, 07:25 AM
This was what I meant. Say you have 2 boards
a) Help (In English)
b) Hilfe (In German)

Configure the access permissions so that HELP group is visible to only usergroup 20 and Hilfe is visible to usergroup 21. Then create your link in the header and make it display the text "ENGLISH BOARD" if the visitor's usergroup is 21 and "DEUTCHE" if visitor's usergroup is 20.

If a visitor from usergroup 20 visits your board he will only see the board HELP and he didnt even know you have another board named "Hilfe", (let alone its contents). He will also see a text in the neader "DEUTCHE" and if he can understand German, he can click it and to his ignorety the hack will change his usergroup to 21 on the background. Now he will see your board differently. Board HELP dissappears for him while a new forum HILFE appears. You can even apply different styles/colors/buttons etc. to different languages. So you would have 1 board but from the visitor's point of view they can think you have 2 seperate boards..

Chris M
10-06-2002, 08:51 AM
That is clever...

How would you make a link that changes their usergroup?:confused:

Satan

izz
10-06-2002, 09:13 AM
Sound interesting
Can you please give me the PHP code that changes the usergroup according to the language?
Will the usergroup assigned to the user override his original usergroup (if he is a moderator for example)?

Logician
10-06-2002, 10:05 AM
ok this is not tested but should work:

1- Edit template phpinclude and add this:


if ($bbuserinfo['usergroupid']==E) {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=en">English</a> ';}
elseif ($bbuserinfo['usergroupid']==D) {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=de">Deutch</a> ';}



(Replace E and D with the usergroupids)

2- edit misc.php, find:

// ############################### start who posted ###############################

Before that add:


if ($action=="changelanguage") {
include("./global.php");
if ($bbuserinfo['usergroupid']==D AND $language='en')
{
$DB_site->query("UPDATE user SET usergroupid=E WHERE userid=$bbuserinfo[userid]");
}
if ($bbuserinfo['usergroupid']==E AND $language='de')
{
$DB_site->query("UPDATE user SET usergroupid=D WHERE userid=$bbuserinfo[userid]");
}
$goto="index.php?s=$session[sessionhash]";
eval("standardredirect(\"".gettemplate("language_changed")."\",\"$goto\");");
}

(Replace E and D with the usergroupids)

3- Create a template named:language_changed
its content: "Language Changed.. You are taken to the forum home"


4- Edit header template and put $change_lan to anywhere you like..

That's it..

And yes this option will only apply to usergroups E and D, not mods, admins etc. If you set your permissions correctly, they will see the entire board..

Make sure the general permissions of usergroups E and D are exactly same except forum access permissions. (Say if E is granted PM rights, either should D)

There maybe a parse errors etc, since I didnt test it, but nothing we can't fix. Just holler if it does not work.. :)

Chris M
10-06-2002, 10:28 AM
It works well:)

Satan

Chris M
10-06-2002, 10:41 AM
:D

This first one is of an English User:D

Satan

Chris M
10-06-2002, 10:42 AM
This one is of the Re-direct Screen...:D

Satan

Chris M
10-06-2002, 10:44 AM
This screenshot is of a German User...:)

Satan

Merjawy
10-07-2002, 02:13 AM
Originally posted by Logician
This was what I meant. Say you have 2 boards
a) Help (In English)
b) Hilfe (In German)
..


I have been doing just that for a while, I have a board with about 4 languages and I use different styles making each lang. style the default for the right section with its own buttons and stuff


has english, german, french and arabic

at first I did one set of animated buttons that flip from language to another , then I changed to using sperate folders for each style

theres still little things that ya have to share but no biggie

izz
10-07-2002, 06:44 AM
but for this to work fine, the normal users must belong to one of the two groups, no?
If the user belong to a group like mods for example, he should not see the language switching link.

Logician
10-07-2002, 07:03 AM
Originally posted by izz
but for this to work fine, the normal users must belong to one of the two groups, no?

Yes the users must belong to one of the 2 groups. If you have problems about putting the users manually to the specific usergroups well another hack in register.php can handle this too. You can create 2 different register templates (in English and in German) and put a hidden form variable inside, then in register.php control this variable and put the user into the relevant usergroup. So users following the "English" registration page will be put into usergroup 20, while others 21 etc.

If the user belong to a group like mods for example, he should not see the language switching link.
Yes he will not see it if you applied my code. The link will be visible to only 2 usergroups. Mods, Admins etc. will see all the boards in the forum if you didnt restrict their permissions.

izz
10-07-2002, 07:12 AM
what about renaming the "registered" group to English (E in your example) from VB control pannel? Will this default all new regisrtants to the English group?

Logician
10-07-2002, 07:26 AM
sure it will

izz
10-07-2002, 07:38 AM
can you please justify step 4? We did not define a variable "change_lan", so what are you referring to? What is the exact code to put?

(sorry if the question sounds dummy, since I'm not a PHP guy)

Logician
10-07-2002, 08:03 AM
Originally posted by izz
can you please justify step 4? We did not define a variable "change_lan", so what are you referring to? What is the exact code to put?

Yes we did.. (In step 1). The variable will stand for the language switch link in the header. It will bear the value "English" if the user is from german usergroup, and German if the user is from the English usergroup. You'll see what it does better if you put it in your header and login as a user from usergroup E or D.

izz
10-07-2002, 10:59 AM
:(
It sems a headache to me, it is not working.
I also need to worry about having two completely different style sets since the other language is a right-to-left.
It seems that having the two installations which use the same membership table is easier for perfect separation in styles and forums.
Did anybody try this out before?

Logician
10-07-2002, 12:14 PM
Originally posted by izz
:(
It sems a headache to me, it is not working.
I also need to worry about having two completely different style sets since the other language is a right-to-left.
It seems that having the two installations which use the same membership table is easier for perfect separation in styles and forums.
Did anybody try this out before?
If you gave up just because you couldnt make it run, well you dont need to. Give me the problems you had with exact details and I can help you run the hack.

If you didnt like the solution and this is why you dont apply it, it's your call anyway..

But if this is the case I want to remind you that your project will require much more hacking than my solution and there a lot of tackles to handle in your 2 forums/1 database method.

Just a few points you should be considering about your project:
1- You banned a user in one board, he is not banned in the other. You have to ban it there too. Same applies if you changed any info (usergroup, username, email, settings etc.) of the user in your Admin CP

2- If user forgets his email and uses lost password recovery form, only his password in one board will change.

3- If user changes his email, only one email in one board will change.

4- If user changes any of the settings after registration, the setting will apply to one board.

There are many other issues you need to handle with way a lot of hacking on your project.. ;) In other words be ready to have much more headaches.. :knockedout:

izz
10-07-2002, 12:28 PM
lol :)
thanks for your prompt response and manner.
But I feel that your didn't get my suggested solution well.

I meant two databases but one single (user) table.
For example we may setup the english forum normally, but in the Arabic version we modify the register.php file so that it submits the registrations to the English database/user table.
Whenever a user changes his password, the change will go to one table which is used by both versions.
The hack should care that any user related action shall deel with the english database.

This is just to clarify my idea. But still I guess your solution is easier but I may need more hints on deeling with styles, and how to let the "unregistered" viewers see the desired language.
In all cases I appreciate your manner and logic Mr. Logician :)

Logician
10-07-2002, 01:15 PM
I believe I understood you quite well. Actually this is why I insist on my solution because what you are proposing is way harder than it seems to you. :)

Let's concentrate on my solution for a minute: What's your reservations on my hack and what do you think you cant do it in my hack while you can do in your method if you can apply? Enlist them and let me cure your worries.

As for styles or Arabic templates, both solutions are same. You planned to create an arabic style set in your method, and in my solution I propose the same solution. Create a new style for arabic and apply to Arabic forums. Actually you can modify my code so that while the hack changes user's usergroup, it changes his default style too, so when user clicks the "Arabic" link in the header he will start browsing the forum in your Arabic style too.

As for "unregistered" user it's upto you how they see your board. All you have to do is to apply a default style set for your forum and configure "guest"s board permisssions according to your wish. You can make guest see which ever forums you want and in whichever template set you like.

Any other worries? ;)

You might not want to apply my solution but you can not apply your method either. It wouldnt be possible to have 2 different database's and 1 shared user table unless you create a very sophisticated hack which would be very hard to develop. Unless what you think, it's not only registration.php that changes user's details in user table: Say user A in arabic board added someone to his ignore list. How do you plan to handle this request? (FYI. ignore lists are saved in "user" table), same applies someone sends a pm to someone else (pm popup warning is saved in user table), and there are way a lot of other incidents that you should deal with.

To handle them, you cant simply make second board use first board's user table. Because it requires way too much hacking. User table is referenced in many places in many vb script. Your best bet would be program a script that will make replication. This is still hard to code and really a few people can handle this project. Besides even this might not be very handy and there are still some other tackles in this method. Check the discussion here: https://vborg.vbsupport.ru/showthread.php?s=&threadid=39966&highlight=replication

Considering the simplicity of my solution, believe me you wouldnt want to embark upon your way.. :)

izz
10-08-2002, 11:01 AM
Yes Mr Logician :) I beleive in your solution now... and want to apply it.
Please let me know if it is possible to ask more questions about this issue? Since I'm comming from ASP and has no experience in PHP I think I will need to ask about each piece of code I may use.
If you feel the discussion is not usefull for the public anymore, we may proceed by PMs if you don't mind?

Logician
10-08-2002, 12:25 PM
Sure you can ask questions.. If your questions are private, contact me via email (I prefer email to PM), but if the answers to your questions would be helpful to others, you can ask here. So others than me can answer, while others than you can read. ;)

izz
10-08-2002, 12:56 PM
thanks for your generousity,
my first question is helpful to all people who may be interested in our hack.

May I ask you to rearrange your hack code to consider the following:
1. Language style changes with the user group.
2. Guests can see a default language style (Arabic in my case), and can see the language switching code

By then I will re-apply the code and tell you the problem I faced

Logician
10-09-2002, 04:52 PM
Originally posted by izz
May I ask you to rearrange your hack code to consider the following:
1. Language style changes with the user group.

First create a new "template set" for your Arabic language and edit all templates accordingly so that texts are in Arabic.

Do same by adding a new "replacement set" for your Arabic language and edit your colors/fonts etc.

Now create a new style set and point your Arabic template and replacements sets. Name it as "Arabic".

Do all above for English language.

Note style ids of English and Arabic styles.

To test if they work or not, first make all stylesets (by modify) "user selectable" and then login to your User CP, and change styles. See if language changes as it should be.

(You can find a lot of information about 2 styles in 2 languages in vbulletin.com, if you cant handle it)

If everything is ok upto now, replace my hack code:

$DB_site->query("UPDATE user SET usergroupid=E WHERE userid=$bbuserinfo[userid]");


AS:

$DB_site->query("UPDATE user SET usergroupid=E, styleid=Englishstyleid WHERE userid=$bbuserinfo[userid]");


and

$DB_site->query("UPDATE user SET usergroupid=E WHERE userid=$bbuserinfo[userid]");


AS:

$DB_site->query("UPDATE user SET usergroupid=D, styleid=Arabicstyleid WHERE userid=$bbuserinfo[userid]");


Now when users clicks the link, their styleid will automatically change too (so does the language/colors/fonts everything about your forum) ;)

Originally posted by izz

2. Guests can see a default language style (Arabic in my case), and can see the language switching code

This will be again done in your Admin CP, you dont need any hacks.

After you completed the steps above, click Modify/Forums and choose modify ALL forums according to this:

Custom style set for this forum : (Any style you want)
Override users custom styles: No

The style you set will be the default for guest. So for example if you set English style here, all guests will see these boards in English..

As you can see most of the work is default vb behaviour and does not require any hacking. And in fact even if you used 2 different boards, you would do some of this work..

Hope this helps..

izz
10-12-2002, 01:24 PM
:hurt: :hurt:
Thank you very much.
I don't know why the link we put in misc.php never apears in the page!!
I used the following code:
if ($action=="changelanguage") {
include("./global.php");
if ($bbuserinfo['usergroupid']=='Arabic' AND $language='en')
{
$DB_site->query("UPDATE user SET usergroupid=English, styleid=English WHERE userid=$bbuserinfo[userid]");
}
if ($bbuserinfo['usergroupid']=='English' AND $language='ar')
{
$DB_site->query("UPDATE user SET usergroupid=Arabic, styleid=Arabic WHERE userid=$bbuserinfo[userid]");
}
$goto="index.php?s=$session[sessionhash]";
eval("standardredirect(\"".gettemplate("language_changed")."\",\"$goto\");");
}
I have two usergrops: Arabic, and English
Two styles: Arabic and English

In the phpinclude template I put the following:

if ($bbuserinfo['usergroupid']=='English') {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=en">English</a> ';}
elseif ($bbuserinfo['usergroupid']=='Arabic') {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=ar">Arabic</a> ';}

May be I have a problem in quoting the strings somewhere???

Logician
10-12-2002, 04:57 PM
Your forgot to edit usergroupids. Please follow me:


if ($action=="changelanguage") {
include("./global.php");
if ($bbuserinfo['usergroupid']=='YYY' AND $language='en')
{
$DB_site->query("UPDATE user SET usergroupid=XXX, styleid=ZZZ WHERE userid=$bbuserinfo[userid]");
}
if ($bbuserinfo['usergroupid']=='XXX' AND $language='ar')
{
$DB_site->query("UPDATE user SET usergroupid=YYY, styleid=WWW WHERE userid=$bbuserinfo[userid]");
}
$goto="index.php?s=$session[sessionhash]";
eval("standardredirect(\"".gettemplate("language_changed")."\",\"$goto\");");
}


and


if ($bbuserinfo['usergroupid']=='XXX') {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=en">English</a> ';}
elseif ($bbuserinfo['usergroupid']=='YYY') {$change_lan=' <a href="misc.php?s='.$session[sessionhash].'&action=changelanguage&language=ar">Arabic</a> ';}


In the codes above:
All XXX will be replaced with the usergroupid of the English users
All YYY will be replaced with the usergroupid of the Arabic users
All ZZZ will be replaced with the styleid of the English styleset
All WWW will be replaced with the styleid of the Arabic styleset

If you dont know how to find usergroup ids this (https://vborg.vbsupport.ru/showthread.php?s=&threadid=39145) should help..