X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Ffai%2Fadmin%2Ffai%2Fclass_faiVariable.inc;h=0847d8842c3584d039447498b6a37c63d011f938;hb=ff3ef83f8dcb54659807a39f8513486b5c0badb0;hp=9390146c6688ce550fa67e0658db124bc2b1b685;hpb=29b2315fcec54f808e2b3dddb8990c474596aea2;p=gosa.git diff --git a/gosa-plugins/fai/admin/fai/class_faiVariable.inc b/gosa-plugins/fai/admin/fai/class_faiVariable.inc index 9390146c6..0847d8842 100644 --- a/gosa-plugins/fai/admin/fai/class_faiVariable.inc +++ b/gosa-plugins/fai/admin/fai/class_faiVariable.inc @@ -43,13 +43,10 @@ class faiVariable extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + $res = FAI::get_all_objects_for_given_object($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); foreach($res as $obj){ - - /* Skip not relevant objects */ - if(!preg_match("/".normalizePreg($this->dn)."$/i",$obj['dn'])) continue; - $objects = array(); + $objects['description'] = ""; $objects['status'] = "FreshLoaded"; $objects['dn'] = $obj['dn']; $objects = $this->get_object_attributes($objects,$this->subAttributes); @@ -66,9 +63,9 @@ class faiVariable extends plugin function acl_base_for_current_object($dn) { - if($dn == "new"){ + if($dn == "new" || $dn == ""){ if($this->dn == "new"){ - $dn = session::get('CurrentMainBase'); + $dn= $this->parent->parent->acl_base; }else{ $dn = $this->dn; } @@ -102,7 +99,7 @@ class faiVariable extends plugin } if($this->dn != "new"){ - session::set('objectinfo',$this->dn); + set_object_info($this->dn); } @@ -116,7 +113,7 @@ class faiVariable extends plugin $this->dialog->set_acl_base($c_dn); $this->dialog->FAIstate = $this->FAIstate; $this->dialog->parent = &$this; - session::set('objectinfo',$this->SubObjects[$var]['dn']); + set_object_info($this->SubObjects[$var]['dn']); $this->is_dialog=true; } @@ -127,7 +124,7 @@ class faiVariable extends plugin $c_dn = $this->acl_base_for_current_object($this->SubObjects[$var]['dn']); $acl = $this->ui->get_permissions($c_dn,"fai/faiVariable"); if(preg_match("/d/",$acl)){ - if($this->SubObjects[$var]['status'] == "edited"){ + if($this->SubObjects[$var]['status'] != "new"){ $this->SubObjects[$var]['status']= "delete"; }else{ unset($this->SubObjects[$var]); @@ -147,15 +144,16 @@ class faiVariable extends plugin }else{ $obj = $this->dialog->save(); if(isset($obj['remove'])){ - if($this->SubObjects[$obj['remove']['from']]['status']=="edited"){ + if($this->SubObjects[$obj['remove']['from']]['status'] != "new"){ $this->SubObjects[$obj['remove']['from']]['status'] = "delete"; - }elseif($this->SubObjects[$obj['remove']['from']]['status']=="new"){ + }else{ unset($this->SubObjects[$obj['remove']['from']]); } $obj['status'] = "new"; $this->SubObjects[$obj['remove']['to']] = $obj; unset($this->SubObjects[$obj['remove']['to']]['remove']); }else{ + $obj['status'] = "edited"; $this->SubObjects[$obj['cn']]=$obj; } $this->is_dialog=false; @@ -259,12 +257,12 @@ class faiVariable extends plugin $ldap = $this->config->get_ldap_link(); $ldap->cd ($this->dn); $release = $this->parent->parent->fai_release; - $use_dn = preg_replace("/".normalizePreg(FAI::get_release_dn($this->dn))."/i", $release, $this->dn); + $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $this->dn); new log("remove","fai/".get_class($this),$use_dn,$this->attributes); FAI::prepare_to_save_FAI_object($use_dn,array(),true); foreach($this->SubObjects as $name => $obj){ - $use_dn = preg_replace("/".normalizePreg(FAI::get_release_dn($this->dn))."/i", $release, $obj['dn']); + $use_dn = preg_replace("/".preg_quote(FAI::get_release_dn($this->dn), '/')."/i", $release, $obj['dn']); FAI::prepare_to_save_FAI_object($use_dn,array(),true); } $this->handle_post_events("remove"); @@ -278,11 +276,6 @@ class faiVariable extends plugin { if((isset($_POST['FAIvariable_posted'])) && !preg_match("/freeze/", $this->FAIstate) ){ plugin::save_object(); - foreach($this->attributes as $attrs){ - if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; - } - } } } @@ -297,7 +290,7 @@ class faiVariable extends plugin */ if($this->is_new){ $release = $this->parent->parent->fai_release; - $new_dn= 'cn='.$this->cn.",".get_ou('faivariableou').get_ou('faiou').$release; + $new_dn= 'cn='.$this->cn.",".get_ou('faiVariableRDN').get_ou('faiBaseRDN').$release; $res = faiManagement::check_class_name("FAIvariable",$this->cn,$new_dn); if(isset($res[$this->cn])){ $message[] = msgPool::duplicated(_("Name")); @@ -327,18 +320,7 @@ class faiVariable extends plugin * Because we must delete old entries first. * After deletion, we perform add and modify */ - $Objects = array(); - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] == "delete"){ - $Objects[$name] = $obj; - } - } - foreach($this->SubObjects as $name => $obj){ - if($obj['status'] != "delete"){ - $Objects[$name] = $obj; - } - } - + $Objects = $this->SubObjects; foreach($Objects as $name => $obj){ foreach($this->sub64coded as $codeIt){ @@ -347,7 +329,7 @@ class faiVariable extends plugin $tmp = array(); foreach($this->subAttributes as $attrs){ - if(empty($obj[$attrs])){ + if(!isset($obj[$attrs]) || $obj[$attrs] == ""){ $obj[$attrs] = array(); } $tmp[$attrs] = $obj[$attrs]; @@ -388,33 +370,14 @@ class faiVariable extends plugin /* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry) */ - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($source['dn']); - $attrs_to_search = $this->subAttributes; - $attrs_to_search[] = "FAIstate"; - $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))",$attrs_to_search); - while($object = $ldap->fetch()){ - - /* Skip objects, that are tagged as removed */ - if(isset($object['FAIstate'][0])){ - if(preg_match("/removed$/",$object['FAIstate'][0])){ - continue; - } - } - - /* Set status for save management */ - foreach($this->subAttributes as $attrs){ - if(!isset($object[$attrs][0])){ - $this->SubObjects[$object['cn'][0]][$attrs]=""; - }else{ - $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]); - } - $this->SubObjects[$object['cn'][0]]['status'] = "edited"; - $this->SubObjects[$object['cn'][0]]['dn'] = $object['dn']; + $res = FAI::get_all_objects_for_given_object($source['dn'],"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))"); + foreach($res as $obj){ + + $objects = array(); + $objects['status'] = "edited"; + $objects['dn'] = $obj['dn']; + $objects = $this->get_object_attributes($objects,$this->subAttributes); + $this->SubObjects[$objects['cn']] = $objects; } }