Code

Updated management class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 18 Jan 2010 09:30:55 +0000 (09:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 18 Jan 2010 09:30:55 +0000 (09:30 +0000)
-Allow to skip the page header.
Updated class_baseSelectDialog to use the new generation lists

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15165 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_baseSelectDialog.inc
gosa-core/include/class_management.inc

index d43da2ee64ab7daee81b27d2932d052ff47c0a22..1aebc8328c97971dd698468956c630dcd1c66f20 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-class baseSelectDialog extends MultiSelectWindow
+class baseSelectDialog extends management
 {
-  var $selectedBase        = ""; // Used for navigation 
-  var $base_selection_regex = "*"; // Used regex ... 
-  var $BaseToUse         = false;  // used to specify the selected base, 
-                                      // false if none is selected
+  // The plugin description
+  public $plugname      = "Base";
+  public $plIcon        = "plugins/departments/images/plugin.png";
+  public $plDescription = "Choose a base";
+  public $plHeadline    = "Base";
 
-  var $allowedBases         = array();
-  var $parent               = NULL;
-  function baseSelectDialog (&$config,$parent,$onlyAllowThisBases = array())
-  {
-    $module= "department";
-    MultiSelectWindow::MultiSelectWindow($config, "BASEselectWindow", $module);
-   
-    $this->parent = $parent;
-    $this->selectedBase = $config->current['BASE'];
-    $this->allowedBases  = $onlyAllowThisBases;
-
-    $this->SetTitle("Base");
-    $this->SetSummary(_("Choose a base"));
-    $this->SetListHeader("<div style='background:#F0F0F9;padding:5px;'>".
-        " <input class='center' type='image' src='images/lists/root.png' align='middle'
-        title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
-        " <input class='center' type='image' align='middle' src='images/lists/back.png'
-        title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
-        " <input class='center' type='image' align='middle' src='images/lists/home.png'
-        title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
-        " <input class='center' type='image' src='images/lists/reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
-        "</div>");
+  protected $skipHeader = TRUE;
+  protected $allowedBases = array();
 
-    $this->SetInformation(_("Step in the prefered tree and click save to use the current subtree as base. Or click the image at the end of each entry."));
+  // #FIXME  -  Updated plugins to use a function instead of the public class var. 
+  public $BaseToUse = "";
 
-    $this->EnableAplhabet   (true);
-    $this->EnableCloseButton(true);
-    $this->EnableSaveButton (true);
+  function __construct (&$config,$parent,$onlyAllowThisBases = array())
+  { 
+    $this->config = $config;
+    $this->ui = get_userinfo();
+    $this->allowedBases = $onlyAllowThisBases;
 
-    $this->SetSaveButtonString(_("Use"));
-    $this->SetCloseButtonString(_("Cancel"));
+#    // Build filter
+#    if (session::global_is_set(get_class($this)."_filter")){
+#      $filter= session::global_get(get_class($this)."_filter");
+#    } else {
+      $filter = new filter(get_template_path("dep-filter.xml"));
+#    }
+    $this->setFilter($filter);
 
-    $this->AddHeader(array("string"=>"&nbsp;","attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string"=>_("Base")));
-
-    /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
-    $this->AddRegex   ("base_selection_regex",_("Filter entries with this syntax"),"*"      , true);
+    // Build headpage
+    $headpage = new listing(get_template_path("dep-list.xml"));
+    $headpage->registerElementFilter("depLabel", "baseSelectDialog::filterDepLabel");
+    $headpage->setFilter($filter);
+    parent::__construct($config, $this->ui, "departments", $headpage);
   }
 
-  function execute()
-  {
-    $this->ClearElementsList();
-    $this->AddDepartments($this->selectedBase,2);
-    return($this->Draw());
-  }
 
-  function setEntries()
+  // A filter which allows to open a department by clicking on the departments name.
+  static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
   {
-    // Do nothing here 
+    $ou = $ou[0];
+    if($dn == $base){
+      $ou =".";
+    }
+    $dn= LDAP::fix(func_get_arg(1));
+    return("<a href='?plug=".$_GET['plug']."&amp;PID=$pid&amp;act=listing_open_$row' title='$dn'>$ou</a>");
   }
 
-  function Save()
+  
+  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
   {
-    MultiSelectWindow :: Save();  
-    $this->BaseToUse = $this->selectedBase;
+    if(count($target) == 1){
+      $this->BaseToUse = array_pop($target);
+    }
   }
 
-  function isSelected() 
+  function save_object()
   {
-    return($this->BaseToUse);
+    // Damn ... , we've to call post detection manually & thus twice ...
+    // #FIXME - We should fix the class handling in the plugins to match the class_management style.
+    //        - save_object isn't needed anymore, just call execute...
+    $this->handleActions($this->detectPostActions());
   }
 
-  function setCurrentBase($base)
+  function isClosed()
   {
-    $this->selectedBase = $base;
+    return(!empty($this->BaseToUse));
   }
+
+ function isSelected() 
+ {
+   return($this->BaseToUse);
+ }
+
+ function setCurrentBase($base)
+ {
+   $headpage = $this->getHeadpage();
+   $headpage->setBase = $base;
+ }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 544051dd06b291e088e3f49a374b0a6346009824..98f02cee2fa00e1f020fc4958dc88d4833b15697 100644 (file)
@@ -60,6 +60,9 @@ class management
   // Whether to display the apply button or not
   protected $displayApplyBtn = FALSE;
 
+  // Whether to display a header or not.
+  protected $skipHeader = false;
+
   // Whether to display a footer or not.
   protected $skipFooter = false;
 
@@ -203,6 +206,8 @@ class management
    */
   protected function getHeader()
   {
+    if($this->skipHeader) return("");
+
     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')."\">".