Code

Updated images
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index a0b98cb72bf38de666448cab648d5b95b66b89a2..4413c7ef91bb3b950fa72f3b360658481eabb237 100644 (file)
@@ -58,7 +58,7 @@
 class systemManagement extends management
 {
   var $plHeadline     = "Systems";
-  var $plDescription  = "List of systems";
+  var $plDescription  = "Systems";
   var $plIcon  = "plugins/systems/images/plugin.png";
 
   // Tab definition 
@@ -86,18 +86,19 @@ class systemManagement extends management
     $this->storagePoints = array_unique($sP);
 
     // Build filter
-    if (session::global_is_set(get_class($this)."_filter")){
     $filter= session::global_get(get_class($this)."_filter");
-    } else {
+#    if (session::global_is_set(get_class($this)."_filter")){
#    $filter= session::global_get(get_class($this)."_filter");
+  #  } else {
       $filter = new filter(get_template_path("system-filter.xml", true));
       $filter->setObjectStorage($this->storagePoints);
-    }
+   # }
     $this->setFilter($filter);
 
     // Build headpage
     $headpage = new listing(get_template_path("system-list.xml", true));
+    $headpage->registerElementFilter("systemRelease", "systemManagement::systemRelease");
     $headpage->setFilter($filter);
-    $filter->setConverter('INCOMING', 'systemManagement::incomingFilterConverter');
+    $filter->setConverter('systemManagement::incomingFilterConverter');
 
     // Register Daemon Events
     if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){
@@ -708,10 +709,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']));
     }
   }
 
@@ -832,9 +833,9 @@ class systemManagement extends management
 
           if($data['OG'] != "none"){
             $this->tabObject->base = preg_replace("/^[^,]+,".preg_quote(get_ou('ogroupRDN'), '/')."/i", "", $data['OG']);
-            $this->tabObject->by_object[$plugClass]->base = $this->tabObject->base;
+            $this->tabObject->by_object[$plugClass]->baseSelector->setBase($this->tabObject->base);
           } else {
-            $this->tabObject->by_object[$plugClass]->base = $headpage->getBase();
+            $this->tabObject->by_object[$plugClass]->baseSelector->setBase($headpage->getBase());
             $this->tabObject->base = $headpage->getBase();
           }
 
@@ -1068,8 +1069,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()
@@ -1146,9 +1264,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'),
@@ -1156,17 +1274,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'),
@@ -1174,8 +1292,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'),
@@ -1183,8 +1301,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(),
@@ -1215,6 +1333,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'];
@@ -1225,6 +1345,42 @@ class systemManagement extends management
   }
 
 
+  static function systemRelease($a,$b,$c,$objectclasses= null,$class= null)
+  {
+    global $config;
+
+    // No objectclasses set - go ahead
+    if(!$objectclasses) return(" ");
+
+    // Skip non fai objects
+    if (!in_array_ics("FAIobject", $objectclasses)) {
+      return " ";
+    }
+
+    // If we've an own fai class, just use this
+    if ($class && is_array($class)) {
+      foreach (explode(' ', $class[0]) as $element) {
+        if ($element[0] == ":") {
+          return " ".image('images/empty.png')." ".mb_substr($element, 1);
+        }
+      }
+    }
+
+    // Load information if needed
+    $ldap = $config->get_ldap_link();
+    $ldap->cd($config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaGroupOfNames)(FAIclass=*)(member=".$b."))",array('FAIclass','cn'));
+    while($attrs = $ldap->fetch()){
+      $rel = preg_replace("/^.*:/","",$attrs['FAIclass'][0]);
+      $sys = sprintf(_("Inherited from %s"),$attrs['cn'][0]);
+      $str = " ".image('plugins/ogroups/images/ogroup.png', "", $sys)." ".$rel;
+      return($str);
+    }
+    
+    return(" ");
+  }
+
+
   /*! \brief  !! Incoming dummy acls, required to defined acls for incoming objects
    */
   static function plInfo()