Code

Added some fixes for iframe scrolling
[gosa.git] / plugins / admin / systems / class_servNfs.inc
index e89bab3ea9e939c26340ba83a4a0a27a576fb302..c7b05c3621f7a1fe0e7aa8781fee7acf93982569 100644 (file)
@@ -24,36 +24,36 @@ class servnfs extends plugin
   var $volume        ="";  // Volume
   var $option        ="";  // Options
   var $is_edit           =false;
-  var $allow_mounts = false; //do we allow mount entries?
   var $create_mount_init = false; //mount entry set for this entry (while editing)?
   var $create_mount = false; //save mount entry
 
-  function servnfs ($config, $acl, $allow_mounts, $dn= NULL,$entry = false,$mount = false)
+  var $parent       = NULL;
+
+  function servnfs ($config, $parent,$entry= false,$mount =false)
   {
+    $this->parent = $parent;
+    $dn = $parent->dn;
     plugin::plugin ($config, $dn);
-    
-    $this->types   = array("NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
+
+    $this->types   = array("CIFS" => "CIFS", "NFS"=>"NFS","samba"=>"samba","netatalk"=>"netatalk","NCP"=>"NCP");
     if($dn){
       $this->host = substr($dn, 3, strpos($dn, ',')-3);
     }
-    
-    $this->acl = $acl;
-       $this->allow_mounts=$allow_mounts;
-       
+
     $this->charsets = array();
 
-    if(!file_exists("/etc/gosa/encodings")){
-      print_red(_("The file '/etc/gosa/encodings' does not exist, can't get supported charsets."));
+    if(!file_exists(CONFIG_DIR."/encodings")){
+      print_red(sprintf(_("The file '%s/encodings' does not exist, can't get supported charsets."),CONFIG_DIR));
     }else{
-      if(!is_readable("/etc/gosa/encodings")){
-        print_red(_("Can't read '/etc/gosa/encodings', please check permissions."));
+      if(!is_readable(CONFIG_DIR."/encodings")){
+        print_red(sprintf(_("Can't read '%s/encodings', please check permissions."),CONFIG_DIR));
       }else{
-        $fp = fopen("/etc/gosa/encodings","r");
+        $fp = fopen(CONFIG_DIR."/encodings","r");
         $i = 100;
         while(!feof($fp)&&$i){
           $i -- ;
           $str = trim(fgets($fp,256));
-      
+
           /* Skip comments */
           if(!preg_match("/^#/",$str)){
             $arr = split("\=",$str);
@@ -62,20 +62,19 @@ class servnfs extends plugin
             }
           }
         }
-
-    
       }
     }
 
     if($entry){
       list($this->name, $this->description, $this->type, $this->charset,
-           $this->path, $this->option, $this->volume)= split("\|",$entry."|");
+          $this->path, $this->option, $this->volume)= split("\|",$entry."|");
       $this->is_edit          = true;
-      
+
     }else{
       $this->attributes[] = "name";
     }
-    
+
+
     $this->create_mount_init = $mount;
   }
 
@@ -95,49 +94,47 @@ class servnfs extends plugin
       $smarty->assign($attr,$this->$attr);
     }
 
-    $smarty->assign("nameACL","");    
-    $smarty->assign("name",$this->name);
+    $tmp = $this->parent->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->parent->getacl($name));
+    }
 
+    $smarty->assign("name",$this->name);
     if($this->is_edit){
-      $smarty->assign("nameACL"," disabled ");
-    }
-    
-    $smarty->assign("allow_mounts", $this->allow_mounts);
+      $smarty->assign("nameACL", preg_replace("/w/","",$this->parent->getacl("name")));
+    } 
+    $smarty->assign("allow_mounts", $this->parent->allow_mounts);
     $smarty->assign("mount_checked", "");
-    
-    
-    $appleMountsACL=chkacl($this->acl,"gotoShareAppleMounts");
-    $appleMountsACLset=strpos($appleMountsACL, "disabled");
-    $smarty->assign("appleMountsACL", $appleMountsACL);
-    $smarty->assign("appleMountsACLset", $appleMountsACLset);
-  
+
+    $smarty->assign("appleMountsACL",    $this->getacl("appleMounts"));
+
     if (($this->type == "netatalk") || ($this->type == "NFS")) {
-        if ($this->create_mount_init) {
-          $smarty->assign("mount_checked", "checked");
-        } else {
+      if ($this->create_mount_init) {
+        $smarty->assign("mount_checked", "checked");
+      } else {
         $tmp = split(",", $this->dn);
         $clip = $tmp[0] . ",ou=servers,ou=systems,";
         $mountsdn = "cn=mounts," . substr($this->dn, strlen($clip));
-          switch ($this->type) {
-            case "netatalk" : {
-              $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
-              break;
-            }
-            case "NFS" : {
-              $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
-              break;
-            }
-            default : {
-              continue;
-            }
+        switch ($this->type) {
+          case "netatalk" : {
+            $mountdn = "cn=".$this->host.":/".$this->name.",".$mountsdn;
+            break;
+          }
+          case "NFS" : {
+            $mountdn = "cn=".$this->host.":".$this->path.",".$mountsdn;
+            break;
           }
+          default : {
+                      continue;
+                    }
+        }
         $ldap = $this->config->get_ldap_link();
         $ldap->cat($mountdn, array('dn'));
         $attrs = $ldap->fetch();
         if (count($attrs) > 0) {
-            $smarty->assign("mount_checked", "checked");
+          $smarty->assign("mount_checked", "checked");
         }
-        }        
+      }        
     }
 
     $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
@@ -153,17 +150,19 @@ class servnfs extends plugin
   /* Save data to object */
   function save_object()
   {
-    plugin::save_object(TRUE);
-    if(isset($_POST['path'])){
-      foreach($this->attributes as $attr){
-        $this->$attr = $_POST[$attr];
+    if(isset($_POST['servnfs_posted'])){
+
+      foreach($this->attributes as $name){
+        if($this->parent->acl_is_writeable($name) && isset($_POST[$name])){
+          $this->$name = $_POST[$name];
+        }
       }
-    }
-    
-    if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
+
+      if ((isset($_POST['netatalk_mount'])) && (($this->type == "netatalk") || ($this->type == "NFS"))) {
         $this->create_mount = true;
-    } else {
+      } else {
         $this->create_mount = false;
+      }
     }
   }
 
@@ -181,7 +180,7 @@ class servnfs extends plugin
 
     // only 0-9a-z
     if(!$this->is_edit){
-      if(preg_match("/[^a-z0-9\.\-_]/i",$this->name)){
+      if(!preg_match("/^[a-z0-9\._]+$/i",$this->name)){
         $message[]=_("Please specify a valid name for your share.");
       }
       if(empty($this->name)){
@@ -189,29 +188,29 @@ class servnfs extends plugin
       }
     }
 
-    if(preg_match("/\|/",$this->description)){
+    if(preg_match("/[^a-z0-9äöü._+ -]+/i",$this->description)){
       $message[]=_("Description contains invalid characters.");
     }
 
-    if(preg_match("/\|/",$this->volume)){
+    if(preg_match("/[^a-z0-9._+ -]/i",$this->volume)){
       $message[]=_("Volume contains invalid characters.");
     }
-  
+
     if(preg_match("/\|/",$this->path)){
       $message[]=_("Path contains invalid characters.");
     }
 
-    if(preg_match("/\|/",$this->option)){
+    if(preg_match("/[^a-z0-9\.,=_+ -]/i",$this->option)){
       $message[]=_("Option contains invalid characters.");
     }
 
-  /* remove a / at the end of the path, we neither need it there nor
-   * do we want to check for it later.
-   */
-  if(substr($this->path, -1, 1) == '/') {
-    $this->path=substr($this->path, 0, -1);
-  }
-  
+    /* remove a / at the end of the path, we neither need it there nor
+     * do we want to check for it later.
+     */
+    if(substr($this->path, -1, 1) == '/') {
+      $this->path=substr($this->path, 0, -1);
+    }
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
     $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
@@ -250,11 +249,12 @@ class servnfs extends plugin
 
     return(array($this->name=>$s_return));
   }
-  
+
   function should_create_mount() {
     return $this->create_mount;
   }
 
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: