Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

FEATURE: added delete comment functionality. MINOR: added documentation

  • Loading branch information...
commit d9580ed600148cfdb1444423306314c3734b0d95 1 parent 7bb952b
@wilr wilr authored
View
29 code/controllers/CommentingController.php
@@ -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 @@ public function Link($action = "") {
}
/**
+ * 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() {
View
4 code/dataobjects/Comment.php
@@ -55,7 +55,7 @@ public function requireDefaultRecords() {
}
}
- DB::alterationMessage("Migrated PageComment to Comment""changed");
+ DB::alterationMessage("Migrated PageComment to Comment","changed");
DB::getConn()->dontRequireTable('PageComment');
}
}
@@ -100,6 +100,8 @@ function fieldLabels($includerelations = true) {
* @return DataObject
*/
public function getParent() {
+ if(!$this->BaseClass) $this->BaseClass = "SiteTree";
+
return DataObject::get_by_id($this->BaseClass, $this->ParentID);
}
View
1  docs/en/Configuration.md
@@ -0,0 +1 @@
+## Configuration
View
19 docs/en/Installing.md
@@ -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*
View
0  docs/en/Upgrading.md
No changes.
View
15 javascript/CommentsInterface.js
@@ -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()) {
Please sign in to comment.
Something went wrong with that request. Please try again.