From f25323480ca8496e65c25e636e403d45187875be Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 4 Dec 2007 17:42:09 +0000 Subject: Blogs is now part of LibertyContent so use correct index method in search package and get rid of some legacy code --- refresh.php | 11 +++++------ refresh_functions.php | 43 +++++++------------------------------------ 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/refresh.php b/refresh.php index c2c6a3b..40bc081 100644 --- a/refresh.php +++ b/refresh.php @@ -1,6 +1,6 @@ isPackageActive( 'blogs' ) ) { - //Can't use the new random function with blogs - they aren'tin liberty_content yet. - $locs['random_refresh_index_blogs'] = ''; - //Can use new function for blog_posts though ... + // if blogs is active, let's always refresh + random_refresh_index("blogs"); $locs['random_refresh_index']="blog_posts"; } diff --git a/refresh_functions.php b/refresh_functions.php index 8ca0927..0959a94 100644 --- a/refresh_functions.php +++ b/refresh_functions.php @@ -1,6 +1,6 @@ isPackageActive( 'blogs' ) ) { - require_once( BLOGS_PKG_PATH.'BitBlog.php' ); - // get random blog - $cant = $gBitSystem->mDb->getOne("SELECT COUNT(*) FROM `".BIT_DB_PREFIX."blogs`", array()); - if($cant > 0) { - $query = "SELECT `blog_id` FROM `" . BIT_DB_PREFIX . "blogs`"; - $blogId = $gBitSystem->mDb->getOne($query, array(), 1, rand(0, $cant - 1)); - refresh_index_blogs($blogId); - } - } -} - -function refresh_index_blogs( $pBlogId = 0 ) { - global $gBitSystem; - if( $pBlogId > 0 and $gBitSystem->isPackageActive( 'blogs' ) ) { - require_once( BLOGS_PKG_PATH.'BitBlog.php' ); - $query = "SELECT `title`, `data`, uu.`login` AS `user_login`, uu.`real_name` - FROM `".BIT_DB_PREFIX."blogs` b - INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON b.`content_id` = lc.`content_id` - INNER JOIN `".BIT_DB_PREFIX."users_users` uu ON uu.`user_id` = lc.`user_id` - WHERE `blog_id` = ? "; - $res = $gBitSystem->mDb->getRow($query, array($pBlogId)); - $words = prepare_words($res["title"]." ".$res["user_login"]." ".$res["real_name"]." ".$res["data"]); - insert_index($words, BITBLOG_CONTENT_TYPE_GUID, -1, $pBlogId); - } -} - function refresh_index_oldest(){ global $gBitSystem; - $contentId = $gBitSystem->mDb->getOne("SELECT `content_id` FROM `" . BIT_DB_PREFIX . + $contentId = $gBitSystem->mDb->getOne("SELECT `content_id` FROM `" . BIT_DB_PREFIX . "search_index` ORDER BY `last_update`", array()); if ( isset($contentId) ) { refresh_index($contentId); @@ -170,7 +141,7 @@ function delete_index_content_type($pContentType) { $sql = "DELETE FROM `" . BIT_DB_PREFIX . "search_index`"; $array = array(); if ( $pContentType <> "pages" ) { - $sql .= " WHERE `content_id` IN (SELECT `content_id` FROM `" . BIT_DB_PREFIX . + $sql .= " WHERE `content_id` IN (SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_content` where `content_type_guid` = ?)"; $array = array($pContentType); } -- cgit v1.3