Changeset 428 for branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
- Timestamp:
- Oct 31, 2009, 11:36:52 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/include/custom_functions.php
r409 r428 422 422 function xpress_post_views_count($args ='') { 423 423 global $xoops_db,$wpdb; 424 424 global $blog_id; 425 425 static $post_cache_views; 426 426 … … 442 442 if($post_id==0) return null; 443 443 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); 446 451 if (!$post_views) { 447 452 $post_cache_views[$post_id] = 0; … … 473 478 global $xoops_db,$wpdb; 474 479 global $table_prefix; 480 global $blog_id; 475 481 static $views; 476 482 … … 481 487 482 488 $views_db = get_wp_prefix() . 'views'; 489 if (is_null($blog_id)) $blog_id = 0; 483 490 484 491 if($post_id==0 || !empty($views[$post_id])) return null; … … 489 496 if ($current_user_id ==$post_author_id) return null; 490 497 } 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; 493 504 $post_views_found = $xoops_db->get_var($sql); 494 505 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; 496 507 }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 } 498 513 } 499 514 $xoops_db->query($sql);
Note: See TracChangeset
for help on using the changeset viewer.