From: hickert Date: Fri, 16 Mar 2007 10:12:11 +0000 (+0000) Subject: Added new function get_sieve X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ef93a2b8004d4640e4c3b5df31edbf624fcb42f1;p=gosa.git Added new function get_sieve Move code from parser to management class git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5795 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Parser.inc b/include/sieve/class_My_Parser.inc index 698fbbadf..816950e99 100644 --- a/include/sieve/class_My_Parser.inc +++ b/include/sieve/class_My_Parser.inc @@ -10,27 +10,6 @@ class My_Parser extends Parser function execute() { - /* Create dump of current sieve script */ - if(isset($_POST['Save_Copy'])){ - - /* force download dialog */ - header("Content-type: application/tiff\n"); - if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) || - preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) { - header('Content-Disposition: filename="dump.script"'); - } else { - header('Content-Disposition: attachment; filename="dump.script"'); - } - header("Content-transfer-encoding: binary\n"); - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - header("Cache-Control: no-cache"); - header("Pragma: no-cache"); - header("Cache-Control: post-check=0, pre-check=0"); - echo $this->get_sieve_script(); - exit(); - } - $ret = $this->dumpParseTree(); return($ret); } diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 0dd19a21e..0d718b2e5 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -69,14 +69,14 @@ class My_Tree extends Tree if($node['class'] == "block-start"){ $tmp = array_pop($this->mode_stack); $this->handle_elements($tmp,$node_id); - $this->handle_elements(array("TYPE" => "block_start"),$node_id); + $this->handle_elements(array("TYPE" => "block_start"),preg_replace("/[^0-9]/","",microtime())); } /* This closes the last mode */ if($node['class'] == "block-end"){ $tmp = array_pop($this->mode_stack); $this->handle_elements($tmp,$node_id); - $this->handle_elements(array("TYPE" => "block_end"),$node_id); + $this->handle_elements(array("TYPE" => "block_end"),preg_replace("/[^0-9]/","",microtime())); } /* Semicolon indicates a new command */ @@ -518,12 +518,6 @@ class My_Tree extends Tree return($tmp); } - function Add_Element() - { - $tmp = array("ELEMENTS" => array(array("class" => "qouted-string","text"=> "Bla bla, later more"))); - $this->pap[] = new sieve_comment($tmp,rand(1000,100000)); - } - function check() { $msgs = array(); diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index 81b6b3452..3a4cc1f7a 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -51,28 +51,6 @@ class sieveManagement extends plugin var $add_element_type = "sieve_comment"; - function get_sieve() - { - /* Connect to sieve class and try to get all available sieve scripts */ - $cfg= $this->config->data['SERVERS']['IMAP'][$this->parent->gosaMailServer]; - $this->Sieve_Error = ""; - - /* Log into the mail server */ - $sieve= new sieve( - $cfg["sieve_server"], - $cfg["sieve_port"], - $this->parent->uid, - $cfg["password"], - $cfg["admin"]); - - /* Try to login */ - if (!$sieve->sieve_login()){ - $this->Sieve_Error = $sieve->error_raw; - return(FALSE); - } - return($sieve); - } - /* Initialize the class and load all sieve scripts * try to parse them and display errors */ @@ -140,6 +118,32 @@ class sieveManagement extends plugin } + /* Return a sieve class hanlde, + * false if login fails + */ + function get_sieve() + { + /* Connect to sieve class and try to get all available sieve scripts */ + $cfg= $this->config->data['SERVERS']['IMAP'][$this->parent->gosaMailServer]; + $this->Sieve_Error = ""; + + /* Log into the mail server */ + $sieve= new sieve( + $cfg["sieve_server"], + $cfg["sieve_port"], + $this->parent->uid, + $cfg["password"], + $cfg["admin"]); + + /* Try to login */ + if (!$sieve->sieve_login()){ + $this->Sieve_Error = $sieve->error_raw; + return(FALSE); + } + return($sieve); + } + + /* Handle sieve list */ function execute() @@ -382,6 +386,28 @@ class sieveManagement extends plugin */ if($this->current_handler){ + /* Create dump of current sieve script */ + if(isset($_POST['Save_Copy'])){ + + /* force download dialog */ + header("Content-type: application/tiff\n"); + if (preg_match('/MSIE 5.5/', $HTTP_USER_AGENT) || + preg_match('/MSIE 6.0/', $HTTP_USER_AGENT)) { + header('Content-Disposition: filename="dump.script"'); + } else { + header('Content-Disposition: attachment; filename="dump.script"'); + } + header("Content-transfer-encoding: binary\n"); + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + header("Cache-Control: post-check=0, pre-check=0"); + echo $this->scripts[$this->current_script]['SCRIPT']; + exit(); + } + + /**** * Add new element to ui ****/ @@ -418,6 +444,34 @@ class sieveManagement extends plugin */ if(isset($_POST['select_new_element_type'])){ + $this->add_new_id; + + $data = $this->current_handler->tree_->pap; + + /* Get index of the element identified by object_id == $this->add_new_id; */ + $index = -1; + foreach($data as $key => $obj){ + if($obj->object_id == $this->add_new_id && $index==-1){ + $index = $key; + } + } + + /* We have found the specified object_id + * and want to detect the next free position + * to insert the new element. + */ + if($index != -1){ + if($this->add_above_below == "above"){ + $direction ="up"; + $next_free = $this->current_handler->tree_->_get_next_free_move_slot($index,$direction); + $next_free ++; + }else{ + $next_free = $this->current_handler->tree_->_get_next_free_move_slot($index,$direction); + $direction = "down"; + } + $this->add_new_id = $this->current_handler->tree_->pap[$next_free]->object_id; + } + /* Create elements we should add */ $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); if($this->add_element_type == "sieve_if"){ @@ -426,7 +480,6 @@ class sieveManagement extends plugin } $start = $end = array(); $found = false; - $data = $this->current_handler->tree_->pap; /* Add above current element*/ if($this->add_above_below == "above"){ diff --git a/include/sieve/templates/edit_frame_base.tpl b/include/sieve/templates/edit_frame_base.tpl index 1f80feb96..a5552beb4 100644 --- a/include/sieve/templates/edit_frame_base.tpl +++ b/include/sieve/templates/edit_frame_base.tpl @@ -3,7 +3,6 @@ -