Core Boxx – Comments Module

This is a dreadfully simple comments module for Core Boxx – Add comments to a post, video, image, product, or whatever you want…

 

TABLE OF CONTENTS

Download & Notes Quick Reference

 

 

DOWNLOAD & NOTES

First, here are the download links and a quick “setup guide” for the impatient folks who don’t have the patience to read through everything.

 

DOWNLOAD LINKS

Download Core Boxx Comments Module | GitHubSource Forge

 

LICENSE

Core Boxx is released under the MIT License. You are free to use it for your own personal and commercial projects, modify it as you see fit. On the condition that there the software is provided “as-is”. There are no warranties provided and “no strings attached”. Code Boxx and the authors are not liable for any claims, damages, or liabilities.

 

 

INSTALLATION & REQUIREMENTS

  • Download and set up the “main Core Boxx” if you have not already done so.
  • Import lib/SQL-comments.sql into your database.
  • The user module must be installed.

 

MORE DEVELOPMENT NOTES

  • This module will assume that comments are only open for registered users.
  • If you want to open up for the public… Some form of identification needs still need to be in place – Use the PHP session ID as the “user ID”, or generate a random ID in the cookie.
  • Otherwise, remember to add your own “user needs to be signed in first” protection for all the library functions.
  • Also, you decide if users can update and delete their own comments.

 

QUICK REFERENCE

This section is a quick walkthrough of the general module structures.

 

COMMENTS TABLE

Field Description
comment_id Primary key, auto-increment.
user_id The user that made the comment.
id The ID of whatever you want to attach comments to – Post, product, image, video, etc…
timestamp The time when the comment is posted.
message The comment itself.

 

COMMENTS LIBRARY FUNCTIONS

save($uid, $id, $message, $cid)

Save a comment.

  • $uid User ID.
  • $id The post/product/video/image ID.
  • $message Comment message itself.
  • $cid Comment ID – If left blank, will add a new entry, if not, update this entry.
echo $_CORE->Comments->save(1, 999, "Testing")
 ? "OK" : $_CORE->error;
del($cid)

Deletes the specified comment ID.

echo $_CORE->Comments->del(999)
 ? "OK" : $_CORE->error}
count($id)

Count the total number of comments for the given ID.

$entries = $_CORE->Comments->count(999);
get($cid)

Get all comments for the specified ID.

$comments = $_CORE->Comments->get(999);

 

 

COMMENTS API FUNCTIONS

Accessible at http://yoursite.com/api/comments/REQUEST/. These are pretty much a replica of the above library functions, except in REST API format. Feel free to delete api/API-comments.php if you don’t intend to integrate an API.

api/comments/save/

Save a comment.

  • $_POST['uid'] – INT, the user ID.
  • $_POST['id'] – INT, the post/product/video/image ID.
  • $_POST['message'] – STRING, comment.
  • $_POST['cid'] – INT, comment ID. Only if updating a comment.
api/comments/del/

Delete a comment.

  • $_POST['cid'] – INT, the comment ID.
api/comments/get/

Get comments.

  • $_POST['id'] – INT, “item ID”.

Leave a Comment

Your email address will not be published. Required fields are marked *