Git Product home page Git Product logo

sfdoctrinemoderatableplugin's Introduction

sfDoctrineModeratablePlugin

Usage

 actAs:
    Moderatable:
        fields:                 [title, description]
        strip:                  false
        replace:                false
        default_flag:           'unmoderated'
        post_mod:               false

And enable the preDQL in the application configuration (usually frontend):

class [APPLICATION]Configuration extends sfApplicationConfiguration
{
   ....

   public function configureDoctrine(Doctrine_Manager $manager)
   {
     $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
   }
}

If you want the field to be an enum (if you're using MySQL etc), then set the following in your global ProjectConfiguration:

 public function configureDoctrine(Doctrine_Manager $manager)
 {
   $manager->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);
   $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_CHARSET, 'utf8');
   $manager->setAttribute(Doctrine_Core::ATTR_DEFAULT_TABLE_COLLATE, 'utf8_general_ci');
   $manager->setAttribute(Doctrine_Core::ATTR_QUERY_LIMIT, Doctrine_Core::LIMIT_ROWS);
 }

Or in your databases.yml:

  attributes:
    use_native_enum: true

Options

  • fields - YAML array of fields to check
  • strip - If true then remove all profane strings.
  • replace - Replace profane strings with '*****'. If strip: true then this has no effect.
  • profane_flag - Default status for items flagged as profane, can have the values 'flagged' or 'rejected' - default is 'rejected'
  • default_flag - Default moderation state. It can have the values 'unmoderated', 'safe' or 'followup' - default is 'unmoderated'
  • unmoderated - not yet been moderated
  • safe - no problems here
  • followup - needs investigation
  • flagged - reported by user or profanities detected (if profamne_flag set to flagged)
  • rejected - rejected by moderator or profanities detected (if profamne_flag set to rejected)
  • post_mod - true or false
  • Pre-moderated - means it's displayed only if someone moderates it first in the backend.
  • Post-moderated - means it's displayed once it's added by the user. It can be taken off the website by moderator on the backend app. It also can be flagged in the frontend app by anyone - in this case (usually) it's awaiting moderation, while still visible, but only for 1h (flagged_threshold). If no one moderates the flagged request within this time, the item usually is taken off the website.
  • flagged_threshold - number of seconds after which a reported (but as yet, unmoderated) item should be ommitted from results sets - default 1h.

Adding more profanities to check for

You may want to add more strings to check for, personal information for example, or maybe just a load more profanities the plugin developers have never heard.

Your extra words should be defined in one or more files, following this format:

<?php
// probably going to be a bigger array than this!
$extra_words = array('word1', 'word2');

Important - the plugin looks for the variable $extra_words and will throw an exception if you use a different name.

Define the location of these files in your app.yml:

moderatable_plugin:
  extra_profanities:
    - /full/path/to/file1.php
    - /full/path/to/file2.php

It might be helpful to remember you can parse PHP in the YAML files. For example, specifying a file in the Symfony lib directory:

moderatable_plugin:
  extra_profanities:
    - <?php printf('%s/%s', sfConfig::get('sf_lib_dir'), 'file1.php') ?>
    - <?php printf('%s/%s', sfConfig::get('sf_lib_dir'), 'file2.php') ?>

If the file is not found, the plugin will fail silently and your extra words will have been ignored (obviously).

sfdoctrinemoderatableplugin's People

Contributors

angelsk avatar benlancaster avatar

Stargazers

Janusz Slota avatar Michal Moravec avatar

Watchers

Kolba avatar James Cloos avatar Jimmy Wong avatar  avatar Joe Harlow avatar

sfdoctrinemoderatableplugin's Issues

Update README add dql callbacks

I always forget what option on Doctrine needs to be enabled, so please add this section into your README file

Remember, in order for the dql callbacks to be executed we must enable an attribute first.

class frontendConfiguration extends sfApplicationConfiguration
{
  public function configure()
  {
  }

  public function configureDoctrine(Doctrine_Manager $manager)
  {
    $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
  }
}

Reference: http://www.doctrine-project.org/blog/cookbook-recipe-relation-dql-behavior

Needs to be javascript library agnostic

Currently includes jQuery library. Needs to have dependancies in readme for JS - and abstracted out of the template. Should support Mootools too - perhaps via a config option.

Update README add pre/post moderation documentation

Hi,

Another request to update documentation with SQL like title ;-)

Can you add some documentation to readme file. As I don't work with this plugin often I tend to forget how it works, so here is some additional info I'd like to see in the README file. It can be found in comments in PHP files.

Pre-moderated - means it's displayed only if someone moderates it first in the backend.

Post-moderated - means it's displayed once it's added by the user. It can be taken off the website by moderator on the backend app. It also can be flagged in the frontend app by anyone - in this case (usually) it's awaiting moderation, while still visible, but only for 1h (flagged_threshold). If no one moderates the flagged request within this time, the item usually is taken off the website.

You can setup the plugin as a pre or post moderated using default_flag configuration option.

flag and default_flag options can have values: unmoderated, safe, followup, flagged or rejected, where:

  • unmoderated - default value if not set.
  • safe - no problems here
  • followup - needs investigation (use this as default state (default_flag) for pre-moderation)
  • flagged - reported by user or profanities detected
  • flagged_threshold - number of seconds after which a reported (but as yet, unmoderated) item should be ommitted from results sets - default 1h.

Sample post-moderation config

Moderatable:
  fields:         [ title, content ]

Sample pre-moderation config:

Moderatable:
  fields:         [ title, content ]
  default_flag:   'followup'

"Janet"

"Janet" in list of profanities - means that name field was turned into stars.

Probably should be removed.

ETA: "Pat", "Pox", "Bite", "Breast" (in ref to cancer), "Coke" in reference to the brand, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.