Code

Set mode to read_only if we edit frozen apps
[gosa.git] / gosa-plugins / goto / admin / applications / class_applicationGeneric.inc
index 1b6b1f6cdda125600f2b00fda394bbd6e2fc242b..59a67c8b8dcdb9d9541ff37fe34525d738127231 100644 (file)
@@ -57,11 +57,12 @@ class application extends plugin
         $this->base= dn2base($ui->dn);
       }
     } else {
-      $this->base= preg_replace ("/^[^,]+,".get_ou('applicationou')."/", "", $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("applicationou").normalizePreg($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("/".normalizePreg($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;
           }
         }  
       }
@@ -413,7 +385,7 @@ class application extends plugin
 
     /* Permissions for that base? */
     if ($this->base != ""){
-      $new_dn= "cn=".$this->cn.",".get_ou('applicationou').$this->base;
+      $new_dn= "cn=".$this->cn.",".get_ou('applicationRDN').$this->base;
     } else {
       $new_dn= $this->dn;
     }
@@ -445,7 +417,7 @@ class application extends plugin
     if($this->is_release()){
       $base = $this->parent->parent->app_release;
     }else{
-      $base = get_ou('applicationou').$this->base;
+      $base = get_ou('applicationRDN').$this->base;
     }
 
     $ldap->ls("(&(objectClass=gosaApplication)(cn=".$this->cn."))",$base,array("cn"));
@@ -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;
 
@@ -532,7 +505,7 @@ class application extends plugin
   function set_picture($filename)
   {
     if (!is_file($filename)){
-      $filename= "./images/default_icon.png";
+      $filename= "./plugins/goto/images/default_icon.png";
       $this->gosaApplicationIcon= "*removed*";
     }
 
@@ -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").