Code

Closes #280 Made applications selectable in mime generic
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Nov 2007 07:47:28 +0000 (07:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Nov 2007 07:47:28 +0000 (07:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7928 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/mimetypes/class_mimetypeGeneric.inc
plugins/admin/mimetypes/generic.tpl

index c96097586c3b02f91de534db714414e85294c85c..38b695e9869f151644b115c56e4b790675b329dc 100644 (file)
@@ -26,6 +26,8 @@ class mimetype extends plugin
        var $gotoMimeGroup                                                      = "";
        var $iconData                                                               = NULL;     
        var $base                                                                             = "";
+  var $ApplicationList                  = array();  
+
 
   /* To prevent errors when using the 'apply' button, we use this variables 
       to manage array attributes */
@@ -73,6 +75,15 @@ class mimetype extends plugin
       }
     }
 
+    /* Create list of defined applications in GOsa */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaApplication)(cn=*))",array('cn'));
+    $this->ApplicationList = array();
+    while($attrs = $ldap->fetch()){
+      $this->ApplicationList[$attrs['cn'][0]] = $attrs['cn'][0];
+    }
+
     /* If both radio buttons arn't set, set option I */
     if(!$this->gotoMimeLeftClickAction_I && !$this->gotoMimeLeftClickAction_E){
       $this->gotoMimeLeftClickAction_I = true;
@@ -247,20 +258,36 @@ class mimetype extends plugin
     }  
 
     /* Add gotoMimeFilePattern */
-    if(isset($_POST['AddNewApplication']) && isset($_POST['NewApplication'])){
+    if(isset($_POST['AddNewApplication']) && 
+            (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){
       if($this->acl_is_writeable("gotoMimeApplication")){
-        $str = $_POST['NewApplication'];
-        if(!empty($str)){
+        $str = "";
+        if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){
+          $str = get_post("NewApplicationSelect");
+        }
+        if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){
+          $str = get_post("NewApplication");
+        }
+        if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){
           $this->use_gotoMimeApplication[] = $str;
         }
       }
     }  
 
-    /* Add gotoMimeFilePattern */
-    if(isset($_POST['AddNewEmbeddedApplication']) && isset($_POST['NewEmbeddedApplication'])){
+    /* Add embedded application 
+     *  - From input or from select box 
+     */
+    if(isset($_POST['AddNewEmbeddedApplication']) && 
+            (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){
       if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){
-        $str = $_POST['NewEmbeddedApplication'];
-        if(!empty($str)){
+        $str = "";
+        if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){
+          $str = get_post('NewEmbeddedApplicationSelect');
+        }
+        if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){
+          $str = get_post('NewEmbeddedApplication');
+        }
+        if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){
           $this->use_gotoMimeEmbeddedApplication[] = $str;
         }
       }
@@ -332,6 +359,8 @@ class mimetype extends plugin
     $smarty->assign("gotoMimeApplications",                    $DivApps->DrawList());
     $smarty->assign("gotoMimeEmbeddedApplications",    $DivEApps->DrawList());
 
+    $smarty->assign("ApplicationList",$this->ApplicationList);
+  
     /* Assign class vars to smarty */
     foreach($this->attributes as $attr){
       $smarty->assign($attr,$this->$attr);
index 06556cf4bc82e7e10483d09faa2889c0e5f84451..1cb6d754951f88d674b479f1c1d4b08a9f09ed75 100644 (file)
 {render acl=$gotoMimeApplicationACL}   
                        {$gotoMimeApplications}         
 {/render}
+
+{render acl=$gotoMimeApplicationACL}   
+                       <select name="NewApplicationSelect">
+                               <option value="">-</option>
+                               {html_options options=$ApplicationList}
+                       </select>
+{/render}
 {render acl=$gotoMimeApplicationACL}   
                        <input type='text'       name='NewApplication'    value='' title='{t}Enter an application name here{/t}'>
 {/render}
 {render acl=$gotoMimeEmbeddedApplicationACL}
                        {$gotoMimeEmbeddedApplications}         
 {/render}
+{render acl=$gotoMimeEmbeddedApplicationACL}
+                       <select name="NewEmbeddedApplicationSelect">
+                               <option value="">-</option>
+                               {html_options options=$ApplicationList}
+                       </select>
+{/render}
 {render acl=$gotoMimeEmbeddedApplicationACL}
                        <input type='text'       name='NewEmbeddedApplication'    value='' 
                                title='{t}Enter an application name here{/t}'>