index 1e4f6829f73e71e83093dbf245f9333e9b3b63d6..05f4895141ed53d8f739a4e24f7e1888d3b6964b 100644 (file)
var $comparators = array();
var $match_types = array();
var $operators = array();
-
+ var $parent = NULL;
/* Initialize class
* $elements contains all tokens that belongs to this if/else tag
* $object_id cotains an unique tag id, to be able to create uniqe html post names
*/
- function sieve_if($elements,$object_id)
+ function sieve_if($elements,$object_id,$parent)
{
+ $this->parent = $parent;
+
/* Possible address parts we can select */
$this->address_parts = array(
":all" => _("Complete adress")." ("._("Default").")",
*/
function get_sieve_script_part()
{
- $tmp = "if ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1);
+ $tmp = $this->TYPE." ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1);
return($tmp);
}
*******************/
case "true" :
- case "fasle" :
+ case "false" :
{
/* Can't fail anyway */
break;
}
/* Add allof/anyof tag */
- $script.= " ".$key." ( ";
+ if($Inverse){
+ $script .= "not ";
+ }
+ $script.= $key." ( ";
/* Add each test parameter */
foreach($data as $key2 => $dat){
$values["Address_Part"] = ":all";
}
$data[$type]=$values;
+
+ $this->parent->add_require("relational");
+ if($type == "envelope"){
+ $this->parent->add_require("envelope");
+ }
+
+
break;
}
case "allof" :
{
$tmp= array(
"Inverse" => FALSE,
- "Match_type" => ":contains",
- "Value_List" => array(1,"M"));
+ "Match_type" => ":over",
+ "Value_List" => array("1M"));
$tmp['LastError'] = "";
$data[$type] = $tmp;
$parsed[$key]['LastError'] = _("Invalid operator given.");
}
$parsed[$key]['Comparator'] = $cp;
+
+ if($cp == "i;ascii-numeric"){
+ $this->parent->add_require("comparator-i;ascii-numeric");
+ }
}
/* In case of :count and :value match types
$Units = array( "M" => _("Megabyte") ,
"K" => _("Kilobyte"));
+ /* Toggle Inverse ? */
+ if(isset($_POST['toggle_inverse_'.$element_id])){
+ $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse'];
+ }
+
/* Reset error */
$parsed[$key]['LastError'] ="";
$name .= "<b>"._("Condition")."</b>";
if($this->TYPE == "if"){
$name .= " - "._("If");
+ }elseif($this->TYPE == "elsif"){
+ $name .= " - "._("Else if");
}else{
$name .= " - "._("Else");
}
$smarty->assign("Name", $name);
$smarty->assign("Contents", $this->get_as_html());
- $object = $smarty->fetch(get_template_path("templates/element_if_else.tpl",TRUE,dirname(__FILE__)));
+
+ if($this->TYPE == "if"){
+ $object = $smarty->fetch(get_template_path("templates/element_if.tpl",TRUE,dirname(__FILE__)));
+ }else{
+ $object = $smarty->fetch(get_template_path("templates/element_elsif.tpl",TRUE,dirname(__FILE__)));
+ }
$str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
return($str);
}
$smarty->assign("DisplayAdd",TRUE);
$smarty->assign("DisplayDel",FALSE);
$cont_tmp = $smarty->fetch(get_template_path("templates/object_test_container.tpl",TRUE,dirname(__FILE__)));
- $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/",_("Klick here to add a new test"),$cont_tmp);
+ $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/",_("Click here to add a new test"),$cont_tmp);
$smarty->assign("Inverse",$Inverse);
$smarty->assign("Contents",$cont_tmp.$Contents);
}
default :
{
- $ret = "<table width='100%' cellspacing=0 cellpadding=0>
- <tr>
- <td style='background-color: #FEDCA9 ; border: solid 1px #EEEEEE'>";
- $ret.= $key."<br>";
- $ret.= " </td>
- </tr>
- </table>";
+ trigger_error(_("Unhandled switch type"));
}
}
}