Code

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

gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc
gosa-plugins/goto/admin/systems/goto/printer.tpl
gosa-plugins/goto/admin/systems/goto/workstation.tpl

index f584a00693c71a60307469f0975c243d69565922..9bc8b69f146fbdc9e226352502e57dc55ca9207b 100644 (file)
@@ -41,6 +41,7 @@ class printgeneric extends plugin
   var $gotoGroupAdminPrinter ;
   var $gotoGroupPrinter;
   var $gotoUserPrinter ;
+  var $baseSelector;
 
   /* attribute list for save action */
   var $attributes     = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress", 
@@ -176,6 +177,12 @@ class printgeneric extends plugin
     }
     $this->orig_cn    = $this->cn;
     $this->orig_base  = $this->base;
+
+    /* 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 set_acl_base($base)
@@ -314,6 +321,7 @@ class printgeneric extends plugin
     }
 
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
 
     /* Assign acls */
     $tmp = $this->plInfo();
@@ -375,51 +383,13 @@ class printgeneric extends plugin
       }
     }
 
-    /* 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);
-        $this->baseSelection = true;
-      }
-    }
-
-    /* Dialog handling for base select dialog
-     * Check if base was selected, dialog aborted etc */
-    if(is_object($this->dialog)){
-
-      $this->dialog->save_object();
-      if($this->baseSelection){
-        if($this->dialog->isClosed()){
-          $this->dialog = false;
-          $this->baseSelection = 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;
-          $this->baseSelection = false;
-        }else{
-          return($this->dialog->execute());
-        }
-      }
-    }
-
-    /* Fill templating stuff */
-    $smarty->assign("bases", $this->get_allowed_bases());
-    $smarty->assign("base_select", $this->base);
-
     /* Assign attributes */
     foreach ($this->attributes as $attr){
       $smarty->assign("$attr", $this->$attr);
     }
 
+    $smarty->assign("base", $this->baseSelector->render());
+
     // Act on add user/grouo requests 
     if(isset($_POST['AddUser'])){
       $this->userSelect = new userGroupSelect($this->config, get_userinfo());
@@ -724,13 +694,17 @@ class printgeneric extends plugin
       $this->netConfigDNS->save_object();
     }
     
-    /* Set new base if allowed */
-    $tmp = $this->get_allowed_bases();
-    if(isset($_POST['base'])){
-      if(isset($tmp[$_POST['base']])){
-        $this->base= $_POST['base'];
+    /* 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;
       }
     }
+
   }
 
   /* Check supplied data */
index 07bb9cd6cde29ca57cb4c72309338cd563fc787e..a93579f8c188a2e2186c64216f75e9ac442b159a 100644 (file)
@@ -38,6 +38,7 @@ class workgeneric extends plugin
   var $modes= array();
 
   var $netConfigDNS;
+  var $baseSelector;
 
   var $inheritTimeServer = true;
 
@@ -163,6 +164,12 @@ class workgeneric extends plugin
     $this->orig_dn= $this->dn;
     $this->orig_cn= $this->cn;
     $this->orig_base= $this->base;
+
+    /* 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);
   }
 
 
@@ -228,37 +235,6 @@ class workgeneric extends plugin
       return($display);
     }
 
-    /* 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 */
-      $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());
-      }
-    }
-
     /* Add new ntp Server to our list */ 
     if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
@@ -273,6 +249,7 @@ class workgeneric extends plugin
 
     /* Fill templating stuff */
     $smarty= get_smarty();
+    $smarty->assign("usePrototype", "true");
 
     /* Set acls */
     $tmp = $this->plInfo();
@@ -283,7 +260,6 @@ class workgeneric extends plugin
     $smarty->assign("cn", $this->cn);
     $smarty->assign("description", $this->description);
     $smarty->assign("l", $this->l);
-    $smarty->assign("bases", $this->get_allowed_bases());
     $smarty->assign("staticAddress", "");
 
     $tmp = array();
@@ -328,9 +304,10 @@ class workgeneric extends plugin
     $smarty->assign("gotoNtpServers", $ntpser);
 
     /* Variables */
-    foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
+    foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){
       $smarty->assign($val."_select", $this->$val);
     }
+    $smarty->assign("base", $this->baseSelector->render());
 
     /* tell smarty the inherit checkbox state */
     $smarty->assign("inheritTimeServer",$this->inheritTimeServer);
@@ -410,11 +387,14 @@ class workgeneric extends plugin
     plugin::save_object();
     $this->base = $base_tmp;
 
-    /* Save base, since this is no LDAP attribute */
-    $tmp = $this->get_allowed_bases();
-    if(isset($_POST['base'])){
-      if(isset($tmp[$_POST['base']])){
-        $this->base= $_POST['base'];
+    /* 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;
       }
     }
 
index 4d63647c52f8dd64ff267a70a40d00d8d677de50..56e280513660fc9bba5f9de369d92cf7c73e5831 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 user 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 6309ec7744a8028fa1948585d3bf0b2149295cf2..8e9a099972f26c039d800509d986a686b1aac2fc 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 group 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>