Advertisement:

Author Topic: Share user database for 2 (or more) different forums.  (Read 380579 times)

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 73,189
Re: Share user database for 2 (or more) different forums.
« Reply #320 on: March 31, 2010, 12:15:22 PM »
See, that's the thing. You've thrown so much in the posts, out of context, that it's very hard to actually follow.

I actually thought you needed updateStats(array('totalMembers' => '+')); first of all.
No good deed goes unpunished
All helpful urges should be circumvented

Offline j4r3k

  • Newbie
  • *
  • Posts: 6
Re: Share user database for 2 (or more) different forums.
« Reply #321 on: March 31, 2010, 12:30:38 PM »
Sorry for the mess.
I updated my first post, is it clear now what I'm trying to achieve?
Deleted my other posts.

Offline Mr. Doug

  • Jr. Member
  • **
  • Posts: 160
  • Gender: Male
    • Putter Talk
Re: Share user database for 2 (or more) different forums.
« Reply #322 on: March 31, 2010, 02:33:48 PM »
Sorry for the mess.
I updated my first post, is it clear now what I'm trying to achieve?
Deleted my other posts.

That actually confuses things more sometimes...
--
Doug Hardman
doug (at) puttertalk (dot) com

Offline j4r3k

  • Newbie
  • *
  • Posts: 6
Re: Share user database for 2 (or more) different forums.
« Reply #323 on: April 01, 2010, 06:11:13 AM »
OK, here is a solution that updates all your forums total members count right away after new user registration (there is no need to use 'update statistics' from admin panel). For SMF 1.1.11.

First of all we'll make it work using the 'update statistics' option too. In Subs.php

Find
Code: [Select]
updateSettings($changes);

Replace with
Code: [Select]
//updateSettings($changes);
foreach ($changes as $variable => $value)
{
db_query("
UPDATE prefix1_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

db_query("
UPDATE prefix2_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

$modSettings[$variable] = $value === true ? $modSettings[$variable] + 1 : ($value === false ? $modSettings[$variable] - 1 : stripslashes($value));
}

add more prefixes according to your needs.

Second step: make it work after user registration. In Subs.php

Find
Code: [Select]
if ($update)
{
foreach ($changeArray as $variable => $value)
{
db_query("
UPDATE {$db_prefix}settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

Replace with
Code: [Select]
if ($update)
{
foreach ($changeArray as $variable => $value)
{
db_query("
UPDATE {$db_prefix}settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

if ($variable == 'totalMembers')
{
db_query("
UPDATE prefix1_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);

db_query("
UPDATE prefix2_settings
SET value = " . ($value === true ? 'value + 1' : ($value === false ? 'value - 1' : "'$value'")) . "
WHERE variable = '$variable'
LIMIT 1", __FILE__, __LINE__);
}
$modSettings[$variable] = $value === true ? $modSettings[$variable] + 1 : ($value === false ? $modSettings[$variable] - 1 : stripslashes($value));


Note that in this step you must enter only the prefixes that are in other forums than you are currently editing. For example if your are editing Subs.php in forum with prefix1 then you enter prefix2, prefix3 into the if statement. prefix1 is handled by {$db_prefix}.

Remember to edit all Subs.php in each forum so the 'update statistics' and user registration works on each forum same way.

Offline Liam.

  • SMF Hero
  • ******
  • Posts: 2,239
  • Gender: Male
Re: Share user database for 2 (or more) different forums.
« Reply #324 on: April 10, 2010, 04:40:34 PM »
Great bit there j4r3k, I'm soon to try that on my 1.1.11 test forums - have you tried if this works on 2.0 RC3 aswell though?

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #325 on: April 10, 2010, 06:45:10 PM »
Great bit there j4r3k, I'm soon to try that on my 1.1.11 test forums - have you tried if this works on 2.0 RC3 aswell though?
It's a littble bit complicated with 2.0 RC3 files. It is no longer just Subs.php file. You may have to go through other files as well. I normally use UltraEdit to check all files for the relevant code. By the VIEW tips & tricks in MySQL / phpAdmin works. That is all I can say.

Offline j4r3k

  • Newbie
  • *
  • Posts: 6
Re: Share user database for 2 (or more) different forums.
« Reply #326 on: April 11, 2010, 06:51:36 AM »
have you tried if this works on 2.0 RC3 aswell though?

No, I didn't.

Offline Liam.

  • SMF Hero
  • ******
  • Posts: 2,239
  • Gender: Male
Re: Share user database for 2 (or more) different forums.
« Reply #327 on: April 11, 2010, 07:14:10 AM »
I have a mass search/replace program I could use... But would that be the only thing, changing it in all of the files instead of just Subs?

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #328 on: April 19, 2010, 06:59:07 PM »
I have a mass search/replace program I could use... But would that be the only thing, changing it in all of the files instead of just Subs?
Yes all the files in sources folder.

Offline FireDitto

  • Full Member
  • ***
  • Posts: 617
  • Gender: Female
  • Shadow In The Flame
    • @SPWeyr on Twitter
    • Second Pass Weyr RPG
Re: Share user database for 2 (or more) different forums.
« Reply #329 on: June 05, 2010, 10:34:12 PM »
I'm using RC3, and I'm not entirely sure I'm searching for the correct thing, as I can't seem to find that which I need to replace...

Quote
2. Modifying the source code
Open each of the .php files located in the Sources directory in your hard drive using a text editor program. Find all occurances of "{$db_prefix}members" and replace with "smf1_members" (without quotes). Do this for every single .php file in the Sources directory. Also find and replace the following:
"{$db_prefix}im_recipients" => "smf1_im_recipients"
"{$db_prefix}instant_messages" => "smf1_instant_messages"
"{$db_prefix}membergroups" => "smf1_membergroups"

am I looking for:
{$db_prefix}instant_messages
{$rpg2_}instant_messages
$rpg2_instant_messages
rpg2_instant_messages

... or what? Sorry, but I'm completely lost! >.< and nothing seems to be throwing up a result.
Second Pass Weyr
An AU Pernse RPG

SMF 2.0.6 with SP 2.3.5

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #330 on: June 06, 2010, 08:12:00 AM »
You are looking for this:
$db_prefix
with a note that it may not be in (or only in) the form of {$db_prefix}. Backup before you make any changes. Do read all the questions and guides in here, if any, especially regarding the caveat in doing this. Good luck in getting any help as this mod is way back to 2004 and there are many changes in SMF especially now it is 2.0 RC3 when then it was in very early 1.1.x.

IMHO,you might prefer this with some caveat as well.

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #331 on: June 11, 2010, 05:34:54 PM »
You are welcome. Hope we all will always try to learn and share earned knowledge to each other.

Offline FireDitto

  • Full Member
  • ***
  • Posts: 617
  • Gender: Female
  • Shadow In The Flame
    • @SPWeyr on Twitter
    • Second Pass Weyr RPG
Re: Share user database for 2 (or more) different forums.
« Reply #332 on: June 13, 2010, 04:57:30 AM »
Ugh. I got an error.

I followed the instructions here with the added:

prefix_membergroups to shared_membergroups

And am now getting the following error on both sites:

"Connection Problems

Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later."


Did I screw up something in changing the membergroups, or elsewhere? I can't seem to find where I messed up.

Thanks.
Second Pass Weyr
An AU Pernse RPG

SMF 2.0.6 with SP 2.3.5

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #333 on: June 13, 2010, 10:11:45 AM »
Have you completed all the steps correctly? Because my forums also stop working until I have finished all the steps correctly. Remember, always to backup your database in full before doing this and restore it back if anything goes on.

Check this list:
1. Ensure using USE smf correctly i.e. change smf to your database name.
2. Ensure using ALTER TABLE correctly.
3. Ensure CREATE VIEW correctly as well.
4. Lastly, DO NOT keep original table in the same original name.

IMHO your forums seems not connecting to database may be due to any of the above. Solutions? Restore your database and do it again.
« Last Edit: June 13, 2010, 10:21:17 AM by Abu Fahim Ismail »

Offline FireDitto

  • Full Member
  • ***
  • Posts: 617
  • Gender: Female
  • Shadow In The Flame
    • @SPWeyr on Twitter
    • Second Pass Weyr RPG
Re: Share user database for 2 (or more) different forums.
« Reply #334 on: June 13, 2010, 09:33:42 PM »
I'm not *positive* where I messed up, but I re-did it very carefully and it's working beautifully now.

Thanks =)
Second Pass Weyr
An AU Pernse RPG

SMF 2.0.6 with SP 2.3.5

Offline FireDitto

  • Full Member
  • ***
  • Posts: 617
  • Gender: Female
  • Shadow In The Flame
    • @SPWeyr on Twitter
    • Second Pass Weyr RPG
Re: Share user database for 2 (or more) different forums.
« Reply #335 on: June 14, 2010, 02:36:30 AM »
Um, I'm having another issue now:

Although all the mods are installing correctly and without error, none of them are actually working... I thought it was a one off, and posted on the support thread, but after installing more with the same kind of results, I believe it's probably my editing of this that's cause the issue... somewhere.

Why would this be, and how do I correct it?
« Last Edit: June 14, 2010, 02:47:12 AM by FireDitto »
Second Pass Weyr
An AU Pernse RPG

SMF 2.0.6 with SP 2.3.5

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #336 on: June 14, 2010, 12:44:05 PM »
Mods error might be due to the caveat as mentioned and discussed in this thread. If you can list the mods, maybe we will know where the fault came from.

Else, you have edited the sources file using the original mod which you shouldn't if you are using the database approach. If you did this, that may be the cause of your problem(s) and not the mod(s) (except if the mod is related to profile avatar like what Arantor had advised, although it is very unlikely in your case).

Offline FireDitto

  • Full Member
  • ***
  • Posts: 617
  • Gender: Female
  • Shadow In The Flame
    • @SPWeyr on Twitter
    • Second Pass Weyr RPG
Re: Share user database for 2 (or more) different forums.
« Reply #337 on: June 15, 2010, 12:47:04 AM »
My mods are as follows; this is more or less a complete list of the mods I'll be employing:

Not working

EzPortal - perfect install, but member changes are not being saved [eg, who can view what].
Sub Accounts - Installed perfectly, but comes up with "Unknown column 'mem.is_shareable' in 'field list'" when I activated it in the Administration panel, and it's now all I get on that forum... I expect that would just be a few edits to make it working?

Working:
Add IP2Location to track IP.
Effectivly Remove SMF Logo.
Display Name on Registration.
Member Color Link.
Team Page.
Justify BBC.
Custom Forms.

Waiting for Update
Multiple Forums Mod



Thanks for any help =)
« Last Edit: June 15, 2010, 01:27:39 AM by FireDitto »
Second Pass Weyr
An AU Pernse RPG

SMF 2.0.6 with SP 2.3.5

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,927
  • Gender: Male
Re: Share user database for 2 (or more) different forums.
« Reply #338 on: June 15, 2010, 07:27:56 AM »
Nice trick. I just needed that.

Offline Hj Ahmad Rasyid Hj Ismail

  • SMF Hero
  • ******
  • Posts: 4,905
  • Gender: Male
  • Busy mode is on.
    • ahmad.rasyid.ismail on Facebook
    • ahrasis on GitHub
    • ahrasis on LinkedIn
    • @ahrasis on Twitter
    • ElkArte Malaysia
Re: Share user database for 2 (or more) different forums.
« Reply #339 on: June 15, 2010, 09:23:04 AM »
Not working

EzPortal - perfect install, but member changes are not being saved [eg, who can view what].
Sub Accounts - Installed perfectly, but comes up with "Unknown column 'mem.is_shareable' in 'field list'" when I activated it in the Administration panel, and it's now all I get on that forum... I expect that would just be a few edits to make it working?
I think Sub Account Mod as well as ezPortal do modify / add database. Maybe you want to share their tables too?

I listed the note on the Caveat & Gotchas of this database mod:
This thread does discuss multiple ways of doing it, but all require significant change or come with significant caveats and gotchas. There's no simple way that actually works cleanly without any side effects :(
Avatar Caveat:
Note that member avatars are shared if they use an external URL or pick from the gallery (since that's stored in the members table, along with their post count) but not if they upload their own (since that's stored in the attachments table)
Membergroup Caveat:
Yup, that's the idea but do see the caveats from me above, like about membergroups and so on.
Attachment Caveat:
Assuming you have two topic and two message tables, you'll be duplicating attachments unless you modify all the attachment handling code too (have fun with that)

Basically, an attachment is attached to a post by id. If you attach a file to message id 1000, the same attachment is visible in BOTH sides' message 1000.
Cookie Caveat:
I've had no issues with cookies. Just make sure your cookies aren't named the same way. (keep them all different.)
Theme & Board Caveat:
I found a caveat to a shared member DB. Make sure all the Themes on your boards are numbered the same way. If I make a change the default to one (and reset the members options), all 3 get the change pushed.
Custom Profile Caveat:
Note also that custom profile fields are also in that table...
Statistic Caveat:
I ran into the same thing. If you run the "update statistics" maintenance, it fixes it. So now I just run that every few days until I can get around to writing a cron script that does it for me. Everything functions correctly, it just doesn't update the number of users in the bottom of the page..
Hope this will help. Happy testing! ;)