XPressME Integration Kit

Trac


Ignore:
Timestamp:
May 19, 2011, 6:47:15 PM (13 years ago)
Author:
toemon
Message:

Database::getInstance()を使わずに、global $xoopsDB を使用する。(xoops3対策)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Ver3.0/xpressme_integration_kit/include/onupdate.php

    r590 r749  
    2121        } 
    2222 
    23         $db =& Database::getInstance() ; 
    2423        $mid = $module->getVar('mid') ; 
    2524         
     
    8079if( ! function_exists( 'xpress_put_siteurl' ) ) : 
    8180function xpress_put_siteurl($mydirname,$url){ 
    82                 global $xoopsModule; 
     81                global $xoopsModule,$xoopsDB; 
    8382                $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    84                 $xoopsDB =& Database::getInstance(); 
    8583                $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 
    8684 
     
    9290if( ! function_exists( 'xpress_put_home' ) ) : 
    9391function xpress_put_home($mydirname,$url){ 
    94                 global $xoopsModule; 
     92                global $xoopsModule,$xoopsDB; 
    9593                $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    96                 $xoopsDB =& Database::getInstance(); 
    9794                $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 
    9895 
     
    104101if( ! function_exists( 'get_xpress_option' ) ) { 
    105102        function get_xpress_option($mydirname,$option_name){ 
    106                 global $xoopsModule; 
     103                global $xoopsModule,$xoopsDB; 
    107104                $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    108                 $xoopsDB =& Database::getInstance(); 
    109105                $option_table = $xoopsDB->prefix($wp_prefix . '_options'); 
    110106 
     
    135131if( ! function_exists( 'get_db_version' ) ) : 
    136132function get_db_version($mydirname){ 
    137                 global $xoopsModule; 
     133                global $xoopsModule,$xoopsDB; 
    138134                $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 
    139                 $xoopsDB =& Database::getInstance(); 
    140135                $db_xpress_option = $xoopsDB->prefix($wp_prefix . '_options'); 
    141136 
     
    180175function xpress_table_make($module, $mydirname) 
    181176{ 
    182         $db =& Database::getInstance() ; 
     177        global $xoopsDB; 
    183178        $mid = $module->getVar('mid') ; 
    184179 
     
    195190                KEY post_id (post_id) 
    196191                ) TYPE=MyISAM"; 
    197                 $db->queryF( $queries ) ; 
     192                $xoopsDB->queryF( $queries ) ; 
    198193                $msgs[] = "$views_table table of XPressME was made."; 
    199194        } else { 
    200195                if (!is_found_table_column($views_table,'blog_id')){ 
    201196                        $queries ="ALTER TABLE $views_table ADD blog_id bigint(20)  FIRST"; 
    202                         $db->queryF( $queries ) ; 
     197                        $xoopsDB->queryF( $queries ) ; 
    203198                        $msgs[] = "$views_table  ADD blog_id ."; 
    204199                } 
     
    206201                // The table is repaired. 
    207202                $non_blogid_sql ="SELECT * FROM $views_table WHERE blog_id IS NULL OR blog_id < 1"; 
    208                 $non_blogid_res = $db->query($non_blogid_sql, 0, 0); 
    209                 while($row = $db->fetchArray($non_blogid_res)){ 
     203                $non_blogid_res = $xoopsDB->query($non_blogid_sql, 0, 0); 
     204                while($row = $xoopsDB->fetchArray($non_blogid_res)){ 
    210205                        $total_view = $row['post_views']; 
    211206                        $post_id = $row['post_id']; 
    212207                        $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"; 
    213                         $new_blogid_res = $db->query($new_blogid_sql, 0, 0); 
    214                         if ($db->getRowsNum($new_blogid_res)  > 0){ 
    215                                 $new_row = $db->fetchArray($new_blogid_res); 
     208                        $new_blogid_res = $xoopsDB->query($new_blogid_sql, 0, 0); 
     209                        if ($xoopsDB->getRowsNum($new_blogid_res)  > 0){ 
     210                                $new_row = $xoopsDB->fetchArray($new_blogid_res); 
    216211                                $total_view = $total_view + $new_row['post_views_sum']; 
    217212                                $del_sql = "DELETE FROM $views_table WHERE post_id = $post_id AND blog_id = 1"; 
    218                                 $db->queryF( $del_sql ) ; 
     213                                $xoopsDB->queryF( $del_sql ) ; 
    219214                        } 
    220215                        $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)"; 
    221                         $db->queryF( $update_sql ) ; 
     216                        $xoopsDB->queryF( $update_sql ) ; 
    222217                } 
    223218        } 
     
    233228                        KEY post_id (post_id) 
    234229                        )TYPE=MyISAM"; 
    235                 $db->queryF( $queries ) ; 
     230                $xoopsDB->queryF( $queries ) ; 
    236231                $msgs[] = "$d3forum_link table of XPressME was made."; 
    237232        } else { 
    238233                if (!is_found_table_column($d3forum_link,'forum_id')){ 
    239234                        $queries ="ALTER TABLE $d3forum_link ADD forum_id bigint(20) unsigned NOT NULL default '0' AFTER wp_post_ID"; 
    240                         $db->queryF( $queries ) ; 
     235                        $xoopsDB->queryF( $queries ) ; 
    241236                        $msgs[] = "$d3forum_link  ADD forum_id ."; 
    242237                        // The table is repaired. 
    243238//                      $update_sql = "UPDATE $d3forum_link SET forum_id = 1 WHERE(forum_id IS NULL OR forum_id < 1)"; 
    244 //                      $db->queryF( $update_sql ) ; 
     239//                      $xoopsDB->queryF( $update_sql ) ; 
    245240                } 
    246241                if (!is_found_table_column($d3forum_link,'blog_id')){ 
    247242                        $queries ="ALTER TABLE $d3forum_link ADD blog_id bigint(20)  unsigned NOT NULL default '0' AFTER forum_id"; 
    248                         $db->queryF( $queries ) ; 
     243                        $xoopsDB->queryF( $queries ) ; 
    249244                        $msgs[] = "$d3forum_link  ADD blog_id ."; 
    250245                        // The table is repaired. 
    251246                        $update_sql = "UPDATE $d3forum_link SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 
    252                         $db->queryF( $update_sql ) ; 
     247                        $xoopsDB->queryF( $update_sql ) ; 
    253248                } 
    254249        } 
     
    266261                        KEY groupid (groupid) 
    267262                        )TYPE=MyISAM"; 
    268                 $db->queryF( $queries ) ; 
     263                $xoopsDB->queryF( $queries ) ; 
    269264                $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; 
    270                 $db->queryF( $sql ) ; 
     265                $xoopsDB->queryF( $sql ) ; 
    271266                $msgs[] = "$group_role table of XPressME was made."; 
    272267        } else { 
    273268                if (!is_found_table_column($group_role,'blog_id')){ 
    274269                        $queries ="ALTER TABLE $group_role ADD blog_id bigint(20)  AFTER groupid"; 
    275                         $db->queryF( $queries ) ; 
     270                        $xoopsDB->queryF( $queries ) ; 
    276271                        $msgs[] = "$group_role  ADD blog_id ."; 
    277272                } 
    278273                // The table is repaired. 
    279274                $update_sql = "UPDATE $group_role SET blog_id = 1 WHERE(blog_id IS NULL OR blog_id < 1)"; 
    280                 $db->queryF( $update_sql ) ; 
     275                $xoopsDB->queryF( $update_sql ) ; 
    281276        } 
    282277         
     
    295290                        KEY notify_reserve_id (notify_reserve_id) 
    296291                        )TYPE=MyISAM"; 
    297                 $db->queryF( $queries ) ; 
     292                $xoopsDB->queryF( $queries ) ; 
    298293                $msgs[] = "$notify_reserve table of XPressME was made."; 
    299294        } 
     
    304299if( ! function_exists( 'enhanced_table_check' ) ) : 
    305300function enhanced_table_check($mydirname,$table_name){ 
    306                 global $xoopsModule; 
     301                global $xoopsModule,$xoopsDB; 
    307302                 
    308                 $xoopsDB =& Database::getInstance(); 
    309303                $xpress_prefix = $xoopsDB->prefix(preg_replace('/wordpress/','wp',$mydirname) . '_'); 
    310304                $db_enhanced = $xpress_prefix . $table_name; 
     
    325319if( ! function_exists( 'is_found_table_column' ) ) : 
    326320function is_found_table_column($table,$column){ 
    327                 global $xoopsModule; 
    328                 $xoopsDB =& Database::getInstance(); 
     321                global $xoopsModule,$xoopsDB; 
    329322 
    330323                $sql = "DESCRIBE $table $column"; 
Note: See TracChangeset for help on using the changeset viewer.