summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 95d9099)
raw | patch | inline | side by side (parent: 95d9099)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 5 Mar 2007 05:59:06 +0000 (05:59 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 5 Mar 2007 05:59:06 +0000 (05:59 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5744 594d385d-05f5-0310-b6e9-bd551577e9d8
include/sieve/class_My_Parser.inc | patch | blob | history | |
include/sieve/class_My_Tree.inc | patch | blob | history | |
include/sieve/class_sieveElement_If.inc | patch | blob | history | |
include/sieve/class_sieveManagement.inc | patch | blob | history | |
include/sieve/templates/element_address.tpl | [new file with mode: 0755] | patch | blob |
include/sieve/templates/element_boolean.tpl | [new file with mode: 0755] | patch | blob |
index f0a3f9d89729b0d9867f7c54842ed356cd5e5371..b59cfecd4b1a3fd0d6b5688be0e9232e84ed72d6 100644 (file)
<?php
+
+
+/* This class is inherited from the original 'Parser'
+ * class written by Heiko Hund
+ */
class My_Parser extends Parser
{
+
+ /* Initiate parser, but use some other
+ * classes, that are rewritten.
+ */
function parse($script)
{
$this->status_text = "incomplete";
return $this->status_;
}
+
+ /* Should be obsolete in the end. */
function dumpToken_(&$token)
{
if (is_array($token))
index 744f974c0c49c4da064f9eeab52221135bab8c52..e76290c8baa84b94637279a5101e61a580a9ad5b 100644 (file)
<?php
+
+
+/* This class is inherited from the original 'Tree'
+ * class written by Heiko Hund.
+ * It is partly rewritten to create a useable html interface
+ * for each single sieve token.
+ * This gives us the ability to edit existing sieve filters.
+ */
class My_Tree extends Tree
{
var $dumpFn_;
var $pap = array();
+ /* Create a html interface for the current sieve filter
+ */
function dump()
{
error_reporting(E_ALL);
/* This closes the last mode */
if($node['class'] == "block-start"){
$tmp = array_pop($this->mode_stack);
- $this->handle_elements($tmp);
- $this->handle_elements(array("TYPE" => "block_start"));
+ $this->handle_elements($tmp,$node_id);
+ $this->handle_elements(array("TYPE" => "block_start"),$node_id);
}
/* This closes the last mode */
if($node['class'] == "block-end"){
$tmp = array_pop($this->mode_stack);
- $this->handle_elements($tmp);
- $this->handle_elements(array("TYPE" => "block_end"));
+ $this->handle_elements($tmp,$node_id);
+ $this->handle_elements(array("TYPE" => "block_end"),$node_id);
}
/* Semicolon indicates a new command */
if($node['class'] == "semicolon"){
$tmp =array_pop($this->mode_stack);
- $this->handle_elements($tmp);
+ $this->handle_elements($tmp,$node_id);
}
/* Handle comments */
/* Remove last mode from mode stack, cause it was only valid for a single line */
if($rewoke_last){
$tmp =array_pop($this->mode_stack);
- $this->handle_elements($tmp);
+ $this->handle_elements($tmp,$node_id);
}
/* If this is a sub element, just call this for all childs */
}
- function handle_elements($data)
+ /* Create a class for each resolved object.
+ * And append this class to a list of objects.
+ */
+ function handle_elements($data,$id)
{
if(!isset($data['TYPE'])){
return;
$class_name= "sieve_".$type ;
if(class_exists($class_name)){
- $this->pap[] = new $class_name($data);
+ $this->pap[] = new $class_name($data,$id);
}else{
echo "<font color='red'>Missing : ".$class_name."</font>"."<br>";
}
}
+/* This checks if there is a string at the current position
+ * in the token array.
+ * If there is a string list at the current position,
+ * this function will return a complete list of all
+ * strings used in this list.
+ * It also returns an offset of the last token position
+ */
function sieve_get_strings($data,$id)
{
$ret = array();
index 18964bef50dce03566463a789caaa0c780105aa5..20a10b41a72436a6fb74768df5b78eb10a4b91e3 100644 (file)
{
var $_parsed = array();
var $TYPE = "if";
+ var $id = -1;
- function sieve_if($elements)
+ function sieve_if($elements,$object_id)
{
+ $this->id = $object_id;
$this->elements = $elements;
$this->_parsed = $this->_parse($elements['ELEMENTS'],1);
}
<td style='width:100%;background-color:#DDDDDD; padding:5px; border: solid 2px #AAAAAA;'>".
$name;
$str .= $this->get_as_html();
-
$str .= " </td>
</tr>
</table>";
/* Returns all elements as html */
- function get_as_html($parsed = NULL)
+ function get_as_html($parsed = NULL,$id = 1,$obj_id=1)
{
$header_parts = array(":all",":localpart",":domain",":user",":detail");
-
$ret ="";
if($parsed == NULL){
$parsed = $this->_parsed;
$Inverse = FALSE;
}
+ /* Id used to have unique html names */
+ $element_id = $this->id."_".$id."_".$obj_id;
+
/* Create elements */
switch($key)
{
case "true" :
case "false" :
{
- /* Set default */
- $type = TRUE;
-
- /* Use false as default if element is false */
- if($key == "false"){
- $type = FALSE;
- }
-
/* Inverse element if required */
if($Inverse){
- $type = !$type;
+ if($key == "true"){
+ $key = "false";
+ }else{
+ $key = "true";
+ }
}
- /* Return value */
- if($type){
- $ret = "<div><img src='images/true.png' class='center'>"._("Boolean true")."</div>";
- }else{
- $ret = "<div><img src='images/false.png' class='center'>"._("Boolean false")."</div>";
- }
+ /* Get template */
+ $smarty = get_smarty();
+ $smarty->assign("values" , array("false" => _("False"), "true" => _("True")));
+ $smarty->assign("selected" , $key);
+ $smarty->assign("ID" , $element_id);
+ $ret .= $smarty->fetch(get_template_path("templates/element_boolean.tpl",TRUE,dirname(__FILE__)));
+ break;
}
- break;
/*******************
case "address" :
{
$ret ="";
+
+ print_a($data);
+
+ $comparators = array("i;octet" => _("Normal"),"i;ascii-casemap"=>_("Case sensitive"),"i;ascii-numeric"=>_("Numeric"));
+ $av_match_type= array(":is",":contains",":matches",":over",":count",":value",":under");
+ $mtv = array("lt","le","eq","ge","gt","ne");
+
+ $smarty = get_smarty();
+ $smarty->assign("c_values" , $comparators);
+ $smarty->assign("c_selected" , $data['Comparator']);
+
+ $smarty->assign("match_types",$av_match_type);
+ $smarty->assign("match_type",$data['Match_type']);
+
+ $smarty->assign("match_type_value",$data['Match_type_value']);
+ $smarty->assign("match_type_values",$mtv);
- /* Create comparator */
- $ret .= _("Match type")." ";
- $arr =array("i;octet" => _("Normal"),"i;ascii-casemap"=>_("Case sensitive"),"i;ascii-numeric"=>_("Numeric"));
- $ret .= "<select>";
- foreach($arr as $ar ){
- $ret .= "<option value='".$ar."'>".$ar."</option>";
+ $keys = "";
+ foreach($data['Key_List'] as $key){
+ $keys .= $key."\n";
}
- $ret .= "</select>";
-
- /* Create address part */
- $ret.= _("Checking Header");
+
+ $values = "";
+ foreach($data['Value_List'] as $key){
+ $values .= $key."\n";
+ }
+ $smarty->assign("keys",$keys);
+ $smarty->assign("values",$values);
+
+
+ $smarty->assign("ID" , $element_id);
+ $ret .= $smarty->fetch(get_template_path("templates/element_address.tpl",TRUE,dirname(__FILE__)));
break;
}
if($key == "Inverse" ){
continue;
}
- $ret.= $this->get_as_html($dat);
+ $ret.= $this->get_as_html($dat, ($id +1),$key);
}
$ret.= " </td>
</tr>
if($key == "Inverse" ){
continue;
}
- $ret.= $this->get_as_html($dat);
+ $ret.= $this->get_as_html($dat, ($id + 1),$key);
}
$ret.= " </td>
</tr>
}
default : $tmp[$id] = $type;
}
-
+
return($tmp);
}
index 945a6d2843a634e74cf56d986b59e4605dafc088..44ea8c8cf81545774bcbb62428f452605aa46871 100644 (file)
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/* The sieve management class displays a list of sieve
+ * scripts for the given mail account.
+ * The account is identified by the parents uid attribute.
+ *
+ * $config The config object
+ * $dn The object edited
+ * $parent The parent object that provides the uid attribute
+ */
class sieveManagement extends plugin
{
var $parent = NULL;
var $scripts= array();
-
+
+ /* Initialize the class and load all sieve scripts
+ * try to parse them and display errors
+ */
function sieveManagement($config,$dn,$parent)
{
$this->parent = $parent;
}
}
+
+ /* Handle sieve list
+ */
function execute()
{
$once = TRUE;
}
+ /* Create list of available sieve scripts
+ */
$List = new divSelectBox("sieveManagement");
-
foreach($this->scripts as $key => $script){
-
$field1 = array("string" => $script['NAME']);
-
if($script['STATUS']){
$field2 = array("string" => _("Parse successful"));
}else{
$field2 = array("string" => _("Parse failed") .$script['MSG']);
}
-
$field3 = array("string" => _("Script length")." : ".strlen($script['SCRIPT']));
$field4 = array("string" => "<input type='image' name='editscript_".$key."' src='images/edit.png'>");
-
$List ->AddEntry(array($field1,$field2,$field3,$field4));
}
diff --git a/include/sieve/templates/element_address.tpl b/include/sieve/templates/element_address.tpl
--- /dev/null
@@ -0,0 +1,29 @@
+<b>{t}Address{/t}</b>
+<br>
+
+{t}Comparator{/t}
+<select name='comparator_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options options=$c_values selected=$c_selected}
+</select>
+<br>
+
+{t}Match type{/t}
+<select name='matchtype_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options values=$match_types output=$match_types selected=$match_type}
+</select>
+<br>
+
+{if $match_type == ":value"}
+ {t}Match type operator{/t}
+ <select name='matchtypeoperator_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options values=$match_type_values output=$match_type_values selected=$match_type_value}
+ </select>
+<br>
+
+ <textarea name='keys_{$ID}'>{$keys}</textarea>
+<br>
+ <textarea name='values_{$ID}'>{$values}</textarea>
+
+{/if}
+
+
diff --git a/include/sieve/templates/element_boolean.tpl b/include/sieve/templates/element_boolean.tpl
--- /dev/null
@@ -0,0 +1,5 @@
+<b>{t}Bool{/t}</b>
+<select name='boolean_{$ID}' title='{t}Boolean value{/t}'>
+ {html_options options=$values selected=$selected}
+</select>
+<br>