Code

Allow to create country objects.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 Jun 2008 13:47:40 +0000 (13:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 12 Jun 2008 13:47:40 +0000 (13:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11305 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/departments/class_countryGeneric.inc
gosa-core/plugins/admin/departments/class_departmentGeneric.inc
gosa-core/plugins/admin/departments/class_departmentManagement.inc
gosa-core/plugins/admin/departments/class_divListDepartment.inc
gosa-core/plugins/admin/departments/tabs_department.inc

index 6477cd146ae90454f6db50b0c6ecb49e69afe109..d44f72e682f4434a05a06b66fc301937c27f4255 100644 (file)
@@ -25,9 +25,18 @@ class country extends department
        /* attribute list for save action */
        var $attributes     = array( "c", "description");
        var $objectclasses  = array("top", "country");
-  var $type ="c";
+  var $type   ="c";
+  var $c      ="";
+  var $orgi_c ="";
+
+  var $namingAttr = "c";
+
+  function check()
+  {
+    $message = plugin::check();
+    return($message);
+  }
 
-  var $c ="";
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 62b3947afa36c125cbdbf6a937bd210935c13340..3962c47942570b43d7a8585d1f728fa42ac1464d 100644 (file)
@@ -37,6 +37,7 @@ class department extends plugin
   var $view_logged = FALSE;
 
   var $type ="ou";
+  var $namingAttr = "ou";
 
        /* Headpage attributes */
        var $last_dep_sorting= "invalid";
@@ -60,7 +61,13 @@ class department extends plugin
                $this->ui= get_userinfo();
                $this->dn= $dn;
                $this->orig_dn= $dn;
-               $this->orig_ou= $this->ou;
+
+    /* Save current naming attribuet 
+     */
+    $nA      = $this->namingAttr;
+    $orig_nA = "orig_".$nA;
+    $this->$orig_nA = $this->$nA;
+
                $this->config= $config;
 
                /* Set base */
index baf9ae2e4d35b166650dff300021cb8f94b95b82..03cf292c68afe1185318e8e0f87d14b3299bf256 100644 (file)
@@ -305,7 +305,6 @@ class departmentManagement extends plugin
           So don't move it below the moved check !.
        */
       $message= $this->deptabs->check();
-      $obj = $this->deptabs->by_object['department'];
 
       /*************
         MOVED ? 
@@ -333,7 +332,7 @@ class departmentManagement extends plugin
         $this->ObjectInSaveMode = true;
 
         /* This object must be tagged, so set ObjectTaggingRequested to true */
-        if($this->deptabs->by_object['department']->must_be_tagged()){
+        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."));
@@ -427,6 +426,8 @@ class departmentManagement extends plugin
       $result[$tmp[$base_back]]=$tmp2;
     }
 
+    
+
     if($this->DivListDepartment->SubSearch){
       $res= get_list("(&(|(ou=$Regex)(description=$Regex))(objectClass=gosaDepartment))",
           "department", $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
@@ -435,7 +436,16 @@ class departmentManagement extends plugin
           "department", $base, array("ou", "description"), GL_SIZELIMIT );
     }
 
+    
+    /**/
+    $non_ou = get_list("(&(|(c=$Regex)(description=$Regex))(objectClass=country))",
+          "department", $base, array("c", "description"), GL_SIZELIMIT );
+  
     $this->departments= array();
+    foreach($non_ou as $obj){
+      $this->departments[] = $obj['dn'];
+    }
+
 
     /* Add current base to the list of available departments, but only if its naming attribute is 'ou' */
     if(preg_match("/^ou=/",$base)){
index 55ef8d2fac7cd8e8f0899241808d8933c7c4cb95..6fa3f8d0779effceb6245756b67e89aa9812652f 100644 (file)
@@ -195,48 +195,59 @@ class divListDepartment extends MultiSelectWindow
 
       $actions= "";      
 
-      $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department");
-      $acl_all = $ui->has_complete_category_acls($this->config->departments[$key] ,"department");
+      if(!isset($this->config->departments[$key])){
 
-      $actions.= "<input class='center' type='image' src='images/lists/edit.png'
-        alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
+        $field01 = array("string" => "&nbsp;", "attach" => "style='width:20px;'");
+        $field0 = array("string" => "<img src='images/".$non_empty."lists/folder.png' 
+            title='"._("department")."' alt='department'>", 
+            "attach" => "style='text-align:center;width:20px;'");
+        $field1 = array("string" => $val, "attach" => "style='' title='".$val."'");
+        $field2 = array("string" => "", "attach" => "style='border-right: 0px;'");
 
-      if(preg_match("/d/",$acl)){
-        $actions.= "<input class='center' type='image' src='images/lists/trash.png'
-          alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
-      }
+      }else{
+        $acl = $ui->get_permissions($this->config->departments[$key] ,"department/department");
+        $acl_all = $ui->has_complete_category_acls($this->config->departments[$key] ,"department");
 
-      if(!isset($this->config->departments[trim($key)])){
-        $this->config->departments[trim($key)]="";
-      }
+        $actions.= "<input class='center' type='image' src='images/lists/edit.png'
+          alt='"._("edit")."'   name='dep_edit_%KEY%' title='"._("Edit this entry")."'>";
 
-      /* check if this department contains sub-departments
-         Display different image in this case
-       */
-      $non_empty="";
-      $nkey= normalizePreg($key);
-      foreach($this->config->departments as $keyd=>$vald ){
-        if(preg_match('/$nkey\/.*/',$keyd)){
-          $non_empty="full";
+        if(preg_match("/d/",$acl)){
+          $actions.= "<input class='center' type='image' src='images/lists/trash.png'
+            alt='"._("delete")."'   name='dep_del_%KEY%' title='"._("Delete this entry")."'>";
         }
-      }
 
-      $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($this->config->departments[$key]));
+        if(!isset($this->config->departments[trim($key)])){
+          $this->config->departments[trim($key)]="";
+        }
 
-      if($val == "."){
-        $field01 = array("string" => "&nbsp;",
-            "attach" => "style='width:20px;'");
-      }else{
-        $field01 = array("string" => "<input type='checkbox' id='item_selected_".base64_encode($key)."' 
-            name='item_selected_".base64_encode($key)."'>" ,
-            "attach" => "style='width:20px;'");
-      }
+        /* check if this department contains sub-departments
+           Display different image in this case
+         */
+        $non_empty="";
+        $nkey= normalizePreg($key);
+        foreach($this->config->departments as $keyd=>$vald ){
+          if(preg_match('/$nkey\/.*/',$keyd)){
+            $non_empty="full";
+          }
+        }
+
+        $title = preg_replace('/ /', '&nbsp;', @LDAP::fix($this->config->departments[$key]));
 
-      $field0 = array("string" => "<img src='images/".$non_empty."lists/folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
-      $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;'");
+        if($val == "."){
+          $field01 = array("string" => "&nbsp;",
+              "attach" => "style='width:20px;'");
+        }else{
+          $field01 = array("string" => "<input type='checkbox' id='item_selected_".base64_encode($key)."' 
+              name='item_selected_".base64_encode($key)."'>" ,
+              "attach" => "style='width:20px;'");
+        }
+
+        $field0 = array("string" => "<img src='images/".$non_empty."lists/folder.png' title='"._("department")."' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
+        $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($field01,$field0,$field1,$field2));
     }
 
index 65fc151ef45dc2327fcfbb1d29213ecbd7030522..e8a7842487da9107811ff9967961f148265c2145 100644 (file)
@@ -24,11 +24,23 @@ class deptabs extends tabs
 {
   var $base= "";
   var $moved = FALSE;
+  var $base_name = "department";
 
   function deptabs($config, $data, $dn,$category)
   {
     tabs::tabs($config, $data, $dn,$category);
 
+    /* Detect the base class  (The classs which extends from department)
+     */
+    $class = "department";
+    foreach($this->by_object as $name => $object){
+      if($object instanceOf department){
+        $this->base_name = get_class($object);
+        break;
+      }
+    }
+
+
     /* Add references/acls/snapshots */
     $this->addSpecialTabs();
     $this->by_object['acl']->skipTagging= TRUE;;
@@ -47,11 +59,19 @@ class deptabs extends tabs
   {
     return(FALSE);
     if($this->moved) return(FALSE);
-    $baseobject= &$this->by_object['department'];
-    $ou       = preg_replace('/,/', '\,', $baseobject->ou);  
-    $new_dn   = @LDAP::convert('ou='.$ou.','.$baseobject->base);
-    $old_ou   = preg_replace('/,/', '\,', $baseobject->orig_ou);
-    $old_dn   = @LDAP::convert('ou='.$ou.','.$baseobject->orig_base);
+    $baseobject= &$this->by_object[$this->base_name];
+
+    $namingAttr       = $baseobject->namingAttr;
+    $orig_namingAttr  = $baseobject->orig_namingAttr;
+
+    $value       = preg_replace('/,/', '\,', $baseobject->$namingAttr);  
+    $orig_value  = preg_replace('/,/', '\,', $baseobject->$orig_namingAttr);  
+
+    $new_dn   = @LDAP::convert($namingAttr.'='.$value.','.$baseobject->base);
+    $old_dn   = @LDAP::convert($namingAttr.'='.$orig_value.','.$baseobject->orig_base);
+
+    print_a(array($new_dn,$old_dn));
+
     if ($this->dn != $new_dn && $this->dn != "new"){
       return(TRUE); 
     }
@@ -73,7 +93,7 @@ class deptabs extends tabs
   function move_me()
   {
     if(!$this->am_i_moved()) return;
-    $baseobject= &$this->by_object['department'];
+    $baseobject= &$this->by_object[$this->base_name];
     $ou       = preg_replace('/,/', '\,', $baseobject->ou);  
     $new_dn   = @LDAP::convert('ou='.$ou.','.$baseobject->base);
     $old_ou   = preg_replace('/,/', '\,', $baseobject->orig_ou);
@@ -87,9 +107,12 @@ class deptabs extends tabs
 
   function save($ignore_account= FALSE)
   {
-    $baseobject= &$this->by_object['department'];
-    $ou       = preg_replace('/,/', '\,', $baseobject->ou);  
-    $new_dn   = @LDAP::convert('ou='.$ou.','.$baseobject->base);
+    $baseobject= &$this->by_object[$this->base_name];
+
+    $namingAttr       = $baseobject->namingAttr;
+
+    $nAV      = preg_replace('/,/', '\,', $baseobject->$namingAttr); 
+    $new_dn   = @LDAP::convert($namingAttr.'='.$nAV.','.$baseobject->base);
 
     /* Move group? */
     if ($this->dn != $new_dn && $this->dn != "new"){