Code

Added some comments.
[gosa.git] / gosa-core / plugins / admin / departments / class_departmentManagement.inc
index 170c562f4e1e6db38a8b696ff3392b174ba04180..781744d20e6f32ec2410c47b7207baf7646a317d 100644 (file)
@@ -23,7 +23,8 @@
 class departmentManagement extends management
 {
   var $plHeadline     = "Departments";
-  var $plDescription  = "Manage departmentw";
+  var $plDescription  = "Manage Departments";
+  var $plIcon         = "plugins/departments/images/plugin.png";
 
   // Tab definition 
   protected $tabClass = "deptabs";
@@ -37,21 +38,18 @@ class departmentManagement extends management
     $this->config = $config;
     $this->ui = $ui;
    
-    $this->storagePoints = array("");
     // Build filter
-    #if (session::global_is_set(get_class($this)."_filter")){
+    if (session::global_is_set(get_class($this)."_filter")){
       $filter= session::global_get(get_class($this)."_filter");
-#    } else {
+    } else {
       $filter = new filter(get_template_path("dep-filter.xml", true));
- #     $filter->setObjectStorage($this->storagePoints);
- #   }
-    $this->setFilter($filter);
+    }
 
     // Build headpage
     $headpage = new listing(get_template_path("dep-list.xml", true));
     $headpage->registerElementFilter("depLabel", "departmentManagement::filterDepLabel");
     $headpage->setFilter($filter);
+    $this->setFilter($filter);
 
     // Add copy&paste and snapshot handler.
     if ($this->config->boolValueIsTrue("main", "copyPaste")){
@@ -64,14 +62,86 @@ class departmentManagement extends management
     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");
+  }
+
+  // Inject additional actions here.
+  function detectPostActions()
+  {
+    $actions = management::detectPostActions();
+    if(isset($_GET['PerformRecMove'])) $actions['action'] = "performRecMove";
+    if(isset($_GET['TagDepartment'])) $actions['action'] = "tagDepartment";
+    return($actions);
+  }
+
+  // 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();
+  }
+
+  // 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));
+  }
+
+  // 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();
+    $type = $this->headpage->getType($target[0]);
+    return(management::editEntry($action,$target,$all,$this->tabClass,$types[$type]['TAB'],$this->aclCategory));
   }
 
+
+  // Overriden save handler - We've to take care about the department tagging here.
+  protected function saveChanges()
+  {
+    management::saveChanges();
+  
+    global $config; 
+    $config->get_departments();
+    $config->make_idepartments();
+    $this->config = $config;
+
+    $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)));
+    }
+  }
+
+  // An action handler which enables to switch into deparmtment by clicking the names.
   function openEntry($action,$entry)
   {
     $this->headpage->setBase(array_pop($entry));
   }
 
 
+  // Overridden remove request method - Avoid removal of the ldap base.
+  protected function removeEntryRequested($action="",$target=array(),$all=array())
+  {
+    $target = array_remove_entries(array($this->config->current['BASE']),$target);
+    return(management::removeEntryRequested($action,$target,$all)); 
+  }
+
+
+  // A filter which allows to open a department by clicking on the departments name.
   static function filterDepLabel($row,$dn,$params,$ou,$pid,$base)
   {
     $ou = $ou[0];
@@ -83,7 +153,6 @@ class departmentManagement extends management
   }
 
 
-
   /*! \brief  Returns information about all container types that GOsa con handle.
     @return Array   Informations about departments supported by GOsa.
    */
@@ -161,31 +230,6 @@ class departmentManagement extends management
     $types['organizationalUnit']['IMG_FULL']= "images/lists/folder-full.png";//:wplugins/departments/images/department.png";
     $types['organizationalUnit']['TITLE']   = _("Department");
     $types['organizationalUnit']['TPL']     = "generic.tpl";
-
-#  /* Alias
-#   */
-#  $types['alias']['ACL']     = "alias";
-#  $types['alias']['CLASS']   = "alias";
-#  $types['alias']['TAB']     = "ALIASTABS";
-#  $types['alias']['ATTR']    = "???";
-#  $types['alias']['OC']      = "???";
-#  $types['alias']['IMG']     = "plugins/departments/images/department_alias.png";
-#  $types['alias']['IMG_FULL']= "plugins/departments/images/department_alias.png";
-#  $types['alias']['TITLE']   = _("Alias");
-#  $types['alias']['TPL']     = "alias.tpl";
-#
-#  /* Referal
-#   */
-#  $types['referal']['ACL']     = "referal";
-#  $types['referal']['CLASS']   = "referal";
-#  $types['referal']['TAB']     = "REFERALTABS";
-#  $types['referal']['ATTR']    = "???";
-#  $types['referal']['OC']      = "???";
-#  $types['referal']['IMG']     = "plugins/departments/images/department_referal.png";
-#  $types['referal']['IMG_FULL']= "plugins/departments/images/department_referal.png";
-#  $types['referal']['TITLE']   = _("Referal");
-#  $types['referal']['TPL']     = "referal.tpl";
-
     return($types);
   }
 }