summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ca6bb20)
raw | patch | inline | side by side (parent: ca6bb20)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 Mar 2007 06:47:29 +0000 (06:47 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 Mar 2007 06:47:29 +0000 (06:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5809 594d385d-05f5-0310-b6e9-bd551577e9d8
include/sieve/class_sieveManagement.inc | patch | blob | history | |
include/sieve/templates/create_script.tpl | patch | blob | history | |
include/sieve/templates/edit_frame_base.tpl | patch | blob | history |
index 94b8a1116a3667a421f0d85af585fe721261282f..4f47fbc721ab91a7816c3671ea397212e94281d3 100644 (file)
plugin::plugin($config,$dn);
/* Get sieve */
- if(!$sieve = $this->get_sieve()){
+ if(!$this->sieve_handle = $this->get_sieve()){
print_red(
sprintf(
_("Can't log into SIEVE server. Server says '%s'."),
/* Get all sieve scripts names */
- if($sieve->sieve_listscripts()){
- if (is_array($sieve->response)){
- foreach($sieve->response as $key => $name){
+ if($this->sieve_handle->sieve_listscripts()){
+ if (is_array($this->sieve_handle->response)){
+ foreach($this->sieve_handle->response as $key => $name){
$data = array();
$data['NAME'] = $name;
/* Get script contents */
foreach($this->scripts as $key => $script){
$p = new My_Parser;
- $sieve->sieve_getscript($script['NAME']);
+ $this->sieve_handle->sieve_getscript($script['NAME']);
$script = "";
- foreach($sieve->response as $line){
+ foreach($this->sieve_handle->response as $line){
$script.=$line;
}
$this->scripts[$key]['PARSER'] = $p;
$this->scripts[$key]['EDITED'] = FALSE;
}
- $this->sieve_handle = $sieve;
+ $this->sieve_handle = $this->sieve_handle;
}
$this->Sieve_Error = "";
/* Log into the mail server */
- $sieve= new sieve(
+ $this->sieve_handle= new sieve(
$cfg["sieve_server"],
$cfg["sieve_port"],
$this->parent->uid,
$cfg["admin"]);
/* Try to login */
- if (!$sieve->sieve_login()){
- $this->Sieve_Error = $sieve->error_raw;
+ if (!$this->sieve_handle->sieve_login()){
+ $this->Sieve_Error = $this->sieve_handle->error_raw;
return(FALSE);
}
- return($sieve);
+ return($this->sieve_handle);
}
if(preg_match("/[^a-z]/i",$name)){
$err = _("Only a-z are allowed in script names.");
}
+
+ $tmp = $this->get_used_script_names();
+ if(in_array_ics($name,$tmp)){
+ $err =_("The specified name is already in use.");
+ }
}
/* Create script if everything is ok */
$script = preg_replace("/_(x|y)/","",$script);
$once = FALSE;
- /* Get sieve */
- if(!$sieve = $this->get_sieve()){
- print_red(
- sprintf(
- _("Can't log into SIEVE server. Server says '%s'."),
- to_string($this->Sieve_Error)));
- }
+ /* We can only activate existing scripts */
+ if(!$this->scripts[$script]['IS_NEW']){
- /* Try to activate the given script and update
- * class script array.
- */
- if(!$sieve->sieve_setactivescript($this->scripts[$script]['NAME'])){
- print_red(sprintf(_("Can't activate sieve script on server. Server says '%s'."),to_string($sieve->error_raw)));
- }else{
- foreach($this->scripts as $key => $data){
- if($key == $script){
- $this->scripts[$key]['ACTIVE'] = TRUE;
- }else{
- $this->scripts[$key]['ACTIVE'] = FALSE;
+ /* Get sieve */
+ if(!$this->sieve_handle = $this->get_sieve()){
+ print_red(
+ sprintf(
+ _("Can't log into SIEVE server. Server says '%s'."),
+ to_string($this->Sieve_Error)));
+ }
+
+ /* Try to activate the given script and update
+ * class script array.
+ */
+ if(!$this->sieve_handle->sieve_setactivescript($this->scripts[$script]['NAME'])){
+ print_red(sprintf(_("Can't activate sieve script on server. Server says '%s'."),to_string($this->sieve_handle->error_raw)));
+ }else{
+ foreach($this->scripts as $key => $data){
+ if($key == $script){
+ $this->scripts[$key]['ACTIVE'] = TRUE;
+ }else{
+ $this->scripts[$key]['ACTIVE'] = FALSE;
+ }
}
}
}
}else{
/* Get sieve */
- if(!$sieve = $this->get_sieve()){
+ if(!$this->sieve_handle = $this->get_sieve()){
print_red(
sprintf(
_("Can't log into SIEVE server. Server says '%s'."),
to_string($this->Sieve_Error)));
}
- if(!$sieve->sieve_deletescript($this->scripts[$this->script_to_delete]['NAME'])){
- print_red(sprintf(_("Can't remove sieve script from server. Server says '%s'."),to_string($sieve->error_raw)));
+ if(!$this->sieve_handle->sieve_deletescript($this->scripts[$this->script_to_delete]['NAME'])){
+ print_red(sprintf(_("Can't remove sieve script from server. Server says '%s'."),to_string($this->sieve_handle->error_raw)));
}else{
unset($this->scripts[$this->script_to_delete]);
}
"attach" => "style='width:30px;'");
}
- if($active){
+ if($active || $script['IS_NEW']){
$field6 = array("string" => "<img src='images/empty.png' alt=' '>".
"<input type='image' name='editscript_".$key."' src='images/edit.png'>".
"<input type='image' name='delscript_".$key."' src='images/edittrash.png'>");
}
}
+
+ function get_used_script_names()
+ {
+ $ret = array();
+ foreach($this->scripts as $script){
+ $ret[] = $script['NAME'];
+ }
+ return($ret);
+ }
+
+
function save()
{
/* Get sieve */
- if(!$sieve = $this->get_sieve()){
+ if(!$this->sieve_handle = $this->get_sieve()){
print_red(
sprintf(
_("Can't log into SIEVE server. Server says '%s'."),
foreach($this->scripts as $key => $script){
if($script['EDITED']){
$data = $this->scripts[$key]['SCRIPT'];
- if(!$sieve->sieve_sendscript($script['NAME'], $data)){
- gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($sieve->error_raw));
+ if(!$this->sieve_handle->sieve_sendscript($script['NAME'], $data)){
+ gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
$everything_went_fine = FALSE;
- print_red(to_string($sieve->error_raw));
+ print_red(to_string($this->sieve_handle->error_raw));
$this->scripts[$key]['MSG'] = "<font color='red'>".
_("Failed to save sieve script").": ".
- to_string($sieve->error_raw).
+ to_string($this->sieve_handle->error_raw).
"</font>";
}
}
index 0559f54a91da35a05b2069fb716e201eed9207a8..240cdba59246c24a0293d19393121bca7ca1cd8d 100644 (file)
<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 language="JavaScript" type="text/javascript">
+ document.mainform.NewScriptName.focus();
</script>
diff --git a/include/sieve/templates/edit_frame_base.tpl b/include/sieve/templates/edit_frame_base.tpl
index 241ab9429aa1a0eac39f9f3043fe98234283c819..84d2bd62284210803f02a62742d40d22fe518a4b 100644 (file)
<input type='submit' name='Import_Script' value="{t}Import{/t}">
{if $Mode != "Source-Only"}
- <input type='submit' name='View_Source' value="{t}View source{/t}">
+
+ {if $Mode == "Source"}
<input type='submit' name='View_Structured' value="{t}View structured{/t}">
+ {else}
+ <input type='submit' name='View_Source' value="{t}View source{/t}">
+ {/if}
{/if}
</td>
</tr>