XPressME Integration Kit

Trac

Changeset 426


Ignore:
Timestamp:
Oct 28, 2009, 4:51:16 PM (14 years ago)
Author:
toemon
Message:

WordPressMUを使用したときWhat's New Module用のインターフェース(include/data.inc.php)で
存在しないテーブルを参照してしまうバグを修正 Fixed #228

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/XPressMU/xpressme_integration_kit/include/data.inc.php

    r261 r426  
    4343        $modRes = $xoopsDB->query($modSQL, 0, 0); 
    4444        $modRow = $xoopsDB->fetchArray($modRes); 
    45         $module_id = $modRow['mid'];     
     45        $module_id = $modRow['mid']; 
    4646 
    4747        $table_config = $xoopsDB->prefix('config'); 
     
    5252 
    5353        $url_mod = XOOPS_URL."/modules/".$mydirname; 
    54  
    55         $table_posts      = $xoopsDB->prefix($wp_prefix . "_posts"); 
    56         $table_categories = $xoopsDB->prefix($wp_prefix . "_categories"); 
    57         $table_post2cat   = $xoopsDB->prefix($wp_prefix . "_post2cat"); 
    58         $table_views   = $xoopsDB->prefix($wp_prefix . "_views"); 
    59         $table_term_relationships = $xoopsDB->prefix($wp_prefix . "_term_relationships"); 
    60         $table_term_taxonomy = $xoopsDB->prefix($wp_prefix . "_term_taxonomy"); 
    61         $table_terms = $xoopsDB->prefix($wp_prefix . "_terms"); 
    62  
    63 //      $sql = "SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY post_date DESC"; 
    64  
    65         $sql1 = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status FROM ".$table_posts." WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ORDER BY post_date DESC"; 
    66  
    6754         
    68         $res1 = $xoopsDB->query($sql1, $limit, $offset); 
     55        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     56        $prefix = $xoopsDB->prefix($wp_prefix); 
     57        $options_tables = get_table_list($prefix,'options'); 
     58        $table_count = count($options_tables); 
     59        $sql1 = ''; 
     60        foreach( $options_tables as $options_table){ 
     61                $blog_url = get_blog_option($options_table , 'siteurl'); 
     62                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     63                $blogname = get_blog_option($options_table , 'blogname'); 
     64                 
     65                $table_prefix = get_multi_prefix($options_table,'options'); 
     66                 
     67                $table_posts      = $table_prefix . "posts"; 
     68                 
     69                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     70                $sub_sql .= " FROM ".$table_posts; 
     71                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     72 
     73                if ($table_count > 1){ 
     74                        $sub_sql = '(' . $sub_sql . ')'; 
     75                        if (!empty($sql1)) $sql1 = $sql1 . ' UNION '; 
     76                        $sql1 = $sql1 . $sub_sql; 
     77                } else { 
     78                        $sql1 =  $sub_sql; 
     79                } 
     80        } 
     81        $sql1 .= " ORDER BY post_date DESC LIMIT $offset,$limit"; 
     82 
     83        $res1 = $xoopsDB->queryF($sql1); 
    6984 
    7085        $i = 0; 
     
    7489        { 
    7590                $id = $row1['ID']; 
    76                 if ($wp_db_version < 6124){ 
    77                         $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id; 
    78                 } else { 
    79                         $sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 
    80                         $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id "; 
    81                         $sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";                
    82                 } 
    83                 $row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) ); 
     91                $blog_url = $row1['blog_url']; 
     92                $blogname = $row1['blogname']; 
     93                $table_views   =$modules_table = $xoopsDB->prefix($wp_prefix) . "_views"; 
     94                $table_term_relationships = $row1['table_prefix'] . "term_relationships"; 
     95                $table_term_taxonomy = $row1['table_prefix'] . "term_taxonomy"; 
     96                $table_terms = $row1['table_prefix'] . "terms"; 
     97                $table_categories = $row1['table_prefix'] . "categories"; 
     98                $table_post2cat   = $row1['table_prefix'] . "post2cat"; 
     99 
     100                if ($table_count <= 1){ 
     101                        if ($wp_db_version < 6124){ 
     102                                $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id; 
     103                        } else { 
     104                                $sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 
     105                                $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id "; 
     106                                $sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";                
     107                        } 
     108                        $row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) ); 
     109                        $ret[$i]['cat_link'] = $blog_url."/index.php?cat=".$row2['cat_ID']; 
     110                        $ret[$i]['cat_name'] = $row2['cat_name']; 
     111                } else { 
     112                        $ret[$i]['cat_link'] = $blog_url; 
     113                        $ret[$i]['cat_name'] = $blogname; 
     114                } 
     115 
    84116                if ($row1['post_type'] == 'page'){ 
    85                                 $ret[$i]['link']     = $url_mod."/?page_id=".$id; 
    86                 } else { 
    87                         $ret[$i]['link']     = $url_mod."/index.php?p=".$id; 
    88                 } 
    89                 $ret[$i]['cat_link'] = $url_mod."/index.php?cat=".$row2['cat_ID']; 
     117                                $ret[$i]['link']     = $blog_url."/?page_id=".$id; 
     118                } else { 
     119                        $ret[$i]['link']     = $blog_url."/index.php?p=".$id; 
     120                } 
    90121 
    91122                $ret[$i]['title']    = $row1['post_title']; 
    92                 $ret[$i]['cat_name'] = $row2['cat_name']; 
    93123 
    94124                $ret[$i]['uid'] = wp_uid_to_xoops_uid($row1['post_author'],$mydirname); 
     
    139169                $wp_prefix = $mydirname; 
    140170        } 
    141  
    142         $sql = "SELECT count(*) FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." ORDER BY ID"; 
    143         $array = $xoopsDB->fetchRow( $xoopsDB->query($sql) ); 
     171        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     172        $prefix = $xoopsDB->prefix($wp_prefix); 
     173        $options_tables = get_table_list($prefix,'options'); 
     174        $table_count = count($options_tables); 
     175        $sql = ''; 
     176        foreach( $options_tables as $options_table){ 
     177                $blog_url = get_blog_option($options_table , 'siteurl'); 
     178                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     179                $blogname = get_blog_option($options_table , 'blogname'); 
     180                 
     181                $table_prefix = get_multi_prefix($options_table,'options'); 
     182                $table_posts      = $table_prefix . "posts"; 
     183 
     184                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     185                $sub_sql .= " FROM ".$table_posts; 
     186                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     187 
     188                if ($table_count > 1){ 
     189                        $sub_sql = '(' . $sub_sql . ')'; 
     190                        if (!empty($sql)) $sql = $sql . ' UNION '; 
     191                        $sql = $sql . $sub_sql; 
     192                } else { 
     193                        $sql =  $sub_sql; 
     194                } 
     195        } 
     196 
     197        $array = $xoopsDB->fetchRow( $xoopsDB->queryF($sql) ); 
    144198        $num = $array[0]; 
    145199        if (empty($num)) $num = 0; 
     
    160214                $wp_prefix = $mydirname; 
    161215        } 
    162         $sql = "SELECT ID, post_title, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY ID"; 
    163         $result = $xoopsDB->query($sql,$limit,$offset); 
     216         
     217        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     218        $prefix = $xoopsDB->prefix($wp_prefix); 
     219        $options_tables = get_table_list($prefix,'options'); 
     220        $table_count = count($options_tables); 
     221        $sql = ''; 
     222        foreach( $options_tables as $options_table){ 
     223                $blog_url = get_blog_option($options_table , 'siteurl'); 
     224                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     225                $blogname = get_blog_option($options_table , 'blogname'); 
     226                 
     227                $table_prefix = get_multi_prefix($options_table,'options'); 
     228                $table_posts      = $table_prefix . "posts"; 
     229 
     230                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     231                $sub_sql .= " FROM ".$table_posts; 
     232                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     233 
     234                if ($table_count > 1){ 
     235                        $sub_sql = '(' . $sub_sql . ')'; 
     236                        if (!empty($sql)) $sql = $sql . ' UNION '; 
     237                        $sql = $sql . $sub_sql; 
     238                } else { 
     239                        $sql =  $sub_sql; 
     240                } 
     241        } 
     242 
     243        $result = $xoopsDB->queryF($sql,$limit,$offset); 
    164244 
    165245        $i = 0; 
     
    169249        { 
    170250                $id = $row1['ID']; 
     251                $blog_url = $row1['blog_url']; 
     252                $blogname = $row1['blogname']; 
    171253                $ret[$i]['id'] = $id; 
    172                 $ret[$i]['link'] = XOOPS_URL."/modules/xpress/index.php?p=".$id.""; 
     254                $ret[$i]['link'] = $blog_url . "/index.php?p=".$id; 
    173255                $ret[$i]['title'] = $row1['post_title']; 
    174256                $ret[$i]['time']  = $row1['unix_post_date']; 
     
    180262} 
    181263 
     264if( ! function_exists( 'get_blog_option' ) ) { 
     265        function get_blog_option($option_table,$option_name){ 
     266                $xoopsDB =& Database::getInstance(); 
     267 
     268                $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; 
     269                 
     270                $result =  $xoopsDB->query($sql, 0, 0); 
     271                if ($xoopsDB->getRowsNum($result)  > 0){ 
     272                        $row = $xoopsDB->fetchArray($result); 
     273                        return $row['option_value']; 
     274                } 
     275                return 0; 
     276        } 
     277} 
     278 
    182279 
    183280// --- function end --- 
  • trunk/xpressme_integration_kit/include/data.inc.php

    r261 r426  
    4343        $modRes = $xoopsDB->query($modSQL, 0, 0); 
    4444        $modRow = $xoopsDB->fetchArray($modRes); 
    45         $module_id = $modRow['mid'];     
     45        $module_id = $modRow['mid']; 
    4646 
    4747        $table_config = $xoopsDB->prefix('config'); 
     
    5252 
    5353        $url_mod = XOOPS_URL."/modules/".$mydirname; 
    54  
    55         $table_posts      = $xoopsDB->prefix($wp_prefix . "_posts"); 
    56         $table_categories = $xoopsDB->prefix($wp_prefix . "_categories"); 
    57         $table_post2cat   = $xoopsDB->prefix($wp_prefix . "_post2cat"); 
    58         $table_views   = $xoopsDB->prefix($wp_prefix . "_views"); 
    59         $table_term_relationships = $xoopsDB->prefix($wp_prefix . "_term_relationships"); 
    60         $table_term_taxonomy = $xoopsDB->prefix($wp_prefix . "_term_taxonomy"); 
    61         $table_terms = $xoopsDB->prefix($wp_prefix . "_terms"); 
    62  
    63 //      $sql = "SELECT ID, post_title, post_content, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY post_date DESC"; 
    64  
    65         $sql1 = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status FROM ".$table_posts." WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) ORDER BY post_date DESC"; 
    66  
    6754         
    68         $res1 = $xoopsDB->query($sql1, $limit, $offset); 
     55        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     56        $prefix = $xoopsDB->prefix($wp_prefix); 
     57        $options_tables = get_table_list($prefix,'options'); 
     58        $table_count = count($options_tables); 
     59        $sql1 = ''; 
     60        foreach( $options_tables as $options_table){ 
     61                $blog_url = get_blog_option($options_table , 'siteurl'); 
     62                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     63                $blogname = get_blog_option($options_table , 'blogname'); 
     64                 
     65                $table_prefix = get_multi_prefix($options_table,'options'); 
     66                 
     67                $table_posts      = $table_prefix . "posts"; 
     68                 
     69                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     70                $sub_sql .= " FROM ".$table_posts; 
     71                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     72 
     73                if ($table_count > 1){ 
     74                        $sub_sql = '(' . $sub_sql . ')'; 
     75                        if (!empty($sql1)) $sql1 = $sql1 . ' UNION '; 
     76                        $sql1 = $sql1 . $sub_sql; 
     77                } else { 
     78                        $sql1 =  $sub_sql; 
     79                } 
     80        } 
     81        $sql1 .= " ORDER BY post_date DESC LIMIT $offset,$limit"; 
     82 
     83        $res1 = $xoopsDB->queryF($sql1); 
    6984 
    7085        $i = 0; 
     
    7489        { 
    7590                $id = $row1['ID']; 
    76                 if ($wp_db_version < 6124){ 
    77                         $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id; 
    78                 } else { 
    79                         $sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 
    80                         $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id "; 
    81                         $sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";                
    82                 } 
    83                 $row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) ); 
     91                $blog_url = $row1['blog_url']; 
     92                $blogname = $row1['blogname']; 
     93                $table_views   =$modules_table = $xoopsDB->prefix($wp_prefix) . "_views"; 
     94                $table_term_relationships = $row1['table_prefix'] . "term_relationships"; 
     95                $table_term_taxonomy = $row1['table_prefix'] . "term_taxonomy"; 
     96                $table_terms = $row1['table_prefix'] . "terms"; 
     97                $table_categories = $row1['table_prefix'] . "categories"; 
     98                $table_post2cat   = $row1['table_prefix'] . "post2cat"; 
     99 
     100                if ($table_count <= 1){ 
     101                        if ($wp_db_version < 6124){ 
     102                                $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$id; 
     103                        } else { 
     104                                $sql2  = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 
     105                                $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id "; 
     106                                $sql2 .= "WHERE ($table_term_relationships.object_id =" . $id.") AND ($table_term_taxonomy.taxonomy='category')";                
     107                        } 
     108                        $row2 = $xoopsDB->fetchArray( $xoopsDB->query($sql2) ); 
     109                        $ret[$i]['cat_link'] = $blog_url."/index.php?cat=".$row2['cat_ID']; 
     110                        $ret[$i]['cat_name'] = $row2['cat_name']; 
     111                } else { 
     112                        $ret[$i]['cat_link'] = $blog_url; 
     113                        $ret[$i]['cat_name'] = $blogname; 
     114                } 
     115 
    84116                if ($row1['post_type'] == 'page'){ 
    85                                 $ret[$i]['link']     = $url_mod."/?page_id=".$id; 
    86                 } else { 
    87                         $ret[$i]['link']     = $url_mod."/index.php?p=".$id; 
    88                 } 
    89                 $ret[$i]['cat_link'] = $url_mod."/index.php?cat=".$row2['cat_ID']; 
     117                                $ret[$i]['link']     = $blog_url."/?page_id=".$id; 
     118                } else { 
     119                        $ret[$i]['link']     = $blog_url."/index.php?p=".$id; 
     120                } 
    90121 
    91122                $ret[$i]['title']    = $row1['post_title']; 
    92                 $ret[$i]['cat_name'] = $row2['cat_name']; 
    93123 
    94124                $ret[$i]['uid'] = wp_uid_to_xoops_uid($row1['post_author'],$mydirname); 
     
    139169                $wp_prefix = $mydirname; 
    140170        } 
    141  
    142         $sql = "SELECT count(*) FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." ORDER BY ID"; 
    143         $array = $xoopsDB->fetchRow( $xoopsDB->query($sql) ); 
     171        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     172        $prefix = $xoopsDB->prefix($wp_prefix); 
     173        $options_tables = get_table_list($prefix,'options'); 
     174        $table_count = count($options_tables); 
     175        $sql = ''; 
     176        foreach( $options_tables as $options_table){ 
     177                $blog_url = get_blog_option($options_table , 'siteurl'); 
     178                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     179                $blogname = get_blog_option($options_table , 'blogname'); 
     180                 
     181                $table_prefix = get_multi_prefix($options_table,'options'); 
     182                $table_posts      = $table_prefix . "posts"; 
     183 
     184                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     185                $sub_sql .= " FROM ".$table_posts; 
     186                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     187 
     188                if ($table_count > 1){ 
     189                        $sub_sql = '(' . $sub_sql . ')'; 
     190                        if (!empty($sql)) $sql = $sql . ' UNION '; 
     191                        $sql = $sql . $sub_sql; 
     192                } else { 
     193                        $sql =  $sub_sql; 
     194                } 
     195        } 
     196 
     197        $array = $xoopsDB->fetchRow( $xoopsDB->queryF($sql) ); 
    144198        $num = $array[0]; 
    145199        if (empty($num)) $num = 0; 
     
    160214                $wp_prefix = $mydirname; 
    161215        } 
    162         $sql = "SELECT ID, post_title, UNIX_TIMESTAMP(post_date) AS unix_post_date, post_status FROM ".$xoopsDB->prefix($wp_prefix . "_posts")." WHERE post_status='publish' ORDER BY ID"; 
    163         $result = $xoopsDB->query($sql,$limit,$offset); 
     216         
     217        require_once (XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/include/general_functions.php'); 
     218        $prefix = $xoopsDB->prefix($wp_prefix); 
     219        $options_tables = get_table_list($prefix,'options'); 
     220        $table_count = count($options_tables); 
     221        $sql = ''; 
     222        foreach( $options_tables as $options_table){ 
     223                $blog_url = get_blog_option($options_table , 'siteurl'); 
     224                $blog_url = preg_replace('/\/$/', '' ,$blog_url); 
     225                $blogname = get_blog_option($options_table , 'blogname'); 
     226                 
     227                $table_prefix = get_multi_prefix($options_table,'options'); 
     228                $table_posts      = $table_prefix . "posts"; 
     229 
     230                $sub_sql  = "SELECT ID, post_author, post_title, post_content, post_type, comment_count, post_date, UNIX_TIMESTAMP(post_date) AS unix_post_date, UNIX_TIMESTAMP(post_modified) AS unix_post_modified, post_status, '$blog_url' AS blog_url, '$table_prefix' AS table_prefix, '$blogname' AS blogname "; 
     231                $sub_sql .= " FROM ".$table_posts; 
     232                $sub_sql .= " WHERE (post_status='publish') AND (UNIX_TIMESTAMP(post_date) <= UNIX_TIMESTAMP()) "; 
     233 
     234                if ($table_count > 1){ 
     235                        $sub_sql = '(' . $sub_sql . ')'; 
     236                        if (!empty($sql)) $sql = $sql . ' UNION '; 
     237                        $sql = $sql . $sub_sql; 
     238                } else { 
     239                        $sql =  $sub_sql; 
     240                } 
     241        } 
     242 
     243        $result = $xoopsDB->queryF($sql,$limit,$offset); 
    164244 
    165245        $i = 0; 
     
    169249        { 
    170250                $id = $row1['ID']; 
     251                $blog_url = $row1['blog_url']; 
     252                $blogname = $row1['blogname']; 
    171253                $ret[$i]['id'] = $id; 
    172                 $ret[$i]['link'] = XOOPS_URL."/modules/xpress/index.php?p=".$id.""; 
     254                $ret[$i]['link'] = $blog_url . "/index.php?p=".$id; 
    173255                $ret[$i]['title'] = $row1['post_title']; 
    174256                $ret[$i]['time']  = $row1['unix_post_date']; 
     
    180262} 
    181263 
     264if( ! function_exists( 'get_blog_option' ) ) { 
     265        function get_blog_option($option_table,$option_name){ 
     266                $xoopsDB =& Database::getInstance(); 
     267 
     268                $sql = "SELECT option_value FROM $option_table WHERE option_name = '" . $option_name . "'"; 
     269                 
     270                $result =  $xoopsDB->query($sql, 0, 0); 
     271                if ($xoopsDB->getRowsNum($result)  > 0){ 
     272                        $row = $xoopsDB->fetchArray($result); 
     273                        return $row['option_value']; 
     274                } 
     275                return 0; 
     276        } 
     277} 
     278 
    182279 
    183280// --- function end --- 
Note: See TracChangeset for help on using the changeset viewer.