Development

Changeset 5346 for plugins/sfModerationPlugin

You must first sign up to be able to contribute.

Show
Ignore:
Timestamp:
10/02/07 18:26:55 (6 years ago)
Author:
francois
Message:

sfModerationPlugin Fixed behavior system and added auto-registering system

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfModerationPlugin/README

    r5313 r5346  
    5151 
    5252{{{ 
    53 sfPropelBehavior::add('Item', array('spam_tag' => array('status_column' => 'my_spam_tag'))); 
     53sfPropelBehavior::add('Item', array('moderation' => array('status_column' => 'my_spam_tag'))); 
    5454}}} 
    5555 
    5656    Note that the column must still be an integer with default value equal to '1'. 
    5757     
     58  Alternatively, you can let the plugin register the behavior on models on its own. This is particularly useful if you need to add the behavior to models defined in a third party plugin, or if you have many models to extend. To do so, you just need to list the models to be extended in your `app.yml`: 
     59   
     60{{{ 
     61all: 
     62  sfModerationPlugin: 
     63    auto_register_behavior: true 
     64    moderated_classes:      [Item] 
     65}}} 
     66   
    5867  * Rebuild your model: 
    5968 
     
    131140=== Trunk === 
    132141 
     142  * francois: Added auto-registering system 
     143 
    133144=== 2007-09-09 | 0.6.0 Beta === 
    134145 
  • plugins/sfModerationPlugin/config/config.php

    r5313 r5346  
    2727)); 
    2828 
     29$moderated_classes = sfConfig::get('app_sfModerationPlugin_moderated_classes', false); 
     30if(sfConfig::get('app_sfModerationPlugin_auto_register_behavior', true) && $moderated_classes) 
     31{ 
     32  if(isset($moderated_classes[0])) 
     33  { 
     34    // simple array 
     35    foreach($moderated_classes as $model) 
     36    { 
     37      sfPropelBehavior::add($model, array('moderation')); 
     38    } 
     39  } 
     40  else 
     41  { 
     42    // associative array 
     43    foreach($moderated_classes as $model => $params) 
     44    { 
     45      sfPropelBehavior::add($model, array('moderation' => $params)); 
     46    } 
     47  } 
     48} 
     49 
  • plugins/sfModerationPlugin/lib/SfPeerBuilder.php

    r5313 r5346  
    214214 
    215215"; 
    216       $tmp = preg_replace('/{/', '{'.$mixer_script, $tmp, 1); 
     216      $tmp = preg_replace('/public static function doSelectJoin.*\(Criteria \$c, \$con = null\)\n\s*{/', '\0'.$mixer_script, $tmp); 
    217217    } 
    218218 
     
    256256 
    257257"; 
    258       $tmp = preg_replace('/{/', '{'.$mixer_script, $tmp, 1); 
     258      $tmp = preg_replace('/public static function doSelectJoinAllExcept.*\(Criteria \$c, \$con = null\)\n\s*{/', '\0'.$mixer_script, $tmp); 
    259259    } 
    260260