Code

Added empty lines
[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("description","type","charset","path","option");
13   var $objectclasses    = array("whatever");
14   var $is_account       = true;
16   var $name          ="";  // Name of  
17   var $description   ="";  // description
18   var $type          ="";  // Type FS/Samba/NCP
19   var $charset       ="";  // charset
20   var $types         =array();  // Array Types NFS/Samba/NCP
21   var $charsets      =array();  // Array with charsets
22   var $path          ="";  // Path
23   var $option        ="";  // Options
24   var $is_edit           =false;
27   function servnfs ($config, $dn= NULL,$entry = false)
28   {
29     plugin::plugin ($config, $dn);
30     $this->types   = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP");
31     $this->charsets = 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->name          = $tmp[0];  // Name of NFS
41       $this->description   = $tmp[1];  // description
42       $this->type          = $tmp[2];  // Type NFS/Samba/NCP
43       $this->charset       = $tmp[3];  // charset
44       $this->path          = $tmp[4];  // Path
45       $this->option        = $tmp[5];  // Options
46       $this->is_edit          = true;
47     }else{
48       $this->attributes[] = "name";
49     }
50   }
52   function execute()
53   {
54         /* Call parent execute */
55         plugin::execute();
57     /* Fill templating stuff */
58     $smarty= get_smarty();
60     $smarty->assign("charsets" ,$this->charsets);
61     $smarty->assign("types"    ,$this->types);
63     /* attrs to smarty*/
64     foreach($this->attributes as $attr){
65       $smarty->assign($attr,$this->$attr);
66     }
68     $smarty->assign("nameACL","");    
69     $smarty->assign("name",$this->name);
71     if($this->is_edit){
72       $smarty->assign("nameACL"," disabled ");
73     }
75     $display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
76     return($display);
77   }
79   function remove_from_parent()
80   {
81     /* This cannot be removed... */
82   }
85   /* Save data to object */
86   function save_object()
87   {
88     plugin::save_object(TRUE);
89     if(isset($_POST['path'])){
90       foreach($this->attributes as $attr){
91         $this->$attr = $_POST[$attr];
92       }
93     }
94   }
97   /* Check supplied data */
98   function check()
99   {
100     $message= array();
102     // fixme : a check for the path ?  ? 
103     if(empty($this->path)){
104       $message[]=_("Please specify a valid path for your setup.");
105     }
107     // only 0-9a-z
108     if(!$this->is_edit){
109       if(preg_match("/[^a-z0-9]/i",$this->name)){
110         $message[]=_("Please specify a valid name for your setup.");
111       }
112       if(empty($this->name)){
113         $message[]=_("Please specify a name for your setup.");
114       }
115     }
117     if(preg_match("/\|/",$this->description)){
118       $message[]=_("Description contains invalid characters.");
119     }
120   
121     if(preg_match("/\|/",$this->path)){
122       $message[]=_("Path contains invalid characters.");
123     }
125     if(preg_match("/\|/",$this->option)){
126       $message[]=_("Option contains invalid characters.");
127     }
129     $ldap= $this->config->get_ldap_link();
130     $ldap->cd($this->config->current['BASE']);
131     $ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
132     while($test = $ldap->fetch()){
133       if($test['dn']==$this->dn)
134         continue;
135       foreach($test['goExportEntry'] as $entry){
136         $tmp = split("\|",$entry);
137         if($tmp[0] == $this->name){
138           $message[]="Name already in use";
139         }
140       }
141     }
142     return ($message);
143   }
146   /* Save to LDAP */
147   function save()
148   {
149     /* Everything seems perfect, lets 
150        generate an new export Entry 
151      */
153     $s_return = "";
155     $s_return.= $this->name."|";     
156     $s_return.= $this->description."|";     
157     $s_return.= $this->type."|";     
158     $s_return.= $this->charset."|";     
159     $s_return.= $this->path."|";     
160     $s_return.= $this->option;     
162     return(array($this->name=>$s_return));
163   }
167 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
168 ?>