Code

bb85475f5f9fc6e2d6ac7a8a6b208b3aa9218774
[gosa.git] / plugins / admin / systems / class_servNfs.inc
1 <?php
3 class servnfs extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary      = "Manage server objects";
7   var $cli_description  = "Some longer text\nfor help";
8   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account   = TRUE;
12   var $attributes       = array("NFSdescription","NFStype","NFScharset","NFSpath","NFSoption");
13   var $objectclasses    = array("whatever");
14   var $is_account       = true;
16   var $NFSname          ="";  // Name of NFS 
17   var $NFSdescription   ="";  // description
18   var $NFStype          ="";  // Type NFS/Samba/NCP
19   var $NFScharset       ="";  // charset
20   var $NFStypes         =array();  // Array Types NFS/Samba/NCP
21   var $NFScharsets      =array();  // Array with charsets
22   var $NFSpath          ="";  // Path
23   var $NFSoption        ="";  // Options
24   var $is_edit           =false;
27   function servnfs ($config, $dn= NULL,$entry = false)
28   {
29     plugin::plugin ($config, $dn);
30     $this->NFStypes   = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP");
31     $this->NFScharsets = array("UTF-8" => "UTF-8",
32                         "ISO8859-1"=>"ISO8859-1 (Latin 1)",
33                         "ISO8859-2"=>"ISO8859-2 (Latin 2)",
34                         "ISO8859-3"=>"ISO8859-3 (Latin 3)",
35                         "ISO8859-4"=>"ISO8859-4 (Latin 4)",
36                         "ISO8859-5"=>"ISO8859-5 (Latin 5)");
38     if($entry){
39       $tmp = split("\|",$entry);
40       $this->NFSname          = $tmp[0];  // Name of NFS
41       $this->NFSdescription   = $tmp[1];  // description
42       $this->NFStype          = $tmp[2];  // Type NFS/Samba/NCP
43       $this->NFScharset       = $tmp[3];  // charset
44       $this->NFSpath          = $tmp[4];  // Path
45       $this->NFSoption        = $tmp[5];  // Options
46       $this->is_edit          = true;
47     }else{
48     $this->attributes[] = "NFSname";
49     }
50   }
52   function execute()
53   {
54     /* Fill templating stuff */
55     $smarty= get_smarty();
57     $smarty->assign("NFScharsets" ,$this->NFScharsets);
58     $smarty->assign("NFStypes"    ,$this->NFStypes);
60     /* attrs to smarty*/
61     foreach($this->attributes as $attr){
62       $smarty->assign($attr,$this->$attr);
63     }
64     
65     $smarty->assign("NFSnameACL","");    
67     if($this->is_edit){
68       $smarty->assign("NFSnameACL"," disabled ");
69       $smarty->assign("NFSname","");
70     }
72     $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
73     return($display);
74   }
76   function remove_from_parent()
77   {
78     /* This cannot be removed... */
79   }
82   /* Save data to object */
83   function save_object()
84   {
85     plugin::save_object(TRUE);
86     if(isset($_POST['NFSpath'])){
87       foreach($this->attributes as $attr){
88         $this->$attr = $_POST[$attr];
89       }
90     }
91   }
94   /* Check supplied data */
95   function check()
96   {
97     $message= array();
99     // fixme : a check for the path ?  ? 
100     if(empty($this->NFSpath)){
101       $message[]=_("Please specify a valid path for your setup.");
102     }
103   
104     // only 0-9a-z
105     if(!$this->is_edit){
106       if(preg_match("/[^a-z0-9]/i",$this->NFSname)){
107         $message[]=_("Please specify a valid name for your setup.");
108       }
109       if(empty($this->NFSname)){
110         $message[]=_("Please specify a name for your setup.");
111       }
112     }
114     $ldap= $this->config->get_ldap_link();
115     $ldap->cd($this->config->current['BASE']);
116     $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
117     while($test = $ldap->fetch()){
118       if($test['dn']==$this->dn)
119         continue;
120       foreach($test['goExportEntry'] as $entry){
121         $tmp = split("\|",$entry);
122         if($tmp[0] == $this->NFSname){
123           $message[]="Name already in use";
124         }
125       }
126     }
127     return ($message);
128   }
131   /* Save to LDAP */
132   function save()
133   {
134     /* Everything seems perfect, lets 
135        generate an new export Entry 
136     */
137   
138     $s_return = "";
139     
140     $s_return.= $this->NFSname."|";     
141     $s_return.= $this->NFSdescription."|";     
142     $s_return.= $this->NFStype."|";     
143     $s_return.= $this->NFScharset."|";     
144     $s_return.= $this->NFSpath."|";     
145     $s_return.= $this->NFSoption;     
147     return(array($this->NFSname=>$s_return));
148   }
152 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
153 ?>