index 9b7ff99df7c32e275c125a5a65479a5832b9406c..cc71020a27a0d30fcf7e6a6ffbe9e4af4d1dad3c 100644 (file)
require "tabsProfile.inc";
require "tabsPackage.inc";
+
class faiManagement extends plugin
{
/* Definitions */
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), LDAP::fix($this->dn)));
+ $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), @LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
$this->dialog->by_object[$type[1]]->remove_from_parent ();
unset ($this->dialog);
- gosa_log ("FAI class '".$this->dn."' has been removed");
+ gosa_log ("FAI class '".$this->dn."' has been tagged as removed");
$this->dialog= NULL;
+ $to_del = clean_up_releases($this->dn);
+ save_release_changes_now();
+
+ foreach($to_del as $dn){
+ $ldap->rmdir_recursive($dn);
+ gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn));
+ }
+
} else {
/* Normally this shouldn't be reached, send some extra
if($this->DivListFai->selectedBranch != "main" ){
$baseToUse = $this->DivListFai->selectedBranch;
}
+
+ /* Create new Release name to be able to set faidebianRelease for FAIpackageList */
+
+ $CurrentReleases = $this->getBranches();
+ $NewReleaseName = $name;
+ if(isset($CurrentReleases[$this->DivListFai->selectedBranch])) {
+ if($this->DivListFai->selectedBranch != "main"){
+ $NewReleaseName = $CurrentReleases[$this->DivListFai->selectedBranch]."/".$name;
+ $NewReleaseName = preg_replace("#\/#","/",$NewReleaseName);
+ }else{
+ $NewReleaseName = $name;
+ }
+ }
$appsrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,",$baseToUse);
$appdst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=apps,","ou=".$name.",".$baseToUse) ;
+ $mimesrc = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,",$baseToUse);
+ $mimedst = preg_replace("/ou=fai,ou=configs,ou=systems,/","ou=mime,","ou=".$name.",".$baseToUse) ;
+
/* Print header to have styles included */
echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
echo "<body style='background-image:none;margin:3px;color:black'>";
/* Duplicate applications
*/
- $ldap->cd ($appdst);
- $ldap->recursive_remove();
- $ldap->cd ($this->config->current['BASE']);
- $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$type,true);
+ $ldap->cat($appsrc,array("dn")) ;
+ if($ldap->count()){
+ $ldap->cd ($appdst);
+ $ldap->recursive_remove();
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->copy_FAI_resource_recursive($appsrc,$appdst,$NewReleaseName,$type,true);
+ }
+
+ /* Duplicate mime types
+ */
+ $ldap->cat($mimesrc,array("dn")) ;
+ if($ldap->count()){
+ $ldap->cd ($appdst);
+ $ldap->recursive_remove();
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->copy_FAI_resource_recursive($mimesrc,$mimedst,$NewReleaseName,$type,true);
+ }
+
+ $attr = array();
+ $attr['objectClass'] = array("organizationalUnit","FAIbranch");
+ $attr['ou'] = $name;
+ $attr['FAIstate'] = $type;
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->cd("ou=".$name.",".$baseToUse);
+ $ldap->cat("ou=".$name.",".$baseToUse);
+ if($ldap->count()){
+ $ldap->modify($attr);
+ }else{
+ $ldap->add($attr);
+ }
/* Duplicate fai objects
*/
- $ldap->cd ("ou=".$name.",".$baseToUse);
- $ldap->recursive_remove();
- $ldap->cd ($this->config->current['BASE']);
- $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$type,true);
+// $ldap->cd ("ou=".$name.",".$baseToUse);
+// $ldap->recursive_remove();
+// $ldap->cd ($this->config->current['BASE']);
+// $ldap->copy_FAI_resource_recursive($baseToUse,"ou=".$name.",".$baseToUse,$NewReleaseName,$type,true);
echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
<br><input type='submit' name='CloseIFrame' value='"._("Continue")."'>
$this->dialog = new $a_setup[0]($this->config,
$this->config->data['TABS'][$a_setup[2]],$this->dn);
- $this->is_dialog = true;
+ $this->is_dialog = false;
}
* If it was possible to save it, remove dialog object.
* If it wasn't possible, show errors and keep dialog.
*/
- if((isset($_POST['edit_finish'])) && (isset($this->dialog->config))){
+ if((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && (isset($this->dialog->config))){
$this->dialog->save_object();
- if(count($this->dialog->check())!=0){
- foreach($this->dialog->check() as $msg){
+ $msgs= $this->dialog->check();
+ if(count($msgs)!=0){
+ foreach($msgs as $msg){
print_red($msg);
}
}else{
- del_lock ($this->dn);
$this->dialog->save();
- unset($this->dialog);
- $this->dialog=NULL;
- $this->is_dialog=false;
- unset($_SESSION['objectinfo']);
+ save_release_changes_now();
+ if (!isset($_POST['edit_apply'])){
+ del_lock ($this->dn);
+ unset($this->dialog);
+ $this->dialog=NULL;
+ $this->is_dialog=false;
+ unset($_SESSION['objectinfo']);
+ }
}
}
if(($this->dialog != NULL) && (isset($this->dialog->config))){
$display .= $this->dialog->execute();
/* Don't show buttons if tab dialog requests this */
- if (((isset($this->dialog->current))&&($this->dialog->by_object[$this->dialog->current]->is_dialog))){
-
- }elseif(((isset($this->dialog->current))&&(!$this->dialog->by_object[$this->dialog->current]->is_dialog))){
- $display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=\"submit\" name=\"edit_finish\" value=\""._("Save")."\">\n";
- $display.= " \n";
- $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
- $display.= "</p>";
- }elseif(!isset($this->dialog->current)){
- $display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
- $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
- $display.= "</p>";
- }
- return($display);
+
+ if(isset($this->dialog->current)){
+
+ $obj = $this->dialog->by_object[$this->dialog->current];
+
+ if((isset($obj->is_dialog) && (!$obj->is_dialog)) || (isset($obj->dialog) && (!$obj->dialog))){
+
+ $display.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= " \n";
+ if ($this->dn != "new"){
+ $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+ $display.= " \n";
+ }
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+ }elseif(!isset($this->dialog->current)){
+ $display.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+ }
+ }else{
+ $display.= "<p style=\"text-align:right\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_continue\" value=\""._("Continue")."\"> ";
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "</p>";
+
+ }
+ return($display);
}
Dialog display
****************/
+ /* Check if there is a snapshot dialog open */
+ $base = $this->DivListFai->selectedBase;
+ if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+ return($str);
+ }
+
/* Display dialog with system list */
+ $this->DivListFai->parent = $this;
$this->DivListFai->execute();
-
- /* Add departments if subsearch is disabled */
- if(!$this->DivListFai->SubSearch){
- $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4);
- }
+ $this->DivListFai->AddDepartments($this->DivListFai->selectedBase,4);
$this->reload();
$this->DivListFai->setEntries($this->objects);
return($this->DivListFai->Draw());
}
+ /* Return departments, that will be included within snapshot detection */
+ function get_used_snapshot_bases()
+ {
+ $tmp = array();
+ $types = array("hooks","scripts","disk","packages","profiles","templates","variables");
+ foreach($types as $type){
+ if($this->DivListFai->selectedBranch == "main"){
+ $tmp[] = "ou=".$type.",ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
+ }else{
+ $tmp[] = "ou=".$type.",".$this->DivListFai->selectedBranch;
+ }
+ }
+ return($tmp);
+ }
+
+
/* Get available branches for current base */
function getBranches($base = false,$prefix = "")
{
$ret = array("main"=>"/");
$ldap = $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
if(!$base){
- $base= "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
+ $base= $_SESSION['CurrentMainBase'];
}
- $ldap->cd($base);
- $ldap->ls("(objectClass=FAIbranch)",$base);
- while($attrs = $ldap->fetch()){
- if((isset($attrs['ou']))&&($attrs['dn']!=$base)){
- $ret[$attrs['dn']]= $prefix.$attrs['ou'][0];
- $ret = array_merge($ret,$this->getBranches($attrs['dn'],"".$prefix.$attrs['ou'][0]."/"));
- }
+ $tmp = get_all_releases_from_base($base,true);
+ foreach($tmp as $dn => $name){
+ $ret[$dn]=$name;
}
- return($ret);
+ return ($ret);
}
+
/* reload list of objects */
- function reload()
- {
- /* Create a new list of FAI object
- * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
- */
- $ObjectTypes = array(
- "FAIpartitionTable" => array("OU"=>"ou=disks," , "CHKBOX"=>"ShowPartitions"),
- "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages"),
- "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts"),
- "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables"),
- "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks"),
- "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles"),
- "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates"));
+ function reload()
+ {
+ /* Variable initialisation */
+ $str = "";
+ $Regex = $this->DivListFai->Regex;
+ $this->objects = array();
- /* Set base for all searches */
- $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
+ /* Get base */
+ $base = "ou=fai,ou=configs,ou=systems,".$this->DivListFai->selectedBase;
if($this->DivListFai->selectedBranch != "main"){
$br = $this->getBranches();
if(isset($br[$this->DivListFai->selectedBranch])){
}
}
- $Regex = $this->DivListFai->Regex;
- $str = "";
- $objects = array();
- $this->objects = array();
+ $this->lock_type = get_release_tag(get_release_dn($base));
- /* Walk through possible sub departments and fetch all FAI objects */
- foreach($ObjectTypes as $type => $obj){
+ /* Get resolved release dependencies */
+ $tmp = get_all_objects_for_given_base($base,"(&(|(objectClass=FAIpartitionTable)(objectClass=FAIpackageList)(objectClass=FAIscript)
+ (objectClass=FAIvariable)(objectClass=FAIhook)(objectClass=FAIprofile)(objectClass=FAItemplate))(cn=$Regex))");
- /* Skip all unchecked types */
- if(! $this->DivListFai->$obj['CHKBOX']){
- continue;
- }
+ /* Create a new list of FAI object
+ * Generate List of Partitions,Hooks,Scripts,Templates,Profiles ...
+ */
+ $ObjectTypes = array(
+ "FAIpartitionTable" => array("OU"=>"ou=disk," , "CHKBOX"=>"ShowPartitions"),
+ "FAIpackageList" => array("OU"=>"ou=packages," , "CHKBOX"=>"ShowPackages"),
+ "FAIscript" => array("OU"=>"ou=scripts," , "CHKBOX"=>"ShowScripts"),
+ "FAIvariable" => array("OU"=>"ou=variables," , "CHKBOX"=>"ShowVariables"),
+ "FAIhook" => array("OU"=>"ou=hooks," , "CHKBOX"=>"ShowHooks"),
+ "FAIprofile" => array("OU"=>"ou=profiles," , "CHKBOX"=>"ShowProfiles"),
+ "FAItemplate" => array("OU"=>"ou=templates," , "CHKBOX"=>"ShowTemplates"));
- /* Fetch objects from fai sub department */
- if($this->DivListFai->SubSearch){
- $res= get_list("(&(objectClass=".$type.")(cn=$Regex))", $this->ui->subtreeACL, preg_replace("/^.*ou=fai,ou=configs,ou=systems,/","",$base),
- array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT | GL_SUBSEARCH);
- }else{
- $res= get_list("(&(objectClass=".$type.")(cn=$Regex))", $this->ui->subtreeACL, $obj['OU'].$base,
- array("cn","description","objectClass","FAIclass","FAIstate"), GL_SIZELIMIT);
- }
+ /* Ge listed ldap objects */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ foreach($tmp as $entry){
- /* Walk through objects */
- foreach($res as $object){
+ /* Get some more informations about the object */
+ $ldap->cat($entry['dn'], array("cn","description","objectClass","FAIclass","FAIstate","objectClass"));
+ $object = $ldap->fetch();
- /* Prepare object */
- unset($object['objectClass']['count']);
- if(!isset($object['description'][0])){
- $object['description'][0]="";
- }
-
- /* Clean up object informations */
- $obj['cn'] = $object['cn'][0];
- $obj['dn'] = $object['dn'];
- $obj['description'] = $object['description'][0];
- $obj['objectClass'] = $object['objectClass'];
-
- /* Append type to this string, to be able to check if the selected
- * entry is of type 'freeze' or 'branch'
- */
- if(isset($object['FAIstate'])){
- $obj['FAIstate'] = $object['FAIstate'][0];
- $str.="|".$obj['FAIstate'];
- }else{
- $obj['FAIstate'] ="";
+ /* Walk through possible types */
+ foreach($ObjectTypes as $type => $rest){
+
+ /* Skip all unchecked types */
+ if(! $this->DivListFai->$rest['CHKBOX']){
+ continue;
+ }
+
+ if(in_array($type,$object['objectClass'])){
+
+ /* Prepare object */
+ unset($object['objectClass']['count']);
+ if(!isset($object['description'][0])){
+ $object['description'][0]="";
+ }
+
+ /* Clean up object informations */
+ $obj = array();
+ $obj['cn'] = $object['cn'][0];
+ $obj['dn'] = $object['dn'];
+ $obj['description'] = $object['description'][0];
+ $obj['objectClass'] = $object['objectClass'];
+
+ /* Append type to this string, to be able to check if the selected
+ * entry is of type 'freeze' or 'branch'
+ */
+ if(!isset($object['FAIstate'])){
+ $obj['FAIstate'] = $this->lock_type;
+ }else{
+ $obj['FAIstate'] = $object['FAIstate'][0];
+ }
+
+ $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
+ $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
}
- $this->objects[strtolower($obj['cn']).$obj['cn'].$type] = $obj;
- $this->objects[strtolower($obj['cn']).$obj['cn'].$type]['type']=$type;
}
}
- /* Tell class what we have currently opened
- 'main' has type '' */
- if(preg_match("/freeze/",$str)){
- $this->lock_type = "freeze";
- }elseif(preg_match("/branch/",$str)){
- $this->lock_type = "branch";
- }else{
- $this->lock_type = "";
- }
-
ksort($this->objects);
reset ($this->objects);
function CheckNewBranchName($name,$base)
{
$f = $this->DivListFai->selectedBranch;
- if(empty($name)){
+ if($name == ""){
return(false);
}elseif(in_array($name,$this->getBranches($f))) {
return(false);
- }elseif(empty($name)){
- return(false);
- }elseif(in_array($name,array("fai","disk","packages","scripts","templates","hooks","variables","profiles","apps"))){
+ }elseif(is_department_name_reserved($name,$base)){
return(false);
}
return(true);
$this->DivListFai->save_object();
}
+
+ /* Return plugin informations for acl handling */
+ function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Management"),
+ "plDescription" => _("FAI management"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 0,
+ "plSection" => array("administration"),
+ "plCategory" => array("fai"=> array("description" => _("FAI"),
+ "objectClass" => "FAIclass")),
+ "plProvidedAcls"=> array()));
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>