Code

Addd comment
[gosa.git] / gosa-core / include / class_management.inc
index 359cad23bc8970998fb510a10878639b47b458dc..60eb713e84fb19439e8a95c32765c2f9b261cd9a 100644 (file)
@@ -33,7 +33,7 @@ class management
   public $plHeadline    = "unconfigured";
 
   // The currently used object(s) (e.g. in edit, removal)
-  protected $dn = "";
+  public $dn = "";  // this is public due to some compatibility problems with class plugin..
   protected $dns = array();
 
   // The last used object(s).
@@ -46,6 +46,7 @@ class management
   // The tab definitions to use for the current object.
   protected $tabClass = "";         // e.g. usertabs
   protected $tabType = "";          // e.g. USERTABS
+  protected $aclPlugin = "";        // e.g. generic
   protected $aclCategory = "";      // e.g. users
   protected $objectName = "";       // e.g. users
 
@@ -58,7 +59,10 @@ class management
   protected $last_dialogObject = null;
 
   // Whether to display the apply button or not
-  protected $displayApplyBtn = "";
+  protected $displayApplyBtn = FALSE;
+
+  // Whether to display a header or not.
+  protected $skipHeader = false;
 
   // Whether to display a footer or not.
   protected $skipFooter = false;
@@ -80,7 +84,7 @@ class management
   protected $actions = array();
 
   // Attributes managed by this plugin, can be used in post events;
-  protected $attributes = array(); 
+  public $attributes = array(); 
 
   function  __construct(&$config,$ui,$plugname, $headpage)
   {
@@ -137,9 +141,6 @@ class management
       $this->filter->update();
       session::global_set(get_class($this)."_filter", $this->filter);
       session::set('autocomplete', $this->filter);
-      if (!$this->filter->isValid()){
-        msg_dialog::display(_("Filter error"), _("The filter is incomplete!"), ERROR_DIALOG);
-      }
     }
 
     // Handle actions (POSTs and GETs)
@@ -158,7 +159,7 @@ class management
 
     // Display tab object.
     if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){
-      $this->tabObject->save_object();
+#      $this->tabObject->save_object();
       $display = $this->tabObject->execute();
       $display.= $this->_getTabFooter();
       return($this->getHeader().$display);
@@ -203,14 +204,8 @@ class management
    */
   protected function getHeader()
   {
-    if (get_object_info() != ""){
-      $display= print_header(get_template_path($this->plIcon),_($this->plDescription),
-          "<img alt=\"\" class=\"center\" src=\"".get_template_path('images/lists/locked.png')."\">".
-          LDAP::fix(get_object_info()));
-    } else {
-      $display= print_header(get_template_path($this->plIcon),_($this->plDescription));
-    }
-    return($display);
+    // We do not display any headers right now.
+    if(1 || $this->skipHeader) return("");
   }
 
 
@@ -433,7 +428,8 @@ class management
    *  @param  Array   'all'     A combination of both 'action' and 'target'.
    */
   function saveSnapshot($action="",$target=array(),$all=array())
-  {
+  { 
+    if(!is_object($this->dialogObject)) return;
     $this->dialogObject->save_object();
     $msgs = $this->dialogObject->check();
     if(count($msgs)){
@@ -568,10 +564,14 @@ class management
     if(empty($tabClass) || empty($tabType)){
       // No tab type defined
     }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!");
+      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!");
+      } else {
+        msg_dialog::display(_("Error"), sprintf(_("No tab declaration for '%s' found in your configuration file. Cannot create plugin instance!"), $tabType), ERROR_DIALOG);
+      }
     }
   }
 
@@ -746,6 +746,7 @@ class management
     $this->dns = array();
     $this->tabObject = null;
     $this->dialogObject = null;
+    $this->skipFooter = FALSE;
     set_object_info();
   }
 
@@ -904,7 +905,36 @@ class management
         msg_dialog::display(_("Error"), $message, ERROR_DIALOG);
       }
     }
+  }
 
+  function is_modal_dialog()
+  {
+    return(is_object($this->tabObject) || is_object($this->dialogObject));
+  }
+
+
+  /*! \brief    Forward command execution request
+   *             to the correct method.
+   */
+  function handle_post_events($mode, $addAttrs= array())
+  {
+    if(!in_array($mode, array('add','remove','modify'))){
+      trigger_error(sprintf("Invalid post event type given '%s'! Valid types are [add,modify,remove].", $mode));
+      return;
+    }
+    switch ($mode){
+      case "add":
+        plugin::callHook($this,"POSTCREATE", $addAttrs);
+      break;
+
+      case "modify":
+        plugin::callHook($this,"POSTMODIFY", $addAttrs);
+      break;
+
+      case "remove":
+        plugin::callHook($this,"POSTREMOVE", $addAttrs);
+      break;
+    }
   }
 }