Code

Fixed picture removement.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Jun 2006 11:23:24 +0000 (11:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 28 Jun 2006 11:23:24 +0000 (11:23 +0000)
Fixed saving; array() attributes produced errors on ldap->add
Fixed radio buttons, one of them must be selected

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3959 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/mimetypes/class_mimetypeGeneric.inc

index 95ac692ab01e1e2abb215d637c9459ade0f67500..33932e2c61ecad3ab446db7f2c17dd089c85d391 100644 (file)
@@ -16,10 +16,11 @@ class mimetype extends plugin
        var $ui;
        var $cn                                                                 = "";                                   
        var $gotoMimeLeftClickAction                    = "I";
-       var $gotoMimeLeftClickAction_I                  = false;
+       var $gotoMimeLeftClickAction_I                  = true;
        var $gotoMimeLeftClickAction_E                  = false;
        var $gotoMimeLeftClickAction_Q                  = false;
        var $gotoMimeIcon                                               = "*removed*";
+       var $use_gotoMimeIcon                                   = NULL;
        var $description                                                = "";
        var $gotoMimeFilePattern                                = array();
        var $gotoMimeApplication                                = array();
@@ -43,12 +44,17 @@ class mimetype extends plugin
 
        /* Select options */
        var $MimeGroups                 = array("video","audio","system");
-               
+
+       /* Orig_Dn is used to verify if this object is new or only edited */            
+       var $orig_dn                    = "";
 
        function mimetype($config,$dn= NULL)
        {
                plugin::plugin ($config, $dn);
 
+               /* Save original dn */
+               $this->orig_dn = $dn;   
+
                /* get gotoMimeLeftClickActions I/E/Q */
                if(isset($this->gotoMimeLeftClickAction)){
                        $str = $this->gotoMimeLeftClickAction;
@@ -60,6 +66,11 @@ class mimetype extends plugin
                        }
                }
 
+               /* If both radio buttons arn't set, set option I */
+               if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
+                       $this->gotoMimeLeftClickAction_I = true;
+               }
+
                /* Get list of array attributes */
                foreach(array("gotoMimeFilePattern") as $attr){
                        $this->$attr = array();
@@ -319,9 +330,7 @@ class mimetype extends plugin
                        foreach($this->$use_attr as $entry){
                                $tmp[] = $entry."|".$i ++;
                        }
-                       if($this->new && count($tmp) == 0){
-                               $this->$attr = "";
-                       }
+                       $this->$attr = $tmp;
                }
 
                /* Create array entries */
@@ -329,19 +338,32 @@ class mimetype extends plugin
                        $i                              = 0;
                        $use_attr               = "use_".$attr;
                        $tmp                    = array();
-                       $this->$attr    = "";
+                       $this->$attr    = array();
                        foreach($this->$use_attr as $entry){
                                $tmp[] = $entry;
                        }
                        $this->$attr = $tmp;
                }
 
+               if($this->use_gotoMimeIcon != "*removed*"){
+                       $this->gotoMimeIcon = $this->iconData;
+               }else{
+                       $this->gotoMimeIcon = "";
+               }
+       
                plugin::save();
 
-               if($this->gotoMimeIcon != "*removed"){
-                       $this->attrs['gotoMimeIcon'] = $this->iconData;
+               /* If this is a newly created object, skip storing those 
+                       attributes that contain an empty array */
+               if($this->orig_dn == "new"){
+                       foreach(array("gotoMimeEmbeddedApplication","gotoMimeApplication","gotoMimeFilePattern") as $attr){
+                               if(!count($this->$attr)){
+                                       unset($this->attrs[$attr]);
+                               }
+                       }
                }
-               
+
+
                $ldap = $this->config->get_ldap_link();
                $ldap-> cd ( $this->config->current['BASE']);
                $ldap->cat($this->dn);
@@ -400,7 +422,7 @@ class mimetype extends plugin
        {
                if (empty($filename)){
                        $filename= "./images/default_icon.png";
-                       $this->gotoMimeIcon= "*removed*";
+                       $this->use_gotoMimeIcon= "*removed*";
                }
 
                if (file_exists($filename)){