Discuz!官方免费开源建站系统

 找回密码
 立即注册
搜索

[已解决] 请问 x 1.5 里怎么合并用户?

[复制链接]
superrise 发表于 2010-11-22 23:00:57 | 显示全部楼层 |阅读模式
本帖最后由 superrise 于 2010-11-23 20:08 编辑

就象合并版块一样,合并用户,帖子、相册等等。。后台里面没找到。。请官方给个方法。谢谢

————————————————————————————————————————————————

自己搞定了,原来在function_member.php 里面有一个 membermerge 函数,但是从来没有调用过,我在这个基础做了一些修改。


  • function getuidfields() {
  •         return array(
  •                 'forum_access',
  •                 'forum_activity',
  •                 'forum_activityapply',
  •                 'forum_attachment',
  •                 'forum_attachmentfield',
  •                 'forum_creditslog',
  •                 'forum_debate',
  •                 'forum_debatepost',
  •                 'home_favorite',
  •                 'forum_medallog',
  •                 'common_member_magic',
  •                 'forum_memberrecommend|recommenduid',
  •                 'forum_moderator',
  •                 'forum_modwork',
  •                 'common_mytask',
  •                 'forum_order',
  •                 'forum_groupinvite',
  •                 'forum_groupuser',
  •                 'forum_pollvoter',
  •                 'forum_post|authorid',
  •                 'forum_thread|authorid',
  •                 'forum_threadmod',
  •                 'forum_tradecomment|raterid,rateeid',
  •                 'forum_tradelog|sellerid,buyerid',
  •                 'home_album',
  •                 'home_appcreditlog',
  •                 'home_blacklist|uid,buid',
  •                 'home_blog',
  •                 'home_blogfield',
  •                 'home_class',
  •                 'home_clickuser',
  •                 'home_comment|uid,authorid',
  •                 'home_docomment',
  •                 'home_doing',
  •                 'home_feed',
  •                 'home_feed_app',
  •                 'home_pic',
  •                 'home_share',
  •                 'home_userapp',
  •                 'home_userappfield',
  •                 'common_admincp_member'
  •         );
  • }
  • function membermerge($olduid, $newuid) {
  •         $uidfields = getuidfields();
  •         foreach($uidfields as $value) {
  •                 list($table, $field, $stepfield) = explode('|', $value);
  •                 $fields = !$field ? array('uid') : explode(',', $field);
  •                 foreach($fields as $field) {
  •                         DB::query("UPDATE `".DB::table($table)."` SET `$field`='$newuid' WHERE `$field`='$olduid'");
  •                 }
  •         }
  •         $oldname = DB::result(DB::query("SELECT username FROM ".DB::table('common_member')." where uid = $olduid"), '');
  •         $newname = DB::result(DB::query("SELECT username FROM ".DB::table('common_member')." where uid = $newuid"), '');
  •         DB::query("UPDATE `".DB::table("forum_post")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  •         DB::query("UPDATE `".DB::table("forum_thread")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  •         DB::query("UPDATE `".DB::table("home_comment")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  • }

复制代码

然后调用 membermerge函数,比如:
membermerge(36108,3); //uid: 36108 -> uid: 3

除了个人资料、统计以外,其他都可以合并过去。
回复

使用道具 举报

紫晨 发表于 2010-11-22 23:04:36 | 显示全部楼层
回复

使用道具 举报

baxter 发表于 2010-11-22 23:05:03 | 显示全部楼层
回复 superrise 的帖子

没有该功能的。。
回复

使用道具 举报

 楼主| superrise 发表于 2010-11-23 07:55:57 | 显示全部楼层
有没有能手动合并用户的插件?
回复

使用道具 举报

 楼主| superrise 发表于 2010-11-23 20:06:45 | 显示全部楼层
自己搞定了,原来在function_member.php 里面有一个 membermerge 函数,但是从来没有调用过,我在这个基础做了一些修改。


  1.                                
  2. function getuidfields() {
  3.         return array(
  4.        
  5.                 'forum_access',
  6.                 'forum_activity',
  7.                 'forum_activityapply',
  8.                 'forum_attachment',
  9.                 'forum_attachmentfield',
  10.                 'forum_creditslog',
  11.                 'forum_debate',
  12.                 'forum_debatepost',
  13.                 'home_favorite',
  14.                 'forum_medallog',
  15.                 'common_member_magic',
  16.                 'forum_memberrecommend|recommenduid',
  17.                 'forum_moderator',
  18.                 'forum_modwork',
  19.                 'common_mytask',
  20.                 'forum_order',
  21.                 'forum_groupinvite',
  22.                 'forum_groupuser',
  23.                 'forum_pollvoter',
  24.                 'forum_post|authorid',
  25.                 'forum_thread|authorid',
  26.                 'forum_threadmod',
  27.                 'forum_tradecomment|raterid,rateeid',
  28.                 'forum_tradelog|sellerid,buyerid',
  29.                 'home_album',
  30.                 'home_appcreditlog',
  31.                 'home_blacklist|uid,buid',
  32.                 'home_blog',
  33.                 'home_blogfield',
  34.                 'home_class',
  35.                 'home_clickuser',
  36.                 'home_comment|uid,authorid',
  37.                 'home_docomment',
  38.                 'home_doing',
  39.                 'home_feed',
  40.                 'home_feed_app',
  41.                 'home_pic',
  42.                 'home_share',
  43.                 'home_userapp',
  44.                 'home_userappfield',
  45.                 'common_admincp_member'
  46.         );
  47. }

  48. function membermerge($olduid, $newuid) {

  49.        
  50.         $uidfields = getuidfields();
  51.         foreach($uidfields as $value) {
  52.                 list($table, $field, $stepfield) = explode('|', $value);
  53.                 $fields = !$field ? array('uid') : explode(',', $field);
  54.                 foreach($fields as $field) {
  55.                         DB::query("UPDATE `".DB::table($table)."` SET `$field`='$newuid' WHERE `$field`='$olduid'");
  56.                 }
  57.         }
  58.        

  59.         $oldname = DB::result(DB::query("SELECT username FROM ".DB::table('common_member')." where uid = $olduid"), '');
  60.         $newname = DB::result(DB::query("SELECT username FROM ".DB::table('common_member')." where uid = $newuid"), '');
  61.        
  62.         DB::query("UPDATE `".DB::table("forum_post")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  63.         DB::query("UPDATE `".DB::table("forum_thread")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  64.         DB::query("UPDATE `".DB::table("home_comment")."` SET `author`='$newname' WHERE `author`= '$oldname'");
  65.                        
  66.                                
  67. }
复制代码
然后调用 membermerge函数,比如:
membermerge(36108,3); //uid: 36108 -> uid: 3

除了个人资料、统计以外,其他都可以合并过去。
回复

使用道具 举报

信宁军 发表于 2010-11-23 20:14:52 | 显示全部楼层
学习一下
回复

使用道具 举报

番禺人网 发表于 2010-11-23 20:49:25 | 显示全部楼层
帮忙顶贴。也是来学习。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2025-8-27 11:03 , Processed in 0.090213 second(s), 14 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表