Code

Updated object movement.
[gosa.git] / plugins / admin / departments / class_departmentManagement.inc
index 018e2e38aa35fb21e9a0eedddaaac9af899b581f..2bdcf1b879adea05cf4e60150f35271476b5b97e 100644 (file)
@@ -107,8 +107,8 @@ class departmentManagement extends plugin
      */
     if ($s_action=="new"){
       $this->dn= "new";
-      $this->deptabs= new deptabs($this->config,
-          $this->config->data['TABS']['DEPTABS'], $this->dn);
+      $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department");
+      $this->deptabs->set_acl_base($this->DivListDepartment->selectedBase);
     }
 
 
@@ -129,12 +129,10 @@ class departmentManagement extends plugin
       /* Lock the current entry, so everyone will get the  above dialog */
       add_lock ($this->dn, $this->ui->dn);
 
-      /* Set up the users ACL's for this 'dn' */
-      $this->acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-
       /* Register deptabs to trigger edit dialog */
-      $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn);
-      $this->deptabs->set_acl($this->acl);
+      $this->deptabs= new deptabs($this->config,$this->config->data['TABS']['DEPTABS'], $this->dn,"department");
+      $this->deptabs->set_acl_base($this->dn);
+
       $_SESSION['objectinfo']= $this->dn;
     }
 
@@ -149,15 +147,22 @@ class departmentManagement extends plugin
     if ($s_action =="del"){
       $this->dn= $this->config->departments[trim($s_entry)];
 
-      /* Check locking */
-      if (($user= get_lock($this->dn)) != ""){
-        $_SESSION['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)));
-        $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
-        return ($display);
+      /* 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['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)));
+          $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
+          return ($display);
+        }
+      }else{
+        print_red (_("You have no permission to remove this department."));
       }
     }
 
@@ -170,9 +175,10 @@ class departmentManagement extends plugin
      * Finally delete department 
      */
     if (isset($_POST['delete_department_confirm'])){
-      $acl= get_permissions ($this->dn, $this->ui->subtreeACL);
-      $acl= get_module_permission($acl, "department", $this->dn);
-      if (chkacl($acl, "delete") == ""){
+
+      /* check acls */
+      $acl = $this->ui->get_permissions($this->dn,"department/department");
+      if(preg_match("/d/",$acl)){
         $this->remove_from_parent();
         gosa_log ("Department object'".$this->dn."' has been removed");
       } else {
@@ -185,7 +191,18 @@ class departmentManagement extends plugin
       Edit department finished 
      ***************/
 
-    if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config))){
+    if ((isset($_POST['edit_finish'])) && (isset($this->deptabs->config)) && !isset($_POST['dep_move_confirm'])){
+      $this->deptabs->save_object();
+      $obj = $this->deptabs->by_object['department'];
+      if($obj->orig_dn != "new"){
+        if($obj->orig_ou != $obj->ou || $obj->base != $obj->orig_base){
+          return($smarty->fetch(get_template_path("dep_move_confirm.tpl",TRUE)));
+        }
+      }
+    }
+
+    /* Save changes */
+    if ((isset($_POST['edit_finish'])|| isset($_POST['dep_move_confirm'])) && (isset($this->deptabs->config))){
 
       /* Check tabs, will feed message array */
       $message= $this->deptabs->check();
@@ -194,7 +211,7 @@ class departmentManagement extends plugin
       if (count($message) == 0){
 
         $this->deptabs->save(true);
-        $this->deptabs->by_object['department']->save();     
+        $this->config->get_departments();
 
         /* This object must be tagged, so set ObjectTaggingRequested to true */
         if($this->deptabs->by_object['department']->must_be_tagged()){
@@ -206,11 +223,6 @@ class departmentManagement extends plugin
           $this->RecursiveRemoveRequested = true;
         }              
       
-        $this->config->get_departments($this->dn);
-        $this->config->make_idepartments();
-        $this->DivListDepartment->config=$this->config;
-
         /* This var indicated that there is an object which isn't saved right now. */
         $this->ObjectInSaveMode = true;
 
@@ -240,6 +252,7 @@ class departmentManagement extends plugin
     /* initiate recursive remove  (Is called from iframe, generates output)*/
     if(isset($_GET['PerformRecMove'])){
       $this->deptabs->by_object['department']->recursive_move("","",true);
+      $this->DivListDepartment->selectedBase = $this->deptabs->by_object['department']->dn;  
       exit();
     }
 
@@ -268,6 +281,7 @@ class departmentManagement extends plugin
        remove locks & save object tab & unset current object */
     if($this->ObjectInSaveMode && (!$this->RecursiveRemoveRequested) && (!$this->ObjectTaggingRequested)){
       $this->deptabs->save();
+      $this->config->get_departments();
       $this->ObjectInSaveMode = false;
       if ($this->dn != "new"){
         del_lock ($this->dn);
@@ -342,10 +356,10 @@ class departmentManagement extends plugin
 
     if($this->DivListDepartment->SubSearch){
       $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
-          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+          "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
     }else{
       $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
-          $this->ui->subtreeACL, $base, array("ou", "description"), GL_SIZELIMIT );
+          "department", $base, array("ou", "description"), GL_SIZELIMIT );
     }
 
     $this->departments= array();
@@ -406,9 +420,9 @@ class departmentManagement extends plugin
   {
     /* reload department */
     $this->config->get_departments();
-    $config = $this->config;
 
     $this->config->make_idepartments();
+    $this->DivListDepartment->config= $this->config;
     $this->DivListDepartment->save_object();
   }