XPressME Integration Kit

Trac


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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); 
Note: See TracChangeset for help on using the changeset viewer.