pcreportcontent

Provides a reusable widget enabling users to 'reporting inappropriate content'
5 followers

PcReportContent

General

This extension is a simple extension that provides a widget that enables registered users to report incidents of "inappropriate content" in the site. This is highly useful for sites that are rich with user-generated-content.

Features

  • Supports multiple instances of widget on the same page.
  • Enables reporting on unknown (=dynamic) type of content. This implies some requirements as well (see below).
  • Flexible 'moderator email address' can be configured per-view file (with system wide default).
  • Reports are sent via email. No DB recording, etc.
  • Messages to user (not report email sent) are i18n-ready out of the box.
  • Utilizes cache for some operations, for better performance (via CActiveRecord.cache()).

Requirements

  • Tested with Yii v1.1.10. Donno about other versions of Yii.
  • Only registered users can report inappropriate content. When guest tries to send a report he'll get a message asking him to login or register.
  • This extension uses 'mail' extension for actual email sending. It needs to be installed and configured as 'mail' application component.
  • Models being reported on assumed to be extending PcBaseArModel class provided by PcBaseArModel extension . At minimum, if you do not wish to use that base class, implement a static method named getCreatorRelationName(). See the mentioned extension for more info on this requirement (look at the documentation of the mentioned method - abstract method on that class).
  • For every model that you need to enable 'report inappropriate content' on, its controller must declare an external action that is defined by this extension. This is so in order to enable processing of such reports and to do it all via this widget - encapsulating all funcationality within (almost all in the widget - but all in the extension). This is done using the widget as an action provider. Since that by default (yiic webapp...), the controllers of the webapp are extending Controller class, typically found in /protected/components, I recommend putting the following into this class (Controller):
public function actions() {
  return array(
    'report.' => 'ext.PcReportContent.PcReportContent',
  );
}
  • When guest users try to make a report, they get a message asking them to either login or register. It uses two system parameters to do so:
    • Yii::app()->params['registrationRoute']
    • Yii::app()->user->loginUrl[0]
  • Please let me know if something is missing.

Installation and Usage

Unpack this extension into /protected/extensions. Eventually you should have /protected/extensions/PcReportContent/PcReportContent.php (and the rest of the package in the exact tree given in the downloadable package).

Make sure the requirements above have been satisfied.

main.php

Edit this config file and add the following:

'import' => array(
  //...
  'ext.PcReportContent.PcReportContent',
  //...
);

If you use clean URLs with the CUrlManager, you'll might need to add 2 rules to main.php 'rules' config param passed to CUrlManager (I needed to, but it depends on your other rules), along the lines of:

// Report inappropriate content extension. do not move these line below. keep them above others or bugs might occur.
'<module:\w+>/<controller:\w+>/report.ProcessReportContent' => '<module>/<controller>/report.ProcessReportContent',
                '<controller:\w+>/report.ProcessReportContent' => '<controller>/report.ProcessReportContent',

Edit the view file in which you want to have this widget that enables users to report inappropriate content. Typically, this would be some view.php file for whatever model:

$this->widget('PcReportContent', array('modelClassId' => $model->id, 'modelClassName' => get_class($model), 'moderatorEmailAddress' => 'moderator@yourdomain.com'));

Where: - $model is assumed to be the model object passed to the view file for rendering. - moderatorEmailAddress is an optional parameter that allows moderator email address per view file.

Configuration parameters:

When instantiating the widgets (in the view file):

The following options are the supported config parameters that can be passed to $this->widget() when this widget is being intantiated:

  1. modelClassName: Mandatory. The class name of the model this widget refers to.
  2. modelClassId: Mandatory. The primary key, numerical id, of the model this widget refers to.
  3. maxReportLength: Optional. The max report length. Reports longer than this value will be trimmed to this length when the report is sent to the moderator.
  4. moderatorEmailAddress. Optional. As mentioned above, this specifies the moderator email address for which the reports of this specific widget instantiation should be sent to.

In main.php

The following are system wide parameters that can be controlled/set in main.php config file. All of them are optional:

  1. PcReportContentForceModeratorAddress: boolean. Whether each instance of PcReportContent should specify a moderator email address (or explode) or not.
  2. PcReportContentDefaultModeratorAddress: string. In case PcReportContentForceModeratorAddress was set to false, and no specification of moderatorEmailAddress was set on widget instance, then this is the email address that is used. If none exists, Yii::app()->params['adminEmail'] is used as last resort.

TODOs

Resources

Be the first person to leave a comment

Please to leave your comment.

Create extension