Changeset 428 for branches/XPressMU/xpressme_integration_kit
- Timestamp:
- Oct 31, 2009, 11:36:52 PM (15 years ago)
- Location:
- branches/XPressMU/xpressme_integration_kit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/include/oninstall.php
r406 r428 100 100 } 101 101 $views_queries ="CREATE TABLE $views_table ( 102 blog_id bigint(20) unsigned NOT NULL default '0', 102 103 post_id bigint(20) unsigned NOT NULL default '0', 103 104 post_views bigint(20) unsigned NOT NULL default '0', -
branches/XPressMU/xpressme_integration_kit/include/onupdate.php
r384 r428 175 175 $msgs = array(); 176 176 177 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; 177 178 if (! enhanced_table_check($mydirname,'views')){ 178 $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ;179 179 $queries ="CREATE TABLE $views_table ( 180 blog_id bigint(20) unsigned NOT NULL default '0', 180 181 post_id bigint(20) unsigned NOT NULL default '0', 181 182 post_views bigint(20) unsigned NOT NULL default '0', … … 184 185 $db->queryF( $queries ) ; 185 186 $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 } 186 193 } 187 194 … … 261 268 endif; 262 269 270 if( ! function_exists( 'is_found_table_column' ) ) : 271 function 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 } 286 endif; 263 287 264 288 -
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.