index 4418a255ab267ccebaf5fcb4027e04a66cf426af..26c0a572659f10287d156965b74bdb68579e2095 100644 (file)
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
+ $res = array();
+ $tmp = array();
+
+ if(!is_release_department($Current_DN)) {
+ return($res);
+ }
/* Collect some basic informations and initialize some variables */
$base_release = get_release_dn($Current_DN);
$previous_releases = array_reverse(get_previous_releases_of_this_release($base_release,true));
/* Collect some basic informations and initialize some variables */
$base_release = get_release_dn($Current_DN);
$previous_releases = array_reverse(get_previous_releases_of_this_release($base_release,true));
- $res = array();
- $tmp = array();
/* We must also include the given release dn */
$previous_releases[] = $base_release;
/* We must also include the given release dn */
$previous_releases[] = $base_release;
foreach($deps_to_search as $fai_base){
/* Ldap search for fai classes specified in this release */
foreach($deps_to_search as $fai_base){
/* Ldap search for fai classes specified in this release */
- $ldap->cd($fai_base);
- $ldap->search($filter,array("dn","objectClass","FAIstate"));
-
+ $res_tmp = get_list($filter,"fai",$fai_base,array("dn","objectClass","FAIstate"),GL_SUBSEARCH | GL_SIZELIMIT);
+
/* check the returned objects, and add/replace them in our return variable */
/* check the returned objects, and add/replace them in our return variable */
- while($attr = $ldap->fetch()){
+ foreach($res_tmp as $attr){
$buffer = array();
$buffer = array();
- $name = str_ireplace($release,"",$attr['dn']);
+ $name = preg_replace("/".normalizePreg($release)."/i","",$attr['dn']);
if(isset($attr['FAIstate'][0])){
if(preg_match("/removed$/",$attr['FAIstate'][0])){
if(isset($attr['FAIstate'][0])){
if(preg_match("/removed$/",$attr['FAIstate'][0])){
}
}
-
-/* Return the object defining ObjectClass e.g. FAIscriptEntry */
-function get_FAI_type($attr)
-{
- $arr = array( "FAIprofile","FAIpartitionTable", "FAIpartitionDisk","FAIpartitionEntry","FAIhook","FAIhookEntry",
- "FAIscriptEntry","FAIscript","FAIvariable","FAIvariableEntry","FAIpackageList","FAItemplate",
- "FAItemplateEntry","FAIdebconfInfo","FAIrepository","FAIrepositoryServer","FAIbranch","FAIreleaseTag");
- foreach($arr as $name){
- if(in_array($name,$attr['objectClass'])){
- preg_match("");
- return($name);
- }
- }
- if(DEBUG_FAI_FUNC) { echo "Not found"; }
- return("");
-}
-
-
/* Return all relevant FAI departments */
function get_FAI_departments($suffix = "")
{
/* Return all relevant FAI departments */
function get_FAI_departments($suffix = "")
{
@@ -174,22 +159,32 @@ function prepare_to_save_FAI_object($Current_DN,$objectAttrs,$removed = false)
/* Detect differences in attribute arrays */
function array_diff_FAI($ar1,$ar2)
{
/* Detect differences in attribute arrays */
function array_diff_FAI($ar1,$ar2)
{
+
+ if((!isset($ar1['description'])) || (isset($ar1['description']) && (count($ar1['description']) == 0))){
+ $ar1['description'] = "";
+ }
+ if((!isset($ar2['description'])) || (isset($ar2['description']) && (count($ar2['description']) == 0))){
+ $ar2['description'] = "";
+ }
+
+ if(count($ar1) != count($ar2)) {
+ return (true);
+ }
+
foreach($ar1 as $key1 => $val1){
if((is_array($val1)) && (count($val1)==1)){
$ar1[$key1] = $val1[0];
}
foreach($ar1 as $key1 => $val1){
if((is_array($val1)) && (count($val1)==1)){
$ar1[$key1] = $val1[0];
}
- if(!isset($ar2[$key1])){
- return(true);
- }
-
if((is_array($ar2[$key1])) && (count($ar2[$key1])==1)){
$val1 = $val1[0];
$ar2[$key1] = $ar2[$key1][0];
}
}
if((is_array($ar2[$key1])) && (count($ar2[$key1])==1)){
$val1 = $val1[0];
$ar2[$key1] = $ar2[$key1][0];
}
}
- if(count( array_diff($ar1,$ar2))){
+ ksort($ar1);
+ ksort($ar2);
+ if(count( array_diff($ar1,$ar2)) || arr_diff($ar1,$ar2)){
return(true);
}else{
return(false);
return(true);
}else{
return(false);
}
}
+function arr_diff($ar1,$ar2)
+{
+ foreach($ar1 as $ak1 => $av1){
+ if(!isset($ar2[$ak1]) || (!($av1 === $ar2[$ak1]))){
+ return(true);
+ }elseif(is_array($av1)){
+ return(arr_diff($av1,$ar2[$ak1]));
+ }
+ }
+ return(FALSE);
+}
+
+
+
+
/* check which objects must be saved, and save them */
function save_release_changes_now()
{
/* check which objects must be saved, and save them */
function save_release_changes_now()
{
/* Check if this a leaf release or not */
if(count($following_releases) == 0 ){
/* Check if this a leaf release or not */
if(count($following_releases) == 0 ){
- /* This is a leaf object. It isn't unherited by any other object */
+ /* This is a leaf object. It isn't inherited by any other object */
if(DEBUG_FAI_FUNC) {
echo "<b>Saving directly, is a leaf object</b><br> ".$Current_DN;
print_a($objectAttrs);
if(DEBUG_FAI_FUNC) {
echo "<b>Saving directly, is a leaf object</b><br> ".$Current_DN;
print_a($objectAttrs);
while($attr = $ldap->fetch()){
$buffer = array();
while($attr = $ldap->fetch()){
$buffer = array();
- $name = str_ireplace($release,"",$attr['dn']);
+# $name = str_ireplace($release,"",$attr['dn']);
+ $name = preg_replace("/".normalizePreg($release)."/i","",$attr['dn']);
if(isset($attr['FAIstate'][0])&&(preg_match("/removed$/",$attr['FAIstate'][0]))){
if(isset($attr['FAIstate'][0])&&(preg_match("/removed$/",$attr['FAIstate'][0]))){
$sub_releases = get_sub_releases_of_this_release($base_release);
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
$sub_releases = get_sub_releases_of_this_release($base_release);
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
- $dn_suffix = str_ireplace($base_release,"",$dn);
+# $dn_suffix = str_ireplace($base_release,"",$dn);
+ $dn_suffix = preg_replace("/".normalizePreg($base_release)."/i","",$dn);
/* Check if given object also exists whitin one of these releases */
foreach($sub_releases as $p_release => $name){
/* Check if given object also exists whitin one of these releases */
foreach($sub_releases as $p_release => $name){
}
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
}
/* Get dn suffix. Example "FAIvairableEntry=keksdose,FAIvariable=Keksregal," */
- $dn_suffix = str_ireplace($base_release,"",$dn);
+# $dn_suffix = str_ireplace($base_release,"",$dn);
+ $dn_suffix = preg_replace("/".normalizePreg($base_release)."/i","",$dn);
/* Check if given object also exists whitin one of these releases */
foreach($previous_releases as $p_release){
/* Check if given object also exists whitin one of these releases */
foreach($previous_releases as $p_release){
$ret = array();
/* Explode dns into pieces, to be able to build parent dns */
$ret = array();
/* Explode dns into pieces, to be able to build parent dns */
- $dns_to_check = ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$dn),0);
+ $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$dn));
+
if(!is_array($dns_to_check)){
return;
}
if(!is_array($dns_to_check)){
return;
}
$ldap->cd($config->current['BASE']);
/* Split dn into pices */
$ldap->cd($config->current['BASE']);
/* Split dn into pices */
- $dns_to_check = ldap_explode_dn(str_ireplace(",".$config->current['BASE'],"",$Current_DN),0);
+ $dns_to_check = gosa_ldap_explode_dn(preg_replace("/".normalizePreg(",".$config->current['BASE'])."/i","",$Current_DN));
+
if(!is_array($dns_to_check)){
return;
}
if(!is_array($dns_to_check)){
return;
}