addCondition() public method

Adds a condition to the recipe.
public addCondition ( $condition = [] )
Example #1
0
 /**
  * Generates the maildrop script to handle spam as identified by
  * SpamAssassin.
  *
  * @param Ingo_Rule $rule  Rule object.
  */
 protected function _generateSpam(Ingo_Rule $rule)
 {
     $this->_addItem(Ingo::RULE_SPAM, new Ingo_Script_Maildrop_Comment(_("Spam Filter"), $rule->disable, true));
     $recipe = new Ingo_Script_Maildrop_Recipe(array('action-value' => $rule->mailbox, 'action' => strlen($rule->mailbox) ? 'Ingo_Rule_User_Move' : 'Ingo_Rule_User_Discard', 'disable' => $rule->disable), $this->_params);
     if ($this->_params['spam_compare'] == 'numeric') {
         $recipe->addCondition(array('match' => 'greater than or equal to', 'field' => $this->_params['spam_header'], 'value' => $rule->level));
     } elseif ($this->_params['spam_compare'] == 'string') {
         $recipe->addCondition(array('match' => 'contains', 'field' => $this->_params['spam_header'], 'value' => str_repeat($this->_params['spam_char'], $rule->level)));
     }
     $this->_addItem(Ingo::RULE_SPAM, $recipe);
 }
Example #2
0
 /**
  * Generates the maildrop script to handle spam as identified by
  * SpamAssassin.
  *
  * @param boolean $disable  Disable the spam-filter?
  */
 public function generateSpamfilter($disable = false)
 {
     $spam = $this->_params['storage']->retrieve(Ingo_Storage::ACTION_SPAM);
     if ($spam == false) {
         return;
     }
     $spam_folder = $spam->getSpamFolder();
     $spam_action = empty($spam_folder) ? Ingo_Storage::ACTION_DISCARD : Ingo_Storage::ACTION_MOVE;
     $this->_addItem(Ingo::RULE_SPAM, new Ingo_Script_Maildrop_Comment(_("Spam Filter"), $disable, true));
     $params = array('action-value' => $spam_folder, 'action' => $spam_action, 'disable' => $disable);
     $recipe = new Ingo_Script_Maildrop_Recipe($params, $this->_params);
     if ($this->_params['spam_compare'] == 'numeric') {
         $recipe->addCondition(array('match' => 'greater than or equal to', 'field' => $this->_params['spam_header'], 'value' => $spam->getSpamLevel()));
     } elseif ($this->_params['spam_compare'] == 'string') {
         $recipe->addCondition(array('match' => 'contains', 'field' => $this->_params['spam_header'], 'value' => str_repeat($this->_params['spam_char'], $spam->getSpamLevel())));
     }
     $this->_addItem(Ingo::RULE_SPAM, $recipe);
 }