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.
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.
'import' => array( //... 'application.modules.PcReportContent.extensions.PcReportContentWidget.PcReportContentWidget', 'application.modules.PcReportContent.PcReportContentModule', //... ); 'modules' => array( // ... 'reportContent' => array( 'class' => 'application.modules.PcReportContent.PcReportContentModule', 'targetEmail' => 'firstname.lastname@example.org', // 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)));
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.