Code

Set mode to read_only if we edit frozen apps
[gosa.git] / gosa-plugins / goto / admin / applications / class_applicationGeneric.inc
index f8364a09999fc3dd0ae42a310269a1fce468605c..59a67c8b8dcdb9d9541ff37fe34525d738127231 100644 (file)
@@ -57,11 +57,12 @@ class application extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base= preg_replace ("/^[^,]+,".get_ou('applicationRDN')."/", "", $this->dn);
+      $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou('applicationRDN'), '/')."/i", "", $this->dn);
     }
 
     $this->orig_cn = $this->cn;
     $this->orig_base = $this->base;
+    $this->gosaApplicationFlags = preg_replace("/[^GDLMO]/","",$this->gosaApplicationFlags);
   }
 
 
@@ -166,36 +167,6 @@ class application extends plugin
       $smarty->assign("selectmode", "disabled");
     }
     
-    /* Base select dialog */
-    $once = true;
-    foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once && !preg_match("/freeze/i",$this->FAIstate)){
-        $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()){
-        /* Just allow selection valid bases */ 
-        $tmp = $this->get_allowed_bases();
-        if(isset($tmp[$this->dialog->isSelected()])){
-          $this->base = $this->dialog->isSelected();
-        }
-        $this->dialog= false;
-      }else{
-        return($this->dialog->execute());
-      }
-    }
-
     /* Get random number for pictures */
     srand((double)microtime()*1000000);
     $smarty->assign("rand", rand(0, 10000));
@@ -229,7 +200,7 @@ class application extends plugin
     restore_error_handler();
 
     /* Parse release out of object dn */
-    $release = preg_replace("/".get_ou("applicationRDN").preg_quote($this->base)."$/","",$this->dn);
+    $release = preg_replace("/".preg_quote(get_ou("applicationRDN").$this->base, '/')."$/i","",$this->dn);
     $release = preg_replace("/^cn=[^,]+,/","",$release);
 
     /* Get a list of all groups 
@@ -249,7 +220,7 @@ class application extends plugin
       $ldap->cd($release.$group);
       $ldap->search("(objectClass=gotoMenuEntry)",array("dn"));
       while($attrs = $ldap->fetch()){
-        $info = preg_replace("/".preg_quote($release.$group)."$/","",$attrs['dn']); 
+        $info = preg_replace("/".preg_quote($release.$group, '/')."$/","",$attrs['dn']); 
         if(preg_match("/^cn=".$this->cn."/",$info) && !preg_match("/ou=[^,]+,/",$info)){
           $found[] = $attrs['dn'];
         }
@@ -312,14 +283,15 @@ class application extends plugin
                       "placeInStartmenu"    => "M",
                       "overwriteConfig"     => "O");
 
+
       /* Save application flags */
       foreach($checks as $name => $flag){
         if($this->acl_is_writeable($name)){
           $set = isset($_POST[$name]) && $_POST[$name] == 1;
-          if(!$set && preg_match("/".$flag."/",$this->gosaApplicationFlags)){
-            $this->gosaApplicationFlags = preg_replace("/".$flag."/","",$this->gosaApplicationFlags);  
+          if(!$set && strstr($this->gosaApplicationFlags,$flag)){
+            $this->gosaApplicationFlags = str_replace($flag,"",$this->gosaApplicationFlags);  
           }elseif($set && !preg_match("/".$flag."/",$this->gosaApplicationFlags)){
-            $this->gosaApplicationFlags = preg_replace("/]/",$flag."]",$this->gosaApplicationFlags); 
+            $this->gosaApplicationFlags .= $flag;
           }
         }  
       }
@@ -474,6 +446,7 @@ class application extends plugin
     /* Get application script without header part, to check if we must save the script itself */
     $script = preg_replace('/.*### END HEADER ###/s', '', $this->gotoLogonScript);
 
+    $this->gosaApplicationFlags ="[{$this->gosaApplicationFlags}]";
     plugin::save();
     $this->attrs["gosaApplicationIcon"]= $this->gosaApplicationIcon;
 
@@ -551,8 +524,8 @@ class application extends plugin
   {
     $vars = array("cn");
 
-    $str ="<h2>"._("Application settings")."</h2>
-      <table>
+    $str ="<h3>"._("Application settings")."</h3>
+      <table summary=\""._("Application settings")."\">
       <tr>
       <td>".
       _("Application name").