index 96035b5b2079e9307d576b223beec3fb4113b5dd..ba01e0cf3aaa0bbe50a4a26b2d617e99b4afca3a 100644 (file)
}
/* Check given name */
}
/* Check given name */
- $err = "";
+ $err = false;
/* Is given name in lower case characters ? */
if(isset($_POST['create_script_save'])){
if(!strlen($name)){
/* Is given name in lower case characters ? */
if(isset($_POST['create_script_save'])){
if(!strlen($name)){
- $err = _("You should specify a name for your new script.");
+ $err =true;
+ print_red(_("You should specify a name for your new script."));
}
/* Is given name in lower case characters ? */
if($name != strtolower($name)){
}
/* Is given name in lower case characters ? */
if($name != strtolower($name)){
- $err = _("Only lower case names are allowed here.");
+ $err =true;
+ print_red(_("Only lower case names are allowed."));
}
/* Only chars are allowed here */
if(preg_match("/[^a-z]/i",$name)){
}
/* Only chars are allowed here */
if(preg_match("/[^a-z]/i",$name)){
- $err = _("Only a-z are allowed in script names.");
+ $err =true;
+ print_red(_("Only alphabetical characters are allowed in script names."));
}
$tmp = $this->get_used_script_names();
if(in_array_ics($name,$tmp)){
}
$tmp = $this->get_used_script_names();
if(in_array_ics($name,$tmp)){
- $err =_("The specified name is already in use.");
+ $err =true;
+ print_red(_("The specified name is already in use."));
}
}
/* Create script if everything is ok */
}
}
/* Create script if everything is ok */
- if($this->create_script && isset($_POST['create_script_save']) && $err == "" ){
+ if($this->create_script && isset($_POST['create_script_save']) && !$err){
/* Close dialog */
$this->create_script = FALSE;
/* Close dialog */
$this->create_script = FALSE;
/* Display dialog to enter new script name */
$smarty = get_smarty();
$smarty->assign("NewScriptName",$name);
/* Display dialog to enter new script name */
$smarty = get_smarty();
$smarty->assign("NewScriptName",$name);
- $smarty->assign("Error",$err);
return($smarty->fetch(get_template_path("templates/create_script.tpl",TRUE,dirname(__FILE__))));
}
}
return($smarty->fetch(get_template_path("templates/create_script.tpl",TRUE,dirname(__FILE__))));
}
}
$file = $_FILES['Script_To_Import'];
if($file['size'] == 0){
$file = $_FILES['Script_To_Import'];
if($file['size'] == 0){
- print_red(_("Specified file seams to empty."));
+ print_red(_("Specified file seems to be empty."));
}elseif(!file_exists($file['tmp_name'])){
print_red(_("Upload failed, somehow nothing was uploaded or the temporary file can't be accessed."));
}elseif(!is_readable ($file['tmp_name'])){
}elseif(!file_exists($file['tmp_name'])){
print_red(_("Upload failed, somehow nothing was uploaded or the temporary file can't be accessed."));
}elseif(!is_readable ($file['tmp_name'])){
if(!$else_found && (!(get_class($obj) == "sieve_if" && $elsif_found))){
$element_types['sieve_else'] = _("Else");
}
if(!$else_found && (!(get_class($obj) == "sieve_if" && $elsif_found))){
$element_types['sieve_else'] = _("Else");
}
- $element_types['sieve_elsif'] = _("Else if");
+ $element_types['sieve_elsif'] = _("Else If");
}
}
}
}
}
}
}
$field2 = array("string" => $script['NAME']);
$field3 = array("string" => $script['MSG']);
}
$field2 = array("string" => $script['NAME']);
$field3 = array("string" => $script['MSG']);
- $field4 = array("string" => _("Script length")." : ".strlen($script['SCRIPT']));
+ $field4 = array("string" => _("Script length").": ".strlen($script['SCRIPT']));
if($this->parent->acl_is_writeable("sieveManagement")){
$del = "<input type='image' name='delscript_".$key."' src='images/edittrash.png'
if($this->parent->acl_is_writeable("sieveManagement")){
$del = "<input type='image' name='delscript_".$key."' src='images/edittrash.png'
$field6 = array("string" => $activate."<input type='image' name='editscript_".$key."' src='images/edit.png'
title='"._("Edit script")."'>".$del,
"attach" => "style='border-right:0px; width:70px;'");
$field6 = array("string" => $activate."<input type='image' name='editscript_".$key."' src='images/edit.png'
title='"._("Edit script")."'>".$del,
"attach" => "style='border-right:0px; width:70px;'");
- $List ->AddEntry(array($field1,$field2,$field3,$field4,$field6));
+ $List->AddEntry(array($field1,$field2,$field3,$field4,$field6));
}
}
+
+ $List->SetHeight(400);
/* If the uattrib is empty (Attribute to use for authentification with sieve)
* Display a message that the connection can't be established.
/* If the uattrib is empty (Attribute to use for authentification with sieve)
* Display a message that the connection can't be established.
return(FALSE);
}
return(FALSE);
}
+ /* These element types are allowed to be added here */
+ $element_types= array(
+ "sieve_keep" => _("Keep"),
+ "sieve_comment" => _("Comment"),
+ "sieve_fileinto" => _("File into"),
+ "sieve_keep" => _("Keep"),
+ "sieve_discard" => _("Discard"),
+ "sieve_redirect" => _("Redirect"),
+ "sieve_reject" => _("Reject"),
+ "sieve_require" => _("Require"),
+ "sieve_stop" => _("Stop"),
+ "sieve_vacation" => _("Vacation message"),
+ "sieve_if" => _("If"));
+
+ /* Check if we should add else/elsif to the select box
+ * or not. We can't add else twice!.
+ */
+
+ /* Get posistion of the current element
+ */
+ foreach($this->current_handler->tree_->pap as $key => $obj){
+
+ if($obj->object_id == $id && in_array(get_class($obj),array("sieve_if","sieve_elsif"))){
+
+ /* Get block start/end */
+ $end_id = $this->current_handler->tree_->get_block_end($key);
+ $else_found = FALSE;
+ $elsif_found = FALSE;
+
+ /* Check if there is already an else in this block
+ */
+ for($i = $key ; $i < $end_id ; $i ++){
+ if(get_class($this->current_handler->tree_->pap[$i]) == "sieve_else"){
+ $else_found = TRUE;
+ }
+ if(get_class($this->current_handler->tree_->pap[$i]) == "sieve_elsif"){
+ $elsif_found = TRUE;
+ }
+ }
+
+ if($this->add_above_below == "below"){
+
+ /* Only allow adding 'else' if there is currently
+ * no 'else' statement. And don't allow adding
+ * 'else' before 'elseif'
+ */
+ if(!$else_found && (!(get_class($obj) == "sieve_if" && $elsif_found))){
+ $element_types['sieve_else'] = _("Else");
+ }
+ $element_types['sieve_elsif'] = _("Else If");
+ }else{
+
+ /* Allow adding elsif above elsif */
+ if(in_array(get_class($obj),array("sieve_elsif"))){
+ $element_types['sieve_elsif'] = _("Else If");
+ }
+ }
+ }
+ }
+
+ if(!isset($element_types[$type])){
+ print_red(sprintf(_("Can't add the specified element at the given position.")));
+ return;
+ }
+
+
/* Create elements we should add
* -Some element require also surrounding block elements
*/
/* Create elements we should add
* -Some element require also surrounding block elements
*/