2007-09-07 00:33:58 +02:00
|
|
|
<?php
|
2009-01-20 05:01:45 +01:00
|
|
|
/**
|
|
|
|
* Blog Management Widget
|
|
|
|
* @package blog
|
|
|
|
*/
|
2009-05-21 06:07:53 +02:00
|
|
|
class BlogManagementWidget extends Widget implements PermissionProvider {
|
2007-09-07 00:33:58 +02:00
|
|
|
static $db = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $has_one = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $has_many = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $many_many = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $belongs_many_many = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2009-01-20 05:01:45 +01:00
|
|
|
static $defaults = array();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
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.";
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
function CommentText() {
|
2010-03-11 21:47:59 +01:00
|
|
|
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
|
2007-09-07 00:33:58 +02:00
|
|
|
if($unmoderatedcount == 1) {
|
2007-12-18 02:41:51 +01:00
|
|
|
return _t("BlogManagementWidget.UNM1", "You have 1 unmoderated comment");
|
2007-09-07 00:33:58 +02:00
|
|
|
} else if($unmoderatedcount > 1) {
|
2007-12-18 02:41:51 +01:00
|
|
|
return sprintf(_t("BlogManagementWidget.UNMM", "You have %i unmoderated comments"), $unmoderatedcount);
|
2007-09-07 00:33:58 +02:00
|
|
|
} else {
|
2007-12-18 02:41:51 +01:00
|
|
|
return _t("BlogManagementWidget.COMADM", "Comment administration");
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
|
|
|
}
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
function CommentLink() {
|
2009-05-27 03:26:34 +02:00
|
|
|
if(!Permission::check('BLOGMANAGEMENT')) {
|
2009-02-07 03:19:27 +01:00
|
|
|
return false;
|
|
|
|
}
|
2010-03-11 21:47:59 +01:00
|
|
|
$unmoderatedcount = DB::query("SELECT COUNT(*) FROM \"PageComment\" WHERE \"NeedsModeration\"=1")->value();
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
if($unmoderatedcount > 0) {
|
|
|
|
return "admin/comments/unmoderated";
|
|
|
|
} else {
|
|
|
|
return "admin/comments";
|
|
|
|
}
|
|
|
|
}
|
2009-05-21 06:07:53 +02:00
|
|
|
|
|
|
|
function providePermissions() {
|
2009-05-27 03:26:34 +02:00
|
|
|
return array("BLOGMANAGEMENT" => "Blog management");
|
2009-05-21 06:07:53 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
function WidgetHolder() {
|
2009-05-27 03:26:34 +02:00
|
|
|
if(Permission::check("BLOGMANAGEMENT")) {
|
2009-05-21 06:07:53 +02:00
|
|
|
return $this->renderWith("WidgetHolder");
|
|
|
|
}
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
function PostLink() {
|
2009-05-01 00:05:54 +02:00
|
|
|
$container = BlogTree::current();
|
|
|
|
if ($container) return $container->Link('post');
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
2009-05-21 06:07:53 +02:00
|
|
|
|
2007-09-07 00:33:58 +02:00
|
|
|
}
|
2009-11-30 09:18:56 +01:00
|
|
|
?>
|