2017-01-16 20:57:37 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Comments\Tests\Stubs;
|
|
|
|
|
|
|
|
use SilverStripe\Comments\Extensions\CommentsExtension;
|
|
|
|
use SilverStripe\Control\Director;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
use SilverStripe\Security\Member;
|
|
|
|
use SilverStripe\Security\Permission;
|
2022-11-28 21:35:55 +01:00
|
|
|
use SilverStripe\Security\Security;
|
2017-01-16 20:57:37 +01:00
|
|
|
|
|
|
|
class CommentableItem extends DataObject implements TestOnly
|
|
|
|
{
|
|
|
|
private static $db = array(
|
|
|
|
'Title' => 'Varchar'
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $extensions = array(
|
|
|
|
CommentsExtension::class
|
|
|
|
);
|
|
|
|
|
2017-09-14 00:28:29 +02:00
|
|
|
private static $table_name = 'CommentableItem';
|
|
|
|
|
2017-01-16 20:57:37 +01:00
|
|
|
public function RelativeLink()
|
|
|
|
{
|
|
|
|
return 'CommentableItemController';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canView($member = null)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is needed for canModerateComments
|
|
|
|
public function canEdit($member = null)
|
|
|
|
{
|
|
|
|
if ($member instanceof Member) {
|
|
|
|
$memberID = $member->ID;
|
|
|
|
} elseif (is_numeric($member)) {
|
|
|
|
$memberID = $member;
|
|
|
|
} else {
|
2022-11-28 21:35:55 +01:00
|
|
|
$currentUser = Security::getCurrentUser();
|
|
|
|
$memberID = $currentUser ? $currentUser->ID : 0;
|
2017-01-16 20:57:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($memberID && Permission::checkMember($memberID, array('ADMIN', 'CMS_ACCESS_CommentAdmin'))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function Link()
|
|
|
|
{
|
|
|
|
return $this->RelativeLink();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function AbsoluteLink()
|
|
|
|
{
|
|
|
|
return Director::absoluteURL($this->RelativeLink());
|
|
|
|
}
|
|
|
|
}
|