X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_SnapshotHandler.inc;h=bc912bdbadbaab693e25699bb899c6f9eee834fa;hb=f04b7b95f6468a806353f05cdd3faf97dd744d5c;hp=d371db5fcdd3d0b142a28ac27612722598b8abf1;hpb=a0de0b1a8c3ad3c1b18c57f276c7d8fb65ac0c8c;p=gosa.git diff --git a/gosa-core/include/class_SnapshotHandler.inc b/gosa-core/include/class_SnapshotHandler.inc index d371db5fc..bc912bdba 100644 --- a/gosa-core/include/class_SnapshotHandler.inc +++ b/gosa-core/include/class_SnapshotHandler.inc @@ -27,24 +27,23 @@ class SnapshotHandler { var $isEnabled= false; var $snapshotBases= array(); - /* Create handler */ function SnapshotHandler(&$config) { $this->config = &$config; $config = $this->config; - if($config->get_cfg_value("enableSnapshots") == "true"){ + if($config->get_cfg_value("core","enableSnapshots") == "true"){ /* Check if the snapshot_base is defined */ - if ($config->get_cfg_value("snapshotBase") == ""){ + if ($config->get_cfg_value("core","snapshotBase") == ""){ /* Send message if not done already */ if(!session::is_set("snapshotFailMessageSend")){ session::set("snapshotFailMessageSend",TRUE); msg_dialog::display(_("Configuration error"), - sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."), - "snapshotBase"), ERROR_DIALOG); + sprintf(_("The snapshot functionality is enabled but the required variable %s is not set!"), + bold("snapshotBase")), ERROR_DIALOG); } return; } @@ -56,26 +55,26 @@ class SnapshotHandler { if(!session::is_set("snapshotFailMessageSend")){ session::set("snapshotFailMessageSend",TRUE); msg_dialog::display(_("Configuration error"), - sprintf(_("The snapshot functionality is enabled, but the required compression module is missing. Please install '%s'."),"php5-zip / php5-gzip"), ERROR_DIALOG); + sprintf(_("The snapshot functionality is enabled but the required PHP compression module is missing: %s!"), bold("php5-zip / php5-gzip")), ERROR_DIALOG); } return; } /* check if there are special server configurations for snapshots */ - if ($config->get_cfg_value("snapshotURI") != ""){ + if ($config->get_cfg_value("core","snapshotURI") != ""){ /* check if all required vars are available to create a new ldap connection */ $missing = ""; foreach(array("snapshotURI","snapshotAdminDn","snapshotAdminPassword","snapshotBase") as $var){ - if($config->get_cfg_value($var) == ""){ + if($config->get_cfg_value("core",$var) == ""){ $missing .= $var." "; /* Send message if not done already */ if(!session::is_set("snapshotFailMessageSend")){ session::set("snapshotFailMessageSend",TRUE); msg_dialog::display(_("Configuration error"), - sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not set."), - $missing), ERROR_DIALOG); + sprintf(_("The snapshot functionality is enabled but the required variable %s is not set!"), + bold($missing)), ERROR_DIALOG); } return; } @@ -110,15 +109,15 @@ class SnapshotHandler { $snapshotLdap= null; /* check if there are special server configurations for snapshots */ - if($this->config->get_cfg_value("snapshotURI") != ""){ - $server= $this->config->get_cfg_value("snapshotURI"); - $user= $this->config->get_cfg_value("snapshotAdminDn"); - $password= $this->config->get_credentials($this->config->get_cfg_value("snapshotAdminPassword")); + if($this->config->get_cfg_value("core","snapshotURI") != ""){ + $server= $this->config->get_cfg_value("core","snapshotURI"); + $user= $this->config->get_cfg_value("core","snapshotAdminDn"); + $password= $this->config->get_credentials($this->config->get_cfg_value("core","snapshotAdminPassword")); $snapshotLdap= new ldapMultiplexer(new LDAP($user,$password, $server)); } /* Prepare bases */ - $this->snapshotLdapBase= $this->config->get_cfg_value("snapshotBase"); + $this->snapshotLdapBase= $this->config->get_cfg_value("core","snapshotBase"); $snapshotLdap->cd($this->snapshotLdapBase); if (!$snapshotLdap->success()){ msg_dialog::display(_("LDAP error"), msgPool::ldaperror($snapshotLdap->get_error(), $this->snapshotLdapBase, "", get_class())); @@ -262,17 +261,17 @@ class SnapshotHandler { $ldap->cd($this->config->current['BASE']); /* check if there are special server configurations for snapshots */ - if($config->get_cfg_value("snapshotURI") == ""){ + if($config->get_cfg_value("core","snapshotURI") == ""){ /* Source and destination server are both the same, just copy source to dest obj */ $ldap_to = $ldap; $snapldapbase = $this->config->current['BASE']; }else{ - $server = $config->get_cfg_value("snapshotURI"); - $user = $config->get_cfg_value("snapshotAdminDn"); - $password = $this->config->get_credentials($config->get_cfg_value("snapshotAdminPassword")); - $snapldapbase = $config->get_cfg_value("snapshotBase"); + $server = $config->get_cfg_value("core","snapshotURI"); + $user = $config->get_cfg_value("core","snapshotAdminDn"); + $password = $this->config->get_credentials($config->get_cfg_value("core","snapshotAdminPassword")); + $snapldapbase = $config->get_cfg_value("core","snapshotBase"); $ldap_to = new ldapMultiplexer(new LDAP($user,$password, $server)); $ldap_to -> cd($snapldapbase); @@ -291,13 +290,14 @@ class SnapshotHandler { /* Collect some infos */ $base = $this->config->current['BASE']; - $snap_base = $config->get_cfg_value("snapshotBase"); + $snap_base = $config->get_cfg_value("core","snapshotBase"); $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn); $new_base = preg_replace("/".preg_quote($base, '/')."$/","",$base_of_object).$snap_base; /* Create object */ -#$data = preg_replace('/^dn:.*\n/', '', $ldap->gen_ldif($dn,"(!(objectClass=gosaDepartment))")); - $data = $ldap->gen_ldif($dn,"(&(!(objectClass=gosaDepartment))(!(objectClass=FAIclass)))"); + $data = $ldap->generateLdif(LDAP::fix($dn), + "(&(!(objectClass=gosaDepartment))(!(objectClass=FAIclass)))",array(),'base'); + $newName = str_replace(".", "", $sec."-".$usec); $target= array(); $target['objectClass'] = array("top", "gosaSnapshotObject"); @@ -339,15 +339,12 @@ class SnapshotHandler { function remove_snapshot($dn) { $ui = get_userinfo(); - $old_dn = $this->dn; - $this->dn = $dn; $ldap = $this->config->get_ldap_link(); $ldap->cd($this->config->current['BASE']); - $ldap->rmdir_recursive($this->dn); + $ldap->rmdir_recursive($dn); if(!$ldap->success()){ - msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn)); + msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $dn)); } - $this->dn = $old_dn; } /* returns true if snapshots are enabled, and false if it is disalbed There will also be some errors psoted, if the configuration failed */ @@ -370,13 +367,13 @@ class SnapshotHandler { $cfg= &$this->config->current; /* check if there are special server configurations for snapshots */ - if($this->config->get_cfg_value("snapshotURI") == ""){ + if($this->config->get_cfg_value("core","snapshotURI") == ""){ $ldap_to = $ldap; }else{ - $server = $this->config->get_cfg_value("snapshotURI"); - $user = $this->config->get_cfg_value("snapshotAdminDn"); - $password = $this->config->get_credentials($this->config->get_cfg_value("snapshotAdminPassword")); - $snapldapbase = $this->config->get_cfg_value("snapshotBase"); + $server = $this->config->get_cfg_value("core","snapshotURI"); + $user = $this->config->get_cfg_value("core","snapshotAdminDn"); + $password = $this->config->get_credentials($this->config->get_cfg_value("core","snapshotAdminPassword")); + $snapldapbase = $this->config->get_cfg_value("core","snapshotBase"); $ldap_to = new ldapMultiplexer(new LDAP($user,$password, $server)); $ldap_to -> cd($snapldapbase); if (!$ldap_to->success()){ @@ -385,7 +382,7 @@ class SnapshotHandler { } /* Prepare bases and some other infos */ $base = $this->config->current['BASE']; - $snap_base = $this->config->get_cfg_value("snapshotBase"); + $snap_base = $this->config->get_cfg_value("core","snapshotBase"); $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn); $new_base = preg_replace("/".preg_quote($base, '/')."$/","",$base_of_object).$snap_base; $tmp = array(); @@ -425,13 +422,13 @@ class SnapshotHandler { $cfg= &$this->config->current; /* check if there are special server configurations for snapshots */ - if($this->config->get_cfg_value("snapshotURI") == ""){ + if($this->config->get_cfg_value("core","snapshotURI") == ""){ $ldap_to = $ldap; }else{ - $server = $this->config->get_cfg_value("snapshotURI"); - $user = $this->config->get_cfg_value("snapshotAdminDn"); - $password = $this->config->get_credentials($this->config->get_cfg_value("snapshotAdminPassword")); - $snapldapbase = $this->config->get_cfg_value("snapshotBase"); + $server = $this->config->get_cfg_value("core","snapshotURI"); + $user = $this->config->get_cfg_value("core","snapshotAdminDn"); + $password = $this->config->get_credentials($this->config->get_cfg_value("core","snapshotAdminPassword")); + $snapldapbase = $this->config->get_cfg_value("core","snapshotBase"); $ldap_to = new ldapMultiplexer(new LDAP($user,$password, $server)); $ldap_to -> cd($snapldapbase); if (!$ldap_to->success()){ @@ -441,7 +438,7 @@ class SnapshotHandler { /* Prepare bases */ $base = $this->config->current['BASE']; - $snap_base = $this->config->get_cfg_value("snapshotBase"); + $snap_base = $this->config->get_cfg_value("core","snapshotBase"); $new_base = preg_replace("/".preg_quote($base, '/')."$/","",$base_of_object).$snap_base; /* Fetch all objects and check if they do not exist anymore */ $ui = get_userinfo(); @@ -490,13 +487,13 @@ class SnapshotHandler { $cfg= &$this->config->current; /* check if there are special server configurations for snapshots */ - if($this->config->get_cfg_value("snapshotURI") == ""){ + if($this->config->get_cfg_value("core","snapshotURI") == ""){ $ldap_to = $ldap; }else{ - $server = $this->config->get_cfg_value("snapshotURI"); - $user = $this->config->get_cfg_value("snapshotAdminDn"); - $password = $this->config->get_credentials($this->config->get_cfg_value("snapshotAdminPassword")); - $snapldapbase = $this->config->get_cfg_value("snapshotBase"); + $server = $this->config->get_cfg_value("core","snapshotURI"); + $user = $this->config->get_cfg_value("core","snapshotAdminDn"); + $password = $this->config->get_credentials($this->config->get_cfg_value("core","snapshotAdminPassword")); + $snapldapbase = $this->config->get_cfg_value("core","snapshotBase"); $ldap_to = new ldapMultiplexer(new LDAP($user,$password, $server)); $ldap_to -> cd($snapldapbase); if (!$ldap_to->success()){