Advertisement:

Author Topic: Mambo bridge (both versions) - adding/changing users issues  (Read 4278 times)

Offline jelv

  • Semi-Newbie
  • *
  • Posts: 50
  • Gender: Male
Mambo bridge (both versions) - adding/changing users issues
« on: October 30, 2009, 04:08:39 PM »
The addition of SMF users to Mambo does not set up the Mambo usertype correctly.

Changing the user's SMF Primary Membergroup does not update the Mambo usertype.

See http://www.simplemachines.org/community/index.php?topic=344306.0 which includes a suggested fix.

Edit: Updated description
« Last Edit: April 20, 2010, 03:56:20 AM by Norv »
jelv

Offline jelv

  • Semi-Newbie
  • *
  • Posts: 50
  • Gender: Male
Re: Mambo bridge (both versions) - adding users issue
« Reply #1 on: November 01, 2009, 12:50:55 PM »
Further testing has revealed more places where `usertype` isn't populated - I'm working through fixes for these and will post back soon.
jelv

Offline jelv

  • Semi-Newbie
  • *
  • Posts: 50
  • Gender: Male
Re: Mambo bridge (both versions) - adding/changing users issues
« Reply #2 on: November 01, 2009, 01:47:14 PM »
Proposed fix:

All changes are in the Mambo SMF bridge module components\com_smf\smf.php

function integrate_change_member_data (changing users SMF Primary Membergroup)

      foreach ($memberNames as $memberName){

         $mos_sync_groups = mysql_query("
               SELECT `name`
               FROM " . $configuration->get('mosConfig_dbprefix') . "core_acl_aro_groups
               WHERE `group_id` = " . $group
               );
         list ($group_name) = mysql_fetch_row($mos_sync_groups);

         mysql_query ("UPDATE " . $configuration->get('mosConfig_dbprefix') . "users
                  SET `gid` = '$group', `usertype` = '$group_name'
                  WHERE username = '$memberName'
                  ");


function integrate_login (adding an existing SMF user to Mambo)

      //Just in case....
      if (!isset($group) || $group == '' || $group == 0 )
         $group = '18';
   
      $mos_sync_groups = mysql_query("
            SELECT `name`
            FROM " . $configuration->get('mosConfig_dbprefix') . "core_acl_aro_groups
            WHERE `group_id` = " . $group
            );
      list ($group_name) = mysql_fetch_row($mos_sync_groups);

      $mos_write = mysql_query("
         INSERT INTO " . $configuration->get('mosConfig_dbprefix') . "users
            (name,username,email,password,gid,usertype)
         VALUES ('$username', '$username', '$user_settings[emailAddress]', '$passwd', '$group', '$group_name')");


function integrate_register (registering a new user through SMF to also be added to Mambo)

//Just in case....
   if (!isset($group) || $group == '' || $group == 0 )
      $group = '18';
      
   $mos_sync_groups = mysql_query("
         SELECT `name`
         FROM " . $configuration->get('mosConfig_dbprefix') . "core_acl_aro_groups
         WHERE `group_id` = " . $group
         );
   list ($group_name) = mysql_fetch_row($mos_sync_groups);


   //registration will be considered now
   $r_date = date("Y-m-d H:i:s");
      
   //What if the realName field isn't being used?
   if (!isset($Options['register_vars']['realName']) || $Options['register_vars']['realName']=='')
      $Options['register_vars']['realName'] = $Options['register_vars']['memberName'];
            
   mysql_query("
      INSERT INTO " . $configuration->get('mosConfig_dbprefix') . "users
         (name, username, email, password, registerDate, gid, usertype)
      VALUES (" . $Options['register_vars']['realName'] . ", " . $Options['register_vars']['memberName'] . ", " . $Options['register_vars']['emailAddress'] . ", '" . md5($Options['password']) . "', '$r_date', '$group', '$group_name')");
jelv