mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
BUGFIX: Fixed Links to Moderate Comments from the CMS and front end. MINOR: removed complextable functions which no longer get called, moved logic to the PageComment Class (from r86325)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@90853 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
966c869cd4
commit
8adc6757c2
@ -50,87 +50,6 @@ class CommentTableField extends ComplexTableField {
|
||||
return $output;
|
||||
}
|
||||
|
||||
function spam() {
|
||||
if(!Permission::check('ADMIN')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->methodName = "spam";
|
||||
|
||||
$childId = Convert::raw2sql($_REQUEST['ctf']['childID']);
|
||||
|
||||
if (is_numeric($childId)) {
|
||||
$comment = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($comment) {
|
||||
$comment->IsSpam = true;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitSpam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ham() {
|
||||
if(!Permission::check('ADMIN')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->methodName = "ham";
|
||||
|
||||
$childId = Convert::raw2sql($_REQUEST['ctf']['childID']);
|
||||
|
||||
if (is_numeric($childId)) {
|
||||
$comment = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($comment) {
|
||||
$comment->IsSpam = false;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if(SSAkismet::isEnabled()) {
|
||||
try {
|
||||
$akismet = new SSAkismet();
|
||||
$akismet->setCommentAuthor($comment->getField('Name'));
|
||||
$akismet->setCommentContent($comment->getField('Comment'));
|
||||
|
||||
$akismet->submitHam();
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function approve() {
|
||||
if(!Permission::check('ADMIN')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->methodName = "accept";
|
||||
|
||||
$childId = Convert::raw2sql($_REQUEST['ctf']['childID']);
|
||||
|
||||
if(is_numeric($childId)) {
|
||||
$childObject = DataObject::get_by_id($this->sourceClass, $childId);
|
||||
if($childObject) {
|
||||
$childObject->IsSpam = false;
|
||||
$childObject->NeedsModeration = false;
|
||||
$childObject->write();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function HasSpamButton() {
|
||||
return $this->mode == 'approved' || $this->mode == 'unmoderated';
|
||||
}
|
||||
@ -180,18 +99,6 @@ class CommentTableField_Item extends ComplexTableField_Item {
|
||||
function HasHamButton() {
|
||||
return $this->parent()->HasHamButton();
|
||||
}
|
||||
|
||||
function SpamLink() {
|
||||
return Controller::join_links($this->Link(), "?methodName=spam");
|
||||
}
|
||||
|
||||
function HamLink() {
|
||||
return Controller::join_links($this->Link(), "?methodName=ham");
|
||||
}
|
||||
|
||||
function ApproveLink() {
|
||||
return Controller::join_links($this->Link(), "?methodName=approve");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -59,9 +59,7 @@ class PageComment extends DataObject {
|
||||
}
|
||||
|
||||
function DeleteLink() {
|
||||
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||
return "PageComment/deletecomment/$this->ID";
|
||||
}
|
||||
return (Permission::check('CMS_ACCESS_CMSMain')) ? "PageComment_Controller/deletecomment/$this->ID" : false;
|
||||
}
|
||||
|
||||
function CommentTextWithLinks() {
|
||||
@ -71,22 +69,15 @@ class PageComment extends DataObject {
|
||||
}
|
||||
|
||||
function SpamLink() {
|
||||
$member = Member::currentUser();
|
||||
if(Permission::check('CMS_ACCESS_CMSMain') && !$this->getField('IsSpam')) {
|
||||
return "PageComment/reportspam/$this->ID";
|
||||
}
|
||||
return (Permission::check('CMS_ACCESS_CMSMain') && !$this->IsSpam) ? "PageComment_Controller/reportspam/$this->ID" : false;
|
||||
}
|
||||
|
||||
function HamLink() {
|
||||
if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
|
||||
return "PageComment/reportham/$this->ID";
|
||||
}
|
||||
return (Permission::check('CMS_ACCESS_CMSMain') && $this->IsSpam) ? "PageComment_Controller/reportham/$this->ID" : false;
|
||||
}
|
||||
|
||||
function ApproveLink() {
|
||||
if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('NeedsModeration')) {
|
||||
return "PageComment/approve/$this->ID";
|
||||
}
|
||||
return (Permission::check('CMS_ACCESS_CMSMain') && $this->NeedsModeration) ? "PageComment_Controller/approve/$this->ID" : false;
|
||||
}
|
||||
|
||||
function SpamClass() {
|
||||
@ -203,22 +194,24 @@ class PageComment_Controller extends Controller {
|
||||
function approve() {
|
||||
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
if($comment) {
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
|
||||
// @todo Report to spamprotecter this is true
|
||||
// @todo Report to spamprotecter this is true
|
||||
|
||||
if(Director::is_ajax()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
if(Director::is_ajax()) {
|
||||
echo $comment->renderWith('PageCommentInterface_singlecomment');
|
||||
} else {
|
||||
Director::redirectBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function reportspam() {
|
||||
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
|
||||
|
||||
if($comment) {
|
||||
// check they have access
|
||||
if(Permission::check('CMS_ACCESS_CMSMain')) {
|
||||
@ -226,8 +219,6 @@ class PageComment_Controller extends Controller {
|
||||
// if spam protection module exists
|
||||
if(class_exists('SpamProtectorManager')) {
|
||||
SpamProtectorManager::send_feedback($comment, 'spam');
|
||||
$comment->setField('IsSpam', true);
|
||||
$comment->write();
|
||||
}
|
||||
|
||||
// If Akismet is enabled
|
||||
@ -240,12 +231,11 @@ class PageComment_Controller extends Controller {
|
||||
} catch (Exception $e) {
|
||||
// Akismet didn't work, most likely the service is down.
|
||||
}
|
||||
|
||||
if(SSAkismet::getSaveSpam()) {
|
||||
$comment->setField('IsSpam', true);
|
||||
$comment->write();
|
||||
}
|
||||
}
|
||||
|
||||
$comment->IsSpam = true;
|
||||
$comment->NeedsModeration = false;
|
||||
$comment->write();
|
||||
}
|
||||
}
|
||||
if(Director::is_ajax()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user