From: hickert Date: Mon, 6 Mar 2006 08:17:08 +0000 (+0000) Subject: Freezed releases can now be viewed, but not changed ... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4205d45d652b35991a99017d92d0df2d0f681353;p=gosa.git Freezed releases can now be viewed, but not changed ... git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2811 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/fai/class_faiHook.inc b/plugins/admin/fai/class_faiHook.inc index eef163f88..7dd077eb1 100644 --- a/plugins/admin/fai/class_faiHook.inc +++ b/plugins/admin/fai/class_faiHook.inc @@ -34,16 +34,33 @@ class faiHook extends plugin var $dialog = NULL; // a dialog, e.g. new disk dialog var $SubObjects = array(); // All leafobjects of this object + var $FAIstate = ""; + function faiHook ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl ="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. */ if($dn != "new"){ $this->dn =$dn; + + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ @@ -53,7 +70,7 @@ class faiHook extends plugin while($object = $ldap->fetch()){ /* Set status for save management */ - + foreach($this->subAttributes as $attrs){ if(!isset($object[$attrs][0])){ $this->SubObjects[$object['cn'][0]][$attrs]=""; @@ -61,7 +78,7 @@ class faiHook extends plugin $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; } } - + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; @@ -93,8 +110,8 @@ class faiHook extends plugin function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); @@ -109,6 +126,7 @@ class faiHook extends plugin $entry = preg_replace("/^editscript_/","",$name); $entry = base64_decode(preg_replace("/_.*/","",$entry)); $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$entry]); + $this->dialog->acl = $this->acl; $_SESSION['objectinfo'] = $this->SubObjects[$entry]['dn']; $this->dialog->parent = &$this; $this->is_dialog=true; @@ -129,23 +147,25 @@ class faiHook extends plugin /* Add new sub object */ if(isset($_POST['AddSubObject'])){ $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->acl = $this->acl; $this->dialog->parent = &$this; $this->is_dialog=true; } - + if($this->dn != "new"){ $_SESSION['objectinfo']= $this->dn; } /* Edit selected Sub Object */ if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ $hook = $_POST['SubObject'][0]; - + $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$hook]); + $this->dialog->acl = $this->acl; $this->dialog->parent = &$this; $_SESSION['objectinfo'] = $this->SubObjects[$hook]['dn']; $this->is_dialog=true; } - + /* Remove Sub object */ if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ foreach($_POST['SubObject'] as $hook){ @@ -221,13 +241,19 @@ class faiHook extends plugin } - + /* Divlist added 28.02.2006 Containing FAIscripts */ + $divlist = new divSelectBox("FAIhooks"); - $img_edit = ""; - $img_remo = ""; + if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){ + $img_edit = ""; + $img_remo = ""; + }else{ + $img_edit = ""; + $img_remo = ""; + } foreach($this->getList(true) as $key => $name){ @@ -235,26 +261,23 @@ class faiHook extends plugin $down = ""; }else{ $down = " - "._("Download")." - "; + "._("Download")." + "; } $divlist->AddEntry(array( array("string"=>$name['name']), - array("string"=>$down , "attach" => "style='width:20px;'"), - array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo), - "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + array("string"=>$down , "attach" => "style='width:20px;'"), + array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo), + "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); } $smarty->assign("Entry_divlist",$divlist->DrawList()); /* Divlist creation complete */ - - - $smarty->assign("SubObjects",$this->getList()); $smarty->assign("SubObjectKeys",array_flip($this->getList())); - /* Magic quotes GPC, escapes every ' " \, to solve some security risks + /* 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){ @@ -265,12 +288,16 @@ class faiHook extends plugin } } + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } + $display.= $smarty->fetch(get_template_path('faiHook.tpl', TRUE)); return($display); } /* Generate listbox friendly SubObject list - */ + */ function getList($use_dns=false){ $a_return=array(); foreach($this->SubObjects as $obj){ @@ -310,7 +337,7 @@ class faiHook extends plugin */ function save_object() { - if(isset($_POST['FAIhook_posted'])){ + if((isset($_POST['FAIhook_posted'])) && ($this->FAIstate != "freeze")){ plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ @@ -333,7 +360,7 @@ class faiHook extends plugin function save() { plugin::save(); - + $ldap = $this->config->get_ldap_link(); $ldap->cat($this->dn); @@ -341,7 +368,7 @@ class faiHook extends plugin /* Write FAIscript to ldap*/ $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); }else{ /* Write FAIscript to ldap*/ @@ -351,7 +378,7 @@ $ldap->modify ($this->attrs); $ldap->add($this->attrs); } show_ldap_error($ldap->get_error()); - + /* Prepare FAIscriptEntry to write it to ldap * First sort array. * Because we must delete old entries first. @@ -397,7 +424,7 @@ $ldap->modify ($this->attrs); $obj['status']="modify"; } } - + if($obj['status'] == "delete"){ $ldap->cd($sub_dn); $ldap->rmdir_recursive($sub_dn); @@ -405,7 +432,7 @@ $ldap->modify ($this->attrs); }elseif($obj['status'] == "edited"){ $ldap->cd($sub_dn); $this->cleanup(); -$ldap->modify ($tmp); + $ldap->modify ($tmp); $this->handle_post_events("modify"); }elseif($obj['status']=="new"){ @@ -421,7 +448,7 @@ $ldap->modify ($tmp); show_ldap_error($ldap->get_error()); } } - + function readBinary($attr,$dn){ $Data =""; $ds= ldap_connect($this->config->current['SERVER']); diff --git a/plugins/admin/fai/class_faiHookEntry.inc b/plugins/admin/fai/class_faiHookEntry.inc index 83396e992..8a7f0c990 100644 --- a/plugins/admin/fai/class_faiHookEntry.inc +++ b/plugins/admin/fai/class_faiHookEntry.inc @@ -22,6 +22,8 @@ class faiHookEntry extends plugin var $FAIscript = ""; var $description = ""; var $status = "new"; + + var $FAIstate = ""; function faiHookEntry ($config, $dn= NULL,$object=false) { @@ -33,6 +35,11 @@ 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']; @@ -100,6 +107,14 @@ class faiHookEntry extends plugin } } + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } + $display.= $smarty->fetch(get_template_path('faiHookEntry.tpl', TRUE)); return($display); } @@ -107,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]; diff --git a/plugins/admin/fai/class_faiManagement.inc b/plugins/admin/fai/class_faiManagement.inc index 9ca356db2..3a03dfecf 100644 --- a/plugins/admin/fai/class_faiManagement.inc +++ b/plugins/admin/fai/class_faiManagement.inc @@ -295,10 +295,12 @@ class faiManagement extends plugin $this->dialog= new $a_setup[0]($this->config, $this->config->data['TABS'][$a_setup[2]],$this->dn); $this->is_dialog = true; + if($entry['FAIstate'] == "freeze"){ + $this->dialog->set_acl(array("*none*")) ; + } $_SESSION['objectinfo'] = $this->dn; } - /* Branch handling 09.01.2006 */ @@ -768,9 +770,15 @@ class faiManagement extends plugin } if($value['FAIstate'] == "freeze"){ - $acti = ""; - $edi = "%NAME%"; + $action = ""; + $edi = $editlink; + $acti = $action; }else{ + $action = ""; + $action .= ""; $acti = $action; $edi = $editlink; } diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index 1540bb748..bf9b32ba9 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -54,17 +54,34 @@ class faiPackage extends plugin var $strID =""; var $newDialogShown =false; + var $FAIstate = ""; + function faiPackage ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl ="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. */ if($dn != "new"){ $this->dn =$dn; + + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } } if(isset($this->attrs['FAIpackage'])){ @@ -179,9 +196,11 @@ class faiPackage extends plugin /* Delte selected package */ if(isset($_POST['Delpkg'])){ - foreach($_POST['usedPackages'] as $del){ - if(isset($this->usedPackages[$del])){ - unset($this->usedPackages[$del]); + if($this->FAIstate != "freeze"){ + foreach($_POST['usedPackages'] as $del){ + if(isset($this->usedPackages[$del])){ + unset($this->usedPackages[$del]); + } } } } @@ -194,17 +213,22 @@ class faiPackage extends plugin /* attach new packages */ if(isset($_POST['SaveSubObject'])) { - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msgs){ - print_red($msgs); + if($this->FAIstate != "freeze"){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msgs){ + print_red($msgs); + } + }else{ + $use = $this->dialog->save(); + $this->usedPackages = $use; + $this->dialog = false; + $this->is_dialog=false; + ksort($this->usedPackages); } }else{ - $use = $this->dialog->save(); - $this->usedPackages = $use; $this->dialog = false; $this->is_dialog=false; - ksort($this->usedPackages); } } @@ -219,12 +243,15 @@ class faiPackage extends plugin } $this->dialog = new faiPackageConfiguration($this->config, $this->dn,$pkg, $path, $pkg_config); + $this->dialog ->acl = $this->acl; $this->is_dialog =true; } /* Save Configuration */ if(isset($_POST['SaveObjectConfig'])){ - $this->ConfiguredPackages= array_merge($this->ConfiguredPackages,$this->dialog->save()); + if($this->FAIstate != "freeze"){ + $this->ConfiguredPackages= array_merge($this->ConfiguredPackages,$this->dialog->save()); + } $this->dialog = false; $this->is_dialog=false; } @@ -246,6 +273,10 @@ class faiPackage extends plugin $strsec .= $sec." "; } + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } + $smarty->assign("OptionsACL",""); $smarty->assign("releases",$this->releases); @@ -272,8 +303,11 @@ class faiPackage extends plugin */ function save_object() { - + + if($this->FAIstate == "freeze") return; plugin::save_object(); + + foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ $this->$attrs = $_POST[$attrs]; diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc index 77b2e76e8..b5ea44e3b 100644 --- a/plugins/admin/fai/class_faiPartitionTable.inc +++ b/plugins/admin/fai/class_faiPartitionTable.inc @@ -19,11 +19,15 @@ class faiPartitionTable extends plugin var $is_dialog = false; // specifies which buttons will be shown to save or abort var $dialog = NULL; // a dialog, e.g. new disk dialog + var $FAIstate = ""; + function faiPartitionTable ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl ="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. * First read disks from ldap ... and then the partition definitions for the disks. @@ -31,6 +35,19 @@ class faiPartitionTable extends plugin if($dn != "new"){ $this->dn =$dn; + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + /* Read all disks from ldap taht are defined fot this partition table */ $ldap = $this->config->get_ldap_link(); @@ -94,6 +111,8 @@ class faiPartitionTable extends plugin $usedDiskNames[]= $key; } $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames); + $this->dialog->acl = $this->acl; + $this->dialog->FAIstate = $this->FAIstate; $this->is_dialog = true; } @@ -116,6 +135,8 @@ class faiPartitionTable extends plugin } } $this->dialog = new faiPartitionTableEntry($this->config,$this->dn,$usedDiskNames,$this->disks[$Udisk]); + $this->dialog->acl = $this->acl; + $this->dialog->FAIstate = $this->FAIstate; $_SESSION['objectinfo'] = $this->disks[$Udisk]['dn']; $this->is_dialog = true; } @@ -127,40 +148,46 @@ class faiPartitionTable extends plugin $this->dialog = NULL; $this->is_dialog=false; } - + /* Dialog saved * Save given data from Dialog, if no error is occured */ if(isset($_POST['SaveDisk'])){ - $this->dialog->save_object(); - if(count($this->dialog->check())){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } - }else{ - $disk = $this->dialog->save(); - if(isset($disk['rename'])){ - if($this->disks[$disk['rename']['from']]['status']=="edited"){ - $this->disks[$disk['rename']['from']]['status']="delete"; - }else{ - unset($this->disks[$disk['rename']['from']]); + + if($this->FAIstate != "freeze"){ + $this->dialog->save_object(); + if(count($this->dialog->check())){ + foreach($this->dialog->check() as $msg){ + print_red($msg); } - - foreach($disk['partitions'] as $key => $val){ - if($disk['partitions'][$key]['status']!="delete"){ - $disk['partitions'][$key]['status']= "new"; + }else{ + $disk = $this->dialog->save(); + if(isset($disk['rename'])){ + if($this->disks[$disk['rename']['from']]['status']=="edited"){ + $this->disks[$disk['rename']['from']]['status']="delete"; + }else{ + unset($this->disks[$disk['rename']['from']]); } + + foreach($disk['partitions'] as $key => $val){ + if($disk['partitions'][$key]['status']!="delete"){ + $disk['partitions'][$key]['status']= "new"; + } + } + + $disk['status']="new"; + $disk['cn']= $disk['rename']['to']; } - $disk['status']="new"; - $disk['cn']= $disk['rename']['to']; + $this->disks[$disk['cn']]=$disk; + unset($this->dialog); + $this->dialog = NULL; + $this->is_dialog=false; + ksort($this->disks); } - - $this->disks[$disk['cn']]=$disk; - unset($this->dialog); + }else{ $this->dialog = NULL; $this->is_dialog=false; - ksort($this->disks); } } @@ -168,22 +195,23 @@ class faiPartitionTable extends plugin * Assign delete status for all its partitions */ if((isset($_POST['DelDisk']))&&(!empty($_POST['disks']))){ - - foreach($_POST['disks'] as $disk) { - if($this->disks[$disk]['status']=="edited"){ - $this->disks[$disk."-delete"]=$this->disks[$disk]; - unset($this->disks[$disk]); - $disk = $disk."-delete"; - $this->disks[$disk]['status']="delete"; - foreach($this->disks[$disk]['partitions'] as $name => $value ){ - if($value['status']=="edited"){ - $this->disks[$disk]['partitions'][$name]['status']="delete"; - }else{ - unset($this->disks[$disk]['partitions'][$name]); + if($this->FAIstate != "freeze"){ + foreach($_POST['disks'] as $disk) { + if($this->disks[$disk]['status']=="edited"){ + $this->disks[$disk."-delete"]=$this->disks[$disk]; + unset($this->disks[$disk]); + $disk = $disk."-delete"; + $this->disks[$disk]['status']="delete"; + foreach($this->disks[$disk]['partitions'] as $name => $value ){ + if($value['status']=="edited"){ + $this->disks[$disk]['partitions'][$name]['status']="delete"; + }else{ + unset($this->disks[$disk]['partitions'][$name]); + } } + }else{ + unset($this->disks[$disk]); } - }else{ - unset($this->disks[$disk]); } } } @@ -205,7 +233,11 @@ class faiPartitionTable extends plugin $smarty->assign($attrs."CHK"," disabled "); } } - + + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } + $disks = $this->getDisks(); $smarty->assign("disks" ,$disks); $smarty->assign("diskKeys",array_flip($disks)); @@ -262,6 +294,7 @@ class faiPartitionTable extends plugin */ function save_object() { + if($this->FAIstate == "freeze") return; plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ diff --git a/plugins/admin/fai/class_faiPartitionTableEntry.inc b/plugins/admin/fai/class_faiPartitionTableEntry.inc index 408b361d2..83e7a179c 100644 --- a/plugins/admin/fai/class_faiPartitionTableEntry.inc +++ b/plugins/admin/fai/class_faiPartitionTableEntry.inc @@ -22,6 +22,8 @@ class faiPartitionTableEntry extends plugin var $status = "new"; var $deletePartitions = array(); + var $FAIstate = ""; + function faiPartitionTableEntry ($config, $dn= NULL,$usedDiskNames=array(),$disk=false) { plugin::plugin ($config, $dn); @@ -151,6 +153,15 @@ class faiPartitionTableEntry extends plugin $smarty->assign($attr,$this->$attr); } + foreach($this->UsedAttrs as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } + + /* The user can't change a diskname * if we are currently in edit mode for the specified disk */ @@ -160,6 +171,8 @@ class faiPartitionTableEntry extends plugin $smarty->assign("DISK_cnACL",""); // } + + /* Fetch template and show the result */ $display.= $smarty->fetch(get_template_path('faiPartitionTableEntry.tpl', TRUE)); @@ -199,10 +212,15 @@ class faiPartitionTableEntry extends plugin $dis = " disabled "; } + $disableALL = ""; + if($this->FAIstate =="freeze"){ + $disableALL = " disabled "; + } + if($part['status']!="delete"){ /* Generate Partition select box */ - $PartitionType = ""; foreach($PartitionTypes as $type){ if($part['FAIpartitionType'] == $type){ $PartitionType .=""; @@ -215,7 +233,7 @@ class faiPartitionTableEntry extends plugin /* Generate fsType select box */ - $FAIfsType= ""; foreach($FAIfsTypes as $type){ if($part['FAIfsType'] == $type){ $FAIfsType .=""; @@ -228,10 +246,10 @@ class faiPartitionTableEntry extends plugin $str .= "\n"; $str .= "\n".$PartitionType.""; $str .= "\n".$FAIfsType.""; - $str .= "\n"; - $str .= "\n"; - $str .= "\n"; - $str .= "\n"; + $str .= "\n"; + $str .= "\n"; + $str .= "\n"; + $str .= "\n"; $changeState = "onClick=\"changeState('FAImountPoint_".$key."') ; ". "changeState('FAIpartitionSize_".$key."') ; ". @@ -241,11 +259,11 @@ class faiPartitionTableEntry extends plugin if($part['FAIpartitionFlags']!=false){ - $str .= "\n"; + $str .= "\n"; }else{ - $str .= "\n"; + $str .= "\n"; } - $str .= "\n"; + $str .= "\n"; $str .= "\n"; } } @@ -286,7 +304,7 @@ class faiPartitionTableEntry extends plugin /* Save data to object */ function save_object() { - if(isset($_POST['TableEntryFrameSubmitted'])){ + if((isset($_POST['TableEntryFrameSubmitted'])) && ($this->FAIstate != "freeze") ){ plugin::save_object(); /* Check base attributes */ diff --git a/plugins/admin/fai/class_faiProfile.inc b/plugins/admin/fai/class_faiProfile.inc index c3c6d052b..6df1f06a5 100644 --- a/plugins/admin/fai/class_faiProfile.inc +++ b/plugins/admin/fai/class_faiProfile.inc @@ -30,12 +30,25 @@ class faiProfile extends plugin var $FAIclasses = array(); // Contains classname seperated in an array var $FAIAllclasses = array(); // Contains all possible Classnames + var $FAIstate = ""; + function faiProfile($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); $ldap=$this->config->get_ldap_link(); + $this->acl = "#all#"; + + if($this->dn != "new"){ + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + } + /* Parse ldap attribute to get all assigned classes */ $tmp = split(" ",$this->FAIclass); $tmp2 = array(); @@ -44,7 +57,11 @@ class faiProfile extends plugin $tmp2[trim($class)] = trim($class); } } - + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + /* Sort assigned classes */ if(is_array($tmp2)){ foreach($tmp2 as $class){ @@ -298,7 +315,13 @@ class faiProfile extends plugin $field1 = array("string"=> $usedClass,"attach"=>""); $field2 = array("string"=> $str,"attach"=>""); - $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions).preg_replace("/%s/",base64_encode($usedClass),$linkupdown),"attach"=>"style='border-right:none;'"); + if($this->FAIstate != "freeze"){ + $field3 = array("string"=> preg_replace("/%KEY%/",base64_encode($usedClass),$actions). + preg_replace("/%s/",base64_encode($usedClass),$linkupdown), + "attach"=>"style='border-right:none;'"); + }else{ + $field3 = array("string"=>" ", "attach"=>"style='border-right:none;'"); + } $divlist->AddEntry(array($field1,$field2,$field3)); } @@ -316,6 +339,13 @@ class faiProfile extends plugin } } + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } $display.= $smarty->fetch(get_template_path('faiProfile.tpl', TRUE)); return($display); diff --git a/plugins/admin/fai/class_faiScript.inc b/plugins/admin/fai/class_faiScript.inc index 08859d816..c8bc4d802 100644 --- a/plugins/admin/fai/class_faiScript.inc +++ b/plugins/admin/fai/class_faiScript.inc @@ -34,18 +34,36 @@ class faiScript extends plugin var $dialog = NULL; // a dialog, e.g. new disk dialog var $SubObjects = array(); // All leafobjects of this object + var $FAIstate =""; + function faiScript ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl ="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. */ if($dn != "new"){ + + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + $this->dn =$dn; + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ $ldap = $this->config->get_ldap_link(); @@ -54,7 +72,7 @@ class faiScript extends plugin while($object = $ldap->fetch()){ /* Set status for save management */ - + foreach($this->subAttributes as $attrs){ if(!isset($object[$attrs][0])){ $this->SubObjects[$object['cn'][0]][$attrs]=""; @@ -62,7 +80,7 @@ class faiScript extends plugin $this->SubObjects[$object['cn'][0]][$attrs]=$object[$attrs][0]; } } - + foreach($this->sub64coded as $codeIt){ $this->SubObjects[$object['cn'][0]][$codeIt]=(base64_decode($this->SubObjects[$object['cn'][0]][$codeIt])); } @@ -72,7 +90,7 @@ class faiScript extends plugin } $this->SubObjects[$object['cn'][0]]['FAIscript'] = addslashes ($this->readBinary("FAIscript",$object['dn'])); - + $this->SubObjects[$object['cn'][0]]['status'] = "edited"; $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; } @@ -81,8 +99,8 @@ class faiScript extends plugin function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); @@ -91,6 +109,7 @@ class faiScript extends plugin /* Add new sub object */ if(isset($_POST['AddSubObject'])){ $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->acl = $this->acl; $this->is_dialog=true; } @@ -108,6 +127,7 @@ class faiScript extends plugin $entry = preg_replace("/^editscript_/","",$name); $entry = base64_decode(preg_replace("/_.*/","",$entry)); $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$entry]); + $this->dialog->acl = $this->acl; $_SESSION['objectinfo'] = $this->SubObjects[$entry]['dn']; $this->is_dialog=true; } @@ -123,17 +143,17 @@ class faiScript extends plugin } } ///// Ende new list handling - + /* Edit selected Sub Object */ if((isset($_POST['EditSubObject']))&&(isset($_POST['SubObject']))){ $script = $_POST['SubObject'][0]; - $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$script]); + $this->dialog->acl = $this->acl; $_SESSION['objectinfo'] = $this->SubObjects[$script]['dn']; $this->is_dialog=true; } - + /* Remove Sub object */ if((isset($_POST['DelSubObject']))&&(isset($_POST['SubObject']))){ @@ -203,23 +223,28 @@ class faiScript extends plugin Containing FAIscripts */ $divlist = new divSelectBox("FAIscripts"); - $img_edit = ""; - $img_remo = ""; + if((chkacl($this->acl,"cn")!="") || ($this->FAIstate == "freeze")){ + $img_edit = ""; + $img_remo = ""; + }else{ + $img_edit = ""; + $img_remo = ""; + } foreach($this->getList(true) as $key => $name){ - + if(($this->SubObjects[$key]['status'] == "new") || ($this->SubObjects[$key]['dn'] == "new")){ $down = ""; }else{ $down = " - "._("Download")." - "; + "._("Download")." + "; } $divlist->AddEntry(array( array("string"=>$name['name']), - array("string"=>$down , "attach" => "style='width:20px;'"), - array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo), - "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); + array("string"=>$down , "attach" => "style='width:20px;'"), + array("string"=>str_replace("%s",base64_encode($key),$img_edit.$img_remo), + "attach"=>"style='border-right: 0px;width:50px;text-align:right;'"))); } $smarty->assign("Entry_divlist",$divlist->DrawList()); /* Divlist creation complete @@ -227,10 +252,10 @@ class faiScript extends plugin $smarty->assign("SubObjects",$this->getList()); $smarty->assign("SubObjectKeys",array_flip($this->getList())); - + /* Magic quotes GPC, escapes every ' " \, to solve some security risks - * If we post the escaped strings they will be escaped again - */ + * 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)); @@ -239,12 +264,16 @@ class faiScript extends plugin } } + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } + $display.= $smarty->fetch(get_template_path('faiScript.tpl', TRUE)); return($display); } /* Generate listbox friendly SubObject list - */ + */ function getList($use_dns=false){ $a_return=array(); foreach($this->SubObjects as $obj){ @@ -283,7 +312,7 @@ class faiScript extends plugin */ function save_object() { - if(isset($_POST['FAIscript_posted'])){ + if((isset($_POST['FAIscript_posted'])) && ($this->FAIstate != "freeze")){ plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ @@ -306,15 +335,15 @@ class faiScript extends plugin function save() { plugin::save(); - + $ldap = $this->config->get_ldap_link(); - + $ldap->cat($this->dn); if($ldap->count()!=0){ /* Write FAIscript to ldap*/ $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); }else{ /* Write FAIscript to ldap*/ @@ -324,7 +353,7 @@ $ldap->modify ($this->attrs); $ldap->add($this->attrs); } show_ldap_error($ldap->get_error()); - + /* Prepare FAIscriptEntry to write it to ldap * First sort array. * Because we must delete old entries first. @@ -359,7 +388,7 @@ $ldap->modify ($this->attrs); $tmp[$attrs] = $obj[$attrs]; } } - + $tmp['objectClass'] = $this->subClasses; $sub_dn = "cn=".$obj['cn'].",".$this->dn; @@ -374,7 +403,7 @@ $ldap->modify ($this->attrs); if(empty($tmp['FAIpriority'])){ $tmp['FAIpriority'] ="0"; } - + if($obj['status'] == "delete"){ $ldap->cd($sub_dn); $ldap->rmdir_recursive($sub_dn); @@ -382,7 +411,7 @@ $ldap->modify ($this->attrs); }elseif($obj['status'] == "edited"){ $ldap->cd($sub_dn); $this->cleanup(); -$ldap->modify ($tmp); + $ldap->modify ($tmp); $this->handle_post_events("modify"); }elseif($obj['status']=="new"){ diff --git a/plugins/admin/fai/class_faiScriptEntry.inc b/plugins/admin/fai/class_faiScriptEntry.inc index f52c123c5..91fa11ff7 100644 --- a/plugins/admin/fai/class_faiScriptEntry.inc +++ b/plugins/admin/fai/class_faiScriptEntry.inc @@ -21,6 +21,7 @@ class faiScriptEntry extends plugin var $description = ""; var $status = "new"; + var $FAIstate = ""; function faiScriptEntry ($config, $dn= NULL,$object=false) { @@ -32,6 +33,11 @@ class faiScriptEntry extends plugin $oname = $name; $this->$oname=$value; } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + }else{ if(is_array($object)&&count($object)){ $this->orig_cn= $object['cn']; @@ -89,6 +95,15 @@ class faiScriptEntry extends plugin for($i =0 ; $i < 100 ; $i++){ $FAIprioritys[$i]=$i; } + + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } + $smarty->assign("FAIprioritys",$FAIprioritys); $display.= $smarty->fetch(get_template_path('faiScriptEntry.tpl', TRUE)); return($display); @@ -97,7 +112,7 @@ class faiScriptEntry 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]; diff --git a/plugins/admin/fai/class_faiTemplate.inc b/plugins/admin/fai/class_faiTemplate.inc index 10f81c719..279050b46 100644 --- a/plugins/admin/fai/class_faiTemplate.inc +++ b/plugins/admin/fai/class_faiTemplate.inc @@ -34,11 +34,15 @@ class faiTemplate extends plugin var $dialog = NULL; // a dialog, e.g. new disk dialog var $SubObjects = array(); // All leafobjects of this object + var $FAIstate = ""; + function faiTemplate ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. @@ -46,6 +50,19 @@ class faiTemplate extends plugin if($dn != "new"){ $this->dn =$dn; + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ $ldap = $this->config->get_ldap_link(); @@ -87,6 +104,7 @@ class faiTemplate extends plugin /* Add new sub object */ if(isset($_POST['AddSubObject'])){ $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->acl = $this->acl; $this->is_dialog=true; } @@ -101,6 +119,7 @@ class faiTemplate extends plugin $temp = $_POST['SubObject'][0]; $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$temp]); + $this->dialog->acl = $this->acl; $_SESSION['objectinfo'] = $this->SubObjects[$temp]['dn']; $this->is_dialog=true; } @@ -183,6 +202,9 @@ class faiTemplate extends plugin } } + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } $display.= $smarty->fetch(get_template_path('faiTemplate.tpl', TRUE)); return($display); @@ -223,7 +245,7 @@ class faiTemplate extends plugin */ function save_object() { - if(isset($_POST['FAItemplate_posted'])){ + if((isset($_POST['FAItemplate_posted'])) && ($this->FAIstate != "freeze") ){ plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ @@ -246,15 +268,15 @@ class faiTemplate extends plugin function save() { plugin::save(); - + $ldap = $this->config->get_ldap_link(); - + $ldap->cat($this->dn); if($ldap->count()!=0){ /* Write FAIscript to ldap*/ $ldap->cd($this->dn); $this->cleanup(); -$ldap->modify ($this->attrs); + $ldap->modify ($this->attrs); }else{ /* Write FAIscript to ldap*/ @@ -264,7 +286,7 @@ $ldap->modify ($this->attrs); $ldap->add($this->attrs); } show_ldap_error($ldap->get_error()); - + /* Prepare FAIscriptEntry to write it to ldap * First sort array. * Because we must delete old entries first. diff --git a/plugins/admin/fai/class_faiTemplateEntry.inc b/plugins/admin/fai/class_faiTemplateEntry.inc index 33b361992..33092b851 100644 --- a/plugins/admin/fai/class_faiTemplateEntry.inc +++ b/plugins/admin/fai/class_faiTemplateEntry.inc @@ -25,6 +25,8 @@ class faiTemplateEntry extends plugin var $user = "root"; var $group = "root"; var $binary = false; + + var $FAIstate = ""; function faiTemplateEntry ($config, $dn= NULL,$object=false) { @@ -36,6 +38,11 @@ class faiTemplateEntry extends plugin $oname = $name; $this->$oname=$value; } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + }else{ $this->status = "new"; $this->orig_cn = false; @@ -106,6 +113,14 @@ class faiTemplateEntry extends plugin $smarty->assign("FAItemplateFile",""); + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } + $display.= $smarty->fetch(get_template_path('faiTemplateEntry.tpl', TRUE)); return($display); } @@ -116,7 +131,7 @@ class faiTemplateEntry extends plugin if (!isset($_POST['FAItemplatePath'])){ return; } - if(isset($_POST['SubObjectFormSubmitted'])){ + if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){ foreach($this->attributes as $attrs){ if($attrs == "FAItemplateFile") continue; @@ -130,22 +145,21 @@ class faiTemplateEntry extends plugin $this->$attrs = ""; } } - } - - /* Save mode */ - $tmode= ""; - foreach (array("s", "u", "g", "o") as $type){ - $nr= 1; - $dest= 0; - while ($nr < 5){ - if (isset($_POST["$type$nr"])){ - $dest+= $nr; + /* Save mode */ + $tmode= ""; + foreach (array("s", "u", "g", "o") as $type){ + $nr= 1; + $dest= 0; + while ($nr < 5){ + if (isset($_POST["$type$nr"])){ + $dest+= $nr; + } + $nr+= $nr; } - $nr+= $nr; + $tmode= $tmode.$dest; } - $tmode= $tmode.$dest; + $this->FAImode= $tmode; } - $this->FAImode= $tmode; } /* Check supplied data */ diff --git a/plugins/admin/fai/class_faiVariable.inc b/plugins/admin/fai/class_faiVariable.inc index f6c4a5562..baa760623 100644 --- a/plugins/admin/fai/class_faiVariable.inc +++ b/plugins/admin/fai/class_faiVariable.inc @@ -34,18 +34,36 @@ class faiVariable extends plugin var $dialog = NULL; // a dialog, e.g. new disk dialog var $SubObjects = array(); // All leafobjects of this object + var $FAIstate = ""; + function faiVariable ($config, $dn= NULL) { /* Load Attributes */ plugin::plugin ($config, $dn); + $this->acl ="#all#"; + /* If "dn==new" we try to create a new entry * Else we must read all objects from ldap which belong to this entry. * First read SubObjects from ldap ... and then the partition definitions for the SubObjects. */ + if($dn != "new"){ $this->dn =$dn; + /* Set acls + */ + $ui = get_userinfo(); + $acl = get_permissions ($this->dn, $ui->subtreeACL); + $acli = get_module_permission($acl, "FAIclass", $this->dn); + $this->acl=$acli; + + /* Get FAIstate + */ + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ $ldap = $this->config->get_ldap_link(); @@ -85,6 +103,7 @@ class faiVariable extends plugin /* Add new sub object */ if(isset($_POST['AddSubObject'])){ $this->dialog= new $this->subClassName($this->config,"new"); + $this->dialog->acl = $this->acl; $this->is_dialog=true; } @@ -99,6 +118,7 @@ class faiVariable extends plugin $var = $_POST['SubObject'][0]; $this->dialog= new $this->subClassName($this->config,$this->dn,$this->SubObjects[$var]); + $this->dialog->acl = $this->acl; $_SESSION['objectinfo'] = $this->SubObjects[$var]['dn']; $this->is_dialog=true; } @@ -182,6 +202,11 @@ class faiVariable extends plugin } } + foreach($this->attributes as $attr){ + $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); + } + + $display.= $smarty->fetch(get_template_path('faiVariable.tpl', TRUE)); return($display); } @@ -226,7 +251,7 @@ class faiVariable extends plugin */ function save_object() { - if(isset($_POST['FAIvariable_posted'])){ + if((isset($_POST['FAIvariable_posted'])) && ($this->FAIstate != "freeze") ){ plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ diff --git a/plugins/admin/fai/class_faiVariableEntry.inc b/plugins/admin/fai/class_faiVariableEntry.inc index f36731502..12c66fe13 100644 --- a/plugins/admin/fai/class_faiVariableEntry.inc +++ b/plugins/admin/fai/class_faiVariableEntry.inc @@ -18,6 +18,8 @@ class faiVariableEntry extends plugin var $FAIvariableContent = ""; var $description = ""; var $status = "new"; + + var $FAIstate = ""; function faiVariableEntry ($config, $dn= NULL,$object=false) { @@ -29,6 +31,11 @@ class faiVariableEntry extends plugin $oname = $name; $this->$oname=addslashes($value); } + + if(isset($this->attrs['FAIstate'][0])){ + $this->FAIstate = $this->attrs['FAIstate'][0]; + } + }else{ $this->status = "new"; $this->orig_cn = false; @@ -55,6 +62,14 @@ class faiVariableEntry extends plugin } } + foreach($this->attributes as $attr){ + if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){ + $smarty->assign($attr."ACL"," disabled "); + }else{ + $smarty->assign($attr."ACL"," "); + } + } + $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE)); return($display); } @@ -62,7 +77,7 @@ class faiVariableEntry 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]; diff --git a/plugins/admin/fai/faiHook.tpl b/plugins/admin/fai/faiHook.tpl index 68f2c9132..3bd5c80b1 100644 --- a/plugins/admin/fai/faiHook.tpl +++ b/plugins/admin/fai/faiHook.tpl @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -45,7 +45,7 @@ --> - + diff --git a/plugins/admin/fai/faiHookEntry.tpl b/plugins/admin/fai/faiHookEntry.tpl index 699528a40..ad25455ce 100644 --- a/plugins/admin/fai/faiHookEntry.tpl +++ b/plugins/admin/fai/faiHookEntry.tpl @@ -9,7 +9,7 @@ {t}Name{/t}{$must}  - + @@ -17,7 +17,7 @@ {t}Description{/t}  - + @@ -33,7 +33,7 @@ - {html_options values=$tasks output=$tasks selected=$FAItask} @@ -53,21 +53,21 @@
- +

-   - +   + {$DownMe}

 


-   +  
diff --git a/plugins/admin/fai/faiPackage.tpl b/plugins/admin/fai/faiPackage.tpl index c65598798..a4d4371bd 100644 --- a/plugins/admin/fai/faiPackage.tpl +++ b/plugins/admin/fai/faiPackage.tpl @@ -20,7 +20,7 @@ - + @@ -58,8 +58,8 @@ {html_options options=$usedPackages}
- - + + diff --git a/plugins/admin/fai/faiPartitionTable.tpl b/plugins/admin/fai/faiPartitionTable.tpl index feb0f443f..43db0eb56 100644 --- a/plugins/admin/fai/faiPartitionTable.tpl +++ b/plugins/admin/fai/faiPartitionTable.tpl @@ -20,7 +20,7 @@ - + @@ -40,9 +40,9 @@
- - - + + + diff --git a/plugins/admin/fai/faiPartitionTableEntry.tpl b/plugins/admin/fai/faiPartitionTableEntry.tpl index df23a2ff6..9ceab9439 100644 --- a/plugins/admin/fai/faiPartitionTableEntry.tpl +++ b/plugins/admin/fai/faiPartitionTableEntry.tpl @@ -5,12 +5,12 @@ {$must}  - +   - + @@ -20,13 +20,13 @@

 {t}Partition entries{/t}

{$setup}
- +

 


- +
diff --git a/plugins/admin/fai/faiProfile.tpl b/plugins/admin/fai/faiProfile.tpl index 8ecedab7f..5020bc745 100644 --- a/plugins/admin/fai/faiProfile.tpl +++ b/plugins/admin/fai/faiProfile.tpl @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ - + @@ -35,7 +35,7 @@ --> {$divlist}
- + diff --git a/plugins/admin/fai/faiScript.tpl b/plugins/admin/fai/faiScript.tpl index 1a646b3d9..4c235c361 100644 --- a/plugins/admin/fai/faiScript.tpl +++ b/plugins/admin/fai/faiScript.tpl @@ -20,7 +20,7 @@ - + @@ -45,14 +45,14 @@ --> - + - +