FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » sync up group members with wow roster [Works with 1.7.x]
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
sync up group members with wow roster [Works with 1.7.x] [message #38629] Sun, 19 August 2007 14:37 Go to next message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
add to buddy list
ignore all messages by this user
Please note that there is a new 2.x release of wow roster and I have not tested this tool with it. Please look into my armory version of the tool as the armory is more popular. I do not intend to update this version of the tool.

I have written the following code that will grab a list of members in our roster and dump it into the members group in fudforum. The options are 378639. Please set the options you want for a user, then look in the database for the number and update the code accordingly. Or, you may calculate the permissions and add 65536 to it (it took me a while to figure this out). Also change id 97 to whatever group with which you want to control guild membership access. This will override any existing member with the new options, excluding anyone with higher access.

Update: added UTF-8 support. Forum account must have been created using the alt+#### method for special characters.

The code:
set_time_limit(600);
define('forum_debug', 1);
unset($_SERVER['REMOTE_ADDR']);

require ( '/home/website/.fudforumdata/scripts/GLOBALS.php' );

if (!($FUD_OPT_1 & 1))
    eexit("Forum is currently disabled.\n");

fud_use('forum_adm.inc', true);
fud_use('groups_adm.inc', true);
fud_use('err.inc');
fud_use('db.inc');
fud_use('post_proc.inc');
fud_use('is_perms.inc');
fud_use('users.inc');
fud_use('groups.inc');
fud_use('users_reg.inc');
fud_use('users_adm.inc', true);
fud_use('scripts_common.inc', true);

define('sql_p', $GLOBALS['DBHOST_TBL_PREFIX']);

list($GLOBALS['usr']->lang, $locale) = db_saq("SELECT lang, locale FROM ".sql_p."themes WHERE theme_opt=1|2 LIMIT 1");

$GLOBALS['good_locale'] = setlocale(LC_ALL, $locale);

list($GLOBALS['usr']->lang, $locale) = db_saq("SELECT lang, locale FROM ".sql_p."themes WHERE theme_opt=1|2 LIMIT 1");

$GLOBALS['good_locale'] = setlocale(LC_ALL, $locale);

require_once( 'settings.php' );

$query = 'SELECT `name` from `roster_members` ORDER BY `name`';
$result = $wowdb->query( $query ) or die_quietly($wowdb->error(),'Database Error',basename(__FILE__),__LINE__,$query);
while ( $row = $wowdb->fetch_assoc( $result ) )
{
   $login = xmlEntities(htmlentities(utf8_decode($row['name'])));
   $id = get_id_by_login($login);
   if ( ! empty ( $id ) ) {
      print ( $login . ' - ' . $id . ': ' );
      $r = q('SELECT id,group_members_opt,group_id FROM fud26_group_members WHERE group_id=97 AND user_id='.$id);
      $e = db_rowarr($r);
      if ( ! empty ( $e ) ) {
          print_r ( $e );
          print ( ' ' );
          if ( $e[1] < 378639 ) {
/*             q('UPDATE fud26_group_members SET group_members_opt=378639 WHERE id='.$id); WHY THE HELL DOESN'T This Update the TABLE!!! */
             grp_delete_member(97, $id);
             q('INSERT INTO fud26_group_members (group_members_opt, user_id, group_id) VALUES (378639, '.$id.', 97)'); /* 313103 + 65536 */
             grp_rebuild_cache(array($id));
             print ( "Updating Member!<br>\n" );
          } else {
             print ( "Skipping Member!<br>\n" );
          }
      } else {
         q('INSERT INTO fud26_group_members (group_members_opt, user_id, group_id) VALUES (378639, '.$id.', 97)'); /* 313103 + 65536 */
         grp_rebuild_cache(array($id));
         print ( "Adding Member!<br>\n" );
      }
   }
}

function xmlEntities($s){
    //build first an assoc. array with the entities we want to match
    $table1 = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);

    //now build another assoc. array with the entities we want to replace (numeric entities)
    foreach ($table1 as $k=>$v){
      $table1[$k] = "/$v/";
      $c = htmlentities($k,ENT_QUOTES,"UTF-8");
      $table2[$c] = "&#".ord($k).";";
    }

    $s = preg_replace($table1,$table2,$s);
    return $s;
}

[Updated on: Thu, 05 February 2009 02:34]

Report message to a moderator

Re: sync up group members with wow roster [Works!] [message #158082 is a reply to message #38629] Wed, 28 January 2009 18:16 Go to previous message
Marticus   United States
Messages: 272
Registered: June 2002
Karma: 1
Senior Member
add to buddy list
ignore all messages by this user
I have no confirmed if this code hack functions under the 2.x wow roster environment. I have, however, written something that will work with the armory version running as of the timestamp on this post.

I would like the subject to include wow roster 1.7.x on my topic. Why it is now moderated, I know not. Someone has been busy.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Anti-Bot Modification for FUDForum
Next Topic: sync up group members with wow roster [Works with armory as of Feb 04, 2009]
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 24 05:47:31 EDT 2017

Total time taken to generate the page: 0.00616 seconds