Changeset 590 for trunk/xpressme_integration_kit/wp-content/plugins
- Timestamp:
- Apr 28, 2010, 4:20:08 PM (15 years ago)
- Location:
- trunk/xpressme_integration_kit/wp-content/plugins/xpressme
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/d3forum_comment_synchro.php
r264 r590 115 115 116 116 function get_d3forum_post_ID($wp_comment_ID){ 117 global $xoops_db; 117 global $xoops_db,$blog_id; 118 119 if (empty($blog_id)) $blog_id =1; 118 120 119 121 $wp_d3forum_link = get_wp_prefix() . 'd3forum_link'; 120 122 121 $sql = "SELECT post_id FROM $wp_d3forum_link WHERE comment_ID = $wp_comment_ID ";123 $sql = "SELECT post_id FROM $wp_d3forum_link WHERE comment_ID = $wp_comment_ID AND blog_id = $blog_id"; 122 124 $post_id = $xoops_db->get_var($sql); 123 125 return $post_id; … … 125 127 126 128 function get_wp_comment_ID($d3forum_post_ID){ 127 global $xoops_db; 129 global $xoops_db,$blog_id; 130 131 if (empty($blog_id)) $blog_id =1; 128 132 129 133 $wp_d3forum_link = get_wp_prefix() . 'd3forum_link'; 130 134 131 $sql = "SELECT comment_ID FROM $wp_d3forum_link WHERE post_id = $d3forum_post_ID ";135 $sql = "SELECT comment_ID FROM $wp_d3forum_link WHERE post_id = $d3forum_post_ID AND blog_id = $blog_id"; 132 136 $comment_ID = $xoops_db->get_var($sql); 133 137 return $comment_ID; … … 167 171 global $xpress_config,$xoops_db; 168 172 173 $d3f_forum_id = $xpress_config->d3forum_forum_id; 174 169 175 if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 170 176 $d3f_forum_dir = $xpress_config->d3forum_module_dir; … … 174 180 $sql = "UPDATE $d3f_topic "; 175 181 $sql .= "SET topic_locked = $lock "; 176 $sql .= "WHERE topic_external_link_id = $wp_post_id " ;182 $sql .= "WHERE topic_external_link_id = $wp_post_id AND forum_id = $d3f_forum_id" ; 177 183 $xoops_db->query($sql); 178 184 } … … 180 186 // All comments of WordPress are exported to the D3Forum comment. 181 187 function wp_to_d3forum($forum_id = 1, $d3f_prefix = 'd3forum'){ 182 global $xpress_config,$xoops_db ;188 global $xpress_config,$xoops_db,$wpdb; 183 189 184 190 if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); … … 187 193 $xpress_prefix = get_wp_prefix(); 188 194 189 $wp_comments = $ xpress_prefix . 'comments';195 $wp_comments = $wpdb->comments; 190 196 $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 191 $wp_posts = $ xpress_prefix . 'posts';197 $wp_posts = $wpdb->posts; 192 198 $d3f_topic = $d3forum_prefix . 'topics'; // delete key forum_id 193 199 $d3f_forums = $d3forum_prefix . 'forums'; // delete key forum_id … … 239 245 240 246 $comment_count = 0; 241 $comments = $ xoops_db->get_results($sql);247 $comments = $wpdb->get_results($sql); 242 248 foreach($comments as $comment){ 243 249 $comment_ID = $comment->comment_ID; … … 254 260 // All comments of D3Forum are import to the WordPress comment. 255 261 function d3forum_to_wp($forum_id = 1, $d3f_prefix = 'd3forum'){ 256 global $xpress_config,$xoops_db ;262 global $xpress_config,$xoops_db,$wpdb; 257 263 if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 258 264 … … 260 266 $xpress_prefix = get_wp_prefix() ; 261 267 262 $wp_comments = $ xpress_prefix . 'comments';268 $wp_comments = $wpdb->comments; 263 269 $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 264 270 $wp_dummy = $xpress_prefix . 'dummy'; 265 $wp_d3forum_link = $xpress_prefix . 'd3forum_link';266 271 267 272 $d3f_topic = $d3forum_prefix . 'topics'; … … 287 292 288 293 //All wp post comment count clear 289 $wp_posts = $ xpress_prefix . 'posts';294 $wp_posts = $wpdb->posts; 290 295 $xoops_db->query("UPDATE $wp_posts SET comment_count = 0 WHERE 1 "); 291 296 … … 327 332 $d3forum_dirname = $xpress_config->d3forum_module_dir; 328 333 $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 334 $d3forum_forum_id = $xpress_config->d3forum_forum_id; 329 335 330 336 $post_id = intval( $post_id ) ; … … 332 338 $d3f_topics = $d3forum_prefix . 'topics'; 333 339 334 $sql = "SELECT topic_id,topic_first_post_id FROM $d3f_topics WHERE topic_external_link_id = $post_id ";340 $sql = "SELECT topic_id,topic_first_post_id FROM $d3f_topics WHERE topic_external_link_id = $post_id AND forum_id = $d3forum_forum_id"; 335 341 $row = $xoops_db->get_row($sql) ; 336 342 … … 346 352 347 353 function d3forum_sync_to_wp_comment( $mode , $link_id , $forum_id , $topic_id , $post_id = 0 ){ 348 global $xpress_config,$xoops_db ;354 global $xpress_config,$xoops_db,$wpdb,$blog_id; 349 355 350 356 if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 357 358 if (empty($blog_id)) $blog_id =1; 359 $d3f_forum_id = $xpress_config->d3forum_forum_id; 360 351 361 $d3forum_prefix = get_xoops_prefix() . $xpress_config->d3forum_module_dir . '_'; 352 362 $xpress_prefix = get_wp_prefix(); 353 363 354 $wp_comments = $ xpress_prefix . 'comments';355 $wp_posts = $ xpress_prefix . 'posts';364 $wp_comments = $wpdb->comments; 365 $wp_posts = $wpdb->posts; 356 366 $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 357 367 … … 424 434 $xoops_db->query($wp_sql); 425 435 $wp_sql = "INSERT INTO $wp_d3forum_link "; 426 $wp_sql .= "(comment_ID , post_id ) ";436 $wp_sql .= "(comment_ID , post_id, wp_post_ID, forum_id, blog_id) "; 427 437 $wp_sql .= "VALUES "; 428 $wp_sql .= "($comment_ID, $post_id )";438 $wp_sql .= "($comment_ID, $post_id, $link_id, $d3f_forum_id, $blog_id)"; 429 439 $xoops_db->query($wp_sql); 430 440 if ($comment_approved ==0) do_CommentWaiting($comment_ID, $post_id); … … 458 468 // The content is reflected in the D3Forum comment when there is a change in the WordPress comment. 459 469 function wp_comment_sync_to_d3forum($comment_ID = 0,$sync_mode){ 460 global $xpress_config,$xoops_db,$xoops_config; 470 global $xpress_config,$xoops_db,$xoops_config,$wpdb,$blog_id; 471 472 if (empty($blog_id)) $blog_id =1; 461 473 462 474 if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); … … 468 480 $d3forum_prefix = get_xoops_prefix() . $d3f_forum_dir . '_'; 469 481 $xpress_prefix = get_wp_prefix(); 470 $wp_comments = $xpress_prefix . 'comments'; 471 $wp_posts = $xpress_prefix . 'posts'; 482 $wp_comments = $wpdb->comments; 483 // $wp_comments = $xpress_prefix . 'comments'; 484 $wp_posts = $wpdb->posts; 485 // $wp_posts = $xpress_prefix . 'posts'; 472 486 $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 473 487 $d3f_topic = $d3forum_prefix . 'topics'; … … 484 498 $sql .= "WHERE (comment_ID = $comment_ID) AND ($wp_comments.comment_approved NOT LIKE 'spam') "; 485 499 486 $row = $xoops_db->get_row($sql) ; 500 // $row = $xoops_db->get_row($sql) ; 501 $row = $wpdb->get_row($sql) ; 487 502 if(empty($row)) die( 'READ ' . $wp_comments . '_NG...' .$sql); 488 503 if (! empty($row->comment_type)) return; … … 513 528 if ($sync_mode == 'delete'){ 514 529 $mode = 'delete'; 515 $delete_post_id = $xoops_db->get_var("SELECT post_id FROM $wp_d3forum_link WHERE comment_ID = $comment_ID ");530 $delete_post_id = $xoops_db->get_var("SELECT post_id FROM $wp_d3forum_link WHERE comment_ID = $comment_ID AND blog_id = $blog_id"); 516 531 if (empty($delete_post_id)) return; 517 532 $topic_id = $xoops_db->get_var("SELECT topic_id FROM $d3f_topic WHERE topic_external_link_id = $topic_external_link_id AND forum_id = $forum_id"); … … 528 543 529 544 // if comment on same ID exists then edits comment else reply comment 530 $row = $xoops_db->get_row("SELECT * FROM $wp_d3forum_link WHERE comment_ID = $comment_ID ") ;545 $row = $xoops_db->get_row("SELECT * FROM $wp_d3forum_link WHERE comment_ID = $comment_ID AND blog_id = $blog_id" ) ; 531 546 532 547 if (!empty($row)){ … … 629 644 630 645 $wp_sql = "INSERT INTO $wp_d3forum_link "; 631 $wp_sql .= "(comment_ID , post_id ) ";646 $wp_sql .= "(comment_ID , post_id, wp_post_ID, forum_id, blog_id) "; 632 647 $wp_sql .= "VALUES "; 633 $wp_sql .= "($comment_ID, $post_id )";648 $wp_sql .= "($comment_ID, $post_id, $topic_external_link_id, $d3f_forum_id, $blog_id)"; 634 649 $xoops_db->query($wp_sql); 635 650 … … 666 681 667 682 $wp_sql = "INSERT INTO $wp_d3forum_link "; 668 $wp_sql .= "(comment_ID , post_id , wp_post_ID ) ";683 $wp_sql .= "(comment_ID , post_id , wp_post_ID, forum_id, blog_id) "; 669 684 $wp_sql .= "VALUES "; 670 $wp_sql .= "($comment_ID, $post_id, $topic_external_link_id )";685 $wp_sql .= "($comment_ID, $post_id, $topic_external_link_id, $d3f_forum_id, $blog_id)"; 671 686 $xoops_db->query($wp_sql); 672 687 … … 701 716 function wp_d3forum_delete_post_recursive( $d3forum_dirname , $post_id ,$isChild = false) 702 717 { 718 global $wpdb,$blog_id; 719 global $xpress_config,$xoops_db; 703 720 $post_id = intval( $post_id ) ; // post_id is d3forum post(comments) id. 704 global $xpress_config,$xoops_db; 721 if (empty($blog_id)) $blog_id =1; 722 723 705 724 $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 706 725 $xpress_prefix = get_wp_prefix(); … … 718 737 $xoops_db->query( "DELETE FROM ".$d3forum_prefix."post_votes WHERE post_id=$post_id" ) ; 719 738 720 $wp_comments = $ xpress_prefix . 'comments';721 $wp_posts = $ xpress_prefix . 'posts';739 $wp_comments = $wpdb->comments; 740 $wp_posts = $wpdb->posts; 722 741 $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 723 742 724 743 $comment_ID = get_wp_comment_ID($post_id); // get wordpress comment ID 725 744 if ($comment_ID > 0){ 726 $comment_post_ID = $ xoops_db->get_var("SELECT comment_post_ID FROM $wp_comments WHERE comment_ID = $comment_ID");745 $comment_post_ID = $wpdb->get_var("SELECT comment_post_ID FROM $wp_comments WHERE comment_ID = $comment_ID"); 727 746 if ($isChild){ //The first comment is deleted on the WordPress side. 728 $ xoops_db->query("DELETE FROM $wp_comments WHERE comment_ID = $comment_ID");747 $wpdb->query("DELETE FROM $wp_comments WHERE comment_ID = $comment_ID"); 729 748 if (!empty($comment_post_ID)){ 730 $ xoops_db->query("UPDATE $wp_posts SET comment_count = comment_count -1 WHERE ID = $comment_post_ID");749 $wpdb->query("UPDATE $wp_posts SET comment_count = comment_count -1 WHERE ID = $comment_post_ID"); 731 750 } 732 751 } 733 $xoops_db->query("DELETE FROM $wp_d3forum_link WHERE post_id = $post_id ");752 $xoops_db->query("DELETE FROM $wp_d3forum_link WHERE post_id = $post_id AND blog_id = $blog_id"); 734 753 } 735 754 } … … 741 760 global $xpress_config,$xoops_db; 742 761 $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 743 $xpress_prefix = get_wp_prefix();744 762 745 763 $topic_id = intval( $topic_id ) ; -
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php
r578 r590 644 644 global $xoops_db,$xoops_config; 645 645 646 $multi_blog_use_d3forum = true; 647 646 648 $d3frum_list = array(); 647 649 $module_dir_path = get_xoops_root_path(); … … 654 656 $selected = ''; 655 657 656 if (xpress_is_multiblog() ) {658 if (xpress_is_multiblog() && $multi_blog_use_d3forum) { 657 659 $forum_list .= '<option value="none"' . $selected . '>' . __('WordPress MultiBlog cannot integrate the comments.', 'xpressme') . "</option>\n"; 658 660 } else {
Note: See TracChangeset
for help on using the changeset viewer.