Code

95957ecc554abb8ae838a8128c89ef37cf3313a1
[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     /* Fill templating stuff */
55     $smarty= get_smarty();
57     $smarty->assign("charsets" ,$this->charsets);
58     $smarty->assign("types"    ,$this->types);
60     /* attrs to smarty*/
61     foreach($this->attributes as $attr){
62       $smarty->assign($attr,$this->$attr);
63     }
65     $smarty->assign("nameACL","");    
66     $smarty->assign("name",$this->name);
68     if($this->is_edit){
69       $smarty->assign("nameACL"," disabled ");
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['path'])){
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->path)){
101       $message[]=_("Please specify a valid path for your setup.");
102     }
104     // only 0-9a-z
105     if(!$this->is_edit){
106       if(preg_match("/[^a-z0-9]/i",$this->name)){
107         $message[]=_("Please specify a valid name for your setup.");
108       }
109       if(empty($this->name)){
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->name){
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      */
138     $s_return = "";
140     $s_return.= $this->name."|";     
141     $s_return.= $this->description."|";     
142     $s_return.= $this->type."|";     
143     $s_return.= $this->charset."|";     
144     $s_return.= $this->path."|";     
145     $s_return.= $this->option;     
147     return(array($this->name=>$s_return));
148   }
152 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
153 ?>