Code

Moved to new base selector
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index 97219fb733e290517589aa1a66ce30a7b09b789a..c2a64aecacf70881dcd53bc0d11301e34d8f3480 100644 (file)
 #       |
 #       |->activate_new_device()   (Finally activate the device - FAIsate=..)
 #
-
-
-
 class systemManagement extends management
 {
   var $plHeadline     = "Systems";
@@ -73,7 +69,6 @@ class systemManagement extends management
   protected $objectName   = "system";
   protected $objectInfo = array();
   protected $opsi = NULL;
-  protected $arp_handling_active = FALSE;
   protected $activationQueue  = array();
 
   function __construct($config,$ui)
@@ -139,11 +134,6 @@ class systemManagement extends management
       $this->snapHandler = new SnapshotHandler($this->config);
     }
 
-    // Check whether the arp handling active or not 
-    if($this->config->search("ArpNewDevice","CLASS",array('tabs')) != ""){
-      $this->arp_handling_active = TRUE;
-    }
-
     // Check if we are able to communicate with the GOsa supprot daemon
     if(class_available("gosaSupportDaemon")){
       $o = new gosaSupportDaemon();
@@ -158,6 +148,8 @@ class systemManagement extends management
   }
 
 
+  /*! \brief  Act on password change requests.
+   */
   function setPassword($action,$target)
   {
     if(count($target) == 1){
@@ -183,8 +175,7 @@ class systemManagement extends management
   }
 
 
-
-/*! \brief  This method is used to queue and process copy&paste actions.
+  /*! \brief  This method is used to queue and process copy&paste actions.
    *          Allows to copy, cut and paste mutliple entries at once.
    *  @param  String  'action'  The name of the action which was the used as trigger.
    *  @param  Array   'target'  A list of object dns, which should be affected by this method.
@@ -250,6 +241,8 @@ class systemManagement extends management
   }
 
 
+  /*! \brief  Password change confirmed, now try to change the systems pwd.
+   */
   function passwordChangeConfirmed()
   {
     $tDefs= $this->getObjectDefinitions();
@@ -715,10 +708,10 @@ class systemManagement extends management
     if(!isset($tInfo[$info])){
       trigger_error("Unknown action type '".$action."' cant create a new system!");
     }else{
-      management::newEntry($action,$target,$all, 
+      return(management::newEntry($action,$target,$all, 
           $tInfo[$info]['tabClass'],
           $tInfo[$info]['tabDesc'],
-          $tInfo[$info]['aclCategory']);
+          $tInfo[$info]['aclCategory']));
     }
   }
 
@@ -741,8 +734,9 @@ class systemManagement extends management
   }
 
 
-
-
+  /*! \brief  The system selection dialog was closed. 
+   *          We will now queue the given entry to be activated.
+   */ 
   function systemTypeChosen()
   {
     // Detect the systems target type 
@@ -763,6 +757,8 @@ class systemManagement extends management
   }
 
 
+  /*! \brief  Activate queued goto systems.
+   */
   function handleActivationQueue()
   {
     @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
@@ -1072,8 +1068,125 @@ class systemManagement extends management
   }
 
 
+  /*! \brief  Opens the snapshot creation dialog for the given target.
+   *
+   *  @param  String  'action'  The name of the action which was the used as trigger.
+   *  @param  Array   'target'  A list of object dns, which should be affected by this method.
+   *  @param  Array   'all'     A combination of both 'action' and 'target'.
+   */
+  function createSnapshotDialog($action="",$target=array(),$all=array())
+  {
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Snaptshot creation initiated!");
+
+    $pInfo    = $this->getObjectDefinitions();
+    $headpage = $this->getHeadpage();
+    foreach($target as $dn){
+
+      $entry = $headpage->getEntry($dn);
+      $type = $headpage->getType($dn);
+      if(!isset($pInfo[$type])) {
+        trigger_error('Unknown system type \''.$type.'\'!');
+        return;
+      }
+
+      if(!empty($dn) && $this->ui->allow_snapshot_create($dn,$pInfo[$type]['aclCategory'])){
+        $this->dialogObject = new SnapShotDialog($this->config,$dn,$this);
+        $this->dialogObject->aclCategories = array($pInfo[$type]['aclCategory']);
+        $this->dialogObject->parent = &$this;
+
+      }else{
+        msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s."),$dn),
+            ERROR_DIALOG);
+      }
+    }
+  }
+
+
+  /*! \brief  Displays the "Restore snapshot dialog" for a given target.
+   *          If no target is specified, open the restore removed object
+   *           dialog.
+   *  @param  String  'action'  The name of the action which was the used as trigger.
+   *  @param  Array   'target'  A list of object dns, which should be affected by this method.
+   *  @param  Array   'all'     A combination of both 'action' and 'target'.
+   */
+  function restoreSnapshotDialog($action="",$target=array(),$all=array())
+  {
+    // Set current restore base for snapshot handling.
+    $headpage = $this->getHeadpage();
+    $pInfo    = $this->getObjectDefinitions();
+    if(is_object($this->snapHandler)){
+      $bases = array();
+      foreach($this->storagePoints as $sp){
+        $bases[] = $sp.$headpage->getBase();
+      }
+    }
+
+    // No bases specified? Try base
+    if(!count($bases)) $bases[] = $this->headpage->getBase();
+
+    // No target, open the restore removed object dialog.
+    if(!count($target)){
+
+      $cats = array();
+      foreach($pInfo as $data){
+        $cats[] = $data['aclCategory'];
+      }
+      $cats = array_unique($cats);
+
+      $entry = $headpage->getBase();
+      if(!empty($entry) && $this->ui->allow_snapshot_restore($entry,$cats)){
+        @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$entry,"Snaptshot restoring initiated!");
+        $this->dialogObject = new SnapShotDialog($this->config,$entry,$this);
+        $this->dialogObject->set_snapshot_bases($bases);
+        $this->dialogObject->display_all_removed_objects = true;
+        $this->dialogObject->display_restore_dialog = true;
+        $this->dialogObject->parent = &$this;
+      }else{
+        msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$entry),
+            ERROR_DIALOG);
+      }
+    }else{
+
+      // Display the restore points for a given object.
+      $dn = array_pop($target);
+      $entry = $headpage->getEntry($dn);
+      $type = $headpage->getType($dn);
+      if(!isset($pInfo[$type])) {
+        trigger_error('Unknown system type \''.$type.'\'!');
+        return;
+      }
+
+      if(!empty($dn) && $this->ui->allow_snapshot_create($dn,$pInfo[$type]['aclCategory'])){
+        @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Snaptshot restoring initiated!");
+        $this->dialogObject = new SnapShotDialog($this->config,$dn,$this);
+        $this->dialogObject->set_snapshot_bases($bases);
+        $this->dialogObject->display_restore_dialog = true;
+        $this->dialogObject->parent = &$this;
+      }else{
+        msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$dn),
+            ERROR_DIALOG);
+      }
+    }
+  }
+
+
+  /*! \brief  Restores a snapshot object.
+   *          The dn of the snapshot entry has to be given as ['target'] parameter.
+   *
+   *  @param  String  'action'  The name of the action which was the used as trigger.
+   *  @param  Array   'target'  A list of object dns, which should be affected by this method.
+   *  @param  Array   'all'     A combination of both 'action' and 'target'.
+   */
+  function restoreSnapshot($action="",$target=array(),$all=array())
+  {
+    $dn       = array_pop($target);
+    $this->snapHandler->restore_snapshot($dn);
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Snaptshot restored!");
+    $this->closeDialogs();
+  }
+
 
- /*! \brief  Detects actions/events send by the ui
 /*! \brief  Detects actions/events send by the ui
    *           and the corresponding targets.
    */
   function detectPostActions()
@@ -1150,9 +1263,9 @@ class systemManagement extends management
           "plugClass"   => "workgeneric",
           "tabClass"    => "worktabs",
           "tabDesc"     => "WORKTABS",
-          "aclClass"    => "workstation",
+          "aclClass"    => "workgeneric",
           "sendEvents"  => TRUE,
-          "aclCategory" => "workgeneric"),
+          "aclCategory" => "workstation"),
 
         "gotoTerminal" => array(
             "ou"          => get_ou('terminalRDN'),
@@ -1160,17 +1273,17 @@ class systemManagement extends management
             "tabClass"    => "termtabs",
             "sendEvents"  => TRUE,
             "tabDesc"     => "TERMTABS",
-            "aclClass"    => "terminal",
-            "aclCategory" => "termgeneric"),
+            "aclClass"    => "termgeneric",
+            "aclCategory" => "terminal"),
 
         "gotoPrinter" => array(
             "ou"          => get_ou('printerRDN'),
             "plugClass"   => "printgeneric",
             "tabClass"    => "printtabs",
             "tabDesc"     => "PRINTTABS",
-            "aclClass"    => "printer",
+            "aclClass"    => "printgeneric",
             "sendEvents"  => FALSE,
-            "aclCategory" => "printgeneric"),
+            "aclCategory" => "printer"),
 
         "FAKE_OC_NewDevice" => array(
             "ou"          => get_ou('systemIncomingRDN'),
@@ -1178,8 +1291,8 @@ class systemManagement extends management
             "tabClass"    => "termtabs",
             "sendEvents"  => TRUE,
             "tabDesc"     => "TERMTABS",
-            "aclClass"    => "terminal",
-            "aclCategory" => "termgeneric"),
+            "aclClass"    => "termgeneric",
+            "aclCategory" => "terminal"),
 
         "goFonHardware" => array(
             "ou"          => get_ou('phoneRDN'),
@@ -1187,8 +1300,8 @@ class systemManagement extends management
             "tabClass"    => "phonetabs",
             "tabDesc"     => "PHONETABS",
             "sendEvents"  => FALSE,
-            "aclClass"    => "phone",
-            "aclCategory" => "phoneGeneric"),
+            "aclClass"    => "phoneGeneric",
+            "aclCategory" => "phone"),
 
         "FAKE_OC_winstation" => array(
             "ou"          => get_winstations_ou(),
@@ -1219,6 +1332,8 @@ class systemManagement extends management
     $tabs['gotoTerminal__IS_BUSY'] = &$tabs['gotoTerminal'];
     $tabs['gotoTerminal__IS_ERROR'] = &$tabs['gotoTerminal'];
     $tabs['gotoTerminal__IS_LOCKED'] = &$tabs['gotoTerminal'];
+    $tabs['FAKE_OC_TerminalTemplate'] = &$tabs['gotoTerminal'];
+    $tabs['FAKE_OC_WorkstationTemplate'] = &$tabs['gotoTerminal'];
     $tabs['goServer__IS_BUSY'] = &$tabs['goServer'];
     $tabs['goServer__IS_ERROR'] = &$tabs['goServer'];
     $tabs['goServer__IS_LOCKED'] = &$tabs['goServer'];