X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_faiHookEntry.inc;h=09b5d8dbfb4cb528ea11ee4d4f0882e639643de8;hb=ff3ef83f8dcb54659807a39f8513486b5c0badb0;hp=668e12cf7407ec7ee446f340971abb479021cf9e;hpb=b27dce8b0c43c73a52c85320e3a2086828b43af3;p=gosa.git diff --git a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc index 668e12cf7..09b5d8dbf 100644 --- a/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc +++ b/gosa-plugins/fai/admin/fai/class_faiHookEntry.inc @@ -23,7 +23,7 @@ class faiHookEntry extends plugin function faiHookEntry (&$config, $dn= NULL,$object=false) { - plugin::plugin ($config, $dn); + plugin::plugin ($config, NULL); if($dn != "new"){ $this->orig_cn= $object['cn']; $this->dn=$object['dn']; @@ -31,11 +31,6 @@ class faiHookEntry extends plugin $oname = $name; $this->$oname=$value; } - - if(isset($this->attrs['FAIstate'][0])){ - $this->FAIstate = $this->attrs['FAIstate'][0]; - } - }elseif(is_array($object)){ if(count($object)){ $this->orig_cn= $object['cn']; @@ -64,19 +59,19 @@ class faiHookEntry extends plugin if(isset($_POST['ImportUpload'])){ if(($_FILES['ImportFile']['error']!=0)){ - msg_dialog::display(_("Error"), _("Upload failed!"), ERROR_DIALOG); + msg_dialog::display(_("Error"), msgPool::incorrectUpload(), ERROR_DIALOG); }else if(($_FILES['ImportFile']['size']==0)){ - msg_dialog::display(_("Error"), _("Uploaded file is empty!"), ERROR_DIALOG); + msg_dialog::display(_("Error"), msgPool::incorrectUpload(_("file is empty")), ERROR_DIALOG); }else{ $str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name'])); - $this->FAIscript = $str; + $this->FAIscript = addslashes ($str); } } /* File download requested */ if(isset($_GET['getFAIHook'])){ - send_binary_content($this->FAIscript,$this->cn.".FAIhook"); + send_binary_content(stripslashes($this->FAIscript),$this->cn.".FAIhook"); } /* Create download button*/ @@ -110,10 +105,7 @@ class faiHookEntry extends plugin $tmp = $this->plInfo(); foreach($tmp['plProvidedAcls'] as $name => $translated){ - $acl = $this->getacl($name); - if($this->FAIstate == "freezed"){ - $acl = preg_replace("/w/","",$acl); - } + $acl = $this->getacl($name, preg_match("/freeze/",$this->FAIstate)); $smarty->assign($name."ACL",$acl); } @@ -122,6 +114,7 @@ class faiHookEntry extends plugin }else{ $smarty->assign("FAIscript" , htmlentities($this->FAIscript)); } + $smarty->assign("freeze" , preg_match("/freeze/",$this->FAIstate)); $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); return($display); } @@ -129,7 +122,7 @@ class faiHookEntry extends plugin /* Save data to object */ function save_object() { - if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ + if((isset($_POST['SubObjectFormSubmitted'])) && !preg_match("/^freeze/", $this->FAIstate)){ foreach($this->attributes as $attrs){ if($this->acl_is_writeable($attrs)){ if(isset($_POST[$attrs])){ @@ -149,15 +142,20 @@ class faiHookEntry extends plugin $message= plugin::check(); if(isset($this->parent->SubObjects[$this->cn]) && $this->cn != $this->orig_cn){ - $message[] =_("Name is already in use!"); + $message[]= msgPool::duplicated(_("Name")); } - if(empty($this->FAIscript)) { - $message[]=_("Please enter a script!"); + $c = trim($this->cn); + if($c == ""){ + $message[] = msgPool::required(_("Name")); + } + if(preg_match("/[^a-z0-9_\-]/i",$c)){ + $message[] = msgPool::invalid(_("Name"),$c,"/[a-z0-9_\-]/i"); } - if(empty($this->cn)){ - $message[] = _("Name is empty!"); + $s = trim($this->FAIscript); + if($s == ""){ + $message[]= msgPool::required(_("Script")); } return ($message);