pcreportcontent Provides a reusable widget enabling users to 'reporting inappropriate content'

  1. PcReportContent
  2. General
  3. Features
  4. Requirements
  5. Design
  6. Installation and Configuration
  7. Usage
  8. Resources



This extension enables users to report about inappropriate content they find on a website. It is especially useful and relevant for websites that are rich with user-generated-content.


  • Only authenticated users can report.
  • Enables multiple reports from the same page, but in resource saving mode (e.g., reporting on 'comments' which typically exists in masses on the same page).
  • Reports are sent via email. No DB recording usage.
  • Now (v1.0) with much better design, to improve maintenance.


  • This extension uses the following extensions and to some degree depend on them:
    • PcBaseArModel. This extension sends in its email report the username and user id of the author that created the content that is being reported (along with the details of the author of the report itself). For that, it assumes that the content being reported extends PcBaseArModel, which have special methods in it for fetching the 'author' user by the relations system. The only method that is used is getCreatorRelationName(). You can either implement it directly in your 'reported' classes, or completely update this extension to avoid getting this information and adding it to the emailed report. On that case update PcReportContentModule.reportContent() method.
    • Mail. As mentioned earlier, the reports are being passed by email to some administrative user (see configuration below). For that this module uses this extension. If you wish to do other than email using this extension the only location you'll need to edit is PcReportContentModule.reportContent().


With the arrival of v1.0 there was a major design update. Instead of a widget that also acts as an action provider, this extension is now a Yii module and provides an extension widget - for rendering the form, and only for that. Also, there's a controller for processing AJAX calls from clients side with actual reports, and the main logic lies in the module class. IMHO, that's how extensions are to be typically laid out. Widgets are views and should only render themselves, present stuff. They should not contain logic for processing or serving directly client side requests.

Installation and Configuration

  • This extension is a module (since v1.0). Please unpack it into /protected/modules (typically, but module files could be anywhere you'd like).
  • Edit main.php config file, update the import and modules sections, as demonstrated below
'import' => array(
'modules' => array(
  // ...
  'reportContent' => array(
    'class' => 'application.modules.PcReportContent.PcReportContentModule',
    'targetEmail' => 'address@domain.com', // this can be left out. In this case, default = 'admin@' . Yii::app()->request->serverName
  // ...


In the view file, where you want the compact 'report content' form to appear, use the following code:

// its assumed that you have a $model variable defined in your view file, which contains the content data model. 
// Actually, to be more precise, its assumed that this model has an attribute 'id'.
$this->widget('PcReportContentWidget', array('modelClassId' => $model->id, 'modelClassName' => get_class($model)));
Mass rendering and resources saving mode

If your page includes multiple instances of some content type (e.g. 'comments') and on which every one you'd like to enable 'report inappropriate content' (anyone mentioned 'comments'?), rendering a specific form for every such item can be very resources intensive and this can be avoided. This extension supports this situation by providing a special static method in the module class: getReportFormTemplate(). This method accepts as a parameter the relevant model name and returns the rendered for html as a string, directly to the caller, but with the model id as "MID", not some actual integer id, as it would regularly when used as demonstrated above. This form can then be planted hidden in an HTML page, at the mercy of some nice JS that if the user clicks on 'report content', automagically opens it in front of him, and updates the MID string to the actual model id it clicked on. Form submission should be carried out as usual in the regular code of the widget.


1 0
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Boaz
Created on: Jun 25, 2012
Last updated: 7 years ago


show all

Related Extensions