Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

New plugin: "Flag Reasons" available

+11 votes
415 views
asked Mar 4 in Plugins by q2apro
edited Mar 5 by q2apro

Download and Instructions:
https://github.com/q2apro/q2apro-flag-reasons

screencast

Question2Answer Plugin: Flag Reasons


Description

Adds choice of flag reasons and comment option to each flag vote

Features

  • user gets list of reasons to choose from when clicking on the button "flag"
  • user can add a comment
  • flags and reasons are listed at post

Installation

  • Download the plugin as ZIP from github
  • Make a full backup of your q2a database before installing the plugin.
  • Extract the folder q2apro-flag-reasons from the ZIP file.
  • Move the folder q2apro-flag-reasons to the qa-plugin folder of your Q2A installation.
  • Use your FTP-Client to upload the folder q2apro-flag-reasons into the qa-plugin folder of your server.
  • Navigate to your site, go to Admin -> Plugins and check if the plugin "q2apro Flag Reasons" is listed.
  • Initialize the database (this will create a table qa_flagreasons)
  • Congratulations, your new plugin has been activated.

Disclaimer

The code is probably okay for production environments, but may not work exactly as expected. You bear the risk. Refunds will not be given!

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Copyright

All code herein is OpenSource. Feel free to build upon it and share with the world.

Final Note

If you use the plugin:

  • Translate the plugin into your language and commit the language file.
  • Say thank you by donating a few to the developer.

Have fun!

Update v0.2:

- Flagging of answers and comments now possible.
- Key listener for Enter (submit) and Escape (cancel).
- Click on semi-transparent background closes overaly.

Q2A version: 1.8.0
commented Mar 5 by q2apro
Before updating to the new version, please delete the former table qa_flagreasons, and re-initialize. Because I renamed the "comment" field to "notice" to be more clear.
commented Jul 30 by vivian
Is there any way to hide who flagged from the reasons list. Showing who flagged will rise some hatred among members. So how to make it as only reasons be posted.
commented Aug 23 by vivian
Thank you, it is working now. It wasn't working at first as the code was not encoded in UTF 8. It was in Windows 1252. So the lines after 146 or so were not visible. But however, it was visible on a free hosting where I do some experiments. But still, no changes occurred there :)
Today I tried it by copying the whole code from GitHub and saving it as UTF 8 file. And it worked. Thank you for the help.

4 Answers

0 votes
answered Mar 7 by Piotr Baranowski
so cool plugin, I'll use it on my site. Thanks !
+1 vote
answered Mar 7 by suis
Wow! this plugin too essential for every site. Thank you very much.
commented Mar 8 by q2apro
True, I created it because many of my users asked for it. They could not understand many spam flags, which were essentially not spam but "notices" for moderators to take care of something.
0 votes
answered Jul 22 by vivian
Very useful plugin for a very active website. How can we hide the username of the user who flagged? Flag reasons or notice is enough. Username display should be an option. What change in code can make that not to display  username after reasons or notices?
+1 vote
answered Jul 22 by esqeudero
You should improve this plugin. It lacks security hacks. The spam text input area accepts php and html codes. BE AWARE.
commented Jul 22 by q2apro
In my opinion, your comment is not true. The notice text and other incoming data is saved with q2apro_save_flagreasons() that uses qa_db_query_sub(), with placeholders # $ that get sanitized by the q2a core. See qa-db.php. Please elaborate where you see a security issue.
commented Jul 22 by esqeudero
try this. flag one post and write this on spam text area;
<a href="https://twitter.com">click it</a><div style="font-size:145px;">HACKED</div>

and see the results.

To fix it you should sanitize following code at layer.php
public function post_meta_flags($post, $class)
    {
        if(!empty($post['flags']['suffix']))
        {
            if($class=='qa-a-item' || $class=='qa-c-item')
            {
                $flaginfo = q2apro_count_postflags_output($post['raw']['postid']);
               
                if(!empty($flaginfo))
                {
                    // add flag info to flag output
                    $post['flags']['suffix'] .= ': <br>'.$flaginfo;
                }
            }
        }
       
        // default method call outputs the form buttons
        qa_html_theme_base::post_meta_flags($post, $class);
    }
commented Jul 22 by q2apro
Thanks! Fixed by: $post['flags']['suffix'] .= ': <br>'.htmlspecialchars($flaginfo);
https://github.com/q2apro/q2apro-flag-reasons/blob/master/q2apro-flag-reasons-layer.php
...