mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FEATURE: added delete comment functionality. MINOR: added documentation
This commit is contained in:
parent
7bb952b826
commit
d9580ed600
code
docs/en
javascript
@ -6,6 +6,12 @@
|
||||
|
||||
class CommentingController extends Controller {
|
||||
|
||||
static $allowed_actions = array(
|
||||
'delete',
|
||||
'CommentsForm',
|
||||
'doPostCommentz'
|
||||
);
|
||||
|
||||
private $baseClass = "";
|
||||
private $ownerRecord = "";
|
||||
private $ownerController = "";
|
||||
@ -42,6 +48,29 @@ class CommentingController extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the delete task for deleting {@link Comment}.
|
||||
*
|
||||
* /delete/$ID deletes the $ID comment
|
||||
*/
|
||||
public function delete() {
|
||||
$id = isset($this->urlParams['ID']) ? $this->urlParams['ID'] : false;
|
||||
|
||||
if($id) {
|
||||
$comment = DataObject::get_by_id('Comment', $id);
|
||||
|
||||
if($comment && $comment->canDelete()) {
|
||||
$comment->delete();
|
||||
|
||||
return ($this->isAjax()) ? true : $this->redirectBack();
|
||||
}
|
||||
}
|
||||
|
||||
return ($this->isAjax()) ? false : $this->httpError('404');
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a comment form
|
||||
*
|
||||
* @return Form
|
||||
*/
|
||||
function CommentsForm() {
|
||||
|
@ -55,7 +55,7 @@ class Comment extends DataObject {
|
||||
}
|
||||
}
|
||||
|
||||
DB::alterationMessage("Migrated PageComment to Comment""changed");
|
||||
DB::alterationMessage("Migrated PageComment to Comment","changed");
|
||||
DB::getConn()->dontRequireTable('PageComment');
|
||||
}
|
||||
}
|
||||
@ -100,6 +100,8 @@ class Comment extends DataObject {
|
||||
* @return DataObject
|
||||
*/
|
||||
public function getParent() {
|
||||
if(!$this->BaseClass) $this->BaseClass = "SiteTree";
|
||||
|
||||
return DataObject::get_by_id($this->BaseClass, $this->ParentID);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
## Configuration
|
@ -0,0 +1,19 @@
|
||||
# Installation
|
||||
|
||||
To begin the installation first download the module from online. You can find what version
|
||||
you require for your SilverStripe installation on the silverstripe.org website.
|
||||
|
||||
After you have finished downloading the file, extract the downloaded file to your sites root
|
||||
folder and ensure the name of the module is `comments`.
|
||||
|
||||
Run a database rebuild by visiting *http://yoursite.com/dev/build*. This will add the required database
|
||||
columns and tables for the module to function.
|
||||
|
||||
If you previously had SilverStripe 2.4 installed then you will also need to run the migration script
|
||||
provided. More information on this is in the next section
|
||||
|
||||
## Migrating old comments
|
||||
|
||||
This module replaces the built in commenting system available in versions up to SilverStripe 2.4. To migrate from
|
||||
that you need to run the `InitialCommentMigration` task. You can do this via sake or via a web browser by visiting
|
||||
*http://yoursite.com/dev/tasks/InitialCommentMigration*
|
@ -5,11 +5,22 @@
|
||||
(function($) {
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
// @todo finish
|
||||
/**
|
||||
* Please note this functionality has not been finished
|
||||
* this file is not loaded on your site. It is simply here
|
||||
* to provide a starting point for someone to take it over
|
||||
*
|
||||
* @todo finish
|
||||
*/
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('.comments-holder-container form').submit(function (e) {
|
||||
|
||||
if($('.comment-holder form [name=Name]').val() && $('.comment-holder form [name=Comment]').val()) {
|
||||
|
Loading…
Reference in New Issue
Block a user