added sanity check for pagecomment table

This commit is contained in:
Bjoern Radon 2011-02-12 23:04:57 +01:00
parent 8ccd23db5a
commit 1596b17c32

View File

@ -21,7 +21,9 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
function CommentText() {
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
if(DB::getConn()->hasTable("PageComment")) {
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
}
if($unmoderatedcount == 1) {
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
} else if($unmoderatedcount > 1) {
@ -35,7 +37,9 @@ class BlogManagementWidget extends Widget implements PermissionProvider {
if(!Permission::check('BLOGMANAGEMENT')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
if(DB::getConn()->hasTable("PageComment")){
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
}
if($unmoderatedcount > 0) {
return "admin/comments/unmoderated";