XPressME Integration Kit

Trac

Changeset 590


Ignore:
Timestamp:
Apr 28, 2010, 4:20:08 PM (14 years ago)
Author:
toemon
Message:

D3Forumコメント統合のマルチブログ対応 Fixes#311

Location:
trunk/xpressme_integration_kit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/class/xpressD3commentContent.class.php

    r583 r590  
    99                { 
    1010                //      include_once dirname(dirname(__FILE__)).'/include/common_functions.php' ; 
    11  
     11                        global $forum_id; 
     12                         
    1213                        $db =& Database::getInstance() ; 
    1314                        $myts =& MyTextsanitizer::getInstance() ; 
     
    2324                         
    2425                        $xpress_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    25  
     26                        $blog_info = $this->get_comment_blog_info($forum_id); 
    2627                        // query 
    27                         $post_row = $db->fetchArray( $db->query( "SELECT * FROM ".$db->prefix($xpress_prefix."_posts")." WHERE ID=$post_id AND comment_status ='open'" ) ) ; 
     28                        $post_row = $db->fetchArray( $db->query( "SELECT * FROM ".$blog_info['mb_table_prefix']."posts WHERE ID=$post_id AND comment_status ='open'" ) ) ; 
    2829                        if( empty( $post_row ) ) return '' ; 
    2930 
    3031                        // dare to convert it irregularly 
    3132                        $summary = str_replace( '&' , '&' , htmlspecialchars( xoops_substr( strip_tags( $post_row['post_content'] ) , 0 , 255 ) , ENT_QUOTES ) ) ; 
    32  
     33                        $uri = preg_replace('/\/$/','',$blog_info['home']); 
     34                        $uri .= '/?p='.$post_row['ID']; 
    3335                        return array( 
    34                                 'dirname' => $mydirname , 
    35                                 'module_name' => $module->getVar( 'name' ) , 
     36                                'dirname' => $mydirname. $blog_info['sub_dir'] , 
     37                                'module_name' => $blog_info['blogname'] , 
    3638                                'subject' => $post_row['post_title'] , 
    37                                 'uri' => XOOPS_URL.'/modules/'.$mydirname.'/?p='.$post_row['ID'] , 
     39                                'uri' => $uri , 
    3840                                'summary' => $summary , 
    3941                        ) ; 
     
    6163                function canAddComment($external_link_id) 
    6264                { 
     65                        global $forum_id; 
     66                        global $post; 
     67                         
     68                        if (is_object($post)){  // in wordpress  
     69                                if ($post->ID == $external_link_id){ 
     70                                        if($post->comment_status == 'open'){ 
     71                                                return true; 
     72                                        } else { 
     73                                                return false; 
     74                                        } 
     75                                } 
     76                        } 
    6377                                        $db =& Database::getInstance() ; 
    6478                                        $myts =& MyTextsanitizer::getInstance() ; 
     
    7387                                        if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ; 
    7488                                         
     89                                        $blog_info = $this->get_comment_blog_info($forum_id); 
    7590                                        $xpress_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    7691 
    7792                                        // query 
    78                                         $sql = "SELECT * FROM ".$db->prefix($xpress_prefix."_posts")." WHERE ID=$post_id"; 
     93                                        $sql = "SELECT * FROM ".$blog_info['mb_table_prefix']."posts WHERE ID=$post_id"; 
    7994                                        $post_row = $db->fetchArray( $db->query( $sql ) ) ; 
    8095                                        if( empty( $post_row ) ) return false ; 
     
    156171                function validate_id( $link_id ) 
    157172                { 
     173                        global $forum_id; 
    158174                        $post_id = intval( $link_id ) ; 
    159175                        $mydirname = $this->mydirname ; 
    160176                        $xpress_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    161                          
     177                        $blog_info = $this->get_comment_blog_info($forum_id);            
    162178                        $db =& Database::getInstance() ; 
    163179                         
    164                         list( $count ) = $db->fetchRow( $db->query( "SELECT COUNT(*) FROM ".$db->prefix($xpress_prefix."_posts")." WHERE ID=$post_id AND comment_status ='open'" ) ) ; 
     180                        list( $count ) = $db->fetchRow( $db->query( "SELECT COUNT(*) FROM ".$blog_info['mb_table_prefix'] ."posts WHERE ID=$post_id AND comment_status ='open'" ) ) ; 
    165181 
    166182                        if( $count <= 0 ) return false ; 
     
    185201                function processCommentNotifications( $mode , $link_id , $forum_id , $topic_id , $post_id ) 
    186202                { 
     203                        $blog_info = $this->get_comment_blog_info($forum_id); 
     204                        $wp_full_prefix = $blog_info['mb_table_prefix']; 
     205 
    187206                        $db =& Database::getInstance() ; 
    188207                        $myts =& MyTextsanitizer::getInstance() ; 
     
    198217                        $xpress_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    199218                         
    200                         $table_term_relationships = $db->prefix($xpress_prefix."_term_relationships"); 
    201                         $table_term_taxonomy = $db->prefix($xpress_prefix."_term_taxonomy"); 
    202                         $table_terms = $db->prefix($xpress_prefix."_terms"); 
     219                        $table_term_relationships = $wp_full_prefix ."term_relationships"; 
     220                        $table_term_taxonomy = $wp_full_prefix."term_taxonomy"; 
     221                        $table_terms = $wp_full_prefix."terms"; 
    203222                        $table_categories = $db->prefix($xpress_prefix."_categories"); 
    204223                        $table_post2cat = $db->prefix($xpress_prefix."_post2cat"); 
    205                         $wp_post = $db->prefix($xpress_prefix."_posts"); 
    206                         $wp_options = $db->prefix($xpress_prefix."_options"); 
     224                        $wp_post = $wp_full_prefix."posts"; 
     225                        $wp_options = $wp_full_prefix."options"; 
    207226                        $wp_users  = $db->prefix($xpress_prefix."_users"); 
    208227                                                 
     
    268287                function sync_to_wp_comment( $mode , $link_id , $forum_id , $topic_id , $post_id = 0 ){ 
    269288 
     289                        $blog_info = $this->get_comment_blog_info($forum_id); 
     290                        $wp_full_prefix = $blog_info['mb_table_prefix']; 
     291                        $blog_id = $blog_info['blog_id']; 
     292                        $target_db_prefix = $blog_info['mb_table_prefix']; 
    270293                        $mydirname = $this->mydirname ; 
    271294                        $xpress_prefix = preg_replace('/wordpress/','wp',$mydirname); 
     
    276299                        $xoopsDB =& Database::getInstance(); 
    277300 
    278                         $wp_comments = $xoopsDB->prefix($xpress_prefix . '_comments'); 
    279                         $wp_posts = $xoopsDB->prefix($xpress_prefix . '_posts'); 
     301                        $wp_comments = $wp_full_prefix . 'comments'; 
     302                        $wp_posts = $wp_full_prefix . 'posts'; 
    280303                        $wp_d3forum_link = $xoopsDB->prefix($xpress_prefix . '_d3forum_link'); 
    281304                        $d3f_posts = $xoopsDB->prefix($d3f_prefix . '_posts'); 
     
    355378                                                 
    356379                                                        $wp_sql  = "INSERT INTO $wp_d3forum_link "; 
    357                                                         $wp_sql .=    "(comment_ID , post_id) "; 
     380                                                        $wp_sql .=    "(comment_ID , post_id, forum_id,blog_id) "; 
    358381                                                        $wp_sql .=  "VALUES "; 
    359                                                         $wp_sql .=    "($comment_ID, $post_id)";                 
     382                                                        $wp_sql .=    "($comment_ID, $post_id ,$forum_id,$blog_id)";             
    360383                                                        $wp_res = $xoopsDB->queryF($wp_sql, 0, 0); 
    361384                                                } 
     
    370393                                                break; 
    371394                                        case 'edit': 
    372                                                 $wp_sql = "SELECT comment_ID FROM $wp_d3forum_link WHERE post_id = $post_id"; 
     395                                                $wp_sql = "SELECT comment_ID FROM $wp_d3forum_link WHERE post_id = $post_id "; 
    373396                                                $wp_res = $xoopsDB->query($wp_sql, 0, 0); 
    374397                                                if ($wp_res === false){ 
     
    427450                        } 
    428451                        return $ret; 
    429                 }                                
     452                } 
    430453                 
    431         } 
     454                function get_comment_blog_info($d3forum_forum_id){ 
     455                        $xoopsDB =& Database::getInstance(); 
     456                        $xp_prefix = $wpdirname = basename( dirname( dirname( __FILE__ ) ) ) ; 
     457                        $xp_prefix = preg_replace('/wordpress/','wp',$xp_prefix); 
     458                        $xp_prefix = $xoopsDB->prefix($xp_prefix); 
     459                        $table_name = 'options'; 
     460                        $options_array = array(); 
     461 
     462 
     463                                $sql = "SHOW TABLES LIKE '" . $xp_prefix  . '%' . $table_name . "'"; 
     464                                if($result = $xoopsDB->queryF($sql)){ 
     465                                        while($row = $xoopsDB->fetchRow($result)){ 
     466                                                $wp_option_table = $row[0]; 
     467                                                $pattern = '/'. $table_name . '/'; 
     468                                                $option['mb_table_prefix'] =  preg_replace($pattern,'',$wp_option_table); 
     469                                                if (preg_match('/'. $xp_prefix . '_([0-9]*)_/',$option['mb_table_prefix'],$matchs)){ 
     470                                                        $option['blog_id'] = $matchs[1]; 
     471                                                } else { 
     472                                                        $option['blog_id'] = 1; 
     473                                                } 
     474                                                 
     475                                                $option_sql = "SELECT option_name, option_value FROM $wp_option_table WHERE option_name IN ('home','siteurl','blogname','xpressme_option')"; 
     476                                                if($option_result =  $xoopsDB->query($option_sql, 0, 0)){ 
     477                                                        while($option_row = $xoopsDB->fetchArray($option_result)){ 
     478                                                                $name = $option_row['option_name']; 
     479                                                                $value = $option_row['option_value']; 
     480                                                                if ($name == 'xpressme_option'){ 
     481                                                                        $value =  @unserialize( $value ); 
     482                                                                } 
     483                                                                $option[$name] = $value; 
     484                                                        } 
     485                                                        $option['siteurl'] = preg_replace('/\/$/','',$option['siteurl']); 
     486                                                        $option['home'] = preg_replace('/\/$/','',$option['home']); 
     487                                                         
     488                                                        if ($option['blog_id'] === 1){ 
     489                                                                $option['sub_dir'] = ''; 
     490                                                        } else { 
     491                                                                $xoops_url = str_replace('/','\\/',XOOPS_URL); 
     492                                                                if (preg_match('/'. $xoops_url . '.*' . $wpdirname . '(.*)/',$option['home'],$matchs)){ 
     493                                                                        $option['sub_dir'] = $matchs[1]; 
     494                                                                } else { 
     495                                                                        $option['sub_dir'] = ''; 
     496                                                                } 
     497                                                        } 
     498                                                        if ($option['xpressme_option']['d3forum_forum_id'] == $d3forum_forum_id){ 
     499                                                                return $option; 
     500                                                        } 
     501                                                } 
     502                                        } 
     503                                        return null; 
     504                                } 
     505                } 
     506                function repair_d3forum_link($comment_ID, $post_id ,$forum_id,$blog_id,$target_db_prefix){ 
     507                } 
     508                 
     509        } // class 
    432510} 
    433511?> 
  • trunk/xpressme_integration_kit/include/oninstall.php

    r583 r590  
    110110                post_id int(10) unsigned NOT NULL default '0' , 
    111111                wp_post_ID bigint(20) unsigned NOT NULL default '0', 
     112                forum_id bigint(20) unsigned NOT NULL default '0', 
     113                blog_id bigint(20) unsigned NOT NULL default '0', 
    112114                KEY post_id (post_id) 
    113115                )$charset_collate;"; 
  • trunk/xpressme_integration_kit/include/onupdate.php

    r583 r590  
    223223        } 
    224224         
     225        $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; 
    225226        if (! enhanced_table_check($mydirname,'d3forum_link')){ 
    226                 $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; 
    227227                $queries ="CREATE TABLE $d3forum_link ( 
    228228                        comment_ID bigint(20) unsigned NOT NULL default '0', 
    229229                        post_id int(10) unsigned NOT NULL default '0' , 
    230230                        wp_post_ID bigint(20) unsigned NOT NULL default '0', 
     231                        forum_id bigint(20) unsigned NOT NULL default '0', 
     232                        blog_id bigint(20) unsigned NOT NULL default '0', 
    231233                        KEY post_id (post_id) 
    232234                        )TYPE=MyISAM"; 
    233235                $db->queryF( $queries ) ; 
    234236                $msgs[] = "$d3forum_link table of XPressME was made."; 
     237        } else { 
     238                if (!is_found_table_column($d3forum_link,'forum_id')){ 
     239                        $queries ="ALTER TABLE $d3forum_link ADD forum_id bigint(20) unsigned NOT NULL default '0' AFTER wp_post_ID"; 
     240                        $db->queryF( $queries ) ; 
     241                        $msgs[] = "$d3forum_link  ADD forum_id ."; 
     242                        // The table is repaired. 
     243//                      $update_sql = "UPDATE $d3forum_link SET forum_id = 1 WHERE(forum_id IS NULL OR forum_id < 1)"; 
     244//                      $db->queryF( $update_sql ) ; 
     245                } 
     246                if (!is_found_table_column($d3forum_link,'blog_id')){ 
     247                        $queries ="ALTER TABLE $d3forum_link ADD blog_id bigint(20)  unsigned NOT NULL default '0' AFTER forum_id"; 
     248                        $db->queryF( $queries ) ; 
     249                        $msgs[] = "$d3forum_link  ADD blog_id ."; 
     250                        // The table is repaired. 
     251                        $update_sql = "UPDATE $d3forum_link SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 
     252                        $db->queryF( $update_sql ) ; 
     253                } 
    235254        } 
    236255 
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/d3forum_comment_synchro.php

    r264 r590  
    115115 
    116116function 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; 
    118120 
    119121        $wp_d3forum_link = get_wp_prefix() . 'd3forum_link'; 
    120122         
    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"; 
    122124        $post_id = $xoops_db->get_var($sql); 
    123125        return $post_id; 
     
    125127 
    126128function 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; 
    128132 
    129133        $wp_d3forum_link = get_wp_prefix() . 'd3forum_link'; 
    130134         
    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"; 
    132136        $comment_ID = $xoops_db->get_var($sql); 
    133137        return $comment_ID; 
     
    167171        global $xpress_config,$xoops_db; 
    168172         
     173        $d3f_forum_id = $xpress_config->d3forum_forum_id; 
     174         
    169175        if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 
    170176        $d3f_forum_dir  = $xpress_config->d3forum_module_dir; 
     
    174180                $sql  = "UPDATE $d3f_topic "; 
    175181                $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" ; 
    177183                $xoops_db->query($sql); 
    178184} 
     
    180186// All comments of WordPress are exported to the D3Forum comment.  
    181187function wp_to_d3forum($forum_id = 1, $d3f_prefix = 'd3forum'){ 
    182         global $xpress_config,$xoops_db; 
     188        global $xpress_config,$xoops_db,$wpdb; 
    183189 
    184190        if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 
     
    187193        $xpress_prefix = get_wp_prefix(); 
    188194         
    189         $wp_comments = $xpress_prefix . 'comments'; 
     195        $wp_comments = $wpdb->comments; 
    190196        $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 
    191         $wp_posts = $xpress_prefix . 'posts'; 
     197        $wp_posts = $wpdb->posts; 
    192198        $d3f_topic = $d3forum_prefix . 'topics';        // delete key forum_id 
    193199        $d3f_forums = $d3forum_prefix . 'forums';       // delete key forum_id 
     
    239245 
    240246        $comment_count = 0; 
    241         $comments = $xoops_db->get_results($sql); 
     247        $comments = $wpdb->get_results($sql); 
    242248        foreach($comments as $comment){ 
    243249                $comment_ID = $comment->comment_ID; 
     
    254260// All comments of D3Forum are import to the WordPress comment.  
    255261function d3forum_to_wp($forum_id = 1, $d3f_prefix = 'd3forum'){ 
    256         global $xpress_config,$xoops_db; 
     262        global $xpress_config,$xoops_db,$wpdb; 
    257263        if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 
    258264         
     
    260266        $xpress_prefix = get_wp_prefix() ; 
    261267         
    262         $wp_comments = $xpress_prefix . 'comments'; 
     268        $wp_comments = $wpdb->comments; 
    263269        $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 
    264270        $wp_dummy = $xpress_prefix . 'dummy'; 
    265         $wp_d3forum_link  = $xpress_prefix . 'd3forum_link'; 
    266271         
    267272        $d3f_topic = $d3forum_prefix . 'topics'; 
     
    287292 
    288293        //All wp post comment count clear 
    289         $wp_posts = $xpress_prefix . 'posts'; 
     294        $wp_posts = $wpdb->posts; 
    290295        $xoops_db->query("UPDATE $wp_posts SET  comment_count = 0 WHERE 1 "); 
    291296                 
     
    327332        $d3forum_dirname = $xpress_config->d3forum_module_dir; 
    328333        $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 
     334        $d3forum_forum_id = $xpress_config->d3forum_forum_id; 
    329335 
    330336        $post_id = intval( $post_id ) ; 
     
    332338        $d3f_topics = $d3forum_prefix . 'topics'; 
    333339         
    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"; 
    335341        $row = $xoops_db->get_row($sql) ; 
    336342         
     
    346352 
    347353function 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; 
    349355 
    350356        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 
    351361        $d3forum_prefix = get_xoops_prefix() . $xpress_config->d3forum_module_dir . '_'; 
    352362        $xpress_prefix = get_wp_prefix(); 
    353363         
    354         $wp_comments = $xpress_prefix . 'comments'; 
    355         $wp_posts = $xpress_prefix . 'posts'; 
     364        $wp_comments = $wpdb->comments; 
     365        $wp_posts = $wpdb->posts; 
    356366        $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 
    357367         
     
    424434                                $xoops_db->query($wp_sql); 
    425435                                $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) "; 
    427437                                $wp_sql .=  "VALUES "; 
    428                                 $wp_sql .=    "($comment_ID, $post_id)";                 
     438                                $wp_sql .=    "($comment_ID, $post_id, $link_id, $d3f_forum_id, $blog_id)";              
    429439                                $xoops_db->query($wp_sql);                               
    430440                                if ($comment_approved ==0)      do_CommentWaiting($comment_ID, $post_id); 
     
    458468//  The content is reflected in the D3Forum comment when there is a change in the WordPress comment.  
    459469function 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; 
    461473         
    462474        if (!is_d3forum_setting()) die('The setting of the D3Forum comment integration is wrong. '); 
     
    468480        $d3forum_prefix = get_xoops_prefix() . $d3f_forum_dir . '_'; 
    469481        $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'; 
    472486        $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 
    473487        $d3f_topic = $d3forum_prefix . 'topics'; 
     
    484498        $sql .= "WHERE (comment_ID = $comment_ID) AND ($wp_comments.comment_approved NOT LIKE 'spam') "; 
    485499 
    486         $row = $xoops_db->get_row($sql) ; 
     500//      $row = $xoops_db->get_row($sql) ; 
     501        $row = $wpdb->get_row($sql) ; 
    487502        if(empty($row)) die( 'READ ' . $wp_comments . '_NG...' .$sql); 
    488503        if (! empty($row->comment_type)) return; 
     
    513528        if ($sync_mode == 'delete'){ 
    514529                $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"); 
    516531                if (empty($delete_post_id)) return; 
    517532                $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"); 
     
    528543                         
    529544                        // 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" ) ; 
    531546                         
    532547                        if (!empty($row)){ 
     
    629644                         
    630645                        $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) "; 
    632647                        $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)";               
    634649                        $xoops_db->query($wp_sql); 
    635650                         
     
    666681                         
    667682                        $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) "; 
    669684                        $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)";               
    671686                        $xoops_db->query($wp_sql); 
    672687 
     
    701716function wp_d3forum_delete_post_recursive( $d3forum_dirname , $post_id ,$isChild = false) 
    702717{ 
     718        global $wpdb,$blog_id; 
     719        global $xpress_config,$xoops_db; 
    703720        $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         
    705724        $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 
    706725        $xpress_prefix = get_wp_prefix(); 
     
    718737        $xoops_db->query( "DELETE FROM ".$d3forum_prefix."post_votes WHERE post_id=$post_id" ) ; 
    719738         
    720         $wp_comments = $xpress_prefix . 'comments'; 
    721         $wp_posts = $xpress_prefix . 'posts'; 
     739        $wp_comments = $wpdb->comments; 
     740        $wp_posts = $wpdb->posts; 
    722741        $wp_d3forum_link = $xpress_prefix . 'd3forum_link'; 
    723742 
    724743        $comment_ID = get_wp_comment_ID($post_id);  // get wordpress comment ID 
    725744        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"); 
    727746                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"); 
    729748                        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"); 
    731750                        } 
    732751                }        
    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"); 
    734753        } 
    735754} 
     
    741760        global $xpress_config,$xoops_db; 
    742761        $d3forum_prefix = get_xoops_prefix() . $d3forum_dirname . '_'; 
    743         $xpress_prefix = get_wp_prefix(); 
    744762 
    745763        $topic_id = intval( $topic_id ) ; 
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme_class.php

    r578 r590  
    644644                global $xoops_db,$xoops_config; 
    645645                 
     646                $multi_blog_use_d3forum = true; 
     647                 
    646648                $d3frum_list = array(); 
    647649                $module_dir_path = get_xoops_root_path(); 
     
    654656                        $selected = ''; 
    655657                 
    656                 if (xpress_is_multiblog()) { 
     658                if (xpress_is_multiblog() && $multi_blog_use_d3forum) { 
    657659                        $forum_list .= '<option value="none"' . $selected . '>' . __('WordPress MultiBlog cannot integrate the comments.', 'xpressme') . "</option>\n"; 
    658660                } else {         
Note: See TracChangeset for help on using the changeset viewer.