X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Ffai%2Fclass_faiHookEntry.inc;h=c73d2e886a54b9820edeac61c0aa99266349e588;hb=d4729740d1db57e957c1c6667edf37f5b09e99e1;hp=472050aa6e531ce14cc738a6688bec2b6809e773;hpb=84d2c065af9ce3f287fef380606a593a0cda5a81;p=gosa.git diff --git a/plugins/admin/fai/class_faiHookEntry.inc b/plugins/admin/fai/class_faiHookEntry.inc index 472050aa6..c73d2e886 100644 --- a/plugins/admin/fai/class_faiHookEntry.inc +++ b/plugins/admin/fai/class_faiHookEntry.inc @@ -15,13 +15,15 @@ class faiHookEntry extends plugin var $orig_cn = ""; var $tasks = array("chboot", "configure", "debconf", "extrbase", "faiend", "finish", "install", "instsoft", "mirror", "mountdisks", "partition", "prepareapt", - "savelog", "softupdate", "sysinfo"," updatebase"); + "savelog", "softupdate", "sysinfo","updatebase"); var $dn = ""; var $cn = ""; var $FAItask = ""; var $FAIscript = ""; var $description = ""; var $status = "new"; + + var $FAIstate = ""; function faiHookEntry ($config, $dn= NULL,$object=false) { @@ -33,9 +35,24 @@ class faiHookEntry extends plugin $oname = $name; $this->$oname=$value; } - }else{ - $this->status = "new"; - $this->orig_cn = false; + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + + }elseif(is_array($object)){ + if(count($object)){ + $this->orig_cn= $object['cn']; + $this->dn=$object['dn']; + foreach($object as $name=>$value){ + $oname = $name; + $this->$oname=$value; + } + }else{ + + $this->status = "new"; + $this->orig_cn = false; + } } } @@ -60,16 +77,41 @@ class faiHookEntry extends plugin $this->FAIscript = $str; } } - $smarty->assign("tasks", $this->tasks); + + /* Create download button*/ + if($this->dn != "new"){ + $smarty->assign("DownMe"," + + "); + }else{ + $smarty->assign("DownMe",""); + } + + $used_tasks = $this->parent->getUsedFAItask($this->cn); + $tasks = $this->tasks; + foreach($this->tasks as $id => $task){ + if(in_array($task,$used_tasks)){ + unset($tasks[$id]); + } + } + $smarty->assign("tasks", $tasks); /* Magic quotes GPC, escapes every ' " \, to solve some security risks * If we post the escaped strings they will be escaped again */ foreach($this->attributes as $attrs){ if(get_magic_quotes_gpc()){ - $smarty->assign($attrs,stripslashes($this->$attrs)); + $smarty->assign($attrs,htmlentities(stripslashes($this->$attrs))); + }else{ + $smarty->assign($attrs,htmlentities($this->$attrs)); + } + } + + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); }else{ - $smarty->assign($attrs,($this->$attrs)); + $smarty->assign($attr."ACL"," "); } } @@ -80,7 +122,7 @@ class faiHookEntry extends plugin /* Save data to object */ function save_object() { - if(isset($_POST['SubObjectFormSubmitted'])){ + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ $this->$attrs = $_POST[$attrs]; @@ -88,14 +130,15 @@ class faiHookEntry extends plugin $this->$attrs = ""; } } - $this->FAIscript= recode("DOS..LATIN1", $this->FAIscript); } } /* Check supplied data */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); + if(empty($this->FAIscript)) { $message[]=_("Please enter a value for script."); } @@ -114,6 +157,9 @@ class faiHookEntry extends plugin $tmp[$attrs] = $this->$attrs; } + /* Strip out dos newlines */ + $tmp['FAIscript']= strtr($this->FAIscript, array("\x0D" => "")); + if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){ $tmp['remove']['from'] = $this->orig_cn; $tmp['remove']['to'] = $tmp['cn'];