Code

Reverted to 2.5
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Jun 2006 09:25:25 +0000 (09:25 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Jun 2006 09:25:25 +0000 (09:25 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3935 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/departments/class_departmentGeneric.inc
plugins/admin/departments/class_departmentManagement.inc
plugins/admin/departments/class_divListDepartment.inc
plugins/admin/departments/tabs_department.inc

index 6dd6ff7de85406c7652c6bf4220f60ed8f4c0291..5205da94447f99145248934c108fc8bb617b3a91 100644 (file)
@@ -175,13 +175,6 @@ class department extends plugin
 
        function must_be_tagged()
        {
-    if((isset($this->attrs['gosaUnitTag'][0])) && ($this->is_administrational_unit)){
-      $this->must_be_tagged = false;
-    }elseif((!isset($this->attrs['gosaUnitTag'][0])) && (!$this->is_administrational_unit)){
-      $this->must_be_tagged = false;
-    }else{
-      $this->must_be_tagged = true;
-    }
                return $this->must_be_tagged;
        }
 
@@ -228,8 +221,8 @@ class department extends plugin
 
                /* Check for presence of this department */
                $ldap= $this->config->get_ldap_link();
-               $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
-               if ($this->orig_dn == "new" && $ldap->count()){
+    $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
+    if ($this->orig_dn == "new" && $ldap->count()){
                        $message[]= _("Department with that 'Name' already exists.");
                } elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
                        $message[]= _("Department with that 'Name' already exists.");
@@ -270,8 +263,9 @@ class department extends plugin
                if ($this->is_administrational_unit){
       if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
                        $this->objectclasses[]= "gosaAdministrativeUnit";
-        $this->gosaUnitTag= "";
+                         $this->gosaUnitTag= "";
       }
+
                        if ($this->gosaUnitTag == ""){
 
                                /* It's unlikely, but check if already used... */
@@ -308,9 +302,9 @@ class department extends plugin
                                if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
                                        $tmp[]= $oc;
                                }
-        if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
-          $has_unit_tag= true;
-        }
+                               if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
+                                       $has_unit_tag= true;
+                               }
                        }
                        $this->attrs['objectClass']= $tmp;
 
@@ -336,11 +330,15 @@ class department extends plugin
                }
                show_ldap_error($ldap->get_error(), _("Saving department failed"));
 
+    /* The parameter forces only to set must_be_tagged, and don't touch any objects 
+        This will be done later */
+    $this->tag_objects(true);
+
     /* Fix tagging if needed */
     if (!$this->is_administrational_unit){
       $this->handle_object_tagging();
     }
-
+    
     /* Optionally execute a command after we're done */
                $this->postcreate();
     return(true);
@@ -385,6 +383,7 @@ class department extends plugin
                } else {
                        $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
                }
+
                while ($attrs= $ldap->fetch()){
 
                        /* Skip self */
index c21927f09a08fd225ba3f744085f98f91240fea4..9bb51d3755ed233395f9e600d411000697e92cd9 100644 (file)
@@ -120,7 +120,6 @@ class departmentManagement extends plugin
      * The entry which will be edited is defined in $s_entry
      */
     if (( $s_action=="edit") && (!isset($this->deptabs->config))){
-      $s_entry = convert_department_dn(base64_decode($s_entry));
       $this->dn= $this->config->departments[trim($s_entry)];
 
       if (($user= get_lock($this->dn)) != ""){
@@ -148,7 +147,6 @@ class departmentManagement extends plugin
      * The entry which will be deleted is defined in $s_entry
      */
     if ($s_action =="del"){
-      $s_entry = convert_department_dn(base64_decode($s_entry));
       $this->dn= $this->config->departments[trim($s_entry)];
 
       /* Check locking */
@@ -196,10 +194,7 @@ class departmentManagement extends plugin
       if (count($message) == 0){
 
         $this->deptabs->save(true);
-
-        if(!$this->deptabs->by_object['department']->am_i_moved()){
-          $this->deptabs->save(true);
-        }
+        $this->deptabs->by_object['department']->save();     
 
         /* This object must be tagged, so set ObjectTaggingRequested to true */
         if($this->deptabs->by_object['department']->must_be_tagged()){
@@ -300,20 +295,13 @@ class departmentManagement extends plugin
       $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\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+        $display.= "<input type=submit name=\"edit_finish\" value=\""._("Save")."\">\n";
         $display.= "&nbsp;\n";
         $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
         $display.= "</p>";
       }
       return ($display);
     }else{
-
-      /* Check if there is a snapshot dialog open */
-      $base = $this->DivListDepartment->selectedBase;
-      if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
-        return($str);
-      }
-
       /* Display dialog with group list */
       $this->DivListDepartment->parent = $this;
       $this->DivListDepartment->execute();
@@ -325,14 +313,6 @@ class departmentManagement extends plugin
   }
 
 
-  /* Return departments, that will be included within snapshot detection */
-  function get_used_snapshot_bases()
-  {
-    return(array($this->DivListDepartment->selectedBase));
-  }
-
-
-
   function reload()
   {
     /* Vairaible init */
@@ -364,21 +344,24 @@ class departmentManagement extends plugin
     }
 
     $this->departments= array();
-    $tmp = array();
     foreach ($res as $key => $value){
-      #$tmp[get_sub_department(convert_department_dn($value['dn']))] = $key;
-      $tmp[$key] = get_sub_department(convert_department_dn($value['dn']));
-    }
-    natcasesort($tmp);
-    foreach($tmp as $key => $q){
-      $value = $res [$key];
+
       /* Don't display base as entry on subsearch */
       if(($value['dn'] == $base) && ($this->DivListDepartment->SubSearch)){
         continue;
       }
 
-      $this->departments[base64_encode($value['dn'])]= $value;
+      $cdn= convert_department_dn($value['dn']);
+
+      /* Append to dep list */
+      if(isset($value["description"][0])){
+        $this->departments[$cdn]= get_sub_department($cdn)." - [".$value["description"][0]."]";
+      }else{
+        $this->departments[$cdn]= get_sub_department($cdn);//$value["description"][0];
+      }
     }
+    natcasesort ($this->departments);
+    reset ($this->departments);
   }
 
   function remove_from_parent()
index 9d4af1e2d750b9c7b8ee814cfb0e9f77bdb98535..4eaea028be39dbd20e7ed3a3b0e4a0ef341d1ba0 100755 (executable)
@@ -36,16 +36,11 @@ class divListDepartment extends MultiSelectWindow
     $this->EnableCloseButton(false);
     $this->EnableSaveButton (false);
 
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 20;
-    }
-
     /* set Page header */
     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
     $this->AddHeader(array("string"=>_("Department name"), "attach" => "style=''"));
-    $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
+    $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'"));
+
 
     /* Add SubSearch checkbox */    
     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
@@ -70,24 +65,17 @@ class divListDepartment extends MultiSelectWindow
     }
 
     /* Generate list head */
-    $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
-      " <input type='image' class='center' src='images/list_root.png' align='middle' 
-        title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
-      " <input type='image' class='center' src='images/list_up.png' align='middle' 
-        title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
-      " <input type='image' class='center' src='images/list_home.png' align='middle' 
-        title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
-      " <input class='center' type='image' src='images/list_reload.png' align='middle' 
-        title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
-    $listhead .= $this->get_snapshot_header($this->selectedBase);
-    $listhead .=  " <input class='center' type='image' src='images/list_new_department.png' 
-        align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ".
-      " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
-      _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/list_submit.png' align='middle' 
-        title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
-      "</div>";
+      $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+        " <input type='image' class='center' src='images/list_root.png' align='middle' title='"._("Go to root department")."' name='dep_root' alt='".       _("Root")."'>&nbsp;".
+        " <input type='image' class='center' src='images/list_up.png' align='middle' title='"._("Go up one department")."' name='dep_back' alt='"._("Up").  "'>&nbsp;".
+        " <input type='image' class='center' src='images/list_home.png' align='middle' title='"._("Go to users home department")."' name='dep_home' alt='". _("Home")."'>&nbsp;".
+        " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".      _("Submit")."'>&nbsp;".
+        " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+        " <input class='center' type='image' src='images/list_new_department.png' align='middle' alt='"._("Create new department")."' name='dep_new'>&nbsp; ".
+        " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
+        _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+        " <input class='center' type='image' src='images/list_submit.png' align='middle' title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
+        "</div>";
 
     $this->SetListHeader($listhead);
   }
@@ -100,30 +88,14 @@ class divListDepartment extends MultiSelectWindow
 
   function setEntries($list)
   {
+    $actions= "<input class='center' type='image' src='images/edit.png'
+      alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+    $actions.= "<input class='center' type='image' src='images/edittrash.png'
+      alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
 
     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
 
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 20;
-    }
-
     foreach($list as $key => $val) {
-  
-      $cdn= convert_department_dn($val['dn']);  
-      if(isset($val["description"][0])) {
-        $disp = get_sub_department($cdn)." - [".$val["description"][0]."]";
-      }else{
-        $disp = get_sub_department($cdn);
-      }
-  
-      $actions= "<input class='center' type='image' src='images/edit.png'
-        alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
-      $actions.= $this->GetSnapShotActions($val['dn']);
-      $actions.= "<input class='center' type='image' src='images/edittrash.png'
-        alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
-
       if(!isset($this->config->departments[trim($key)])){
         $this->config->departments[trim($key)]="";
       }
@@ -138,8 +110,8 @@ class divListDepartment extends MultiSelectWindow
 
       $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($this->config->departments[$key]));
       $field0 = array("string" => "<img src='images/".$non_empty."folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
-      $field1 = array("string" => sprintf($linkopen,base64_encode($cdn),$disp), "attach" => "style='' title='".$title."'");
-      $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:
+      $field1 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style='' title='".$title."'");
+      $field2 = array("string" => preg_replace("/%KEY%/", base64_encode($key), $actions), "attach" => "style='width:60px;border-right:0px;text-align:
           right;'");
 
       $this->AddElement( array($field0,$field1,$field2));
index e1b7b98d0684c1eac510e48a6fac2e5d665f954f..285b93a7940589aeb9cc7a6396727a5680f221e9 100644 (file)
@@ -21,6 +21,7 @@ class deptabs extends tabs
     $baseobject= $this->by_object['department'];
     $ou= preg_replace('/,/', '\,', $baseobject->ou);
     $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base);
+    
     if($justsave){
       if ($this->dn != $new_dn && $this->dn != "new"){
         /* if( new_dn is subtree of this->dn ) */
@@ -30,15 +31,16 @@ class deptabs extends tabs
           print_red(_("Try to move tree failed. Destination tree is subtree of source tree."));
         }else{
           /* Prepare to be moved */
-          $baseobject->recursive_move($this->dn, $new_dn);             
+          $baseobject->recursive_move($this->dn, $new_dn);                     
           $this->by_object['department'] = $baseobject;
           return;
         }
       }
-    }else{
-      $this->dn= $new_dn;
-      return(tabs::save(TRUE));
     }
+    $this->dn= $new_dn;
+    $baseobject->dn= $this->dn;
+    $this->by_object['department']= $baseobject;
+    return(tabs::save(TRUE));
   }
 
 }