From: hickert Date: Wed, 21 Jun 2006 06:56:06 +0000 (+0000) Subject: Updated snapshot functions X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=df2c9ab281801434b0596b0ddf6676372f4e00f7;p=gosa.git Updated snapshot functions git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3842 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/class_plugin.inc b/include/class_plugin.inc index 4e83bf9dd..30743f55a 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -996,13 +996,6 @@ class plugin /* Get configuration from gosa.conf */ $tmp = $this->config->data['MAIN']; - - /* Check if the snapshot_base is defined */ - if(!isset($tmp['SNAPSHOT_BASE'])){ - print_red(_("Can't create a new snapshot, the required variable SNAPSHOT_BASE in not configured in your gosa.conf.")); - return; - } - /* Check if the undo level is specified */ if(isset($tmp['SNAPSHOT_UNDO_LEVEL'])){ $UndoLvl = $tmp['SNAPSHOT_UNDO_LEVEL']; @@ -1021,30 +1014,14 @@ class plugin $ldap_to = $ldap; }else{ + $server = $tmp['SNAPSHOT_SERVER']; + $user = $tmp['SNAPSHOT_USER']; + $password = $tmp['SNAPSHOT_PASSWORD']; + $snapldapbase = $tmp['SNAPSHOT_LDAP_BASE']; - /* check if all required vars are available to create a new ldap connection */ - $missing = ""; - foreach(array("SNAPSHOT_SERVER","SNAPSHOT_USER","SNAPSHOT_PASSWORD","SNAPSHOT_LDAP_BASE") as $var){ - if(!isset($tmp[$var])){ - $missing .= $var." "; - } - } - - /* All vars are available, create a seperate ldap connection to store snapshots */ - if($missing == ""){ - $server = $tmp['SNAPSHOT_SERVER']; - $user = $tmp['SNAPSHOT_USER']; - $password = $tmp['SNAPSHOT_PASSWORD']; - $snapldapbase = $tmp['SNAPSHOT_LDAP_BASE']; - - $ldap_to = new LDAP($user,$password, $server); - $ldap_to -> cd($snapldapbase); - show_ldap_error($ldap_to->get_error(), _("Snapshot failed.")); - - }else{ - print_red(sprintf(_("Can't create a new snapshot the following variables are not configured in your gosa.conf '%s'."),$missing)); - return; - } + $ldap_to = new LDAP($user,$password, $server); + $ldap_to -> cd($snapldapbase); + show_ldap_error($ldap_to->get_error(), _("Snapshot failed.")); } @@ -1085,7 +1062,6 @@ class plugin $target['gosaSnapshotTimestamp'] = $newName; } - /* Inset this new snapshot */ $ldap_to->create_missing_trees($new_base); $ldap_to->cd($new_dn); @@ -1113,12 +1089,33 @@ class plugin } - /* returns true if snapshots are enabled */ + /* returns true if snapshots are enabled, and false if it is disalbed + There will also be some errors psoted, if the configuration failed */ function snapshotEnabled() { $tmp = $this->config->data['MAIN']; if(isset($tmp['ENABLE_SNAPSHOT'])){ if (preg_match("/^true$/i", $tmp['ENABLE_SNAPSHOT']) || preg_match("/yes/i", $tmp['ENABLE_SNAPSHOT'])){ + + /* Check if the snapshot_base is defined */ + if(!isset($tmp['SNAPSHOT_BASE'])){ + print_red(_("The snapshot functionality is enabled, but the required variable SNAPSHOT_BASE is not configured in your gosa.conf.")); + return(FALSE); + } + + /* check if there are special server configurations for snapshots */ + if(isset($tmp['SNAPSHOT_SERVER'])){ + + /* check if all required vars are available to create a new ldap connection */ + $missing = ""; + foreach(array("SNAPSHOT_SERVER","SNAPSHOT_USER","SNAPSHOT_PASSWORD","SNAPSHOT_LDAP_BASE") as $var){ + if(!isset($tmp[$var])){ + $missing .= $var." "; + print_red(sprintf(_("The snapshot functionality is enabled, but the required variable(s) '%s' is not configured in your gosa.conf."),$missing)); + return(FALSE); + } + } + } return(TRUE); } } @@ -1138,11 +1135,6 @@ class plugin $ldap->cd($this->config->current['BASE']); $tmp = $this->config->data['MAIN']; - if(!isset($tmp['SNAPSHOT_BASE'])){ - print_red(_("Please specify the attribute SNAPSHOT_BASE in your gosa.conf.")); - return(array()); - } - /* check if there are special server configurations for snapshots */ if(isset($tmp['SNAPSHOT_SERVER'])){ $server = $tmp['SNAPSHOT_SERVER']; @@ -1241,8 +1233,6 @@ class plugin } } - - /* Format result as requested */ if($raw) { return($tmp); @@ -1284,7 +1274,6 @@ class plugin /* Prepare import string */ $data = gzuncompress($ldap_to->get_attribute($dn,'gosaSnapshotData')); -// $data = "dn: ".$restoreObject['gosaSnapshotDN'][0]."\n".$data; /* Import the given data */ $ldap->import_complete_ldif($data,$err,true,true);