mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge branch '3.1'
This commit is contained in:
commit
04a5257e40
10
.travis.yml
10
.travis.yml
@ -4,19 +4,19 @@ dist: trusty
|
||||
matrix:
|
||||
include:
|
||||
- php: 5.6
|
||||
env: DB=MYSQL PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.0.x-dev PHPCS_TEST=1 PHPUNIT_TEST=1
|
||||
- php: 7.0
|
||||
env: DB=PGSQL PHPUNIT_TEST=1
|
||||
env: DB=PGSQL INSTALLER_VERSION=4.1.x-dev PHPUNIT_TEST=1
|
||||
- php: 7.1
|
||||
env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.2.x-dev PHPUNIT_COVERAGE_TEST=1
|
||||
- php: 7.2
|
||||
env: DB=MYSQL PHPUNIT_TEST=1
|
||||
env: DB=MYSQL INSTALLER_VERSION=4.x-dev PHPUNIT_TEST=1
|
||||
|
||||
before_script:
|
||||
- phpenv rehash
|
||||
- phpenv config-rm xdebug.ini
|
||||
- composer validate
|
||||
- composer require silverstripe/installer:4.0.x-dev ezyang/htmlpurifier:* --no-update
|
||||
- composer require silverstripe/installer:"$INSTALLER_VERSION" ezyang/htmlpurifier:* --no-update
|
||||
- if [[ $DB == PGSQL ]]; then composer require --no-update silverstripe/postgresql:2.0.x-dev; fi
|
||||
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
|
||||
|
||||
|
@ -6,31 +6,33 @@
|
||||
/**
|
||||
* Enable form validation
|
||||
*/
|
||||
$('.comments-holder-container form').validate({
|
||||
$('.comments-holder-container form').each(function() {
|
||||
$(this).validate({
|
||||
|
||||
// Ignore hidden elements in this form
|
||||
ignore: ':hidden',
|
||||
// Ignore hidden elements in this form
|
||||
ignore: ':hidden',
|
||||
|
||||
// Use default 'required' for error labels
|
||||
errorClass: "required",
|
||||
// Use default 'required' for error labels
|
||||
errorClass: "required",
|
||||
|
||||
// Use span instead of labels
|
||||
errorElement: "span",
|
||||
// Use span instead of labels
|
||||
errorElement: "span",
|
||||
|
||||
// On error, scroll to the invalid element
|
||||
invalidHandler : function(form, validator){
|
||||
$('html, body').animate({
|
||||
scrollTop: $(validator.errorList[0].element).offset().top - 30
|
||||
}, 200);
|
||||
},
|
||||
// On error, scroll to the invalid element
|
||||
invalidHandler : function(form, validator){
|
||||
$('html, body').animate({
|
||||
scrollTop: $(validator.errorList[0].element).offset().top - 30
|
||||
}, 200);
|
||||
},
|
||||
|
||||
// Ensure any new error message has the correct class and placement
|
||||
errorPlacement: function(error, element) {
|
||||
error
|
||||
.addClass('message')
|
||||
.insertAfter(element);
|
||||
}
|
||||
});
|
||||
// Ensure any new error message has the correct class and placement
|
||||
errorPlacement: function(error, element) {
|
||||
error
|
||||
.addClass('message')
|
||||
.insertAfter(element);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Hide comment reply forms by default (unless visiting via permalink)
|
||||
|
@ -765,6 +765,20 @@ class Comment extends DataObject
|
||||
return $notSpam && (!$maxLevel || $this->Depth < $maxLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy for checking whether the has permission to comment on the comment parent.
|
||||
*
|
||||
* @param Member $member Member to check
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canPostComment($member = null)
|
||||
{
|
||||
return $this->Parent()
|
||||
&& $this->Parent()->exists()
|
||||
&& $this->Parent()->canPostComment($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of all replies
|
||||
*
|
||||
|
@ -8,13 +8,13 @@ use SilverStripe\Comments\Admin\CommentsGridFieldAction;
|
||||
use SilverStripe\Comments\Admin\CommentsGridFieldConfig;
|
||||
use SilverStripe\Comments\Model\Comment;
|
||||
use SilverStripe\Comments\Tests\Stubs\CommentableItem;
|
||||
use SilverStripe\Comments\Tests\Stubs\Team;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -25,6 +25,7 @@ class CommentsGridFieldActionTest extends SapphireTest
|
||||
|
||||
protected static $extra_dataobjects = [
|
||||
CommentableItem::class,
|
||||
Team::class,
|
||||
];
|
||||
|
||||
/** @var ArrayList */
|
||||
|
19
tests/Stubs/Cheerleader.php
Normal file
19
tests/Stubs/Cheerleader.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Comments\Tests\Stubs;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Cheerleader extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'CommentsTest_Cheerleader';
|
||||
|
||||
private static $db = [
|
||||
'Name' => 'Varchar',
|
||||
];
|
||||
|
||||
private static $has_one = [
|
||||
'Team' => Team::class,
|
||||
];
|
||||
}
|
24
tests/Stubs/Player.php
Normal file
24
tests/Stubs/Player.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Comments\Tests\Stubs;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
|
||||
/**
|
||||
* @method ManyManyList Teams()
|
||||
*/
|
||||
class Player extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'CommentsTest_Player';
|
||||
|
||||
private static $db = array(
|
||||
'Name' => 'Varchar',
|
||||
'Email' => 'Varchar',
|
||||
);
|
||||
|
||||
private static $belongs_many_many = [
|
||||
'Teams' => Team::class,
|
||||
];
|
||||
}
|
35
tests/Stubs/Team.php
Normal file
35
tests/Stubs/Team.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Comments\Tests\Stubs;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class Team extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'CommentsTest_Team';
|
||||
|
||||
private static $db = array(
|
||||
'Name' => 'Varchar',
|
||||
'City' => 'Varchar',
|
||||
);
|
||||
|
||||
private static $many_many = [
|
||||
'Players' => Player::class,
|
||||
];
|
||||
|
||||
private static $has_many = [
|
||||
'Cheerleaders' => Cheerleader::class,
|
||||
];
|
||||
|
||||
private static $searchable_fields = [
|
||||
'Name',
|
||||
'City',
|
||||
'Cheerleaders.Name',
|
||||
];
|
||||
|
||||
public function canView($member = null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user