Code

Moved macros to new base selector
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 17:04:06 +0000 (17:04 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 17:04:06 +0000 (17:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15468 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/gofon/gofon/macro/class_gofonMacro.inc
gosa-plugins/gofon/gofon/macro/generic.tpl

index d9aa0b78d73962435b0dab3811efde277f7ba5a7..3fe01851a77b54bcca7827b9ad33bffc9a5ce4c2 100644 (file)
@@ -43,6 +43,7 @@ class macro extends plugin
   var $objectclasses  = array("top", "goFonMacro");
 
   var $goFonHomeServers = array(); // Contains all available asterisk database server 
+  var $baseSelector;
 
   //! The Konstructor   
   /*!  Konstructor, load class with  attributes of the given dn*/
@@ -83,6 +84,12 @@ class macro extends plugin
     
     $this->orig_base = $this->base;
     $this->orig_dn = $this->dn;
+
+    /* 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);
   }
 
 
@@ -103,40 +110,9 @@ class macro extends plugin
     $tmp       = array();
     $number = 0; 
 
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once){
-        $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());
-      }
-    }
-
     /* Fill templating stuff */
     $smarty= get_smarty();
-    $smarty->assign("bases", $this->get_allowed_bases());
+    $smarty->assign("usePrototype", "true");
 
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
@@ -154,8 +130,10 @@ class macro extends plugin
     foreach($this->attributes as $ar){
       $smarty->assign($ar, $this->$ar);
     }
+
+    $smarty->assign("base", $this->baseSelector->render());
+
     /* Checkboxes */
-    $smarty->assign("base_select", $this->base);
     $smarty->assign("vars", $vars);
 
     if($this->goFonMacroVisible){
@@ -351,11 +329,14 @@ class macro 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 5fd717f0eb94bae8fec9ae0586f025ea1fd64a8d..0c504a6b71b16d1dcb65378eca55842958f021ed 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>
+                                          {$base}
                                        {/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}">
-                                       {/render}
-
                                </td>
                        </tr>
                        </table>