mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX show name of members in summary tables
Anonymous comments (posted by the public at large) must have a name and an email address associated with them. On the other hand, a logged in user will have the `Member` record details used for this information, via the Author relationship. However the summary fields do not allow for this, and only reference Name and Email on the Comment model directly, so any comment posted by a logged in member has no data for name and email displayed in the various GridFields in the CMS for administering comments (either per page, or in the global ModelAdmin). To recitfy this we can change the summary fields to use getter methods that will return the Comment model info, or fall back to the Author associated Member record if Name and Email are unset on the Comment.
This commit is contained in:
parent
4ee9720081
commit
dc1f8622e0
@ -125,8 +125,8 @@ class Comment extends DataObject
|
|||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
private static $summary_fields = array(
|
private static $summary_fields = array(
|
||||||
'Name' => 'Submitted By',
|
'getAuthorName' => 'Submitted By',
|
||||||
'Email' => 'Email',
|
'getAuthorEmail' => 'Email',
|
||||||
'Comment.LimitWordCount' => 'Comment',
|
'Comment.LimitWordCount' => 'Comment',
|
||||||
'Created' => 'Date Posted',
|
'Created' => 'Date Posted',
|
||||||
'Parent.Title' => 'Post',
|
'Parent.Title' => 'Post',
|
||||||
@ -450,6 +450,20 @@ class Comment extends DataObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the comment authors email address
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAuthorEmail()
|
||||||
|
{
|
||||||
|
if ($this->Email) {
|
||||||
|
return $this->Email;
|
||||||
|
} elseif ($author = $this->Author()) {
|
||||||
|
return $author->Email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a secure admin-action link authorised for the specified member
|
* Generate a secure admin-action link authorised for the specified member
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user