- Timestamp:
- Jun 8, 2009, 11:46:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Ver2.0/xpressme_integration_kit/include/general_functions.php
r257 r261 8 8 * @package module::xpress 9 9 */ 10 if (!function_exists('wp_uid_to_xoops_uid')){ 11 function wp_uid_to_xoops_uid($wp_uid = '',$mydirname){ 12 global $xoopsDB,$xoops_db; 13 if (empty($mydirname)) 14 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 10 15 11 function wp_uid_to_xoops_uid($wp_uid = ''){ 12 global $xoopsDB; 13 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 16 if ($mydirname == 'wordpress'){ 17 $wp_prefix = 'wp'; 18 } else { 19 $wp_prefix = $mydirname; 20 } 14 21 15 if ($mydirname == 'wordpress'){ 16 $wp_prefix = 'wp'; 17 } else { 18 $wp_prefix = $mydirname; 19 } 22 if (empty($xoops_db)) { // not load XPressME 23 $xoops_user_tbl = $xoopsDB->prefix('users'); 24 $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users"); 20 25 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; 26 $wp_user_SQL ="SELECT user_login FROM $wp_user_tbl WHERE ID = $wp_uid "; 27 $wp_user_Res = $xoopsDB->query($wp_user_SQL, 0, 0); 28 if ($xoopsDB->getRowsNum($wp_user_Res) > 0){ 29 $wp_user_Row = $xoopsDB->fetchArray($wp_user_Res); 30 $wp_user_name = $wp_user_Row['user_login']; 31 32 $xoops_user_SQL ="SELECT uid FROM $xoops_user_tbl WHERE uname LIKE '$wp_user_name'"; 33 $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0); 34 if ($xoopsDB->getRowsNum($xoops_user_Res) > 0){ 35 $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res); 36 $xoops_uid = $xoops_user_Row['uid']; 37 return $xoops_uid; 38 } 39 } 40 return 0; 41 } else { // load XPressME or not Load XOOPS 42 $xoops_user_tbl = get_xoops_prefix() . 'users'; 43 $wp_user_tbl = get_wp_prefix() . 'users'; 44 $wp_user_name = $xoops_db->get_var("SELECT user_login FROM $wp_user_tbl WHERE ID = $wp_uid "); 45 if (empty($wp_user_name)) return 0; 46 $xoops_uid = $xoops_db->get_var("SELECT uid FROM $xoops_user_tbl WHERE uname LIKE '$wp_user_name'"); 47 if (!empty($xoops_uid)) return $xoops_uid; else return 0; 36 48 } 37 49 } 38 return 0;39 50 } 40 function xoops_uid_to_wp_uid($xoops_uid = ''){41 global $xoopsDB;42 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;43 51 44 if ($mydirname == 'wordpress'){ 45 $wp_prefix = 'wp'; 46 } else { 47 $wp_prefix = $mydirname; 52 if (!function_exists('xoops_uid_to_wp_uid')){ 53 function xoops_uid_to_wp_uid($xoops_uid = '',$mydirname){ 54 global $xoopsDB,$xoops_db; 55 if (empty($mydirname)) 56 $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ; 57 58 if ($mydirname == 'wordpress'){ 59 $wp_prefix = 'wp'; 60 } else { 61 $wp_prefix = $mydirname; 62 } 63 64 if (empty($xoops_db)) { // not load XPressME 65 $xoops_user_tbl = $xoopsDB->prefix('users'); 66 $wp_user_tbl = $xoopsDB->prefix($wp_prefix . "_users"); 67 68 $xoops_user_SQL ="SELECT uname FROM $xoops_user_tbl WHERE uid = $xoops_uid"; 69 $xoops_user_Res = $xoopsDB->query($xoops_user_SQL, 0, 0); 70 if ($xoopsDB->getRowsNum($xoops_user_Res) > 0){ 71 $xoops_user_Row = $xoopsDB->fetchArray($xoops_user_Res); 72 $xoops_user_name = $xoops_user_Row['uname']; 73 74 $wp_user_SQL ="SELECT ID FROM $wp_user_tbl WHERE user_login LIKE '$xoops_user_name'"; 75 $wp_user_Res = $xoopsDB->query($wp_user_SQL, 0, 0); 76 if ($xoopsDB->getRowsNum($wp_user_Res) > 0){ 77 $wp_user_Row = $xoopsDB->fetchArray($wp_user_Res); 78 $wp_user_id = $wp_user_Row['ID']; 79 return $wp_user_id; 80 } 81 } 82 return 0; 83 } else { // load XPressME or not Load XOOPS 84 $xoops_user_tbl = get_xoops_prefix() . 'users'; 85 $wp_user_tbl = get_wp_prefix() . 'users'; 86 $xoops_user_name = $xoops_db->get_var("SELECT uname FROM $xoops_user_tbl WHERE uid = $xoops_uid"); 87 if (empty($xoops_user_name)) return 0; 88 $wp_user_id = $xoops_db->get_var("SELECT ID FROM $wp_user_tbl WHERE user_login LIKE '$xoops_user_name'"); 89 if (!empty($wp_user_id)) return $wp_user_id; else return 0; 90 } 48 91 } 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 92 } 69 93 ?>
Note: See TracChangeset
for help on using the changeset viewer.