Home arrow Forum Change SMF's user information through CB interface
  Welcome, Guest. Please login or register.
Did you miss your activation email?
October 13, 2008, 12:49:58 PM
Home New Posts Search Calendar


Login with username, password and session length
+  Joomla Forum
|-+  Joomla Hacks
| |-+  Joomla-SMF Forum Support
| | |-+  Joomla-SMF 2.0.x (Moderators: -Wolverine, kai920)
| | | |-+  Change SMF's user information through CB interface
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Go Down Print
Author Topic: Change SMF's user information through CB interface  (Read 6561 times)
p9939068
Joomla Expert
****

Karma: +18/-5
Offline Offline

Posts: 173


View Profile WWW
Change SMF's user information through CB interface
« on: November 05, 2006, 02:18:27 AM »

I made this post on another thread, but lots of people are still asking for it on other threads, so i'm giving this it's own thread, at least until the original plugin does this.

To fully control SMF information (including signature that everyone wishes so much Grin) purely from CB, this is what you do:

go to com_comprofiler/plugin/user/plug_smfcbplugin/smf_cb.php (this is the SMF-CB plugin that comes with JSMF, not one of brat's plugins), go to the function updateUser and add these lines just above the "return true" at the last line of the function so that the whole function looks like this:
Code:
    function updateUser($data, $extras, $status)
    {
        global $_PLUGINS;
        global $jsmfConfig;
global $_POST, $database;
global $user;
        $jsmf = new jsmfFrontend();

        /*
        Row::id => 76
        Row::name => test
        Row::username => test
        Row::email => test@test.com
        Row::password =>
        Row::usertype => Registered
        Row::block => 0
        Row::sendEmail => 0
        Row::gid => 18
        Row::registerDate =>
        Row::lastvisitDate =>
        Row::activation =>
        Row::params =>
        Row::_tbl => #__users
        Row::_tbl_key => id
        Row::_error =>
        Row::_db => Object id #2
        Extras::id => 76
        Extras::user_id => 76
        Extras::avatar =>
        Extras::avatarapproved =>
        Extras::approved => 1
        Extras::confirmed => 1
        Extras::hits =>
        Extras::_tbl => #__comprofiler
        Extras::_tbl_key => id
        Extras::_error =>
        Extras::_db => Object id #2
        Extras::firstname =>
        Extras::middlename =>
        Extras::lastname =>
         */
         if (!$jsmf->updateMember($data, $extras)) {
            $_PLUGINS->raiseError(0);
            $_PLUGINS->_setErrorMSG("JSMF CB Plugin error::Failed to synchronize user updates to SMF:: ".$jsmf->err);
            return false;
         }

//Mike's hack
//Update smf_members with optional info like gender, MSN, website, location etc
$sql = "SELECT * FROM #__comprofiler WHERE `id` = '".$data->id."'";
$database->setQuery($sql);
$cbData = null;
$database->loadObject( $cbData );
if (!empty($cbData->cb_website)) {
$website = explode("|*|", $cbData->cb_website);
if (substr(htmlspecialchars($website[0], ENT_QUOTES),0,7) != "http://")
$websiteUrl .= "http://";
$websiteUrl .= htmlspecialchars($website[0], ENT_QUOTES);
$websiteTitle = ($website[1] != "") ? htmlspecialchars($website[1], ENT_QUOTES) : $websiteUrl;
}
        $uid = $jsmf->getSMFid($data->id, $data->username);

$query =
"UPDATE {$jsmfConfig->smf_prefix}members SET " .
"\n `personalText` = '".htmlspecialchars($cbData->cb_personaltext, ENT_QUOTES)."', " .
"\n `gender` = '".(($cbData->cb_gender == 'Male') ? '1' : '2')."', " .
"\n `birthdate` = '".$cbData->cb_birthdate."', " .
"\n `websiteTitle` = '".$websiteTitle."', " .
"\n `websiteUrl` = '".$websiteUrl."', " .
"\n `location` = '".htmlspecialchars($cbData->cb_location, ENT_QUOTES)."', " .
"\n `ICQ` = '".htmlspecialchars($cbData->cb_icq, ENT_QUOTES)."', " .
"\n `AIM` = '".htmlspecialchars($cbData->cb_aim, ENT_QUOTES)."', " .
"\n `YIM` = '".htmlspecialchars($cbData->cb_yim, ENT_QUOTES)."', " .
"\n `MSN` = '".htmlspecialchars($cbData->cb_msn, ENT_QUOTES)."', " .
"\n `signature` = '".htmlspecialchars($cbData->cb_signature, ENT_QUOTES)."', " .
"\n `usertitle` = '".htmlspecialchars($cbData->cb_usertitle, ENT_QUOTES)."' " .
"\n WHERE `ID_MEMBER` = '".$uid."'";
$database->setQuery($query);
if (!$database->query()) {
$jsmf->err = $database->getErrorMsg().' ~~~ FROM::'.__FILE__.' || '.__FUNCTION__.' || '.__LINE__;
return false;
}

         return true;
    }
Obviously, you will need to create these fields using CB's field manager: cb_personaltext, cb_gender, cb_birthdate, cb_website (note: cb_website must be of type "Web Address", and select "Hypertext and URL" at the bottom), cb_location, cb_icq, cb_aim, cb_yim, cb_msn, cb_signature, and cb_usertitle.

You should create these fields inside the "Forum Profile" tab created when you installed brat's forum profile plugin (or joomlahack's version of it). If don't see Forum Profile as a valid selection for Tab when you're creating the fields, this is what you need to do: go to your phpmyadmin (or whatever you use to edit mysql), go to jos_comprofiler_tabs, look for Forum Profile under title, and change the fields column to 1. (Note: for users who enable Nest Tabs under CB's configuration > User Profile, this will result in the Forum Profile tab appearing under the Profile tab!)

All the extra fields created should be UNrequired (to suit SMF's conditions), NOT shown in profile (since we're going to use brat's profile plugin to output the result), NOT required during registration (cus the way i hacked the plugin, it only works when users UPDATE their profile, NOT during registration), and of course Published.

Next, remember to go to JSMF's configuration and enable Redirect Profile Links so that SMF's profile will not be viewable through SMF itself.

I have also included an edited copy of brat's plugin's smf_profile.php and smf_profile.html.php (unzip first. it's not the full plugin) which you should probably replace the one you have now. All my edits were commented with "//Mike's hack" at the top so you can easily find where the changes were made.
 
What my hacks do is to hide the Forum Profile tab totally from users who are either not the owner or admin (I think this is sensible, but if you want forum profile to be viewable to everyone, simply edit a line that i've added. Search for the first "Mike's hack" in smf_profile.php), hide the forum profile and settings links from ALL non-admin (including profile owner), hide the "Sync avatar" button from ALL non-admin (including profile owner), re-position the avatar and Personal Text position, and show fields that are NOT empty only.

Remember to backup all files before doing anything! If you wish to change the layout, simply look for all the "Mike's hack"s. Some knowledge of php is required for that. If not, using the files "as is" will work too. This is a pretty "unelegant" hack (as my hacks mostly are Roll Eyes) since i use it for my own purpose only. Hope it helps Smiley

Regards, Mike
Logged

-----
Owner of http://mike.simbunch.com
Creator of ParaInvite, AJAX Sandbox, AJAX SMF Polls, Profile URL etc..
Bob Gordon
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1


View Profile
Re: Change SMF's user information through CB interface
« Reply #1 on: November 05, 2006, 05:28:24 PM »

could u please give me a link to plug in - I can't find it

thx
Logged
p9939068
Joomla Expert
****

Karma: +18/-5
Offline Offline

Posts: 173


View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #2 on: November 06, 2006, 05:34:36 PM »

could u please give me a link to plug in - I can't find it

thx
the smf-cb plugin comes together with the jsmf zip file which you're supposed to unzip first.

the smf-profile plugin can be found here: http://www.joomlahacks.com/component/option,com_smf/Itemid,94/topic,2554.0
Logged

-----
Owner of http://mike.simbunch.com
Creator of ParaInvite, AJAX Sandbox, AJAX SMF Polls, Profile URL etc..
james
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1


View Profile
Re: Change SMF's user information through CB interface
« Reply #3 on: November 08, 2006, 03:35:45 PM »

Awesome! Just what I was looking for.

I replaced the 2 profile files with yours, but left some of the new fields visible on the profile which works great.

Thanks for the hack!
Logged
p9939068
Joomla Expert
****

Karma: +18/-5
Offline Offline

Posts: 173


View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #4 on: November 10, 2006, 01:28:30 PM »

I just discovered that this hack will only work with smf_cb_plugin_2_0 found in the JSMF RC1 package. The change made in smf_cb_plugin_2_0_1 will trigger the hack before the profile is actually updated in CB, so the values remain unchanged. This means updating of SMF fields take precedence, whereas for the hack to work, updating CB fields must take precedence Smiley

Rgds, Mike
Logged

-----
Owner of http://mike.simbunch.com
Creator of ParaInvite, AJAX Sandbox, AJAX SMF Polls, Profile URL etc..
-Wolverine
Moderator
Joomla Guru
*****

Karma: +375/-34
Offline Offline

Posts: 3393


Lead Developer


View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #5 on: November 10, 2006, 02:10:59 PM »

in 2.0.1 the change was made because of the ability of a user to change their username via CB.  When they attempt to change their username in CB we try to correlate this change through several different methods and if they fail then we need to make sure CB fails.  Because if CB succeeds and SMF fails then there is no way to correlate the users going forward and they are viewed as separate users.  Basically you lose all SMF information for that user *and* a new SMF user is created for the new CB username. 

Very, very, very bad.  Suggested workaround is to disable the ability to change usernames.  Or use the plugin as it is distributed.
Logged

Need help?  Check Here First!
Get the JSMF User Guide
SEARCH this forum.
Denney
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2


View Profile
Re: Change SMF's user information through CB interface
« Reply #6 on: November 11, 2006, 08:43:56 AM »

To fix this so it works with RC2, instead of using the above code, use this code:

Find:
Code:
$_PLUGINS->registerFunction( 'onBeforeUserUpdate', 'updateUser', 'jsmfCB');

Add After:
Code:
$_PLUGINS->registerFunction( 'onAfterUserUpdate', 'updateAfterUser', 'jsmfCB');

Find:
Code:
function updateUser($data, $extras, $status) {

Add After END OF FUNCTION!:
Code:
function updateAfterUser($data, $extras, $status) {
global $_PLUGINS;
        global $jsmfConfig;
        $jsmf = new jsmfFrontend();
        $jsmfConfig = $jsmf->loadParams();

//Mike's hack
//Update smf_members with optional info like gender, MSN, website, location etc
global $database, $user;
$sql = "SELECT * FROM #__comprofiler WHERE `id` = '".$data->id."'";
$database->setQuery($sql);
$cbData = null;
$database->loadObject( $cbData );
if (!empty($cbData->cb_website)) {
$website = explode("|*|", $cbData->cb_website);
if (substr(htmlspecialchars($website[0], ENT_QUOTES),0,7) != "http://")
$websiteUrl .= "http://";
$websiteUrl .= htmlspecialchars($website[0], ENT_QUOTES);
$websiteTitle = ($website[1] != "") ? htmlspecialchars($website[1], ENT_QUOTES) : $websiteUrl;
}
        $uid = $jsmf->getSMFid($data->id, $data->username);

$query =
"UPDATE {$jsmfConfig->smf_prefix}members SET " .
"\n `personalText` = '".htmlspecialchars($cbData->cb_personaltext, ENT_QUOTES)."', " .
"\n `gender` = '".(($cbData->cb_gender == 'Female') ? '2' : '1')."', " .
"\n `birthdate` = '".$cbData->cb_birthdate."', " .
"\n `websiteTitle` = '".$websiteTitle."', " .
"\n `websiteUrl` = '".$websiteUrl."', " .
"\n `location` = '".htmlspecialchars($cbData->cb_location, ENT_QUOTES)."', " .
"\n `ICQ` = '".htmlspecialchars($cbData->cb_icq, ENT_QUOTES)."', " .
"\n `AIM` = '".htmlspecialchars($cbData->cb_aim, ENT_QUOTES)."', " .
"\n `YIM` = '".htmlspecialchars($cbData->cb_yim, ENT_QUOTES)."', " .
"\n `MSN` = '".htmlspecialchars($cbData->cb_msn, ENT_QUOTES)."', " .
"\n `signature` = '".htmlspecialchars($cbData->cb_signature, ENT_QUOTES)."', " .
"\n `usertitle` = '".htmlspecialchars($cbData->cb_usertitle, ENT_QUOTES)."' " .
"\n WHERE `ID_MEMBER` = '".$uid."'";
$database->setQuery($query);

if (!$database->query()) {
$jsmf->err = $database->getErrorMsg().' ~~~ FROM::'.__FILE__.' || '.__FUNCTION__.' || '.__LINE__;
return false;
}

return true;
}
Logged
p9939068
Joomla Expert
****

Karma: +18/-5
Offline Offline

Posts: 173


View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #7 on: November 11, 2006, 11:02:16 AM »

Wow, thanks! I think i just got a much clearer picture of how CB plugins work Tongue

Anyway, i just added a new parameter to allow users to hide their email in their smf profile. Create another CB field cb_hideemail (radio button: Yes/No), and use the following function inside smf_cb.php
Code:
/**
* Update smf_members with optional info (field names below):
* personalText, gender, birthdate, websiteTitle, websiteUrl,
* location, hideEmail, ICQ, AIM, YIM, MSN,
* signature, and usertitle
*/
function updateAfterUser($data, $extras, $status) {
        global $_PLUGINS;
        global $jsmfConfig;
global $_POST, $database;
        $jsmf = new jsmfFrontend();
        $jsmfConfig = $jsmf->loadParams();
$sql = "SELECT * FROM #__comprofiler WHERE `id` = '".$data->id."'";
$database->setQuery($sql);
$cbData = null;
$database->loadObject( $cbData );
//Get webpage values
if (!empty($cbData->cb_website)) {
$website = explode("|*|", $cbData->cb_website);
if (substr(htmlspecialchars($website[0], ENT_QUOTES),0,7) != "http://")
$websiteUrl .= "http://";
$websiteUrl .= htmlspecialchars($website[0], ENT_QUOTES);
$websiteTitle = ($website[1] != "") ? htmlspecialchars($website[1], ENT_QUOTES) : $websiteUrl;
}
//Get hideEmail value
if ($cbData->cb_hideemail == "Yes")
$hideEmail = '1';
else
$hideEmail = '0';

        $uid = $jsmf->getSMFid($data->id, $data->username);

$query =
"UPDATE {$jsmfConfig->smf_prefix}members SET " .
"\n `personalText` = '".htmlspecialchars($cbData->cb_personaltext, ENT_QUOTES)."', " .
"\n `gender` = '".(($cbData->cb_gender == 'Male') ? '1' : '2')."', " .
"\n `birthdate` = '".$cbData->cb_birthdate."', " .
"\n `websiteTitle` = '".$websiteTitle."', " .
"\n `websiteUrl` = '".$websiteUrl."', " .
"\n `location` = '".htmlspecialchars($cbData->cb_location, ENT_QUOTES)."', " .
"\n `hideEmail` = '".$hideEmail."', " .
"\n `ICQ` = '".htmlspecialchars($cbData->cb_icq, ENT_QUOTES)."', " .
"\n `AIM` = '".htmlspecialchars($cbData->cb_aim, ENT_QUOTES)."', " .
"\n `YIM` = '".htmlspecialchars($cbData->cb_yim, ENT_QUOTES)."', " .
"\n `MSN` = '".htmlspecialchars($cbData->cb_msn, ENT_QUOTES)."', " .
"\n `signature` = '".htmlspecialchars($cbData->cb_signature, ENT_QUOTES)."', " .
"\n `usertitle` = '".htmlspecialchars($cbData->cb_usertitle, ENT_QUOTES)."' " .
"\n WHERE `ID_MEMBER` = '".$uid."'";
$database->setQuery($query);
if (!$database->query()) {
$jsmf->err = $database->getErrorMsg().' ~~~ FROM::'.__FILE__.' || '.__FUNCTION__.' || '.__LINE__;
return false;
}
}

Rgds, Mike
Logged

-----
Owner of http://mike.simbunch.com
Creator of ParaInvite, AJAX Sandbox, AJAX SMF Polls, Profile URL etc..
asteroidjay
Joomla Newbie
*

Karma: +3/-1
Offline Offline

Posts: 47


View Profile
Re: Change SMF's user information through CB interface
« Reply #8 on: December 02, 2006, 10:30:11 AM »

This works great for me. For RC3, it's necessary to add the
Code:
$_PLUGINS->registerFunction( 'onBeforeUserUpdate', 'updateUser', 'jsmfCB');
as well.

I really hope this hack isn't abandoned in further releases, because it's the only thing that works for me. Sad
Logged

Joomla! 1.0.11
SMF 1.1 RC3
Database Version:  5.0.18-standard-log 
PHP Version:  4.4.2 
Web Server:  Apache/1.3.33 (Unix)
Jordan
Joomla Pro
**

Karma: +3/-31
Offline Offline

Posts: 58



View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #9 on: January 05, 2007, 11:57:04 AM »

wait, where to post that line??

Ok, so wait, does this work on CB 1.0.2, JSMF 2.0 Final, smf_cb_plugin 2.0.1?
Logged

Jordan
Joomla Pro
**

Karma: +3/-31
Offline Offline

Posts: 58



View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #10 on: January 08, 2007, 05:42:49 AM »

Bump  Embarrassed
Logged

Gordon
Joomla Newbie
*

Karma: +0/-0
Offline Offline

Posts: 4


View Profile
Re: Change SMF's user information through CB interface
« Reply #11 on: February 05, 2007, 07:17:46 AM »

@ p9939068

You are a god. Thanks a alot.

Know the smf is 90% perfect for joomla.

On thing is missing.

I´m an old xoopser. And in the xoops newbb boards is the funktion to show all the polls in the normal poll modul.

I have found the ajax modul at your site. But this shows only one poll. I would like to integrate the polls in the poll component of joomla.

Do you know a way to realize this?

Thanks for this perfect mad, that what I searched a long time for.

best regards
Logged
sm8417
Joomla Newbie
*

Karma: +0/-1
Offline Offline

Posts: 9


View Profile
Re: Change SMF's user information through CB interface
« Reply #12 on: February 06, 2007, 02:12:06 PM »

This works like a charm... even with the current release of the bridge. I have one question though. How would one modify it so that it would update upon new user signup?

-sm8417
Logged
fabs
Joomla Newbie
*

Karma: +1/-0
Offline Offline

Posts: 18


View Profile
Re: Change SMF's user information through CB interface
« Reply #13 on: February 14, 2007, 01:40:07 AM »

for some reason the hide email hack does not really accomplish to hide entirely as the email button is still shown in posts on the forum. is it supposed to be like that?
Logged
-Wolverine
Moderator
Joomla Guru
*****

Karma: +375/-34
Offline Offline

Posts: 3393


Lead Developer


View Profile WWW
Re: Change SMF's user information through CB interface
« Reply #14 on: February 14, 2007, 12:56:18 PM »

hide_email only controls the visibility of your email address when viewing a user's profile in SMF.  A separate configuration is used to allow board members to email you, which is more than likely the email button you are seeing.
Logged

Need help?  Check Here First!
Get the JSMF User Guide
SEARCH this forum.
Pages: [1] 2 Go Up Print 
« previous next »
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Joomla Forum | Powered by SMF 1.1 RC1.
© 2001-2005, Lewis Media. All Rights Reserved.
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!

Joomla Hacks is a Joomla Components, Joomla Modules, Joomla Templates, & Joomla Mambots resource portal. None of the text or images in this public website may be copied without the expressed written consent of the authors. Copyright 2005 by JoomlaHacks.com. Powered by Joomla. All rights reserved.
Terms of Use
Joomla Hacks



Joomla Hacks
German Lang French Lang Italian Lang Spanish Lang Japanese Lang Chinese Lang
Search Contact About Advertise Blogs Topsites Submit News Register Login