Code

Updated snapshot mangement
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Jun 2006 07:17:46 +0000 (07:17 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Jun 2006 07:17:46 +0000 (07:17 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3791 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_plugin.inc
plugins/admin/systems/class_divListSystem.inc

index b4f7b1efbcb9e802bb73319446a9a303dd8ea515..b30cdcb1d67c5303fb3a6ed6b4dd3ece7e049f52 100644 (file)
@@ -987,6 +987,8 @@ class plugin
   /* Create a snapshot of the current object */
   function create_snapshot($type= "snapshot", $description= array())
   {
+    if(!$this->snapshotEnabled()) return;
+
     /* Create 2 ldap connections 
         one connection points to the snapshot server and 
         one to our basic ldap server */
@@ -1052,11 +1054,26 @@ class plugin
     }
   }
 
+    
+  /* returns true if snapshots are enabled */
+  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'])){
+        return(TRUE);
+      }
+    }
+    return(false);
+  }
+  
 
   /* Return available snapshots for the given base 
   */
   function Available_SnapsShots($dn,$raw = false)
   {
+    if(!$this->snapshotEnabled()) return(array());
+
     /* Create an additional ldap object which
         points to our ldap snapshot server */
     $ldap= $this->config->get_ldap_link();
@@ -1064,7 +1081,7 @@ class plugin
     $tmp = $this->config->data['MAIN'];
 
     if(!isset($tmp['SNAPSHOT_BASE'])){
-      print_red(_("Please specify the attribute SNAPSHOT_SERVER in your gosa.conf."));
+      print_red(_("Please specify the attribute SNAPSHOT_BASE in your gosa.conf."));
       return(array());
     }
 
@@ -1094,7 +1111,7 @@ class plugin
                     array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description")); 
  
     /* Put results into a list and add description if missing */
-    while($entry = $ldap->fetch()){ 
+    while($entry = $ldap_to->fetch()){ 
       if(!isset($entry['description'][0])){
         $entry['description'][0]  = "";
       }
@@ -1116,6 +1133,7 @@ class plugin
 
   function getAllDeletedSnapshots($base_of_object,$raw = false)
   {
+    if(!$this->snapshotEnabled()) return(array());
   
     /* Create an additional ldap object which
         points to our ldap snapshot server */
@@ -1177,6 +1195,8 @@ class plugin
   /* Restore selected snapshot */
   function restore_snapshot($dn)
   {
+    if(!$this->snapshotEnabled()) return(array());
+
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
     $tmp = $this->config->data['MAIN'];
index d92ffacbe4d3c27b934451217b343857428aba23..d926756144f1d6637dd1f6b027070efa8e0d4971 100644 (file)
@@ -91,11 +91,15 @@ class divListSystem extends MultiSelectWindow
       " <input class='center' type='image' align='middle' src='images/list_home.png'
       title='"._("Go to users department")."' alt='"._("Home")."'                     name='dep_home'>&nbsp;".
       " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".          _("Submit")."'>&nbsp;".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      "  <input class='center' type='image' align='middle' src='images/list_back.png'
-      title='"._("Go up one department")."' alt='"._("Up")."' name='RestoreDeletedSnapShot'>".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      " <input class='center' type='image' align='middle' src='images/select_new_terminal.png'
+      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+
+    if($this->parent->snapshotEnabled()){ 
+      $listhead .= "  <input class='center' type='image' align='middle' src='images/restore.png'
+        title='"._("Restore objects")."' alt='"._("Up")."' name='RestoreDeletedSnapShot'>".
+        " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+    }
+
+    $listhead .= " <input class='center' type='image' align='middle' src='images/select_new_terminal.png'
       name='newsystem_terminal'    alt='"._("New Terminal template")."' title='"._("New Terminal")."'>".
       " <input class='center' type='image' align='middle' src='images/select_new_workstation.png'
       name='newsystem_workstation' alt='"._("New Workstation template")."' title='"._("New Workstation")."'>".
@@ -125,14 +129,18 @@ class divListSystem extends MultiSelectWindow
   function GetSnapShotActions($dn)
   {
     $str = "";
-    $str .="<input class='center' type='image' src='images/snapshot.png' 
-      alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create snapshot")."'>&nbsp;";
-
-    if(count($this->parent->Available_SnapsShots($dn))){
-      $str .="<input class='center' type='image' src='images/restore.png' 
-        alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
-    }else{
-      $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
+
+    if($this->parent->snapshotEnabled()){
+
+      $str .="<input class='center' type='image' src='images/snapshot.png' 
+        alt='"._("Create snapshot")."' name='CreateSnapShot_".base64_encode($dn)."' title='"._("Create snapshot")."'>&nbsp;";
+
+      if(count($this->parent->Available_SnapsShots($dn))){
+        $str .="<input class='center' type='image' src='images/restore.png' 
+          alt='"._("Restore snapshot")."' name='RestoreSnapShot_".base64_encode($dn)."' title='"._("Restore snapshot")."'>&nbsp;";
+      }else{
+        $str.= "<img src='images/empty.png' style='width:16px;' class='center'>&nbsp;";
+      }
     }
     return($str);
   }