diff --git a/gosa-plugins/fai/admin/fai/class_faiHook.inc b/gosa-plugins/fai/admin/fai/class_faiHook.inc
index 6dbbf3ad326ce2b2f363e0f5f653273b1265d8a5..e71fc1b855f504c9007428c6ab98c1a7d3a75b1e 100644 (file)
*/
if($dn != "new"){
$this->dn =$dn;
*/
if($dn != "new"){
$this->dn =$dn;
-
+
/* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
*/
/* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
*/
- $ldap = $this->config->get_ldap_link();
- $ldap->cd ($this->dn);
- $attrs_to_search = $this->subAttributes;
- $attrs_to_search[] = "FAIstate";
- $ldap->search("(&(objectClass=FAIclass)(objectClass=".$this->subClass."))", $attrs_to_search);
-
- $data = array();
- while($object = $ldap->fetch()){
- $data[] = $object;
- }
- foreach($data as $object){
+ $res = FAI::get_all_objects_for_given_base($this->dn,"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))");
+ foreach($res as $obj){
- /* Skip objects, that are tagged as removed */
- if(isset($object['FAIstate'][0])){
- if(preg_match("/removed$/",$object['FAIstate'][0])){
- continue;
- }
- }
+ /* Skip not relevant objects */
+ if(!preg_match("/".preg_quote($this->dn, '/')."$/i",$obj['dn'])) continue;
- /* Set status for save management */
$objects = array();
$objects['status'] = "FreshLoaded";
$objects = array();
$objects['status'] = "FreshLoaded";
- $objects['dn'] = $object['dn'];
+ $objects['dn'] = $obj['dn'];
$objects = $this->get_object_attributes($objects,$this->subAttributes);
$this->SubObjects[$objects['cn']] = $objects;
}
$objects = $this->get_object_attributes($objects,$this->subAttributes);
$this->SubObjects[$objects['cn']] = $objects;
}
function acl_base_for_current_object($dn)
{
function acl_base_for_current_object($dn)
{
- if($dn == "new"){
+ if($dn == "new" || $dn == ""){
if($this->dn == "new"){
if($this->dn == "new"){
- $dn = session::get('CurrentMainBase');
+ $dn= $this->parent->parent->acl_base;
}else{
$dn = $this->dn;
}
}else{
$dn = $this->dn;
}
$this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn']));
$this->dialog->set_acl_category("fai");
$this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn']));
$this->dialog->set_acl_category("fai");
- session::set('objectinfo',$obj['dn']);
+ set_object_info($obj['dn']);
$this->dialog->parent = &$this;
$this->is_dialog=true;
}
$this->dialog->parent = &$this;
$this->is_dialog=true;
}
if(isset($_GET['act']) && isset($_GET['id'])){
if($_GET['act'] == "edit" && isset($this->SubObjects[base64_decode($_GET['id'])])){
$obj = $this->SubObjects[base64_decode($_GET['id'])];
if(isset($_GET['act']) && isset($_GET['id'])){
if($_GET['act'] == "edit" && isset($this->SubObjects[base64_decode($_GET['id'])])){
$obj = $this->SubObjects[base64_decode($_GET['id'])];
- if($obj['status'] == "FreshLoaded"){
+ if($obj['status'] == "FreshLoaded"){
$obj = $this->get_object_attributes($obj,$this->sub_Load_Later);
}
$this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
$this->dialog->FAIstate = $this->FAIstate;
$this->dialog->acl = $this->acl;
$obj = $this->get_object_attributes($obj,$this->sub_Load_Later);
}
$this->dialog= new $this->subClassName($this->config,$this->dn,$obj);
$this->dialog->FAIstate = $this->FAIstate;
$this->dialog->acl = $this->acl;
- session::set('objectinfo',$obj['dn']);
+ $this->dialog->set_acl_base($this->acl_base_for_current_object($obj['dn']));
+ $this->dialog->set_acl_category("fai");
+ set_object_info($obj['dn']);
$this->dialog->parent = &$this;
$this->is_dialog=true;
}
$this->dialog->parent = &$this;
$this->is_dialog=true;
}
$ldap = $this->config->get_ldap_link();
$ldap->cd ($this->dn);
$release = $this->parent->parent->fai_release;
$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){
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");
FAI::prepare_to_save_FAI_object($use_dn,array(),true);
}
$this->handle_post_events("remove");
{
if((isset($_POST['FAIhook_posted'])) && !preg_match("/^freeze/", $this->FAIstate)){
plugin::save_object();
{
if((isset($_POST['FAIhook_posted'])) && !preg_match("/^freeze/", $this->FAIstate)){
plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = $_POST[$attrs];
- }
- }
}
}
}
}
*/
if($this->is_new){
$release = $this->parent->parent->fai_release;
*/
if($this->is_new){
$release = $this->parent->parent->fai_release;
- $new_dn= 'cn='.$this->cn.",".get_ou('faihookou').get_ou('faiou').$release;
+ $new_dn= 'cn='.$this->cn.",".get_ou('faiHookRDN').get_ou('faiBaseRDN').$release;
$res = faiManagement::check_class_name("FAIhook",$this->cn,$new_dn);
if(isset($res[$this->cn])){
$message[] = msgPool::duplicated(_("Name"));
$res = faiManagement::check_class_name("FAIhook",$this->cn,$new_dn);
if(isset($res[$this->cn])){
$message[] = msgPool::duplicated(_("Name"));
$tmp = array();
$attributes = array_merge($this->sub_Load_Later,$this->subAttributes);
foreach($attributes as $attrs){
$tmp = array();
$attributes = array_merge($this->sub_Load_Later,$this->subAttributes);
foreach($attributes as $attrs){
- if(empty($obj[$attrs])){
+ if(!isset($obj[$attrs])) continue;
+ if($obj[$attrs] == ""){
$obj[$attrs] = array();
}
if(!is_array($obj[$attrs])){
$obj[$attrs] = array();
}
if(!is_array($obj[$attrs])){
/* Read all leaf objects of this object (For FAIscript this would be FAIscriptEntry)
*/
/* 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);
+ $res = FAI::get_all_objects_for_given_base($source['dn'],"(&(objectClass=FAIclass)(objectClass=".$this->subClass."))");
+ foreach($res as $obj){
- while($object = $ldap->fetch()){
+ /* Skip not relevant objects */
+ if(!preg_match("/".preg_quote($source['dn'], '/')."$/i",$obj['dn'])) continue;
- /* 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 */
$objects = array();
$objects['status'] = "edited";
$objects = array();
$objects['status'] = "edited";
- $objects['dn'] = $object['dn'];
+ $objects['dn'] = $obj['dn'];
$objects = $this->get_object_attributes($objects,$this->subAttributes);
$objects = $this->get_object_attributes($objects,$this->sub_Load_Later);
$objects = $this->get_object_attributes($objects,$this->subAttributes);
$objects = $this->get_object_attributes($objects,$this->sub_Load_Later);
-
$this->SubObjects[$objects['cn']] = $objects;
}
}
$this->SubObjects[$objects['cn']] = $objects;
}
}