Code

Backported from trunk
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Sep 2011 09:00:01 +0000 (09:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Sep 2011 09:00:01 +0000 (09:00 +0000)
-Kolab my-metworks is a multivalue now.

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

gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc
gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl

index 2a91090d2c035c9f1780a23e89213dd2811cd831..2f15dc7878b99a9a2044af63d16edf05103361e1 100644 (file)
@@ -57,6 +57,8 @@ class servkolab extends goService
         /* Toggle relayhost */
         $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost);
         $this->postfix_relayhost      = preg_replace("/[\[\]]/","",$this->postfix_relayhost);
+        
+        $this->postfix_mynetworksData = preg_split("/[ ,]/", $this->postfix_mynetworks,0, PREG_SPLIT_NO_EMPTY);
 
         /* Is this Server a member of the Kolab extension or not ?*/ 
         if(isset($this->attrs['kolabHost'])) {
@@ -91,6 +93,17 @@ class servkolab extends goService
         $this->postfix_mydestinationList->setColspecs(array('*','20px'));
         $this->postfix_mydestinationList->setHeader(array(_("Name")));
         $this->postfix_mydestinationList->setDefaultSortColumn(0);
+
+        // Prepare lists
+        $this->postfix_mynetworksList = new sortableListing();
+        $this->postfix_mynetworksList->setDeleteable(true);
+        $this->postfix_mynetworksList->setInstantDelete(true);
+        $this->postfix_mynetworksList->setEditable(false);
+        $this->postfix_mynetworksList->setWidth("100%");
+        $this->postfix_mynetworksList->setHeight("100px");
+        $this->postfix_mynetworksList->setColspecs(array('*','20px'));
+        $this->postfix_mynetworksList->setHeader(array(_("Name")));
+        $this->postfix_mynetworksList->setDefaultSortColumn(0);
     }
 
 
@@ -144,6 +157,25 @@ class servkolab extends goService
             }
         }
 
+
+        /* Domain name added/removed 
+         */
+        if($this->acl_is_writeable("postfixmynetworks")){
+            $this->postfix_mynetworksList->save_object();
+            $action = $this->postfix_mynetworksList->getAction();
+            if($action['action'] == 'delete'){
+                $this->postfix_mynetworksData = $this->postfix_mynetworksList->getMaintainedData();
+            }
+            if(isset($_POST['new_network_name']) && isset($_POST['add_network_name'])){
+                $new_domain = trim(get_post('new_network_name'));
+                if(!empty($new_domain)){
+                    $this->postfix_mynetworksData[] = $new_domain;
+                    $this->postfix_mynetworksData = array_unique($this->postfix_mynetworksData);
+                }
+            }
+        }
+
+
         /***************
           Assign informations to smarty 
          ***************/
@@ -181,6 +213,11 @@ class servkolab extends goService
         $this->postfix_mydestinationList->update();
         $smarty->assign("mdDiv",$this->postfix_mydestinationList->render());
 
+        $this->postfix_mynetworksList->setAcl($this->getacl("postfixmynetworks"));
+        $this->postfix_mynetworksList->setListData($this->postfix_mynetworksData);
+        $this->postfix_mynetworksList->update();
+        $smarty->assign("networkDiv",$this->postfix_mynetworksList->render());
+
         /* Load Template */
         $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE,dirname(__FILE__)));
         return ($display);
@@ -353,6 +390,8 @@ class servkolab extends goService
             $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
         }
 
+        $this->postfix_mynetworks = implode($this->postfix_mynetworksData, ',');
+
         /* Check if this server was renamed, in this case we have to remove old cn first*/
         if($this->hostname != $this->cn){
             $tmp = array();
index dc1fcf260cbcd4b7db4358131a79ca733cc13656..7984cb22d0c8555fd3b4ff651f8d1e81e9584bff 100644 (file)
    <hr>
 
    <h3>{t}SMTP privileged networks{/t}</h3>
-   <table summary="{t}SMTP privileged networks{/t}">
-    <tr>
-     <td>
       <label for="postfix_mynetworks">
       {t}Hosts/networks allowed to relay{/t}</label>
       {render acl=$postfixmynetworksACL}
-      <input id="postfix_mynetworks" name="postfix_mynetworks" size="60" maxlength="220" value="{$postfix_mynetworks}" type="text">
+          {$networkDiv}
+      {/render}
+      {render acl=$postfixmynetworksACL}
+          <input size="30" type='text' name='new_network_name' value=''>
+      {/render}
+      {render acl=$postfixmynetworksACL}
+        <button type='submit' name='add_network_name'>{msgPool type=addButton}</button>
       {/render}
-      ( {t}Enter multiple values, separated with{/t} <b>,</b> )
-     </td>
-    </tr>
-   </table>
 
    <hr>