Code

Fixed macro base selection and checks
[gosa.git] / plugins / gofon / macro / class_gofonMacro.inc
index 981b526c2519b8ff882df253482a2d3df774b1d4..1b091cf071873134a2b101aacecff96fec74918f 100755 (executable)
@@ -107,7 +107,7 @@ class macro extends plugin
     foreach($_POST as $name => $value){
       if(preg_match("/^chooseBase/",$name) && $once){
         $once = false;
-        $this->dialog = new baseSelectDialog($this->config, $this);
+        $this->dialog = new baseSelectDialog($this->config, $this,$this->get_allowed_bases());
         $this->dialog->setCurrentBase($this->base);
       }
     }
@@ -120,7 +120,12 @@ class macro extends plugin
       if($this->dialog->isClosed()){
         $this->dialog = false;
       }elseif($this->dialog->isSelected()){
-        $this->base = $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());
@@ -131,13 +136,6 @@ class macro extends plugin
     $smarty= get_smarty();
     $smarty->assign("bases", $this->get_allowed_bases());
   
-    /* Assign base ACL */
-    $baseACL = $this->getacl("base");
-    if(!$this->acl_is_moveable()) {
-      $baseACL = preg_replace("/w/","",$baseACL);
-    }
-    $smarty->assign("baseACL",          $baseACL);
-
     $tmp = $this->plInfo();
     foreach($tmp['plProvidedAcls'] as $name => $translation){
       $smarty->assign($name."ACL",$this->getacl($name));
@@ -358,10 +356,24 @@ class macro extends plugin
   function save_object()
   {
     if (isset($_POST['gofonMacroGenericPosted'])){
-      $old_cn= $this->cn;
-      $old_visible = $this->goFonMacroVisible;
 
+      $old_cn       = $this->cn;
+      $old_visible  = $this->goFonMacroVisible;
+      
+      /* 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;
+
+      /* 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'];
+        }
+      }
 
       /* Restore old cn if we have insuficient acls to change cn ... */
       if(!$this->acl_is_writeable("cn",!$this->is_new)){