From c6f619b0dc4269da41cc35b30ae4a7e5b2159fb1 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Fri, 3 Dec 2010 14:16:35 +1300 Subject: [PATCH] BUGFIX: removed requirement of settings --- code/Commenting.php | 8 ++++- code/controllers/CommentInterface.php | 45 +-------------------------- 2 files changed, 8 insertions(+), 45 deletions(-) diff --git a/code/Commenting.php b/code/Commenting.php index 2d8a638..b073f26 100644 --- a/code/Commenting.php +++ b/code/Commenting.php @@ -36,8 +36,14 @@ class Commenting { * @param string classname to add commenting to * @param array $setting Settings. See {@link self::$default_config} for * available settings + * + * @throws InvalidArgumentException */ - public static function add($class, array $settings) { + public static function add($class, $settings = false) { + if($settings && !is_array($settings)) { + throw new InvalidArgumentException('$settings needs to be an array or null', E_USER_ERROR); + } + self::$enabled_classes[$class] = $settings; Object::add_extension($class, 'CommentsExtension'); diff --git a/code/controllers/CommentInterface.php b/code/controllers/CommentInterface.php index 657e7cc..2c1510d 100755 --- a/code/controllers/CommentInterface.php +++ b/code/controllers/CommentInterface.php @@ -65,27 +65,7 @@ class CommentInterface extends RequestHandler { return $form; } - - function Comments() { - // Comment limits - $limit = array(); - $limit['start'] = isset($_GET['commentStart']) ? (int)$_GET['commentStart'] : 0; - $limit['limit'] = Comment::$comments_per_page; - - $spamfilter = isset($_GET['showspam']) ? '' : "AND \"IsSpam\" = 0"; - $unmoderatedfilter = Permission::check('CMS_ACCESS_CommentAdmin') ? '' : "AND \"NeedsModeration\" = 0"; - $order = self::$order_comments_by; - $comments = DataObject::get("Comment", "\"ParentID\" = '" . Convert::raw2sql($this->page->ID) . "' $spamfilter $unmoderatedfilter", $order, "", $limit); - - if(is_null($comments)) { - return; - } - - // This allows us to use the normal 'start' GET variables as well (In the weird circumstance where you have paginated comments AND something else paginated) - $comments->setPaginationGetVar('commentStart'); - - return $comments; - } + function CommentRssLink() { return Director::absoluteBaseURL() . "Comment/rss?pageid=" . $this->page->ID; @@ -100,27 +80,4 @@ class CommentInterface extends RequestHandler { return Director::absoluteBaseURL() . "Comment/deleteallcomments?pageid=" . $this->page->ID; } } - -} - -/** - * @package comments - */ -class CommentInterface_Form extends Form { - -} - -/** - * @package comments - */ -class CommentInterface_Controller extends ContentController { - function __construct() { - parent::__construct(null); - } - - function newspamquestion() { - if(Director::is_ajax()) { - echo Convert::raw2xml(sprintf(_t('CommentInterface_Controller.SPAMQUESTION', "Spam protection question: %s"),MathSpamProtection::getMathQuestion())); - } - } } \ No newline at end of file