Code

Added DNS and DHCP enable disable options into setup step 2
[gosa.git] / include / sieve / class_sieveManagement.inc
index 90e87bf23b22bff02d4ee041dd397d54e346464c..90b4b54efc1abed34864ce5db604017247889de5 100644 (file)
@@ -62,7 +62,7 @@ class sieveManagement extends plugin
   {
     /* Check given parameter */
     if(!isset($parent->$uattrib)){
-      trigger_error("Sieve Management implementation error. Parameter 4 must be part of the given parent element.");
+      trigger_error("Sieve Management implementation error. Parameter 4 (".$uattrib.") must be part of the given parent element (".get_class($parent).").");
     }
 
     $this->uattrib = $uattrib;
@@ -191,31 +191,35 @@ class sieveManagement extends plugin
       }
  
       /* Check given name */ 
-      $err = "";
+      $err = false;
 
       /* 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)){
-          $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)){
-          $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)){
-          $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 */
-      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;
@@ -252,7 +256,6 @@ class sieveManagement extends plugin
         /* 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__))));
       }
     }
@@ -403,7 +406,7 @@ class sieveManagement extends plugin
         }
       }else{
         foreach($chk as $msgs){
-          print_red(sprintf(_("Please fix all errors before saving. Last error was : %s"),$msgs));
+          print_red(sprintf(_("Please fix all errors before saving. Last error was: %s"),$msgs));
         }
       }
     }
@@ -430,11 +433,11 @@ class sieveManagement extends plugin
           $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."));
+            print_red(_("Upload failed. The temporary file can't be accessed."));
           }elseif(!is_readable ($file['tmp_name'])){
-            print_red(sprintf(_("Can't open file '%s' to read uploaded file contents."),$file['tmp_name']));
+            print_red(sprintf(_("Can't open file '%s'."),$file['tmp_name']));
           }else{
             
             
@@ -565,7 +568,7 @@ class sieveManagement extends plugin
               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");
             }
           }
         }
@@ -641,7 +644,7 @@ class sieveManagement extends plugin
       }
       $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'
@@ -660,8 +663,10 @@ class sieveManagement extends plugin
       $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.
@@ -758,12 +763,12 @@ class sieveManagement extends plugin
           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");
         }else{
          
           /* Allow adding elsif above elsif */ 
           if(in_array(get_class($obj),array("sieve_elsif"))){
-            $element_types['sieve_elsif'] = _("Else if");
+            $element_types['sieve_elsif'] = _("Else If");
           }
         }
       }
@@ -791,6 +796,15 @@ class sieveManagement extends plugin
       $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime()),$parent);
       $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()),$parent);
       $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime()),$parent);
+    }elseif($this->add_element_type == "sieve_vacation"){
+
+      /* Automatically add addresses to sieve alternate addresses */
+      $data = NULL;
+      $tmp = new $this->add_element_type($data, preg_replace("/[^0-9]/","",microtime()),$parent);
+      if(isset($this->parent->gosaMailAlternateAddress)){
+        $tmp->addresses = $this->parent->gosaMailAlternateAddress;
+      }
+      $ele[] = $tmp ;
     }else{
       $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()),$parent);
     }
@@ -1034,7 +1048,8 @@ class sieveManagement extends plugin
       if($script['EDITED']){
         $data = $this->scripts[$key]['SCRIPT'];
         if(!$this->sieve_handle->sieve_sendscript($script['NAME'], addcslashes ($data,"\\"))){
-          gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
+          new log("modify","users/mailAccount".get_class($this),$script['NAME'],"Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
+
           $everything_went_fine = FALSE;
           print_red(to_string($this->sieve_handle->error_raw));
           $this->scripts[$key]['MSG'] = "<font color='red'>".