- Timestamp:
- Dec 15, 2009, 4:52:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/include/onupdate.php
r428 r488 42 42 $site_url= XOOPS_URL."/modules/".$mydirname; 43 43 xpress_put_siteurl($mydirname,$site_url); 44 xpress_put_home($mydirname,$site_url); 45 44 $home = get_xpress_option($mydirname,'home'); 45 $home_check = 'home option is right'; 46 if (strcmp($site_url,$home) !== 0 ){ 47 if (!@fclose(@fopen($home . '/xoops_version.php', "r"))){ 48 xpress_put_home($mydirname,$site_url); 49 $home_check = 'Change home option $home to $site_url'; 50 } 51 } 52 $msgs[] = $home_check; 46 53 // XPressME orignal table update 47 54 $t_mess = xpress_table_make($module , $mydirname); … … 50 57 // make templates 51 58 include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates_make.php' ; 59 $mod_version = $module->getVar('version') ; 60 61 $t_mess = xpress_clean_templates_file($mydirname,$mod_version); 62 $msgs = array_merge($msgs,$t_mess); 63 52 64 $t_mess = xpress_templates_make($mid,$mydirname); 53 54 65 $msgs = array_merge($msgs,$t_mess); 55 66 … … 97 108 endif; 98 109 110 if( ! function_exists( 'get_xpress_option' ) ) { 111 function get_xpress_option($mydirname,$option_name){ 112 global $xoopsModule; 113 $wp_prefix = $mydirname; 114 if ($wp_prefix == 'wordpress'){ 115 $wp_prefix = 'wp'; 116 } 117 $xoopsDB =& Database::getInstance(); 118 $option_table = $xoopsDB->prefix($wp_prefix . '_options'); 119 120 $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; 121 122 $result = $xoopsDB->query($sql, 0, 0); 123 if ($xoopsDB->getRowsNum($result) > 0){ 124 $row = $xoopsDB->fetchArray($result); 125 return $row['option_value']; 126 } 127 return 0; 128 } 129 } 99 130 100 131 if( ! function_exists( 'xpress_message_append_onupdate' ) ) : … … 190 221 $db->queryF( $queries ) ; 191 222 $msgs[] = "$views_table ADD blog_id ."; 223 } 224 225 // The table is repaired. 226 $non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1"; 227 $non_blogid_res = $db->query($non_blogid_sql, 0, 0); 228 while($row = $db->fetchArray($non_blogid_res)){ 229 $total_view = $row['post_views']; 230 $post_id = $row['post_id']; 231 $new_blogid_sql ="SELECT SUM(post_views) as post_views_sum FROM $views_table WHERE post_id = $post_id AND blog_id = 1 GROUP BY post_id"; 232 $new_blogid_res = $db->query($new_blogid_sql, 0, 0); 233 if ($db->getRowsNum($new_blogid_res) > 0){ 234 $new_row = $db->fetchArray($new_blogid_res); 235 $total_view = $total_view + $new_row['post_views_sum']; 236 $del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1"; 237 $db->queryF( $del_sql ) ; 238 } 239 $update_sql = "UPDATE $views_table SET post_views = $total_view , blog_id = 1 WHERE post_id = $post_id AND (blog_id IS NULL OR blog_id < 1)"; 240 $db->queryF( $update_sql ) ; 192 241 } 193 242 }
Note: See TracChangeset
for help on using the changeset viewer.