Code

Added branches container for old stuff
[gosa.git] / gosa-plugins / goto / admin / systems / services / nfs / class_servNfs.inc
index 5756866273baad0c17aba9a4d25b31130c090037..147cc912ca4569a3cff3c6406952c4ecd2d008ba 100644 (file)
@@ -2,11 +2,6 @@
 
 class servnfs extends plugin
 {
-  /* CLI vars */
-  var $cli_summary      = "Manage server objects";
-  var $cli_description  = "Some longer text\nfor help";
-  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* attribute list for save action */
   var $ignore_account   = TRUE;
   var $attributes       = array("description","type","charset","path","option", "volume");
@@ -17,7 +12,7 @@ class servnfs extends plugin
   var $description   ="";  // description
   var $type          ="";  // Type FS/Samba/NCP
   var $charset       ="";  // charset
-  var $host       ="";  // hostname
+  var $host          ="";  // hostname
   var $types         =array();  // Array Types NFS/Samba/NCP/netatalk
   var $charsets      =array();  // Array with charsets
   var $path          ="";  // Path
@@ -44,10 +39,10 @@ class servnfs extends plugin
     $this->charsets = array();
 
     if(!file_exists(CONFIG_DIR."/encodings")){
-      print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR));
+      msg_dialog::display(_("Error"), msgPool::fileDoesNotExist(CONFIG_DIR."/encodings"), ERROR_DIALOG);
     }else{
       if(!is_readable(CONFIG_DIR."/encodings")){
-        print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR));
+        msg_dialog::display(_("Error"), msgPool::cannotReadFile(CONFIG_DIR."/encodings"), ERROR_DIALOG);
       }else{
         $fp = fopen(CONFIG_DIR."/encodings","r");
         $i = 100;
@@ -143,7 +138,7 @@ class servnfs extends plugin
       }        
     }
 
-    $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
+    $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE, dirname(__FILE__)));
     return($display);
   }
 
@@ -179,35 +174,38 @@ class servnfs extends plugin
     /* Call common method to give check the hook */
     $message= plugin::check();
 
-    // fixme : a check for the path ?  ? 
     if(empty($this->path)){
-      $message[]=_("Please specify a valid path for your setup.");
+      $message[]= msgPool::required(_("Path"));
+    }
+
+    if(!tests::is_path($this->path)){
+      $message[]= _("'Path / Volume' must contain at least one '/'!");
+    }
+
+    if(!in_array($this->type,$this->types)){
+      $message[]= msgPool::required(_("Type"));
     }
 
     // only 0-9a-z
     if(!$this->is_edit){
-      if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){
-        $message[]=_("Please specify a valid name for your share.");
-      }
       if(empty($this->name)){
-        $message[]=_("Please specify a name for your share.");
+        $message[]= msgPool::required(_("Name"));
+      }
+      if(!preg_match("/^[a-z0-9\._äüö]*$/ui",$this->name)){
+        $message[]= msgPool::invalid(_("Name"),$this->name,"/[a-z0-9\._äüö]/ui");
       }
     }
 
     if(!empty($this->description) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->description)){
-      $message[]=_("Description contains invalid characters.");
+      $message[]= msgPool::invalid(_("Description"),$this->description,"/^[a-z0-9\._äüö\+ -]*$/ui");
     }
 
     if(!empty($this->volume) && preg_match("/^[^a-z0-9\._äüö\+ -]*$/ui",$this->volume)){
-      $message[]=_("Volume contains invalid characters.");
-    }
-
-    if(preg_match("/\|/",$this->path)){
-      $message[]=_("Path contains invalid characters.");
+      $message[]= msgPool::invalid(_("Volume"),$this->volume,"/^[a-z0-9\._äüö\+ -]*$/ui");
     }
 
     if(!empty($this->option) && preg_match("/^[^a-z0-9\._äüö,=\+ -]*$/ui",$this->option)){
-      $message[]=_("Option contains invalid characters.");
+      $message[]= msgPool::invalid(_("Option"),$this->option,"/^[a-z0-9\._äüö\+ -]*$/ui");
     }
 
     /* remove a / at the end of the path, we neither need it there nor
@@ -227,7 +225,7 @@ class servnfs extends plugin
         foreach($test['goExportEntry'] as $entry){
           $tmp = split("\|",$entry);
           if($tmp[0] == $this->name){
-            $message[]="Name already in use";
+            $message[]= msgPool::duplicated(_("Name"));
           }
         }
       }