From 6ec24f2f00ab5fa1148ad4ab0391771259b884ec Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 11 May 2009 16:27:52 +0000 Subject: Don't attempt to interact with comments if the Gallery2 comment module is not installed. Resolves ticket #276 --- modules/g2_import/helpers/g2_import.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'modules/g2_import/helpers') diff --git a/modules/g2_import/helpers/g2_import.php b/modules/g2_import/helpers/g2_import.php index 8c9b9eb9..f4551bc3 100644 --- a/modules/g2_import/helpers/g2_import.php +++ b/modules/g2_import/helpers/g2_import.php @@ -88,6 +88,15 @@ class g2_import_Core { return $versions["gallery"]; } + static function g2_module_active($module) { + static $plugin_list; + if (!$plugin_list) { + $plugin_list = g2(GalleryCoreApi::fetchPluginList("module")); + } + + return @$plugin_list[$module]["active"]; + } + static function stats() { GalleryCoreApi::requireOnce("modules/comment/classes/GalleryCommentHelper.class"); @@ -97,7 +106,12 @@ class g2_import_Core { $stats["albums"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryAlbumItem")); $stats["photos"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryPhotoItem")); $stats["movies"] = g2(GalleryCoreApi::fetchItemIdCount("GalleryMovieItem")); - list (, $stats["comments"]) = g2(GalleryCommentHelper::fetchAllComments($root_album_id, 1)); + + if (g2_import::g2_module_active("comment")) { + list (, $stats["comments"]) = g2(GalleryCommentHelper::fetchAllComments($root_album_id, 1)); + } else { + $stats["comments"] = 0; + } return $stats; } -- cgit v1.2.3