mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
BUGFIX: removed requirement of settings
This commit is contained in:
parent
f0b544e50a
commit
c6f619b0dc
@ -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');
|
||||
|
@ -66,26 +66,6 @@ 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()));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user