summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 17cd165)
raw | patch | inline | side by side (parent: 17cd165)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 14 Mar 2007 08:41:54 +0000 (08:41 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 14 Mar 2007 08:41:54 +0000 (08:41 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5780 594d385d-05f5-0310-b6e9-bd551577e9d8
index 3774ef0db044968b8a2622685ef01fb2e866dbac..10c30eeb427447819c1f25e3c170be8dcf1b856f 100644 (file)
* Handle new elements
**************/
+ if(isset($_POST['select_new_element_type_cancel'])){
+ $this->add_new = FALSE;
+ }
+
if($this->add_new){
$element_types= array(
function check()
{
$msgs = array();
- foreach($this->pap as $obj){
+ /* Some logical checks.
+ * like : only sieve_comment can appear before require.
+ */
+
+ /* Ensure that there are no command before require
+ * - Get id of last require tag
+ * - Collect object types in from of this tag.
+ * - Check if there are tags collected that are not allowed
+ */
+ $last_found_at = -1;
+ $objs = array();
+ foreach($this->pap as $key => $obj){
+ if(get_class($obj) == "sieve_require"){
+ $last_found_at = $key;
+ }
+ }
+ foreach($this->pap as $key => $obj){
+ if($key == $last_found_at) break;
+ if(!in_array(get_class($obj),array("sieve_comment","sieve_require"))){
+ $objs[] = get_class($obj);
+ }
+ }
+ if(count($objs) && $last_found_at != -1){
+ $str = _("Require must be the first command in the script.");
+ $msgs[] = $str;
+ print_red($str);;
+ }
+
+ foreach($this->pap as $obj){
$o_msgs = $obj->check();
foreach($o_msgs as $o_msg){
$msgs[] = $o_msg;
diff --git a/include/sieve/class_sieveElement_Require.inc b/include/sieve/class_sieveElement_Require.inc
index dffbf375b0762c0b221154072083f3da47ff8345..3b91b8205f8d0b065fb55953dd3be32e1f4c85af 100644 (file)
function sieve_require($data,$object_id)
{
- $this->object_id = $object_id;
- foreach($data['ELEMENTS'] as $node ){
- if(in_array($node['class'],array("quoted-string","text"))){
- $this->data[] = preg_replace("/\"/","",$node['text']);
+ if($data != NULL){
+
+ $this->object_id = $object_id;
+ foreach($data['ELEMENTS'] as $node ){
+ if(in_array($node['class'],array("quoted-string","text"))){
+ $this->data[] = preg_replace("/\"/","",$node['text']);
+ }
}
}
}
$smarty->assign("LastError",$tmp);
$smarty->assign("LastErrorCnt",count($tmp));
$smarty->assign("ID", $this->object_id);
- $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
+ $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
$object= $smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__)));
$str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
return($str);
diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc
index 7de20b9d6f9b84390fd329049512d5d3b6effcca..ec3250d4842c526a10c69678ea111c037f010c51 100644 (file)
$Addresses .= $key.", ";
}
$Addresses = preg_replace("/,$/","",trim($Addresses));
+
$smarty = get_smarty();
$smarty->assign("Reason",$this->reason);
$smarty->assign("Addresses",$Addresses);
$smarty->assign("Days",$this->days);
$smarty->assign("ID",$this->object_id);
$smarty->assign("Expert",$this->Expert);
- return($smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__))));
+
+ $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+ $object= $smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__)));
+ $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+ return($str);
}
}
index cfbbb748ec2520d443a5d2751e14df5ab754cf23..c4b8d338aaca97a7a99cb0706f85617568d05501 100644 (file)
var $script_to_delete =-1;
var $sieve_handle = NULL;
+ var $create_script = FALSE;
/* Initialize the class and load all sieve scripts
* try to parse them and display errors
*/
function execute()
{
+ if(isset($_POST['create_new_script'])){
+ $this->create_script = TRUE;
+ }
+
+ if(isset($_POST['create_script_cancel'])){
+ $this->create_script = FALSE;
+ }
+
+ if($this->create_script){
+ $smarty = get_smarty();
+
+ $name = "";
+ if(isset($_POST['NewScriptName'])){
+ $name = $_POST['NewScriptName'];
+ }
+
+ $err = "";
+ if($name != strtolower($name)){
+ $err = _("Only lower case names are allowed here.");
+ }
+
+ if(preg_match("/[^a-z]/i",$name)){
+ $err = _("Only a-z are allowed in script names.");
+ }
+
+ if($this->create_script && isset($_POST['create_script_save']) && $err == "" ){
+ $this->create_script = FALSE;
+
+ $script = "/*New script */".
+ "stop;";
+ $p = new My_Parser;
+
+ $sc['SCRIPT'] = $script;
+ $sc['MSG'] = "";
+
+ $ret = $p->parse($script);
+ if(!$ret){
+ $sc['MSG'] = "<font color='red'>".$p->status_text."</font>";
+ $sc['STATUS'] = _("Parse failed")."<font color='red'>".$p->status_text."</font>";
+ }else{
+ $sc['STATUS'] = _("Parse successful");
+ }
+ $sc['PARSER'] = $p;
+ $sc['EDITED'] = TRUE;
+ $sc['ACTIVE'] = FALSE;
+ $sc['NAME'] = $name;
+ $this->scripts[$name] = $sc;
+ }else{
+ $smarty->assign("NewScriptName",$name);
+ $smarty->assign("Error",$err);
+ return($smarty->fetch(get_template_path("templates/create_script.tpl",TRUE,dirname(__FILE__))));
+ }
+ }
+
$once = TRUE;
foreach($_POST as $name => $value){
if(preg_match("/^editscript_/",$name) && $once && !$this->current_handler){
$display ="<h2>Sieve script management</h2>";
$display .= _("Be careful. All your changes will be saved directly to sieve, if you use the save button below.");
+ $display .= "<br><input type='submit' name='create_new_script' value='"._("Create new script")."'>";
$display .= $List->DrawList();
$display .= "<p style=\"text-align:right\">\n";
_("Failed to save sieve script").": ".
to_string($this->sieve_handle->error_raw).
"</font>";
-# echo nl2br($data);
+ echo nl2br($data);
}
}
}
diff --git a/include/sieve/templates/create_script.tpl b/include/sieve/templates/create_script.tpl
--- /dev/null
@@ -0,0 +1,22 @@
+<h2>Create a new sieve script</h2>
+{t}Please enter the name for yout new script below.{/t}<br>
+{t}Script names must be lower case and only characters are allowed.{/t}
+
+<br>
+<br>
+{if $Error != ""}
+ <font color='red'>{$Error}</font>
+ <br>
+{/if}
+<b>{t}Script name{/t} : </b><input type='text' name='NewScriptName' value='{$NewScriptName}'>
+
+<br>
+
+<div class='seperator' style='text-align:right; width:100%;'>
+ <input type='submit' name='create_script_cancel' value='{t}Cancel{/t}'>
+
+ <input type='submit' name='create_script_save' value='{t}Next{/t}' id='create_script_save'>
+</div>
+<script type='javascript'>
+ document.getElementById('create_script_save').focus();
+</script>