XPressME Integration Kit

Trac

Changeset 428


Ignore:
Timestamp:
Oct 31, 2009, 11:36:52 PM (14 years ago)
Author:
toemon
Message:

WPMUで閲覧数が正常に機能しないバグ修正 Fixes #241

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/XPressMU/xpressme_integration_kit/include/oninstall.php

    r406 r428  
    100100        } 
    101101        $views_queries ="CREATE TABLE $views_table ( 
     102                blog_id bigint(20) unsigned NOT NULL default '0', 
    102103                post_id bigint(20) unsigned NOT NULL default '0', 
    103104                post_views bigint(20) unsigned NOT NULL default '0', 
  • branches/XPressMU/xpressme_integration_kit/include/onupdate.php

    r384 r428  
    175175        $msgs = array(); 
    176176 
     177        $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 
    177178        if (! enhanced_table_check($mydirname,'views')){ 
    178                 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 
    179179                $queries ="CREATE TABLE $views_table ( 
     180                blog_id bigint(20) unsigned NOT NULL default '0', 
    180181                post_id bigint(20) unsigned NOT NULL default '0', 
    181182                post_views bigint(20) unsigned NOT NULL default '0', 
     
    184185                $db->queryF( $queries ) ; 
    185186                $msgs[] = "$views_table table of XPressME was made."; 
     187        } else { 
     188                if (!is_found_table_column($views_table,'blog_id')){ 
     189                        $queries ="ALTER TABLE $views_table ADD blog_id bigint(20)  FIRST"; 
     190                        $db->queryF( $queries ) ; 
     191                        $msgs[] = "$views_table  ADD blog_id ."; 
     192                } 
    186193        } 
    187194         
     
    261268endif; 
    262269 
     270if( ! function_exists( 'is_found_table_column' ) ) : 
     271function is_found_table_column($table,$column){ 
     272                global $xoopsModule; 
     273                $xoopsDB =& Database::getInstance(); 
     274 
     275                $sql = "DESCRIBE $table $column"; 
     276                $res = $xoopsDB->queryF($sql, 0, 0); 
     277                if ($res === false){ 
     278                        return false; 
     279                } else { 
     280                        if ($xoopsDB->getRowsNum($res)  > 0) 
     281                                return true; 
     282                        else 
     283                                return false; 
     284                } 
     285} 
     286endif; 
    263287 
    264288 
  • branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php

    r409 r428  
    422422function xpress_post_views_count($args ='') { 
    423423        global $xoops_db,$wpdb; 
    424  
     424        global $blog_id; 
    425425        static $post_cache_views; 
    426426 
     
    442442        if($post_id==0) return null; 
    443443        if(!isset($post_cache_views[$post_id])){ 
    444         $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id"; 
    445         $post_views = $xoops_db->get_var($sql); 
     444                if (is_null($blog_id)){ 
     445                        $blog_where = ''; 
     446                } else { 
     447                        $blog_where = ' AND blog_id = '. $blog_id; 
     448                } 
     449                $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " .  $blog_where; 
     450       $post_views = $xoops_db->get_var($sql); 
    446451        if (!$post_views) { 
    447452                $post_cache_views[$post_id] = 0; 
     
    473478        global $xoops_db,$wpdb; 
    474479        global $table_prefix; 
     480        global $blog_id; 
    475481        static $views; 
    476482         
     
    481487 
    482488        $views_db = get_wp_prefix() . 'views'; 
     489        if (is_null($blog_id)) $blog_id = 0; 
    483490 
    484491        if($post_id==0 || !empty($views[$post_id])) return null; 
     
    489496                if ($current_user_id ==$post_author_id) return null; 
    490497        } 
    491  
    492     $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id"; 
     498        if (is_null($blog_id)){ 
     499                $blog_where = ''; 
     500        } else { 
     501                $blog_where = ' AND blog_id = ' . $blog_id; 
     502        } 
     503        $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where; 
    493504        $post_views_found = $xoops_db->get_var($sql); 
    494505        if($post_views_found){ 
    495         $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id"; 
     506        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where; 
    496507    }else{ 
    497         $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; 
     508        if (is_null($blog_id)){ 
     509                        $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; 
     510                } else { 
     511                        $sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)"; 
     512                } 
    498513    } 
    499514    $xoops_db->query($sql); 
  • trunk/xpressme_integration_kit/include/oninstall.php

    r397 r428  
    100100        } 
    101101        $views_queries ="CREATE TABLE $views_table ( 
     102                blog_id bigint(20) unsigned NOT NULL default '0', 
    102103                post_id bigint(20) unsigned NOT NULL default '0', 
    103104                post_views bigint(20) unsigned NOT NULL default '0', 
  • trunk/xpressme_integration_kit/include/onupdate.php

    r384 r428  
    175175        $msgs = array(); 
    176176 
     177        $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 
    177178        if (! enhanced_table_check($mydirname,'views')){ 
    178                 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 
    179179                $queries ="CREATE TABLE $views_table ( 
     180                blog_id bigint(20) unsigned NOT NULL default '0', 
    180181                post_id bigint(20) unsigned NOT NULL default '0', 
    181182                post_views bigint(20) unsigned NOT NULL default '0', 
     
    184185                $db->queryF( $queries ) ; 
    185186                $msgs[] = "$views_table table of XPressME was made."; 
     187        } else { 
     188                if (!is_found_table_column($views_table,'blog_id')){ 
     189                        $queries ="ALTER TABLE $views_table ADD blog_id bigint(20)  FIRST"; 
     190                        $db->queryF( $queries ) ; 
     191                        $msgs[] = "$views_table  ADD blog_id ."; 
     192                } 
    186193        } 
    187194         
     
    261268endif; 
    262269 
     270if( ! function_exists( 'is_found_table_column' ) ) : 
     271function is_found_table_column($table,$column){ 
     272                global $xoopsModule; 
     273                $xoopsDB =& Database::getInstance(); 
     274 
     275                $sql = "DESCRIBE $table $column"; 
     276                $res = $xoopsDB->queryF($sql, 0, 0); 
     277                if ($res === false){ 
     278                        return false; 
     279                } else { 
     280                        if ($xoopsDB->getRowsNum($res)  > 0) 
     281                                return true; 
     282                        else 
     283                                return false; 
     284                } 
     285} 
     286endif; 
    263287 
    264288 
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php

    r400 r428  
    422422function xpress_post_views_count($args ='') { 
    423423        global $xoops_db,$wpdb; 
    424  
     424        global $blog_id; 
    425425        static $post_cache_views; 
    426426 
     
    442442        if($post_id==0) return null; 
    443443        if(!isset($post_cache_views[$post_id])){ 
    444         $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id"; 
    445         $post_views = $xoops_db->get_var($sql); 
     444                if (is_null($blog_id)){ 
     445                        $blog_where = ''; 
     446                } else { 
     447                        $blog_where = ' AND blog_id = '. $blog_id; 
     448                } 
     449                $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " .  $blog_where; 
     450       $post_views = $xoops_db->get_var($sql); 
    446451        if (!$post_views) { 
    447452                $post_cache_views[$post_id] = 0; 
     
    473478        global $xoops_db,$wpdb; 
    474479        global $table_prefix; 
     480        global $blog_id; 
    475481        static $views; 
    476482         
     
    481487 
    482488        $views_db = get_wp_prefix() . 'views'; 
     489        if (is_null($blog_id)) $blog_id = 0; 
    483490 
    484491        if($post_id==0 || !empty($views[$post_id])) return null; 
     
    489496                if ($current_user_id ==$post_author_id) return null; 
    490497        } 
    491  
    492     $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id"; 
     498        if (is_null($blog_id)){ 
     499                $blog_where = ''; 
     500        } else { 
     501                $blog_where = ' AND blog_id = ' . $blog_id; 
     502        } 
     503        $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where; 
    493504        $post_views_found = $xoops_db->get_var($sql); 
    494505        if($post_views_found){ 
    495         $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id"; 
     506        $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where; 
    496507    }else{ 
    497         $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; 
     508        if (is_null($blog_id)){ 
     509                        $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; 
     510                } else { 
     511                        $sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)"; 
     512                } 
    498513    } 
    499514    $xoops_db->query($sql); 
Note: See TracChangeset for help on using the changeset viewer.