index bb85475f5f9fc6e2d6ac7a8a6b208b3aa9218774..7a72a47d206411a5edbac73e4a3a86e84dcabeb9 100644 (file)
/* attribute list for save action */
var $ignore_account = TRUE;
- var $attributes = array("NFSdescription","NFStype","NFScharset","NFSpath","NFSoption");
+ var $attributes = array("description","type","charset","path","option");
var $objectclasses = array("whatever");
var $is_account = true;
- var $NFSname =""; // Name of NFS
- var $NFSdescription =""; // description
- var $NFStype =""; // Type NFS/Samba/NCP
- var $NFScharset =""; // charset
- var $NFStypes =array(); // Array Types NFS/Samba/NCP
- var $NFScharsets =array(); // Array with charsets
- var $NFSpath =""; // Path
- var $NFSoption =""; // Options
+ var $name =""; // Name of
+ var $description =""; // description
+ var $type =""; // Type FS/Samba/NCP
+ var $charset =""; // charset
+ var $types =array(); // Array Types NFS/Samba/NCP
+ var $charsets =array(); // Array with charsets
+ var $path =""; // Path
+ var $option =""; // Options
var $is_edit =false;
function servnfs ($config, $dn= NULL,$entry = false)
{
plugin::plugin ($config, $dn);
- $this->NFStypes = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP");
- $this->NFScharsets = array("UTF-8" => "UTF-8",
- "ISO8859-1"=>"ISO8859-1 (Latin 1)",
- "ISO8859-2"=>"ISO8859-2 (Latin 2)",
- "ISO8859-3"=>"ISO8859-3 (Latin 3)",
- "ISO8859-4"=>"ISO8859-4 (Latin 4)",
- "ISO8859-5"=>"ISO8859-5 (Latin 5)");
+ $this->types = array("NFS"=>"NFS","samba"=>"samba","NCP"=>"NCP");
+
+ $this->charsets = array();
+
+ if(!file_exists("/etc/gosa/encodings")){
+ print_red(_("The file '/etc/gosa/encodings' does not exist, can't get supported charsets."));
+ }else{
+ if(!is_readable("/etc/gosa/encodings")){
+ print_red(_("Can't read '/etc/gosa/encodings', please check permissions."));
+ }else{
+ $fp = fopen("/etc/gosa/encodings","r");
+ $i = 100;
+ while(!feof($fp)&&$i){
+ $i -- ;
+ $str = trim(fgets($fp,256));
+
+ /* Skip comments */
+ if(!preg_match("/^#/",$str)){
+ $arr = split("\=",$str);
+ if(count($arr)==2){
+ $this->charsets[$arr[0]]=$arr[1];
+ }
+ }
+ }
+
+
+ }
+ }
if($entry){
$tmp = split("\|",$entry);
- $this->NFSname = $tmp[0]; // Name of NFS
- $this->NFSdescription = $tmp[1]; // description
- $this->NFStype = $tmp[2]; // Type NFS/Samba/NCP
- $this->NFScharset = $tmp[3]; // charset
- $this->NFSpath = $tmp[4]; // Path
- $this->NFSoption = $tmp[5]; // Options
+ $this->name = $tmp[0]; // Name of NFS
+ $this->description = $tmp[1]; // description
+ $this->type = $tmp[2]; // Type NFS/Samba/NCP
+ $this->charset = $tmp[3]; // charset
+ $this->path = $tmp[4]; // Path
+ $this->option = $tmp[5]; // Options
$this->is_edit = true;
}else{
- $this->attributes[] = "NFSname";
+ $this->attributes[] = "name";
}
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
- $smarty->assign("NFScharsets" ,$this->NFScharsets);
- $smarty->assign("NFStypes" ,$this->NFStypes);
+ $smarty->assign("charsets" ,$this->charsets);
+ $smarty->assign("types" ,$this->types);
/* attrs to smarty*/
foreach($this->attributes as $attr){
$smarty->assign($attr,$this->$attr);
}
-
- $smarty->assign("NFSnameACL","");
+
+ $smarty->assign("nameACL","");
+ $smarty->assign("name",$this->name);
if($this->is_edit){
- $smarty->assign("NFSnameACL"," disabled ");
- $smarty->assign("NFSname","");
+ $smarty->assign("nameACL"," disabled ");
}
$display= $smarty->fetch(get_template_path('servnfs.tpl', TRUE));
function save_object()
{
plugin::save_object(TRUE);
- if(isset($_POST['NFSpath'])){
+ if(isset($_POST['path'])){
foreach($this->attributes as $attr){
$this->$attr = $_POST[$attr];
}
$message= array();
// fixme : a check for the path ? ?
- if(empty($this->NFSpath)){
+ if(empty($this->path)){
$message[]=_("Please specify a valid path for your setup.");
}
-
+
// only 0-9a-z
if(!$this->is_edit){
- if(preg_match("/[^a-z0-9]/i",$this->NFSname)){
+ if(preg_match("/[^a-z0-9]/i",$this->name)){
$message[]=_("Please specify a valid name for your setup.");
}
- if(empty($this->NFSname)){
+ if(empty($this->name)){
$message[]=_("Please specify a name for your setup.");
}
}
+ if(preg_match("/\|/",$this->description)){
+ $message[]=_("Description contains invalid characters.");
+ }
+
+ if(preg_match("/\|/",$this->path)){
+ $message[]=_("Path contains invalid characters.");
+ }
+
+ if(preg_match("/\|/",$this->option)){
+ $message[]=_("Option contains invalid characters.");
+ }
+
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
$ldap->search("(objectClass=goShareServer)", array("goExportEntry"));
continue;
foreach($test['goExportEntry'] as $entry){
$tmp = split("\|",$entry);
- if($tmp[0] == $this->NFSname){
+ if($tmp[0] == $this->name){
$message[]="Name already in use";
}
}
{
/* Everything seems perfect, lets
generate an new export Entry
- */
-
+ */
+
$s_return = "";
-
- $s_return.= $this->NFSname."|";
- $s_return.= $this->NFSdescription."|";
- $s_return.= $this->NFStype."|";
- $s_return.= $this->NFScharset."|";
- $s_return.= $this->NFSpath."|";
- $s_return.= $this->NFSoption;
-
- return(array($this->NFSname=>$s_return));
+
+ $s_return.= $this->name."|";
+ $s_return.= $this->description."|";
+ $s_return.= $this->type."|";
+ $s_return.= $this->charset."|";
+ $s_return.= $this->path."|";
+ $s_return.= $this->option;
+
+ return(array($this->name=>$s_return));
}
}