1 | <?php
|
---|
2 | /*
|
---|
3 | * XPressME - WordPress for XOOPS
|
---|
4 | *
|
---|
5 | * @copyright XPressME Project http://www.toemon.com
|
---|
6 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license
|
---|
7 | * @author toemon
|
---|
8 | * @package module::xpress
|
---|
9 | */
|
---|
10 |
|
---|
11 | function wp_uid_to_xoops_uid($wp_uid = ''){
|
---|
12 | global $xoopsDB;
|
---|
13 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
14 |
|
---|
15 | if ($mydirname == 'wordpress'){
|
---|
16 | $wp_prefix = 'wp';
|
---|
17 | } else {
|
---|
18 | $wp_prefix = $mydirname;
|
---|
19 | }
|
---|
20 |
|
---|
21 | $xoops_user_tbl = $xoopsDB->prefix('users');
|
---|
22 | $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users");
|
---|
23 |
|
---|
24 | $wp_user_SQL ="SELECT user_login FROM $wp_user_tbl WHERE ID = $wp_uid ";
|
---|
25 | $wp_user_Res = $xoopsDB->query($wp_user_SQL, 0, 0);
|
---|
26 | if ($xoopsDB->getRowsNum($wp_user_Res) > 0){
|
---|
27 | $wp_user_Row = $xoopsDB->fetchArray($wp_user_Res);
|
---|
28 | $wp_user_name = $wp_user_Row['user_login'];
|
---|
29 |
|
---|
30 | $xoops_user_SQL ="SELECT uid FROM $xoops_user_tbl WHERE uname LIKE '$wp_user_name'";
|
---|
31 | $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0);
|
---|
32 | if ($xoopsDB->getRowsNum($xoops_user_Res) > 0){
|
---|
33 | $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res);
|
---|
34 | $xoops_uid = $xoops_user_Row['uid'];
|
---|
35 | return $xoops_uid;
|
---|
36 | }
|
---|
37 | }
|
---|
38 | return 0;
|
---|
39 | }
|
---|
40 | function xoops_uid_to_wp_uid($xoops_uid = ''){
|
---|
41 | global $xoopsDB;
|
---|
42 | $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
43 |
|
---|
44 | if ($mydirname == 'wordpress'){
|
---|
45 | $wp_prefix = 'wp';
|
---|
46 | } else {
|
---|
47 | $wp_prefix = $mydirname;
|
---|
48 | }
|
---|
49 |
|
---|
50 | $xoops_user_tbl = $xoopsDB->prefix('users');
|
---|
51 | $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users");
|
---|
52 |
|
---|
53 | $xoops_user_SQL ="SELECT uname FROM $xoops_user_tbl WHERE uid = $xoops_uid";
|
---|
54 | $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0);
|
---|
55 | if ($xoopsDB->getRowsNum($xoops_user_Res) > 0){
|
---|
56 | $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res);
|
---|
57 | $xoops_user_name = $xoops_user_Row['uname'];
|
---|
58 |
|
---|
59 | $wp_user_SQL ="SELECT ID FROM $wp_user_tbl WHERE user_login LIKE '$xoops_user_name'";
|
---|
60 | $wp_user_Res = $xoopsDB->query($wp_user_SQL, 0, 0);
|
---|
61 | if ($xoopsDB->getRowsNum($wp_user_Res) > 0){
|
---|
62 | $wp_user_Row = $xoopsDB->fetchArray($wp_user_Res);
|
---|
63 | $wp_user_id = $wp_user_Row['ID'];
|
---|
64 | return $wp_user_id;
|
---|
65 | }
|
---|
66 | }
|
---|
67 | return 0;
|
---|
68 | }
|
---|
69 | ?>
|
---|