summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 57be904)
raw | patch | inline | side by side (parent: 57be904)
author | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 12 Apr 2011 08:07:01 +0000 (08:07 +0000) | ||
committer | psc <psc@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 12 Apr 2011 08:07:01 +0000 (08:07 +0000) |
- Add a new function get_configured_packages and move logic, which gets
debconf configuration for all configured packages from LDAP, to this
function.
- In object initialisation and PrepareForCopyPaste function use
get_configured_packages instead of duplicating the functionality at
two places.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20704 594d385d-05f5-0310-b6e9-bd551577e9d8
debconf configuration for all configured packages from LDAP, to this
function.
- In object initialisation and PrepareForCopyPaste function use
get_configured_packages instead of duplicating the functionality at
two places.
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@20704 594d385d-05f5-0310-b6e9-bd551577e9d8
trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc | patch | blob | history |
diff --git a/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc b/trunk/gosa-plugins/fai/admin/fai/class_faiPackage.inc
index 3cf8cc46da98c0a16e46950c0ce7fc4886f7af82..796b72da70d7ab1277adb0e8d25e75b4e136dcf4 100644 (file)
ksort($this->usedPackages);
}
- /* Fetch all package configurations from ldap
- */
- $PackageFilter = "";
- foreach($this->usedPackages as $name => $value){
- $PackageFilter .= "(FAIpackage=".$name.")";
- }
- /* Also fetch d-i */
- $PackageFilter .= "(FAIpackage=d-i)";
-
- $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
-
- /* Search for configuration objects */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($this->dn);
- $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType",
- "FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
-
- /* Walk through configurations and append them to our list of ConfiguredPackages
- */
- while($attr = $ldap->fetch()){
-
- /* Skip objects, that are tagged as removed */
- if(isset($object['FAIstate'][0])){
- if(preg_match("/removed$/",$attr['FAIstate'][0])){
- continue;
- }
- }
-
- $tmp =array();
- $tmp['Name'] = $attr['FAIvariable'][0];
- $tmp['Type'] = $attr['FAIvariableType'][0];
- $tmp['Save'] = TRUE;
-
- if (isset($attr['FAIvariableContent'][0])){
- if(!in_array($attr['FAIvariableType'],array("multiselect"))){
- $tmp['Value'] = $attr['FAIvariableContent'][0];
- }else{
- $content = array();
- unset($attr['FAIvariableContent']['count']);
- foreach($attr['FAIvariableContent'] as $attr){
- $tmp['Value'][] = $attr;
- }
- }
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- else {
- $tmp['Value'] = "";
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- }
+ /* Fetch package configurations from LDAP */
+ $this->ConfiguredPackages = $this->get_configured_packages($this->usedPackages, $this->dn);
$this->FAIdebianSection = array();
if(isset($this->attrs['FAIdebianSection'])){
$this->list= $this->genPkgs(TRUE);
}
+ function get_configured_packages($packages, $base)
+ {
+ /* Fetch all package configurations from ldap
+ */
+ $PackageFilter = "";
+ foreach($packages as $name => $value){
+ $PackageFilter .= "(FAIpackage=".$name.")";
+ }
+ /* Also fetch d-i */
+ $PackageFilter .= "(FAIpackage=d-i)";
+
+ $PackageFilter = "(&(objectClass=FAIdebconfInfo)(|".$PackageFilter."))";
+
+ /* Search for configuration objects */
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($base);
+ $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType",
+ "FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
+
+ $configured_packages = array();
+
+ /* Walk through configurations and append them to our list of ConfiguredPackages
+ */
+ while($attr = $ldap->fetch()){
+
+ /* Skip objects, that are tagged as removed */
+ if(isset($object['FAIstate'][0])){
+ if(preg_match("/removed$/",$attr['FAIstate'][0])){
+ continue;
+ }
+ }
+
+ $tmp =array();
+ $tmp['Name'] = $attr['FAIvariable'][0];
+ $tmp['Type'] = $attr['FAIvariableType'][0];
+ $tmp['Save'] = TRUE;
+
+ if (isset($attr['FAIvariableContent'][0])){
+ if(!in_array($attr['FAIvariableType'],array("multiselect"))){
+ $tmp['Value'] = $attr['FAIvariableContent'][0];
+ }else{
+ $content = array();
+ unset($attr['FAIvariableContent']['count']);
+ foreach($attr['FAIvariableContent'] as $attr){
+ $tmp['Value'][] = $attr;
+ }
+ }
+ $configured_packages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
+ }
+ else {
+ $tmp['Value'] = "";
+ $configured_packages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
+ }
+ }
+
+ return $configured_packages;
+ }
+
function execute()
{
$this->FAIdebianSection[$source['FAIdebianSection'][$i]]=$source['FAIdebianSection'][$i];
}
}
+ $this->ConfiguredPackages = $this->get_configured_packages($this->usedPackages, $source['dn']);
- /* Create one filter with all package names,
- instead of calling $ldap->search for every single package
- */
- $PackageFilter = "";
- foreach($this->usedPackages as $name){
- $PackageFilter .= "(FAIpackage=".$name.")";
- }
-
- /* Search for configuration objects */
- $ldap = $this->config->get_ldap_link();
- $ldap->cd($source['dn']);
- $ldap->search($PackageFilter,array("FAIvariable","FAIvariableType","FAIvariableContent","FAIpackage","FAIdebianSection","FAIstate"));
-
- /* Walk through configurations and append them to our list of ConfiguredPackages */
- while($attr = $ldap->fetch()){
-
- /* Skip objects, that are tagged as removed */
- if(isset($object['FAIstate'][0])){
- if(preg_match("/removed$/",$attr['FAIstate'][0])){
- continue;
- }
- }
-
- $tmp =array();
- $tmp['Name'] = $attr['FAIvariable'][0];
- $tmp['Type'] = $attr['FAIvariableType'][0];
-
- if (isset($attr['FAIvariableContent'][0])){
- if(!in_array($attr['FAIvariableType'],array("multiselect"))){
- $tmp['Value'] = $attr['FAIvariableContent'][0];
- }else{
- $content = array();
- unset($attr['FAIvariableContent']['count']);
- foreach($attr['FAIvariableContent'] as $attr){
- $tmp['Value'][] = $attr;
- }
- }
- $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
- }
- }
}