summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 28acf2c)
raw | patch | inline | side by side (parent: 28acf2c)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Mar 2007 06:52:16 +0000 (06:52 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Mar 2007 06:52:16 +0000 (06:52 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5750 594d385d-05f5-0310-b6e9-bd551577e9d8
include/sieve/class_sieveElement_If.inc | patch | blob | history | |
include/sieve/templates/element_address.tpl | patch | blob | history |
index 2324d39c12361c393614d27d5361178eeb5d0aed..e0d8fb1b80f75ab61810aeb95c18a98fe76cec20 100644 (file)
function sieve_if($elements,$object_id)
{
- $this->id = $object_id;
+ $this->id = $object_id;
$this->elements = $elements;
- $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
+ $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
}
/* Create elements */
switch($key)
{
-
+
+
+ /*******************
+ * TRUE FALSE
+ *******************/
+
+ case "address" :
+ {
+ /* address [address-part: tag] [comparator: tag] [match-type: tag] <header-list: string-list> <key-list: string-list> */
+ $address_parts = array( ":all" => _("Complete adress"),
+ ":domain" => _("Domian part") ,
+ ":localpart" => _("Local part"));
+
+ /* comparator type */
+ $comparators = array( "i;octet" => _("Normal"),
+ "i;ascii-casemap" =>_("Case sensitive"),
+ "i;ascii-numeric" =>_("Numeric"));
+
+ /* Match types */
+ $match_types = array( ":is" => _("is"),
+ ":contains" => _("contains"),
+ ":matches" => _("matches"),
+ ":count" => _("count"),
+ ":value" => _("value is"));
+
+ /* Operators */
+ $operators = array( "lt" => _("less than"),
+ "le" => _("less or equal"),
+ "eq" => _("equals"),
+ "ge" => _("greater or equal"),
+ "gt" => _("greater than"),
+ "ne" => _("not equal"));
+
+
+ /* Check if we want to toggle the expert mode */
+ if(isset($_POST['Toggle_Expert_'.$element_id])){
+ $parsed['address']['Expert'] = !$parsed['address']['Expert'];
+ }
+
+ /* Check if match type has changed */
+ if(isset($_POST['matchtype_'.$element_id])){
+ $mt = $_POST['matchtype_'.$element_id];
+
+ if(isset($match_types[$mt])){
+ $parsed['address']['Match_type'] = $mt;
+ }
+ }
+
+ /* In case of :count and :value match types
+ * we have a special match operator we should save.
+ */
+ if(in_array($parsed['address']['Match_type'],array(":value",":count"))){
+ if(isset($_POST['operator_'.$element_id])){
+ $op = $_POST['operator_'.$element_id];
+
+ if(isset($operators[$op])){
+ $parsed['address']['Match_type_value'] = $op;
+ }
+ }
+ }
+
+ /* Get the address fields we should check, they are seperated by , */
+ if(isset($_POST['keys_'.$element_id])){
+ $vls = $_POST['keys_'.$element_id];
+ $tmp = array();
+
+ $tmp2 = split(",",$vls);
+ foreach($tmp2 as $val){
+ $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+ }
+ $parsed['address']['Key_List'] = $tmp;
+ }
+
+ /* Get the values should check for, they are seperated by , */
+ if(isset($_POST['values_'.$element_id])){
+ $vls = $_POST['values_'.$element_id];
+ $tmp = array();
+
+ $tmp2 = split(",",$vls);
+ foreach($tmp2 as $val){
+ $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+ }
+ $parsed['address']['Value_List'] = $tmp;
+ }
+
+
+ break;
+ }
+
/*******************
* TRUE FALSE
*******************/
break;
}
+ /*******************
+ * Exists
+ *******************/
+
case "exists" :
{
/* get list of match values */
}
$parsed['exists']['Values'] = $tmp;
}
+ break;
}
/*******************
break;
}
-
-
+ /*******************
+ * Allof
+ *******************/
case "allof" :
{
break ;
}
-
+ /*******************
+ * Anyof
+ *******************/
+
case "anyof" :
{
foreach($data as $key2 => $dat){
$keys = "";
foreach($data['Key_List'] as $key){
- $keys .= $key."\n";
+ $keys .= $key.", ";
}
+ $keys = preg_replace("/,$/","",trim($keys));
$values = "";
foreach($data['Value_List'] as $key){
- $values .= $key."\n";
+ $values .= $key.", ";
}
+ $values = preg_replace("/,$/","",trim($values));
+
$smarty->assign("keys",$keys);
$smarty->assign("values",$values);
$match_types = array( ":is" => _("is"),
":contains" => _("contains"),
":matches" => _("matches"),
- ":over" => _("is over"),
":count" => _("count"),
- ":value" => _("value is"),
- ":under" => _("is under"));
+ ":value" => _("value is"));
/* Operators */
- $operators = array( "" => "-",
- "lt" => _("less than"),
+ $operators = array( "lt" => _("less than"),
"le" => _("less or equal"),
"eq" => _("equals"),
"ge" => _("greater or equal"),
$smarty->assign("operator" , preg_replace("/\"/","",$data['Match_type_value']));
$smarty->assign("comparator", $data['Comparator']);
$smarty->assign("address_part", $data['Address_Part']);
-
+ $smarty->assign("Expert", $data['Expert']);
+
$keys = "";
foreach($data['Key_List'] as $key){
- $keys .= $key."\n";
+ $keys .= stripslashes($key).", ";
}
+ $keys = preg_replace("/,$/","",trim($keys));
$values = "";
foreach($data['Value_List'] as $key){
- $values .= $key."\n";
+ $values .= stripslashes($key).", ";
}
+ $values = preg_replace("/,$/","",trim($values));
$smarty->assign("keys",$keys);
$smarty->assign("values",$values);
}
+ /* Parse given token identified by $data[$id]
+ * and return the parsed tokens.
+ */
function _parse($data,$id = 0)
{
$av_methods = array("address","allof","anyof","exists","false","header","not","size","true","envelope");
$av_match_type= array(":is",":contains",":matches",":over",":count",":value",":under");
-
$type = $data[$id]['text'];
-
$tmp = array();
-
/* Is there an identifier named 'not' to inverse this filter ? */
$Inverse = FALSE;
if($data[$id]['class'] == "identifier" && $data[$id]['text'] == "not"){
switch($type)
{
-
+
+ /****************
+ * Parse - Envelope / Header / Address
+ ****************/
+
case "envelope" :
case "header":
case "address" :
$Match_type = $node['text'];
/* Get value operator */
- $i ++;
- $node = $data[$i];
+ if(in_array($Match_type,array(":value",":count"))){
+ $i ++;
+ $node = $data[$i];
- if($node['class'] == "quoted-string" && preg_match("/".$value_op."/",$node['text'])){
- $Match_type_value = $node['text'];
+ if($node['class'] == "quoted-string" && preg_match("/".$value_op."/",$node['text'])){
+ $Match_type_value = $node['text'];
+ }
}
}
/* Add to Tree */
$values = array( "Inverse" => $Inverse,
"Comparator" => $Comparator,
+ "Expert" => FALSE,
"Match_type" => $Match_type,
"Match_type_value"=> $Match_type_value,
"Key_List" => $Key_List,
}
+ /****************
+ * Parse - Size
+ ****************/
+
case "size":
{
"Value_List" => $Value_List);
break;
}
+
+
+ /****************
+ * Parse - True / False
+ ****************/
+
case "true":
{
$tmp['true'] = "true";
$tmp['false'] = "false";
break;
}
+
+
+ /****************
+ * Parse - Exists
+ ****************/
+
case "exists":
{
'Values' => $tmp2['STRINGS']);
break;
}
+
+
+ /****************
+ * Parse - Allof
+ ****************/
+
case "allof" :
{
+ /* Get parameter and recursivly call this method
+ * for each parameter
+ */
$id ++;
$tmp2 = $this->get_parameter($data,$id);
break;
}
+
+ /****************
+ * Parse - Anyof
+ ****************/
+
case "anyof" :
{
+ /* Get parameter and recursivly call this method
+ * for each parameter
+ */
$id ++;
$tmp2 = $this->get_parameter($data,$id);
diff --git a/include/sieve/templates/element_address.tpl b/include/sieve/templates/element_address.tpl
index 6f7eda0517c18847e603703b04f90ce0eb635019..6d1644088d1568ae11741d580830acef23fccd49 100755 (executable)
<tr>
<td colspan=3>
<b>{t}Address{/t}</b>
+ <input type='submit' name='Toggle_Expert_{$ID}' value='{t}Toggle expert mode{/t}'>
</td>
</tr>
+ {if $Expert}
<tr>
<td>
- {t}Address part{/t}
+ {t}Match type{/t}
</td>
<td>
- <select name='address_part_{$ID}' title='{t}Boolean value{/t}'>
- {html_options options=$address_parts selected=$address_part}
+ <select name='matchtype_{$ID}' title='{t}Boolean value{/t}' onChange='document.mainform.submit();'>
+ {html_options options=$match_types selected=$match_type}
</select>
+
</td>
+ </tr>
+ <tr>
<td>
- {t}Comparator{/t}
+ {t}Address part that should be used{/t}
</td>
<td>
- <select name='comparator_{$ID}' title='{t}Boolean value{/t}'>
- {html_options options=$comparators selected=$comparator}
+ <select name='address_part_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options options=$address_parts selected=$address_part}
</select>
</td>
<td>
- {t}Match type{/t}
+ {t}Comparator{/t}
</td>
<td>
- <select name='matchtype_{$ID}' title='{t}Boolean value{/t}'>
- {html_options options=$match_types selected=$match_type}
+ <select name='comparator_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options options=$comparators selected=$comparator}
</select>
-
</td>
+ {if $match_type == ":count" || $match_type == ":value"}
<td>
{t}operator{/t}
</td>
<td>
- <select name='operator_{$ID}' title='{t}Boolean value{/t}'>
+ <select name='operator_{$ID}' title='{t}Boolean value{/t}' onChange='document.mainform.submit();'>
{html_options options=$operators selected=$operator}
</select>
</td>
+ {/if}
</tr>
<tr>
<td>
- {t}Address fields{/t}
+ {t}Address fields to include{/t}
</td>
<td>
<textarea name='keys_{$ID}'>{$keys}</textarea>
</td>
<td>
- {t}Match values{/t}
+ {t}Values to match for{/t}
</td>
<td>
<textarea name='values_{$ID}'>{$values}</textarea>
</td>
</tr>
+ {else}
+ <tr>
+ <td style='vertical-align:top;'>
+ {t}If{/t}
+
+ <select onChange='document.mainform.submit();' name='matchtype_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options options=$match_types selected=$match_type}
+ </select>
+
+ {if $match_type == ":count" || $match_type == ":value"}
+ <select name='operator_{$ID}' title='{t}Boolean value{/t}' onChange='document.mainform.submit();'>
+ {html_options options=$operators selected=$operator}
+ </select>
+ {/if}
+ </td>
+ <td>
+ <textarea style='height:30px;' name='keys_{$ID}'>{$keys}</textarea>
+ <textarea style='height:30px;' name='values_{$ID}'>{$values}</textarea>
+ </td>
+ </tr>
+ {/if}
</table>