Code

Added pChart classes and GOsa mapping class to enable auto-include
[gosa.git] / gosa-core / include / class_management.inc
index 66bdc4cf2b73a201e86ef9ecc36b881d2bb39540..e4b9c9ac500e193cba50ab45f3ca0b6622eba106 100644 (file)
@@ -92,6 +92,11 @@ class management
     $this->headpage = $headpage;
     $this->ui = $ui;
     $this->config = $config;
+    $this->initTime = microtime(TRUE);
+
+    // Create statistic table entry 
+    stats::log('management', $class = get_class($this), $this->getAclCategories(),  $action = 'open', 
+            $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
 
     if($this->cpHandler) $this->headpage->setCopyPasteHandler($this->cpHandler);
     if($this->snapHandler) $this->headpage->setSnapshotHandler($this->snapHandler);
@@ -129,6 +134,17 @@ class management
     #session::global_un_set(get_class($this)."_filter");
   }
 
+  
+  /*! \brief  Returns an array with all ACL-Categories we are responsible for.
+   */
+  function getAclCategories()
+  {
+      $ret= $this->aclCategory;
+      if(!is_array($ret)) $ret = array($ret);
+      return($ret);
+  }    
+
+
   /*! \brief  Execute this plugin
    *          Handle actions/events, locking, snapshots, dialogs, tabs,...
    */
@@ -187,7 +203,11 @@ class management
 
       $this->snapHandler->setSnapshotBases($bases);
     }
-  
+    // Create statistic table entry 
+    stats::log('management', $class = get_class($this), $this->getAclCategories(),  $action = 'view',
+            $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
     // Display list
     return($this->renderList());
   }
@@ -437,6 +457,11 @@ class management
     if(isset($this->actions[$action['action']])){
       $func = $this->actions[$action['action']];
       if(!isset($action['targets']))$action['targets']= array(); 
+
+      // Create statistic table entry 
+      stats::log('management', $class = get_class($this), $this->getAclCategories(),  $action['action'],
+              $amount = count($action['targets']), $duration = (microtime(TRUE) - $this->initTime));
+
       return($this->$func($action['action'],$action['targets'],$action));
     }
   } 
@@ -625,11 +650,21 @@ class management
     if(empty($tabClass) || empty($tabType)){
       // No tab type defined
     }else{
-      if (isset($this->config->data['TABS'][$tabType])) {
-        $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
-        $this->tabObject->set_acl_base($this->headpage->getBase());
-        $this->tabObject->parent = &$this;
-        @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+
+        if (isset($this->config->data['TABS'][$tabType])) {
+
+            // Check if the base plugin is available - it is mostly responsible for object creation and removal.
+            $first  = $this->config->data['TABS'][$tabType][0];
+            if(!class_available($first['CLASS'])){
+                msg_dialog::display(_("Internal error"),
+                        sprintf(_("Cannot instantiate tabbed-plug-in, the base plugin (%s) is not available!"), $first['CLASS']),
+                        ERROR_DIALOG);
+            }else{
+                $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
+                $this->tabObject->set_acl_base($this->headpage->getBase());
+                $this->tabObject->parent = &$this;
+                @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+            }
       } else {
         msg_dialog::display(_("Error"), sprintf(_("No tab definition for %s found in configuration file: cannot create plugin instance!"), bold($tabType)), ERROR_DIALOG);
       }
@@ -678,9 +713,10 @@ class management
     if(!empty($altTabType)) $tabType = $altTabType;
     if(!empty($altAclCategory)) $aclCategory = $altAclCategory;
 
+    $this->displayApplyBtn = count($target) == 1;
+
     // Single edit - we only got one object dn.
     if(count($target) == 1){
-      $this->displayApplyBtn = TRUE;
       $this->is_new = FALSE;
       $this->is_single_edit = TRUE;
       $this->is_multiple_edit = FALSE;
@@ -698,11 +734,21 @@ class management
       if(empty($tabClass) || empty($tabType)){
         trigger_error("We can't edit any object(s). 'tabClass' or 'tabType' is empty!");
       }else{
+
         $tab = $tabClass;
-        $this->tabObject= new $tab($this->config,$this->config->data['TABS'][$tabType], $this->dn,$aclCategory);
-        @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Edit entry initiated!");
-        $this->tabObject->set_acl_base($this->dn);
-        $this->tabObject->parent = &$this;
+        
+        // Check if the base plugin is available - it is mostly responsible for object creation and removal.
+        $first  = $this->config->data['TABS'][$tabType][0];
+        if(!class_available($first['CLASS'])){
+            msg_dialog::display(_("Internal error"), 
+                    sprintf(_("Cannot instantiate tabbed-plug-in, the base plugin (%s) is not available!"), $first['CLASS']), 
+                    ERROR_DIALOG);
+        }else{
+            $this->tabObject= new $tab($this->config,$this->config->data['TABS'][$tabType], $this->dn,$aclCategory);
+            @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Edit entry initiated!");
+            $this->tabObject->set_acl_base($this->dn);
+            $this->tabObject->parent = &$this;
+        }
       }
     }else{
 
@@ -950,7 +996,7 @@ class management
 
 
   function postcreate() {
-    $this->handle_post_events('create');
+    $this->handle_post_events('add');
   }
   function postmodify(){
     $this->handle_post_events('modify');