addCondition() 공개 메소드

Adds a condition to the recipe.
public addCondition ( array $condition = [] )
$condition array Array of parameters. Required keys are 'field' and 'value'. 'case' is an optional key.
예제 #1
0
 /**
  * Generates the procmail script to handle the whitelist specified in
  * the rules.
  *
  * @param Ingo_Rule $rule  Rule object.
  */
 protected function _generateWhitelist(Ingo_Rule $rule)
 {
     if (!count($rule)) {
         return;
     }
     $this->_addItem(Ingo::RULE_WHITELIST, new Ingo_Script_Procmail_Comment(_("Whitelisted Addresses"), $rule->disable, true));
     foreach ($rule->addresses as $address) {
         $recipe = new Ingo_Script_Procmail_Recipe(array('action' => 'Ingo_Rule_User_Keep', 'disable' => $rule->disable), $this->_params);
         $recipe->addCondition(array('field' => 'From', 'value' => $address, 'match' => 'address'));
         $this->_addItem(Ingo::RULE_WHITELIST, $recipe);
     }
 }
예제 #2
0
 /**
  * Generates the procmail script to handle the whitelist specified in
  * the rules.
  *
  * @param boolean $disable  Disable the whitelist?
  */
 public function generateWhitelist($disable = false)
 {
     $whitelist = $this->_params['storage']->retrieve(Ingo_Storage::ACTION_WHITELIST);
     $wl_addr = $whitelist->getWhitelist();
     if (!empty($wl_addr)) {
         $this->_addItem(Ingo::RULE_WHITELIST, new Ingo_Script_Procmail_Comment(_("Whitelisted Addresses"), $disable, true));
         foreach ($wl_addr as $address) {
             if (!empty($address)) {
                 $recipe = new Ingo_Script_Procmail_Recipe(array('action' => Ingo_Storage::ACTION_KEEP, 'disable' => $disable), $this->_params);
                 $recipe->addCondition(array('field' => 'From', 'value' => $address, 'match' => 'address'));
                 $this->_addItem(Ingo::RULE_WHITELIST, $recipe);
             }
         }
     }
 }