Code

Updated manager selection
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentManagement.inc
index 2de4cf2b7f7ba8defda52ea728b515eef0b872af..84382e4e3be9cad97338a1f75d92eee08518eb74 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-class departmentManagement extends plugin
+class departmentManagement extends management
 {
-  /* Definitions */
-  var $plHeadline= "Departments";
-  var $plDescription= "Manage Departments";
-
-  /* Headpage attributes */
-  var $last_dep_sorting= "invalid";
-  var $departments= array();
-  var $deptabs= NULL;
-
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-
-  /* Vars to handle operations after saving the department 
-     Recursive move && tagging   */
-  var $ObjectInSaveMode         = false;    // Is true, if current object wasn't saved right now
-  var $dns = array();
-
-  var $acl_module = array("department");
-
-  function departmentManagement (&$config, &$ui)
+  var $plHeadline     = "Directory structure";
+  var $plDescription  = "Manage organizations, organizational units, localities, countries and more";
+  var $plIcon         = "plugins/departments/images/plugin.png";
+
+  // Tab definition 
+  protected $tabClass = "deptabs";
+  protected $tabType = "DEPTABS";
+  protected $aclCategory = "department";
+  protected $aclPlugin   = "generic";
+  protected $objectName   = "department";
+
+  function __construct($config,$ui)
   {
-    $this->ui= &$ui;
-    $this->dn= "";
-    $this->config= &$config;
-    $this->DivListDepartment = new divListDepartment($this->config,$this);
-  }
-
-  function execute()
-  {
-    global $config;
-  
-    /* Call parent execute */
-    plugin::execute();
-
-    /***************
-      Var init 
-     ***************/
-
-    session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^dep_edit_.*/","/^dep_del_.*/","/^item_selected/","/^remove_multiple_departments/","/^menu_action/"));
-
-    /* Reload departments */
-    $smarty                                            = get_smarty();
-    $display                                   = "";
-    $s_action                                  = "";  // Will contain an action, like del or edit
-    $s_entry                                   = "";  // The entry name for edit delete -...
-
-
-    /***************
-      Check posts  
-     ***************/
-
-    // Check Post action
-    foreach($_POST as $key => $val){
-      // Post for delete
-      if(preg_match("/dep_del.*/",$key)){
-        $s_action = "del";
-        $s_entry  = preg_replace("/dep_".$s_action."_/i","",$key);
-        $s_entry  = preg_replace("/_.*$/","",$s_entry);
-        // Post for edit
-      }elseif(preg_match("/dep_edit_.*/",$key)){
-        $s_action="edit";
-        $s_entry  = preg_replace("/dep_".$s_action."_/i","",$key);
-        $s_entry  = preg_replace("/_.*$/","",$s_entry);
-        // Post for new
-      }elseif(preg_match("/^remove_multiple_departments/",$key)){
-        $s_action="del_multiple";
-      }
-    }
-
-    /* Create options */
-    if(isset($_POST['menu_action']) && preg_match("/^dep_new_/",$_POST['menu_action'])){
-      $s_action = "new";
-      $s_entry  = preg_replace("/^dep_new_([a-z]*)/","\\1",$_POST['menu_action']);
-    }
-
-    /* handle remove from layers menu */
-    if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
-      $s_action = "del_multiple";
-    }
-
-
-    /***************
-      Create a new department
-     ***************/
-
-    /* New Entry if Posted action (s_action) == new
-     */
-    if ($s_action=="new"){
-      $this->dn= "new";
-
-      $objects['c'] ['ACL'] = "country";
-      $objects['c'] ['TAB'] = "COUNTRY_TABS";
-      $objects['ou']['ACL'] = "department";
-      $objects['ou']['TAB'] = "DEPTABS";
-      $objects['l'] ['ACL'] = "locatity";
-      $objects['l'] ['TAB'] = "LOCALITY_TABS";
-      $objects['o'] ['ACL'] = "organization";
-      $objects['o'] ['TAB'] = "ORGANIZATION_TABS";
-
-      if(isset($objects[$s_entry])){
-        $tab = $objects[$s_entry]['TAB'];
-        $acl = $objects[$s_entry]['ACL'];
-        $this->deptabs= new deptabs($this->config,$this->config->data['TABS'][$tab], $this->dn,$acl);
-        $this->deptabs->set_acl_base($this->DivListDepartment->selectedBase);
-      }else{
-        trigger_error("Invalid / Not implemented countainer type.");
-      }
-    }
-
-
-    /***************
-      Edit entry
-     ***************/
-
-    /* Edit Entry if Posted action (s_action) == edit 
-     * The entry which will be edited is defined in $s_entry
-     */
-    if (( $s_action=="edit") && (!isset($this->deptabs->config))){
-
-      /* Possible department types
-       */
-      $types['dcObject']           = array("ACL" => "",             "TAB" => "");
-      $types['country']            = array("ACL" => "country",      "TAB" => "COUNTRY_TABS");
-      $types['locality']           = array("ACL" => "locality",     "TAB" => "LOCALITY_TABS");
-      $types['organizationalUnit'] = array("ACL" => "department",   "TAB" => "DEPTABS");
-      $types['organization']       = array("ACL" => "organization", "TAB" => "ORGANIZATION_TABS");
-      $types['Alias??']            = array("ACL" => "alias"     ,   "TAB" => "");
-      $types['Referal??']          = array("ACL" => "referal",      "TAB" => "");
-
-      $this->dn= $this->departments[trim($s_entry)]['dn'];
-      $entry   = $this->departments[trim($s_entry)];
-
-      /* Detect department type 
-       */ 
-      $data = array();
-      foreach($types as $oc => $type){
-        if(in_array($oc,$entry['objectClass'])){
-          $data = $type;
-          break;
-        }
-      }
-
-      /* Check if the department type was editable 
-       */
-      if(!count($data)){
-        trigger_error("Unknown department type skipped '".$this->dn."'.");
-      }elseif(empty($data['TAB'])){
-        // Do nothing, this object is currently not editable
-      }else{
-
-        if (($user= get_lock($this->dn)) != ""){
-          return(gen_locked_message ($user, $this->dn));
-        }
-
-        /* Lock the current entry, so everyone will get the  above dialog */
-        add_lock ($this->dn, $this->ui->dn);
-
-        /* Register deptabs to trigger edit dialog */
-        $this->deptabs= new deptabs($this->config,$this->config->data['TABS'][$data['TAB']], $this->dn,"department");
-        $this->deptabs->set_acl_base($this->dn);
-
-        session::set('objectinfo',$this->dn);
-      }
-    }
-
-
-    /********************
-      Delete MULTIPLE entries requested, display confirm dialog
-     ********************/
-
-    if ($s_action=="del_multiple"){
-      $ids = $this->list_get_selected_items();
-
-
-      if(count($ids)){
-        $this->dns = array();
-        foreach($ids as $id){
-          $id = base64_decode($id);
-          $this->dns[$id] = $dn = $this->config->departments[$id];
-        }
-
-        /* Check locks */
-        if ($user= get_multiple_locks($this->dns)){
-          return(gen_locked_message($user,$this->dns));
-        }
-
-        $dns_names = array();
-        foreach($this->dns as $dn){
-          $dns_names[] = @LDAP::fix($dn);
-        }
-        add_lock ($this->dns, $this->ui->dn);
-
-        /* Lock the current entry, so nobody will edit it during deletion */
-        $smarty->assign("info", msgPool::deleteInfo($dns_names));
-        $smarty->assign("multiple", true);
-        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
-      }
-    }
+    $this->config = $config;
+    $this->ui = $ui;
    
-
-    /********************
-      Delete MULTIPLE entries confirmed
-     ********************/
-
-    /* Confirmation for deletion has been passed. Users should be deleted. */
-    if (isset($_POST['delete_multiple_department_confirm'])){
-
-      /* Remove user by user and check acls before removeing them */
-      foreach($this->dns as $key => $dn){
-        $acl = $this->ui->get_permissions($dn,"department/department");
-        if (preg_match('/d/', $acl)){
-
-          /* Delete request is permitted, perform LDAP action */
-          $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $dn,"department");
-          $this->deptabs->set_acl_base();
-          $this->deptabs->delete ();
-          $this->deptabs = NULL;
-        } else {
-          msg_dialog::display(_("Permission error"), msgPool::permDelete(), WARNING_DIALOG);
-        }
-      }
-
-      /* Remove lock file after successfull deletion */
-      $this->remove_lock();
-      $this->dns = array();
+    // 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", true));
     }
+    $filter->setObjectStorage(array(''));
 
-    /********************
-      Delete MULTIPLE entries Canceled
-     ********************/
+    // Build headpage
+    $headpage = new listing(get_template_path("dep-list.xml", true));
+    $headpage->registerElementFilter("depLabel", "departmentManagement::filterDepLabel");
+    $headpage->setFilter($filter);
+    $this->setFilter($filter);
 
-    /* Remove lock */
-    if(isset($_POST['delete_multiple_department_cancel'])){
-
-      /* Remove lock file after successfull deletion */
-      $this->remove_lock();
-      $this->dns = array();
+    // Add copy&paste and snapshot handler.
+    if ($this->config->boolValueIsTrue("main", "copyPaste")){
+      $this->cpHandler = new CopyPasteHandler($this->config);
     }
-
-
-    /***************
-      Delete entry 
-     ***************/
-
-    /* Delete Entry if Posted action (s_action) == del 
-     * The entry which will be deleted is defined in $s_entry
-     */
-    if ($s_action =="del"){
-      $this->dn= $this->config->departments[trim($s_entry)];
-
-      /* check acls */
-      $acl = $this->ui->get_permissions($this->dn,"department/department");
-      if(preg_match("/d/",$acl)){
-
-        /* Check locking */
-        if (($user= get_lock($this->dn)) != ""){
-          session::set('dn',$this->dn);
-          return(gen_locked_message($user, $this->dn));
-        } else {
-          add_lock ($this->dn, $this->ui->dn);
-          $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), @LDAP::fix($this->dn)));
-          $smarty->assign("multiple", false);
-          $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
-          return ($display);
-        }
-      }else{
-        msg_dialog::display(_("Permission error"), msgPool::permDelete(), WARNING_DIALOG);
-      }
-    }
-
-
-    /***************
-      Delete department confirmed  
-     ***************/
-
-    /* If department deletion is accepted ...
-     * Finally delete department 
-     */
-    if (isset($_POST['delete_department_confirm'])){
-
-      /* check acls */
-      $acl = $this->ui->get_permissions($this->dn,"department/department");
-      if(preg_match("/d/",$acl)){
-        $this->remove_from_parent();
-      } else {
-        msg_dialog::display(_("Permission error"), msgPool::permDelete(), WARNING_DIALOG);
-      }
+    if($this->config->get_cfg_value("enableSnapshots") == "true"){
+      $this->snapHandler = new SnapshotHandler($this->config);
     }
 
-
-    /***************
-      Handle tagging/recursive move (Return output for an iframe)
-     ***************/
-
-    /* initiate recursive remove  (Is called from iframe, generates output)*/
-    if(isset($_GET['PerformRecMove'])){
-      $this->deptabs->move_me();
-      $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn;  
-      exit();
-    }
-
-    /* This department must be tagged (Is called from iframe, generates output)*/
-    if(isset($_GET['TagDepartment'])){
-      $base_name = $this->deptabs->base_name;
-      $this->deptabs->by_object[$base_name]->tag_objects();
-      exit();  
-    }
-
-
-    /***************
-      Edit department finished 
-     ***************/
-
-    if (is_object($this->deptabs) &&          // Ensure we have a valid deptab here 
-        (isset($_POST['edit_finish']) ||      // If 'Save' button is pressed in the edit dialog.
-         isset($_POST['dep_move_confirm']) || // The move(rename) confirmation was given
-         $this->deptabs->move_done())){       // The move(rename) is done, we have to save the rest now.
-
-      /* Check tabs, will feed message array.
-         This call will also initiate a sav_object() call.
-          So don't move it below the moved check !.
-       */
-      $message= $this->deptabs->check();
-
-      /*************
-        MOVED ? 
-         Check if this department has to be moved 
-       *************/  
-      if(!isset($_POST['dep_move_confirm']) && $this->deptabs->am_i_moved()){
-        return($smarty->fetch(get_template_path("dep_move_confirm.tpl",TRUE)));
-      }elseif(isset($_POST['dep_move_confirm']) && $this->deptabs->am_i_moved()){
-        $smarty = get_smarty();
-        $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove&no_output_compression");
-        $smarty->assign("message",_("As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."));
-        return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
-      }
-
-      /* Save, or display error message? */
-      if (count($message) == 0){
-        global $config;
-
-        $this->deptabs->save();
-        $config->get_departments();
-        $config->make_idepartments();
-        $this->config = $config;
-
-        /* This var indicated that there is an object which isn't saved right now. */
-        $this->ObjectInSaveMode = true;
-
-        /* This object must be tagged, so set ObjectTaggingRequested to true */
-        if($this->deptabs->by_object[$this->deptabs->base_name]->must_be_tagged()){
-          $smarty = get_smarty();
-          $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
-          $smarty->assign("message",_("As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog."));
-          return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
-        }              
-
-      } else {
-        /* Ok. There seem to be errors regarding to the tab data,
-           show message and continue as usual. */
-        msg_dialog::displayChecks($message);
-      }
-    }
-
-
-   /***************
-     In case of tagging/moving the object wasn't deleted, do it know
-    ***************/
-
-   /* If there is an unsaved object and all operations are done
-      remove locks & save object tab & unset current object */
-   if($this->ObjectInSaveMode){
-     $this->config->get_departments();
-     $this->ObjectInSaveMode = false;
-     if ($this->dn != "new"){
-       $this->remove_lock();
-     }
-     unset ($this->deptabs);
-     $this->deptabs= NULL;
-     session::un_set('objectinfo');
-   }
-
-
-   /***************
-      Dialog canceled  
-     ***************/
-
-    /* User canceled edit oder delete
-     * Cancel dialog 
-     */
-    if (isset($_POST['edit_cancel']) || isset($_POST['delete_cancel']) || isset($_POST['delete_department_confirm'])){
-      $this->remove_lock();
-      $this->deptabs= NULL;
-      session::un_set('objectinfo');
-    }
-
-    /* Headpage or normal plugin screen? */
-    if ($this->deptabs !== NULL){
-
-      /* Show main page (tabs) */
-      $display= $this->deptabs->execute();
-      if (!$this->deptabs->by_object[$this->deptabs->current]->dialog){
-        $display.= "<p style=\"text-align:right\">\n";
-        $display.= "<input type=submit name=\"edit_finish\" value=\"".msgPool::okButton()."\">\n";
-        $display.= "&nbsp;\n";
-        $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
-        $display.= "</p>";
-      }
-      return ($display);
-    }else{
-      /* Display dialog with group list */
-      $this->DivListDepartment->parent = $this;
-      $this->DivListDepartment->execute();
-      $this->reload();
-      $this->DivListDepartment->DepartmentsAdded = true;
-      $this->DivListDepartment->setEntries($this->departments);
-      return($this->DivListDepartment->Draw());
-    }
+    parent::__construct($config, $ui, "departments", $headpage);
+
+    $this->registerAction("open","openEntry");
+    $this->registerAction("new_domain","newEntry");
+    $this->registerAction("new_country","newEntry");
+    $this->registerAction("new_locality","newEntry");
+    $this->registerAction("new_dcObject","newEntry");
+    $this->registerAction("new_organization","newEntry");
+    $this->registerAction("new_organizationalUnit","newEntry");
+    $this->registerAction("performRecMove","performRecMove");
+    $this->registerAction("tagDepartment","tagDepartment");
   }
 
-
-  function reload()
+  // Inject additional actions here.
+  function detectPostActions()
   {
-    /* Vairaible init */
-    $base         = $this->DivListDepartment->selectedBase;
-    $base_back    = preg_replace("/^[^,]+,/","",$base);
-    $Regex        = $this->DivListDepartment->Regex;
-  
-    // Create Array to Test if we have a valid back button
-    $config = session::get('config');
-    $tmp = $config->idepartments;
-
-    /* Possible department types 
-     */ 
-    $types['dcObject']  = array("ACL" => "department",      "ATTR" => "dc",
-        "CLS" => "(objectClass=dcObject)",
-        "IMG"  => "plugins/departments/images/department.png");
-
-    $types['country']            = array("ACL" => "country",      "ATTR" => "c",
-        "CLS" => "(objectClass=country)",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "c");
-    $types['locality']           = array("ACL" => "locality",     "ATTR" => "l",
-        "CLS" => "(objectClass=locality)",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "l");
-    $types['organizationalUnit'] = array("ACL" => "department",   "ATTR" => "ou",
-        "CLS" => "(&(objectClass=gosaDepartment)(objectClass=organizationalUnit))",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "ou");
-    $types['organization']       = array("ACL" => "organization", "ATTR" => "o",
-        "CLS" => "(objectClass=organization)",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "o");
-    $types['Alias??']            = array("ACL" => "alias"     ,    "ATTR" => "alias?",
-        "CLS" => "(objectClass=alias??)",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "alias");
-    $types['Referal??']          = array("ACL" => "referal",       "ATTR" => "referal?",
-        "CLS" => "(objectClass=referal??)",
-        "IMG" => "plugins/departments/images/country.png", "ABBR" => "referal");
-
+    $actions = management::detectPostActions();
+    if(isset($_GET['PerformRecMove'])) $actions['action'] = "performRecMove";
+    if(isset($_GET['TagDepartment'])) $actions['action'] = "tagDepartment";
+    return($actions);
+  }
 
-    /* Create search filter for each department type
-     */
-    $res = array();
-    if($this->DivListDepartment->SubSearch){
-      foreach($types as $oc => $data){
-        $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$data['CLS'].")",
-            "department", $base, array($data['ATTR'],"objectClass", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-      }
-    }else{
-      foreach($types as $oc => $data){
-        $res= array_merge($res,get_list("(&(|(".$data['ATTR']."=$Regex)(description=$Regex))".$data['CLS'].")",
-            "department", $base, array($data['ATTR'], "objectClass","description"), GL_SIZELIMIT ));
-      }
-    }
+  // Action handler which allows department tagging - Creates the iframe contents.
+  function tagDepartment()
+  {
+    $plugname = $this->last_tabObject->base_name;
+    $this->last_tabObject->by_object[$plugname]->tag_objects();
+    exit();
+  }
 
-    /* Prepare list (sortable index) 
-     */
-    $deps = array();
-    $this->departments = array();
-    foreach($res as $attr){
+  // Overridden new handler - We've different types of departments to create!
+  function newEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+  {
+    $types= $this->get_support_departments();
+    $type = preg_replace("/^new_/","",$action);
+    return(management::newEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
+  }
 
-      /* Don't display base as entry on subsearch */
-      if(($attr['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
-        continue;
-      }
+  // Overridden edit handler - We've different types of departments to edit!
+  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+  {
+    $types= $this->get_support_departments();
+    $headpage = $this->getHeadpage();
+    $type = $headpage->getType($target[0]);
+    return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
+  }
 
-      /* Detect type and create sortable index 
-       */
-      $found =FALSE;
-      foreach($types as $oc => $data){
-        if(in_array($oc,$attr['objectClass'])){
-          $name = $attr[$data['ATTR']][0]."-".$attr['dn'];
-          $deps[$name] = $attr;
-          $found =TRUE;
-          break;
-        }
-      }
-      if(!$found ) trigger_error("Not found!");
-    }
-    uksort($deps, 'strnatcasecmp');
 
-    /* In case of a valid back button create entry 
-     */
-    if(isset($tmp[$base])){
-      $ldap = $this->config->get_ldap_link();
-      $ldap->cd($this->config->current['BASE']);
-      $ldap->cat($base );
-      $attr = $ldap->fetch();
-      foreach($types as $oc => $type){
-        if(in_array($oc,$attr['objectClass'])){
-          $attr[$type['ATTR']][0] = ".";
-        }
-      }
-      if(isset($attr['description'])){
-         unset($attr['description']);
-      }
-      $deps= array_merge(array($attr),$deps);
+  // Overriden save handler - We've to take care about the department tagging here.
+  protected function saveChanges()
+  {
+    $str = management::saveChanges();
+    if(!empty($str)) return($str);
+
+    $this->refreshDeps(); 
+    $plugname = $this->last_tabObject->base_name;
+    if($this->last_tabObject->by_object[$plugname]->must_be_tagged()){
+      $smarty = get_smarty();
+      $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment&no_output_compression");
+      $smarty->assign("message",_("As soon as the tag operation has finished, you can scroll down to end of the page and    press the 'Continue' button to continue with the department management dialog."));
+      return($smarty->fetch(get_template_path("dep_iframe.tpl",TRUE)));
     }
-
-    $this->departments = array_values($deps);
   }
 
-  function remove_from_parent()
+  
+  function refreshDeps()
   {
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd ($this->dn);
-    $ldap->recursive_remove();
-
-    /* Optionally execute a command after we're done */
-    $this->postremove();
-
-    /* Delete references to object groups */
-    $ldap->cd ($this->config->current['BASE']);
-    $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".LDAP::prepare4filter($this->dn)."))", array("cn"));
-    while ($ldap->fetch()){
-      $og= new ogroup($this->config, $ldap->getDN());
-      unset($og->member[$this->dn]);
-      $og->save ();
-    }
+    global $config; 
+    $config->get_departments();
+    $config->make_idepartments();
+    $this->config = $config;
+    $headpage = $this->getHeadpage();
+    $headpage->refreshBasesList();
+  }
 
+  // An action handler which enables to switch into deparmtment by clicking the names.
+  function openEntry($action,$entry)
+  {
+    $headpage = $this->getHeadpage();
+    $headpage->setBase(array_pop($entry));
   }
 
 
-  function list_get_selected_items()
+  // Overridden remove request method - Avoid removal of the ldap base.
+  protected function removeEntryRequested($action="",$target=array(),$all=array())
   {
-    $ids = array();
-    foreach($_POST as $name => $value){
-      if(preg_match("/^item_selected_[a-z0-9\\/\=]*$/i",$name)){
-        $id   = preg_replace("/^item_selected_/","",$name);
-        $ids[$id] = $id;
-      }
-    }
-    return($ids);
+    $target = array_remove_entries(array($this->config->current['BASE']),$target);
+    return(management::removeEntryRequested($action,$target,$all)); 
   }
 
 
-  function remove_lock()
+  // A filter which allows to open a department by clicking on the departments name.
+  static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
   {
-    if (isset($this->dn)){
-      del_lock ($this->dn);
-    }
-    if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
-      del_lock($this->dn);
-    }
-    if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
-      del_lock($this->dns);
+    $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_object()
+  
+  // Finally remove departments and update departmnet browsers
+  function removeEntryConfirmed($action="",$target=array(),$all=array(),$altTabClass="",
+    $altTabType="",$altAclCategory="", $aclPlugin="")
   {
-    /* reload department */
-    $this->config->get_departments();
-
-    $this->config->make_idepartments();
-    $this->DivListDepartment->config= $this->config;
-    $this->DivListDepartment->save_object();
+    management::removeEntryConfirmed($action,$target,$all, $altTabClass,$altTabType,$altAclCategory);
+    $this->refreshDeps();
   }
 
-}
+  /*! \brief  Returns information about all container types that GOsa con handle.
+    @return Array   Informations about departments supported by GOsa.
+   */
+  public static function get_support_departments()
+  {
+    /* Domain 
+     */ 
+    $types = array();
+    $types['domain']['ACL']     = "domain"; 
+    $types['domain']['CLASS']   = "domain"; 
+    $types['domain']['ATTR']    = "dc"; 
+    $types['domain']['TAB']     = "DOMAIN_TABS"; 
+    $types['domain']['OC']      = "domain"; 
+    $types['domain']['IMG']     = "plugins/departments/images/domain.png"; 
+    $types['domain']['IMG_FULL']= "plugins/departments/images/domain.png"; 
+    $types['domain']['TITLE']   = _("Domain"); 
+    $types['domain']['TPL']     = "domain.tpl"; 
+
+    /* Domain component 
+     */
+    $types['dcObject']['ACL']     = "dcObject";
+    $types['dcObject']['CLASS']   = "dcObject";
+    $types['dcObject']['ATTR']    = "dc";
+    $types['dcObject']['TAB']     = "DCOBJECT_TABS";
+    $types['dcObject']['OC']      = "dcObject";
+    $types['dcObject']['IMG']     = "plugins/departments/images/dc.png";
+    $types['dcObject']['IMG_FULL']= "plugins/departments/images/dc.png";
+    $types['dcObject']['TITLE']   = _("Domain Component");
+    $types['dcObject']['TPL']     = "dcObject.tpl";
+
+    /* Country object
+     */
+    $types['country']['ACL']     = "country";
+    $types['country']['CLASS']   = "country";
+    $types['country']['TAB']     = "COUNTRY_TABS";
+    $types['country']['ATTR']    = "c";
+    $types['country']['OC']      = "country";
+    $types['country']['IMG']     = "plugins/departments/images/country.png";
+    $types['country']['IMG_FULL']= "plugins/departments/images/country.png";
+    $types['country']['TITLE']   = _("Country");
+    $types['country']['TPL']     = "country.tpl";
+
+    /* Locality object
+     */
+    $types['locality']['ACL']     = "locality";
+    $types['locality']['CLASS']   = "locality";
+    $types['locality']['TAB']     = "LOCALITY_TABS";
+    $types['locality']['ATTR']    = "l";
+    $types['locality']['OC']      = "locality";
+    $types['locality']['IMG']     = "plugins/departments/images/locality.png";
+    $types['locality']['IMG_FULL']= "plugins/departments/images/locality.png";
+    $types['locality']['TITLE']   = _("Locality");
+    $types['locality']['TPL']     = "locality.tpl";
+
+    /* Organization
+     */
+    $types['organization']['ACL']     = "organization";
+    $types['organization']['CLASS']   = "organization";
+    $types['organization']['TAB']     = "ORGANIZATION_TABS";
+    $types['organization']['ATTR']    = "o";
+    $types['organization']['OC']      = "organization";
+    $types['organization']['IMG']     = "plugins/departments/images/organization.png";
+    $types['organization']['IMG_FULL']= "plugins/departments/images/organization.png";
+    $types['organization']['TITLE']   = _("Organization");
+    $types['organization']['TPL']     = "organization.tpl";
+
+    /* Department
+     */
+    $types['organizationalUnit']['ACL']     = "department";
+    $types['organizationalUnit']['CLASS']   = "department";
+    $types['organizationalUnit']['TAB']     = "DEPTABS";
+    $types['organizationalUnit']['ATTR']    = "ou";
+    $types['organizationalUnit']['OC']      = "organizationalUnit";
+    $types['organizationalUnit']['IMG']     = "images/lists/folder.png";//plugins/departments/images/department.png";
+    $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
+    $types['organizationalUnit']['TITLE']   = _("Department");
+    $types['organizationalUnit']['TPL']     = "generic.tpl";
+    return($types);
+  }
+} 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>