index b87216703eba5c8f9dda884ff5f1290ad266f139..dda58a731aba9b18f6921aae455172fdeb7c8187 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
var $givenName= "";
var $acl= "*none*";
var $dialog= FALSE;
var $givenName= "";
var $acl= "*none*";
var $dialog= FALSE;
+ var $snapDialog = NULL;
/* attribute list for save action */
var $attributes= array();
/* attribute list for save action */
var $attributes= array();
/* Collect some infos */
$base = $this->config->current['BASE'];
$snap_base = $tmp['SNAPSHOT_BASE'];
/* Collect some infos */
$base = $this->config->current['BASE'];
$snap_base = $tmp['SNAPSHOT_BASE'];
- $base_of_object = dn2base($this->dn);
+ $base_of_object = preg_replace ('/^[^,]+,/i', '', $this->dn);
$new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
/* Create object */
$new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
/* Create object */
/* Prepare bases and some other infos */
$base = $this->config->current['BASE'];
$snap_base = $tmp['SNAPSHOT_BASE'];
/* Prepare bases and some other infos */
$base = $this->config->current['BASE'];
$snap_base = $tmp['SNAPSHOT_BASE'];
- $base_of_object = dn2base($dn);
+ $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn);
$new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
$tmp = array();
$new_base = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
$tmp = array();
$ui = get_userinfo();
$tmp = array();
$ldap_to->cd($new_base);
$ui = get_userinfo();
$tmp = array();
$ldap_to->cd($new_base);
- $ldap_to->search("(&(objectClass=gosaSnapshotObject))",array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description"));
+ $ldap_to->ls("(&(objectClass=gosaSnapshotObject))",$new_base,array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description"));
while($entry = $ldap_to->fetch()){
while($entry = $ldap_to->fetch()){
+
+ $chk = str_replace($base,"",$entry['gosaSnapshotDN'][0]);
+ if(preg_match("/,ou=/",$chk)) continue;
+
if(!isset($entry['description'][0])){
$entry['description'][0] = "";
}
if(!isset($entry['description'][0])){
$entry['description'][0] = "";
}
}
}
}
}
+
+
/* Format result as requested */
if($raw) {
return($tmp);
/* Format result as requested */
if($raw) {
return($tmp);
show_ldap_error($ldap_to->get_error().$err, _("Restore snapshot failed."));
}
show_ldap_error($ldap_to->get_error().$err, _("Restore snapshot failed."));
}
+
+ function showSnapshotDialog($base,$baseSuffix)
+ {
+ $once = true;
+ foreach($_POST as $name => $value){
+
+ /* Create a new snapshot, display a dialog */
+ if(preg_match("/^CreateSnapShot_/",$name) && $once){
+ $once = false;
+ $entry = preg_replace("/^CreateSnapShot_/","",$name);
+ $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+ $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+ }
+
+ /* Restore a snapshot, display a dialog with all snapshots of the current object */
+ if(preg_match("/^RestoreSnapShot_/",$name) && $once){
+ $once = false;
+ $entry = preg_replace("/^RestoreSnapShot_/","",$name);
+ $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+ $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+ $this->snapDialog->Restore = true;
+ }
+
+ /* Restore one of the already deleted objects */
+ if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
+ $once = false;
+ $entry = $baseSuffix.$base;
+ $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
+ $this->snapDialog->Restore = true;
+ $this->snapDialog->DeletedOnes = true;
+ }
+ }
+
+ /* Create a new snapshot requested, check
+ the given attributes and create the snapshot*/
+ if(isset($_POST['CreateSnapshot'])){
+ $this->snapDialog->save_object();
+ $msgs = $this->snapDialog->check();
+ if(count($msgs)){
+ foreach($msgs as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->dn = $this->snapDialog->dn;
+ $this->create_snapshot("snapshot",$this->snapDialog->CurrentDescription);
+ $this->snapDialog = NULL;
+ }
+ }
+
+ /* Restore is requested, restore the object with the posted dn .*/
+ if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
+ $entry =trim($_POST['SnapShot']);
+ if(!empty($entry)){
+ $entry = base64_decode($entry);
+ $this->restore_snapshot($entry);
+ $this->snapDialog = NULL;
+ }
+ }
+
+ if(isset($_POST['CancelSnapshot'])){
+ $this->snapDialog = NULL;
+ }
+
+ if($this->snapDialog){
+ $this->snapDialog->save_object();
+ return($this->snapDialog->execute());
+ }
+
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>