Code

Updated base selectors
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 15:05:58 +0000 (15:05 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 15:05:58 +0000 (15:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15454 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/admin/departments/class_department.inc
gosa-core/plugins/admin/departments/country.tpl
gosa-core/plugins/admin/departments/dcObject.tpl
gosa-core/plugins/admin/departments/domain.tpl
gosa-core/plugins/admin/departments/generic.tpl
gosa-core/plugins/admin/departments/locality.tpl
gosa-core/plugins/admin/departments/organization.tpl
gosa-core/plugins/admin/groups/class_group.inc
gosa-core/plugins/admin/ogroups/class_ogroup.inc
gosa-core/plugins/personal/generic/class_user.inc

index 78e514f1e2af041e3b302cd4d85cb3c5cc4e9713..35baf3a11508e0652302066d204e29e350cd43fa 100644 (file)
 
 class department extends plugin
 {
-       /* department attributes */
-       var $ou= "";
-       var $description= "";
-       var $base= "";
-       var $st= "";
-       var $l= "";
-       var $postalAddress= "";
-       var $businessCategory= "";
-       var $telephoneNumber= "";
-       var $facsimileTelephoneNumber= "";
-       var $is_administrational_unit= false;
-       var $gosaUnitTag= "";
+  /* department attributes */
+  var $ou= "";
+  var $description= "";
+  var $base= "";
+  var $st= "";
+  var $l= "";
+  var $postalAddress= "";
+  var $businessCategory= "";
+  var $telephoneNumber= "";
+  var $facsimileTelephoneNumber= "";
+  var $is_administrational_unit= false;
+  var $gosaUnitTag= "";
   var $view_logged = FALSE;
 
   var $type ="organizationalUnit";
   var $namingAttr = "ou";
 
-       /* Headpage attributes */
-       var $last_dep_sorting= "invalid";
-       var $departments= array();
+  /* Headpage attributes */
+  var $last_dep_sorting= "invalid";
+  var $departments= array();
   var $must_be_tagged = false;
 
-       /* attribute list for save action */
-       var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
+  /* attribute list for save action */
+  var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
                        "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
 
   /* Do not append the structural object classes here, they are added dynamically in the constructor */
-       var $objectclasses= array("top", "gosaDepartment");
+  var $objectclasses= array("top", "gosaDepartment");
   var $structuralOC = array("organizationalUnit");
 
   var $initially_was_tagged = false;
   var $orig_base = "";
   var $orig_ou = "";
+  var $baseSelector;
 
-       function department (&$config, $dn)
-       {
+  function department (&$config, $dn)
+  {
     /* Add the default structural obejct class 'locality' if this is a new entry
      */
     $ldap = $config->get_ldap_link();
@@ -80,11 +81,11 @@ class department extends plugin
     }
     $this->objectclasses = array_unique($this->objectclasses);
 
-               plugin::plugin($config, $dn);
-               $this->is_account= TRUE;
-               $this->ui= get_userinfo();
-               $this->dn= $dn;
-               $this->orig_dn= $dn;
+    plugin::plugin($config, $dn);
+    $this->is_account= TRUE;
+    $this->ui= get_userinfo();
+    $this->dn= $dn;
+    $this->orig_dn= $dn;
 
     /* Save current naming attribuet 
      */
@@ -92,28 +93,34 @@ class department extends plugin
     $orig_nA = "orig_".$nA;
     $this->$orig_nA = $this->$nA;
 
-               $this->config= $config;
+    $this->config= $config;
 
-               /* Set base */
-               if ($this->dn == "new"){
-                       $ui= get_userinfo();
-                       if(session::is_set('CurrentMainBase')){
-                               $this->base = session::get('CurrentMainBase');
-                       }else{
-                               $this->base= dn2base($ui->dn);
-                       }
-               } else {
-                       $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
-               }
+    /* Set base */
+    if ($this->dn == "new"){
+           $ui= get_userinfo();
+           if(session::is_set('CurrentMainBase')){
+                   $this->base = session::get('CurrentMainBase');
+           }else{
+                   $this->base= dn2base($ui->dn);
+           }
+    } else {
+           $this->base= preg_replace ("/^[^,]+,/", "", $this->dn);
+    }
 
     $this->orig_base = $this->base;
 
-               /* Is administrational Unit? */
-               if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
-                       $this->is_administrational_unit= true;
-      $this->initially_was_tagged = true;
-               }
-       }
+    /* Is administrational Unit? */
+    if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){
+           $this->is_administrational_unit= true;
+           $this->initially_was_tagged = true;
+    }
+
+    /* Instanciate base selector */
+    $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
+    $this->baseSelector->setSubmitButton(false);
+    $this->baseSelector->setHeight(300);
+    $this->baseSelector->update(true);
+  }
 
        function execute()
        {
@@ -130,6 +137,7 @@ class department extends plugin
                $this->config->get_departments($this->dn);
                $this->config->make_idepartments();
                $smarty= get_smarty();
+                $smarty->assign("usePrototype", "true");
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
@@ -145,56 +153,25 @@ class department extends plugin
       $smarty->assign($nA,$this->getacl($this->namingAttr,TRUE));
     }
 
-               /* Base select dialog */
-               $once = true;
-               foreach($_POST as $name => $value){
-                       if((preg_match("/^chooseBase/",$name) && $once) && ($this->acl_is_moveable())){
-                               $once = false;
-                               $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
-                               $this->dialog->setCurrentBase($this->base);
-                       }
-               }
-
-               /* Dialog handling */
-               if(is_object($this->dialog)){
-                       /* Must be called before save_object */
-                       $this->dialog->save_object();
-
-                       if($this->dialog->isClosed()){
-                               $this->dialog = false;
-                       }elseif($this->dialog->isSelected()){
-
-        /* A new base was selected, check if it is a valid one */
-        $tmp = $this->get_allowed_bases();
-        if(isset($tmp[$this->dialog->isSelected()])){
-          $this->base = $this->dialog->isSelected();
-        }
-  
-                               $this->dialog= false;
-                       }else{
-                               return($this->dialog->execute());
-                       }
-               }
-
-               /* Hide all departments, that are subtrees of this department */
+    /* Hide all departments, that are subtrees of this department */
     $bases = $this->get_allowed_bases();
-               if(($this->dn == "new")||($this->dn == "")){
-                       $tmp = $bases;
-               }else{
-                       $tmp    = array();      
-                       foreach($bases as $dn=>$base){
-                               /* Only attach departments which are not a subtree of this one */
-        if(!preg_match("/".preg_quote($this->dn)."/",$dn)){
-                                       $tmp[$dn]=$base;
-                               }
-                       }
-               }
-               $smarty->assign("bases", $tmp);
+    if(($this->dn == "new")||($this->dn == "")){
+           $tmp = $bases;
+    }else{
+           $tmp        = array();      
+           foreach($bases as $dn=>$base){
+                   /* Only attach departments which are not a subtree of this one */
+                   if(!preg_match("/".preg_quote($this->dn)."/",$dn)){
+                           $tmp[$dn]=$base;
+                   }
+           }
+    }
+    $this->baseSelector->setBases($tmp);
 
-               foreach ($this->attributes as $val){
-                       $smarty->assign("$val", $this->$val);
-               }
-               $smarty->assign("base_select", $this->base);
+    foreach ($this->attributes as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+    $smarty->assign("base", $this->baseSelector->render());
 
     /* Set admin unit flag */
     if ($this->is_administrational_unit) {
@@ -252,11 +229,22 @@ class department extends plugin
 
        /* Save data to object */
        function save_object()
-       {
-    if (isset($_POST['dep_generic_posted'])){
+       {       
+               /* Refresh base */
+               if ($this->acl_is_moveable($this->base)){
+                       if (!$this->baseSelector->update()) {
+                               msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
+                       }
+                       if ($this->base != $this->baseSelector->getBase()) {
+                               $this->base= $this->baseSelector->getBase();
+                               $this->is_modified= TRUE;
+                       }
+               }
 
-      $nA = $this->namingAttr;
-      $old_nA = $this->$nA;
+               if (isset($_POST['dep_generic_posted'])){
+
+                       $nA = $this->namingAttr;
+                       $old_nA = $this->$nA;
 
 
 
@@ -267,14 +255,6 @@ class department extends plugin
       plugin::save_object();
       $this->base = $base_tmp;
 
-      /* Set new base if allowed */
-      $tmp = $this->get_allowed_bases();
-      if(isset($_POST['base'])){
-        if(isset($tmp[$_POST['base']])){
-          $this->base= $_POST['base'];
-        }
-      }
-
       /* Save tagging flag */
       if ($this->acl_is_writeable("gosaUnitTag")){
         if (isset($_POST['is_administrational_unit'])){
index 21081bc7d84db12bac029ac268cd053939b0c25b..eff9c73a104655d5a662d79bca8f25a59b7365e9 100644 (file)
         <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
          </td>
         </tr>
index 2a3c285407c343b9addd072f947b54b21df19e1b..51a6ec45953418285bc7cdc8619a488652d871ac 100644 (file)
         <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
          </td>
         </tr>
index 17d4b90ddca893f5c8bc253bad26feb451444cfd..c30170e6ac9a75db27d8cf906fd31b71ebca3915 100644 (file)
         <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
          </td>
         </tr>
index 14b997cf05dd7ea684500eefd0fa655ef6faa9d6..022098f827e7cf2c7694a9bfcd54e8c4f7c5bb7d 100644 (file)
 
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
        </td>
        </tr>
index 26d802d567499fbfed7da20711df2a69f0abea0c..e009c37f8913f6dc1b867b6a832343a55e50f31f 100644 (file)
         <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
          </td>
         </tr>
index 67ceee88dcb02695da78fe308bbd0355c2af3a27..e7c825ce4c84928c760c663396db83d2f9c74d6b 100644 (file)
 
         <td>
 {render acl=$baseACL}
-         <select id="base" size="1" name="base" title="{t}Choose subtree to place department in{/t}"> 
-          {html_options options=$bases selected=$base_select}
-         </select>
-{/render}
-
-{render acl=$baseACL disable_picture='images/lists/folder_grey.png'}
-        <input type="image" name="chooseBase" src="images/lists/folder.png" class="center" title="{t}Select a base{/t}">
+          {$base}
 {/render}
        </td>
        </tr>
index a2519c1c3052eac498501657497decf8ad79955b..456eb4c25761d517864518b9ba2d4e90a09bf89a 100644 (file)
@@ -291,17 +291,6 @@ class group extends plugin
       $this->dialog= FALSE;
     }
 
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if((preg_match("/^chooseBase/",$name) && $once) && $this->acl_is_writeable("base")){
-          
-        $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
-        $this->dialog->setCurrentBase($this->base);
-      }
-    }
-
     /* Dialog handling */
     if(is_object($this->dialog)){
       /* Must be called before save_object */
index d6ff10d0af586821f125dc3fc8b2b1d9a0cfaa47..5c51363c5701aa5c4d97fe80e5319ea3b654dd83 100644 (file)
@@ -286,16 +286,6 @@ class ogroup extends plugin
       $smarty->assign($name."ACL",$this->getacl($name));
     }
 
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
-        $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
-        $this->dialog->setCurrentBase($this->base);
-      }
-    }
-
     /***********
      * Trusts 
      ***********/
@@ -513,7 +503,12 @@ class ogroup extends plugin
         Ende Trust account
        ******/
 
+      /* Create a base backup and reset the
+         base directly after calling plugin::save_object();
+         Base will be set seperatly a few lines below */
+      $base_tmp = $this->base;
       plugin::save_object();
+      $this->base = $base_tmp;
     }
   }
 
index 7c3d548460670122cbe5d85c1fac5b4f3ca380f6..aec8e0340cdc7b589af5e77ec36fcb0286edee2e 100644 (file)
@@ -308,16 +308,6 @@ class user extends plugin
       return($str);
     }
 
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){
-        $once = false;
-        $this->dialog = new baseSelectDialog($this->config,$this,$this->allowedBasesToMoveTo());
-        $this->dialog->setCurrentBase($this->base);
-      }
-    }
-
     /* Password configure dialog handling */
     if(is_object($this->pwObject) && $this->pwObject->display){
       $output= $this->pwObject->configure();