Comments module

This chapter describes

1 Introduction

Comments module allows users to write comments to some content.

The comment widget can be added to all content objects (except binary files). It lists all comments in a chronological order (newest on top) for this content object. The comment widget is linked to an unique content object ID (for example page123123).

For each comment widget it is possible to define the following:

  • are the comments moderated before displaying or are the comments displayed without moderation (administrator and super administrator will see all comments and the comments not published yet will be marked)
  • who is the administrator of these comments for a single content object (approve/delete) (defined in the module via a parameter – email, does not follow the normal permissions functionality). When the module is added in the CMS in a content page, then we can automatically add the email of the creator of a content page and therefore allow a content editor to moderator comments.
  • can users comment anonymously or are only logged in users allowed to comment
  • if widget allow post anonymous comments, it possible to set requirement fields for it
  • send email to administrator on new comments (yes/no)
  • threaded commenting allowed (only 1 level possible) (yes/no)

There is an administrator role in Gentics Portal.Node PHP which defines who is the super administrator for all comment widgets (approve/delete).

After each comment posted a mail will be sent to the moderator of the content (if configured). In this mail the moderator can read the comment, can delete it by clicking a link or approve it.

Users can remove their own comments (but they are only deactivated and still shown to administrators). Administrators can remove all comments (they are not deleted, but deactivated).

1.1 CommentsWidget

Example:


<?php $this->widget('comments.widgets.CommentsWidget',
    array(
        'contentId' => 12300123,
        'allowAnonymous' => true,
        'requiredForAnonymous' => 'firstname,email',
        'moderatorEmail' => 'someone@gmail.com',
        'dontNeedApprove' => false,
        'oneLevelReply' => true
    )
) ?>

Parameters:

  • contentId – id of content;
  • allowAnonymous – not logged user can write a comment;
  • requiredForAnonymous – the names of the required fields for anonymous comment delimited by a comma. If this parameter is not passed, all of the fields (firstname,lastname,email) are require. If all of them are not required need to pass false or empty string;
  • moderatorEmail – email of the moderator of this comment;
  • dontNeedApprove – do not need to approve comment before it appear on the page;
  • oneLevelReply – threaded commenting allowed;

2 Structure

Comments module is placed in folder <portal>/common/modules/comments.

Structure is the same as for other modules.

The only new thing is that the mail templates which is used for notifying admins/users is placed in folder ../views/mail_templates :

  • comment_created_admin.php – Comment created to admin/moderator
  • comment_created_user.php – Comment created to user (for notification)
  • comment_deleted.php – Comment deleted (notification to user)
  • comment_reply.php – Reply to comment (notification to user)

3 Comments management

Comment can be in one of three states:

  • Approved – Showed to all users
  • Not approved – Showed only to administrator/moderator
  • Deleted – Not showed to anyone, but stored in database

Access to delete or approve comments is controlled in two ways:

  • using RBAC task named “manageComments”
  • specifying moderator email in comment widget

3.1 RBAC task “manageComments”

Super administrator “Task” in RBAC model is named ‘manageComments’. To assign this “Task”, go to <portal>/rights/assignment. Then select ‘manageComments’ from ‘Add Child’ dropdown list and click ‘Add’ button.

3.2 Moderator email

Who is the moderator of these comments for a single content object (can approve/delete) (defined in the module via a parameter – email.

When the widget is added in the CMS in a content page, then we can automatically add the email of the creator of a content page (<node page.creator.email>).