index 5dd08ab682531b8668f298f82871cbdfc38ad789..244af77bde30cf836f0e256d61a0bf2e60e328b0 100644 (file)
/* attribute list for save action */
var $ignore_account= TRUE;
- var $attributes = array("Object_cn","Object_description","Object_FAIscript","Object_FAItask");
+ var $attributes = array("cn","description","FAIscript","FAItask");
var $objectclasses= array();
var $orig_cn = "";
-
- var $Object_dn = "";
- var $Object_cn = "";
- var $Object_FAItask = "";
- var $Object_FAIscript = "";
- var $Object_description = "";
- var $Object_status = "new";
+ var $tasks = array("chboot", "configure", "debconf", "extrbase", "faiend", "finish",
+ "install", "instsoft", "mirror", "mountdisks", "partition", "prepareapt",
+ "savelog", "softupdate", "sysinfo","updatebase");
+ var $dn = "";
+ var $cn = "";
+ var $FAItask = "chboot";
+ var $FAIscript = "";
+ var $description = "";
+ var $status = "new";
+
+ var $FAIstate = "";
function faiHookEntry ($config, $dn= NULL,$object=false)
{
$this->orig_cn= $object['cn'];
$this->dn=$object['dn'];
foreach($object as $name=>$value){
- $oname = "Object_".$name;
+ $oname = $name;
$this->$oname=$value;
}
- }else{
- $this->Object_status = "new";
- $this->orig_cn = false;
- }
-
- if(isset($this->Object_FAIscript)){
- $ds= ldap_connect($this->config->current['SERVER']);
- ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
- if(function_exists("ldap_set_rebind_proc") && isset($this->config->current['RECURSIVE']) && $this->config->current['RECURSIVE'] == "true") {
- ldap_set_option($this->cid, LDAP_OPT_REFERRALS, 1);
- ldap_set_rebind_proc($ds, array(&$this, "rebind"));
- }
- if(isset($this->config->current['TLS']) && $this->config->current['TLS'] == "true"){
- ldap_start_tls($ds);
+ if(isset($this->attrs['FAIstate'][0])){
+ $this->FAIstate = $this->attrs['FAIstate'][0];
}
- $r = ldap_bind($ds);
- $sr= @ldap_read($ds, $this->dn, "FAIscript=*", array("FAIscript"));
- if ($sr) {
- $ei=ldap_first_entry($ds, $sr);
- if ($ei) {
- if ($info = ldap_get_values_len($ds, $ei, "FAIscript")){
- $this->Object_FAIscript = base64_decode($info[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{
- /* close conncetion */
- ldap_unbind($ds);
+ $this->status = "new";
+ $this->orig_cn = false;
+ }
}
-
}
+
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty = get_smarty();
$display = "";
print_red(_("Selected file is empty."));
}else{
$str = utf8_encode(file_get_contents($_FILES['ImportFile']['tmp_name']));
- $this->Object_FAIscript = $str;
+ $this->FAIscript = $str;
+ }
+ }
+
+ /* Create download button*/
+ if($this->dn != "new" && $this->acl_is_readable("FAIscript")){
+ $smarty->assign("DownMe","<a href='getFAIscript.php?id=".base64_encode($this->dn)."'>
+ <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0 class='center'>
+ </a>");
+ }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){
- $smarty->assign($attrs,stripslashes($this->$attrs));
+ if(get_magic_quotes_gpc()){
+ $smarty->assign($attrs,(stripslashes($this->$attrs)));
+ }else{
+ $smarty->assign($attrs,($this->$attrs));
+ }
}
- for($i =1 ; $i <= 100 ; $i++){
- $Object_FAIprioritys[$i]=$i;
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translated){
+ $acl = $this->getacl($name);
+ if($this->FAIstate == "freezed"){
+ $acl = preg_replace("/w/","",$acl);
+ }
+ $smarty->assign($name."ACL",$acl);
}
- $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys);
+
$display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE));
return($display);
}
/* 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];
- }else{
- $this->$attrs = "";
+ if($this->acl_is_writeable($attrs)){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }else{
+ $this->$attrs = "";
+ }
}
}
}
/* Check supplied data */
function check()
{
- $message= array();
- if(empty($this->Object_FAItask)) {
- $message[]=_("Please enter a value for task.");
- }
- if(empty($this->Object_FAIscript)) {
- $message[]=_("Please enter a value for script.");
- }
-
- $str = utf8_encode("üöä");
+ /* Call common method to give check the hook */
+ $message= plugin::check();
- if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){
- $message[] = _("Invalid character in description. Please enter a valid description.");
+ if(empty($this->FAIscript)) {
+ $message[]=_("Please enter a value for script.");
}
- if(empty($this->Object_cn)){
+ if(empty($this->cn)){
$message[] = _("Please enter a name.");
}
- if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
- $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
- }
-
return ($message);
}
{
$tmp=array();
foreach($this->attributes as $attrs){
- $attr = preg_replace("/^Object_/","",$attrs);
- $tmp[$attr] = $this->$attrs;
+ $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'];
}
$tmp['dn'] = $this->dn;
- $tmp['status'] = $this->Object_status;
+ $tmp['status'] = $this->status;
return($tmp);
}
+
+ /* Return plugin informations for acl handling */
+ function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Hook entry"),
+ "plDescription" => _("FAI hook entry"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 21,
+ "plSection" => array("administration"),
+ "plCategory" => array("fai"),
+ "plProvidedAcls" => array(
+ "cn" => _("Name"),
+ "description" => _("Description"),
+ "FAItask" => _("Task"),
+ "FAIscript" => _("FAI script"))
+ ));
+ }
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>