silverstripe-blog/code/widgets/BlogManagementWidget.php

64 lines
1.6 KiB
PHP
Raw Normal View History

2007-09-07 00:33:58 +02:00
<?php
2009-01-20 05:01:45 +01:00
/**
* Blog Management Widget
* @package blog
*/
class BlogManagementWidget extends Widget implements PermissionProvider {
2007-09-07 00:33:58 +02:00
static $db = array();
2009-01-20 05:01:45 +01:00
static $has_one = array();
2009-01-20 05:01:45 +01:00
static $has_many = array();
2009-01-20 05:01:45 +01:00
static $many_many = array();
2009-01-20 05:01:45 +01:00
static $belongs_many_many = array();
2009-01-20 05:01:45 +01:00
static $defaults = array();
2007-09-07 00:33:58 +02:00
static $title = "Blog Management";
static $cmsTitle = "Blog Management";
static $description = "Provide a number of links useful for administering a blog. Only shown if the user is an admin.";
2007-09-07 00:33:58 +02:00
function CommentText() {
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
2007-09-07 00:33:58 +02:00
if($unmoderatedcount == 1) {
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
2007-09-07 00:33:58 +02:00
} else if($unmoderatedcount > 1) {
return sprintf(_t("BlogManagementWidget.UNMM", "You have %i unmoderated comments"), $unmoderatedcount);
2007-09-07 00:33:58 +02:00
} else {
return _t("BlogManagementWidget.COMADM", "Comment administration");
2007-09-07 00:33:58 +02:00
}
}
2007-09-07 00:33:58 +02:00
function CommentLink() {
if(!Permission::check('BLOGMANAGEMENT')) {
return false;
}
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
2007-09-07 00:33:58 +02:00
if($unmoderatedcount > 0) {
return "admin/comments/unmoderated";
} else {
return "admin/comments";
}
}
function providePermissions() {
return array("BLOGMANAGEMENT" => "Blog management");
}
2007-09-07 00:33:58 +02:00
function WidgetHolder() {
if(Permission::check("BLOGMANAGEMENT")) {
return $this->renderWith("WidgetHolder");
}
2007-09-07 00:33:58 +02:00
}
2007-09-07 00:33:58 +02:00
function PostLink() {
$container = BlogTree::current();
if ($container) return $container->Link('post');
2007-09-07 00:33:58 +02:00
}
2007-09-07 00:33:58 +02:00
}
?>