summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa5d4f7)
raw | patch | inline | side by side (parent: fa5d4f7)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Mar 2007 05:00:56 +0000 (05:00 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 6 Mar 2007 05:00:56 +0000 (05:00 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5749 594d385d-05f5-0310-b6e9-bd551577e9d8
include/sieve/class_sieveElement_If.inc | patch | blob | history | |
include/sieve/templates/element_exists.tpl | [new file with mode: 0644] | patch | blob |
include/sieve/templates/element_size.tpl | [new file with mode: 0644] | patch | blob |
index f9e099d2db94a2e181e9497cb21b4c25390ea1d3..2324d39c12361c393614d27d5361178eeb5d0aed 100644 (file)
}
break;
}
+
+ case "exists" :
+ {
+ /* get list of match values */
+ 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['exists']['Values'] = $tmp;
+ }
+ }
+
+ /*******************
+ * Size
+ *******************/
+
+ case "size" :
+ {
+ $Match_types = array( ":over" => _("greater than") ,
+ ":under" => _("lower than"));
+
+ $Units = array( "M" => _("Megabyte") ,
+ "K" => _("Kilobyte"));
+
+ /* Reset error */
+ $parsed['size']['LastError'] ="";
+
+ /* Get match type */
+ if(isset($_POST['Match_type_'.$element_id])){
+ $mt = $_POST['Match_type_'.$element_id];
+ if(isset($Match_types[$mt])){
+ $parsed['size']['Match_type'] = $mt;
+ }else{
+ $parsed['size']['LastError'] = _("Please select a valid match type in the list box below.");
+ }
+ }
+
+ /* Get old values */
+ $value = preg_replace("/[^0-9]*$/","",$parsed['size']['Value_List'][0]);
+ $unit = preg_replace("/^[0-9]*/","",$parsed['size']['Value_List'][0]);
+
+ /* Get value */
+ if(isset($_POST['Value_'.$element_id])){
+ $vl = $_POST['Value_'.$element_id];
+
+ if(is_numeric($vl) && preg_match("/^[0-9]*$/",$vl)){
+ $value = $vl;
+ }else{
+ $parsed['size']['LastError'] = _("Only numeric values are allowed here.");
+ }
+ }
+
+ /* Get unit */
+ if(isset($_POST['Value_Unit_'.$element_id])){
+ $ut = $_POST['Value_Unit_'.$element_id];
+
+ if(isset($Units[$ut])){
+ $unit = $ut;
+ }else{
+ $parsed['size']['LastError'] = _("No valid unit selected");
+ }
+ }
+
+ $parsed['size']['Value_List'][0] = $value.$unit;
+ break;
+ }
+
+
+
case "allof" :
{
}
+ /*******************
+ * Size
+ *******************/
+
+ case "size" :
+ {
+ $Match_types = array( ":over" => _("greater than") ,
+ ":under" => _("lower than"));
+
+ $Units = array( "M" => _("Megabyte") ,
+ "K" => _("Kilobyte"));
+
+ $Match_type = $data['Match_type'];
+ $Value = preg_replace("/[^0-9]/","",$data['Value_List'][0]);
+ $Value_Unit = preg_replace("/[0-9]/","",$data['Value_List'][0]);
+
+ $LastError = "";
+ if(isset($data['LastError'])){
+ $LastError = $data['LastError'];
+ }
+
+ $smarty = get_smarty();
+ $smarty->assign("Inverse",$Inverse);
+ $smarty->assign("LastError",$LastError);
+ $smarty->assign("Match_types",$Match_types);
+ $smarty->assign("Units",$Units);
+ $smarty->assign("Match_type",$Match_type);
+ $smarty->assign("Value",$Value);
+ $smarty->assign("Value_Unit",$Value_Unit);
+ $smarty->assign("ID" , $element_id);
+ $ret .= $smarty->fetch(get_template_path("templates/element_size.tpl",TRUE,dirname(__FILE__)));
+ break;
+ }
+
+ /*******************
+ * Exists
+ *******************/
+
+
+ case "exists" :
+ {
+ $LastError = "";
+ if(isset($data['LastError'])){
+ $LastError = $data['LastError'];
+ }
+
+ $Values = "";
+ foreach($data['Values'] as $val){
+ $Values .= stripslashes($val).", ";
+ }
+ $Values = preg_replace("/,$/","",trim($Values));
+
+ $smarty = get_smarty();
+ $smarty->assign("LastError",$LastError);
+ $smarty->assign("Values",$Values);
+ $smarty->assign("Inverse",$Inverse);
+ $smarty->assign("ID" , $element_id);
+ $ret .= $smarty->fetch(get_template_path("templates/element_exists.tpl",TRUE,dirname(__FILE__)));
+ break;
+ }
+
+
/*******************
* All of
*******************/
$tmp['false'] = "false";
break;
}
+ case "exists":
+ {
+
+ /* Skip first values, [if,not,exists] */
+ $node = $data[$id];
+ while(in_array($node['text'],array("if","not","exists"))){
+ $id ++;
+ $node = $data[$id];
+ }
+
+ /* Get values */
+ $tmp2 = sieve_get_strings($data,$id);
+
+
+ $tmp['exists'] = array('Inverse' => $Inverse,
+ 'Values' => $tmp2['STRINGS']);
+ break;
+ }
case "allof" :
{
$id ++;
diff --git a/include/sieve/templates/element_exists.tpl b/include/sieve/templates/element_exists.tpl
--- /dev/null
@@ -0,0 +1,23 @@
+<b>{t}Exists{/t}</b>
+<table >
+ <tr>
+ <td style='vertical-align:top;'>
+ {if $LastError != ""}
+ <font color='red'>{$LastError}</font>
+ <br>
+ {/if}
+
+ {if $Inverse}
+ {t}If header attribute does not exists{/t}
+ {else}
+ {t}If header attribute(s) exists{/t}
+ {/if}
+ </td>
+ <td>
+ <textarea style='width:300px;height:30px;' name='Values_{$ID}'>{$Values}</textarea>
+ </td>
+ <td>
+ <input type='submit'>
+ </td>
+ </tr>
+</table>
diff --git a/include/sieve/templates/element_size.tpl b/include/sieve/templates/element_size.tpl
--- /dev/null
@@ -0,0 +1,25 @@
+<b>{t}Size{/t}</b>
+<table>
+ <tr>
+ <td>
+ {if $LastError != ""}
+ <font color='red'>{$LastError}</font>
+ <br>
+ {/if}
+
+ {if $Inverse}
+ {t}If size is{/t} <b>{t}not{/t}</b>
+ {else}
+ {t}If size is{/t}
+ {/if}
+ <select name='Match_type_{$ID}' title='{t}Select match type{/t}'>
+ {html_options options=$Match_types selected=$Match_type}
+ </select>
+ <input type='text' name='Value_{$ID}' value='{$Value}'>
+ <select name='Value_Unit_{$ID}' title='{t}Select value unit{/t}'>
+ {html_options options=$Units selected=$Value_Unit}
+ </select>
+ <input type='submit'>
+ </td>
+ </tr>
+</table>