Code

Updated multiple edit.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 9 Jan 2008 11:12:17 +0000 (11:12 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 9 Jan 2008 11:12:17 +0000 (11:12 +0000)
-Mail is party implemented

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

gosa-core/plugins/admin/groups/application.tpl
gosa-core/plugins/admin/groups/class_groupMail.inc
gosa-core/plugins/admin/groups/mail.tpl

index 4b70a54727dea4985bbe1354b849ea1494f5ff50..bc6297ab0e057099e1851e7cbebc7aaab6b690a9 100644 (file)
@@ -8,7 +8,7 @@
                        onClick="toggle('div_use_apps');">
                {t}Modify application settings.{/t}
                <br>
-               <div id="div_use_apps">
+               <div id="div_use_apps" style="visibility: visible;" >
        {else}
                <input type="checkbox" name="use_apps" value="1" class="center"
                        onClick="toggle('div_use_apps');">
index 021fffbcc193d656f358a80fdcd5bc0b30e7fb21..cb1e55ab716bf3e077adada4def7ef46af8da704 100644 (file)
@@ -18,6 +18,8 @@ class mailgroup extends plugin
   var $gosaMailAlternateAddress   = array();  // Set default Alternate Mail Adresses to empty array
   var $gosaMailForwardingAddress  = array();  // Forwarding also empty
 
+  var $gosaMailForwardingAddress_Some  = array();  // Used in multiple edit 
+
   var $gosaMailServer             = "";       // Selected mailserver 
   var $gosaMailQuota              = "";       // Defined Quota 
   var $quotaUsage                 = 0;        // Currently used quota
@@ -61,6 +63,8 @@ class mailgroup extends plugin
   var $objectclasses= array("gosaMailAccount");
   var $CopyPasteVars          = array("quotaUsage","imapacl");
 
+  var $multiple_support = TRUE;
+
   function mailgroup (&$config, $dn= NULL, $ui= NULL)
   {
     /* Initialise all available attributes ... if possible
@@ -311,6 +315,7 @@ class mailgroup extends plugin
   {
     /* Call parent execute */
     //plugin::execute();
+    $display = "";
 
     /* Log view */
     if($this->is_account && !$this->view_logged){
@@ -333,47 +338,53 @@ class mailgroup extends plugin
       $smarty->assign("javascript", "true");
     }
 
-    /* Do we need to flip is_account state? */
-    if(isset($_POST['modify_state'])){
-      if($this->is_account && $this->acl_is_removeable()){
-        $this->is_account= FALSE;
-      }elseif(!$this->is_account && $this->acl_is_createable()){
-        $this->is_account= TRUE;
+    /* Handle actions should not be done, when 
+     *  editing multiple entries at once. e.g. account state
+     */ 
+    if(!$this->multiple_support_active){
+
+      /* Do we need to flip is_account state? */
+      if(isset($_POST['modify_state'])){
+        if($this->is_account && $this->acl_is_removeable()){
+          $this->is_account= FALSE;
+        }elseif(!$this->is_account && $this->acl_is_createable()){
+          $this->is_account= TRUE;
+        }
       }
-    }
 
-    $display = "";
+      $display = "";
 
-    /* Do we represent a valid account? */
-    if (!$this->is_account && $this->parent === NULL){
+      /* Do we represent a valid account? */
+      if (!$this->is_account && $this->parent === NULL){
 
-      $display.= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
-        _("This 'dn' has no valid mail extensions.")."</b>";
-      return ($display);
-    }
+        $display.= "<img alt=\"\" src=\"images/stop.png\" align=middle>&nbsp;<b>".
+          _("This 'dn' has no valid mail extensions.")."</b>";
+        return ($display);
+      }
 
-    /* Show tab dialog headers */
-    $display= "";
-    if ($this->parent !== NULL){
-      if ($this->is_account){
-        $display.= $this->show_disable_header(_("Remove mail account"),
-            _("This account has mail features enabled. You can disable them by clicking below."));
-      } else {
-        $display.= $this->show_enable_header(_("Create mail account"),
-            _("This account has mail features disabled. You can enable them by clicking below."));
-  
-        /* Show checkbox that allows us to remove imap entry too*/
-        if($this->initially_was_account){
-          $c = "";
-          if($this->remove_folder_from_imap){
-            $c= " checked ";
+      /* Show tab dialog headers */
+      $display= "";
+      if ($this->parent !== NULL){
+        if ($this->is_account){
+          $display.= $this->show_disable_header(_("Remove mail account"),
+              _("This account has mail features enabled. You can disable them by clicking below."));
+        } else {
+          $display.= $this->show_enable_header(_("Create mail account"),
+              _("This account has mail features disabled. You can enable them by clicking below."));
+
+          /* Show checkbox that allows us to remove imap entry too*/
+          if($this->initially_was_account){
+            $c = "";
+            if($this->remove_folder_from_imap){
+              $c= " checked ";
+            }
+            $display .= "<h2>Shared folder delete options</h2>
+              <input class='center' type='checkbox' name='remove_folder_from_imap' value='1' ".$c."
+              title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
+            $display .= _("Remove the shared folder and all its contents after saving this account");
           }
-          $display .= "<h2>Shared folder delete options</h2>
-                       <input class='center' type='checkbox' name='remove_folder_from_imap' value='1' ".$c."
-                        title='"._("Remove shared folder from mail server database when entry gets removed in LDAP")."'>";
-          $display .= _("Remove the shared folder and all its contents after saving this account");
+          return ($display);
         }
-        return ($display);
       }
     }
 
@@ -676,7 +687,28 @@ class mailgroup extends plugin
       $smarty->assign("kolab", FALSE);
     }
 
+    /* Multiple support handling */
+    foreach($this->attributes as $attr){
+      if(in_array($attr,$this->multi_boxes)){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
 
+    /* Multiple support handling */
+    foreach(array("kolabFolderType") as $attr){
+      if(in_array($attr,$this->multi_boxes)){
+        $smarty->assign("use_".$attr,TRUE);
+      }else{
+        $smarty->assign("use_".$attr,FALSE);
+      }
+    }
+
+    $smarty->assign("Forward_all",$this->gosaMailForwardingAddress);
+    $smarty->assign("Forward_some",$this->gosaMailForwardingAddress_Some);
+
+    $smarty->assign("multiple_support",$this->multiple_support_active);
     $display.= $smarty->fetch (get_template_path('mail.tpl', TRUE));
     return ($display);
   }
@@ -1062,7 +1094,13 @@ I: Only insider delivery */
   function addForwarder($address)
   {
     $this->gosaMailForwardingAddress[]= $address;
-    $this->gosaMailForwardingAddress= array_unique ($this->gosaMailForwardingAddress);
+    $this->gosaMailForwardingAddress= array_unique($this->gosaMailForwardingAddress);
+
+    /* Update multiple edit values too */
+    if($this->multiple_support_active){
+      $this->gosaMailForwardingAddress_Some= 
+        array_remove_entries (array($address),$this->gosaMailForwardingAddress_Some);
+    }
 
     sort ($this->gosaMailForwardingAddress);
     reset ($this->gosaMailForwardingAddress);
@@ -1074,6 +1112,12 @@ I: Only insider delivery */
   {
     $this->gosaMailForwardingAddress= array_remove_entries ($addresses,
         $this->gosaMailForwardingAddress);
+
+    /* Update multiple edit values too */
+    if($this->multiple_support_active){
+      $this->gosaMailForwardingAddress_Some = array_remove_entries ($addresses,
+          $this->gosaMailForwardingAddress_Some);
+    }
     $this->is_modified= TRUE;
   }
 
@@ -1204,7 +1248,100 @@ I: Only insider delivery */
     }
   }
 
+  function multiple_execute()
+  {
+    return($this->execute());
+  }
+
+
+  function init_multiple_support($attrs,$all)
+  {
+    plugin::init_multiple_support($attrs,$all);
+
+    $this->gosaMailForwardingAddress = array();
+    if(isset($attrs['gosaMailForwardingAddress'])){
+      for($i = 0 ; $i < $attrs['gosaMailForwardingAddress']['count'] ; $i++){
+        $this->gosaMailForwardingAddress[] = $attrs['gosaMailForwardingAddress'][$i];
+      }
+    }
+
+    $this->gosaMailForwardingAddress_Some = array();
+    if(isset($all['gosaMailForwardingAddress'])){
+      for($i = 0 ; $i < $all['gosaMailForwardingAddress']['count'] ; $i++){
+        if(!in_array($all['gosaMailForwardingAddress'][$i],$this->gosaMailForwardingAddress)){
+          $this->gosaMailForwardingAddress_Some[] = $all['gosaMailForwardingAddress'][$i];
+        }
+      }
+    }
+  }
+
+  function multiple_save_object()
+  {
+    if(isset($_POST['multiple_mail_group_posted'])){
+      plugin::multiple_save_object();
+      
+      foreach(array("kolabFolderType") as $attr){
+        if(isset($_POST['use_'.$attr])){
+          $this->multi_boxes[] = $attr;
+        }
+      }
+
+      /* Add special kolab attributes */
+      if(isset($this->config->current['MAILMETHOD'])&&preg_match("/olab/i",$this->config->current['MAILMETHOD'])){
+        if(isset($_POST['kolabFolderType_Type'])){
+          $this->kolabFolderType_Type = get_post("kolabFolderType_Type");
+          $this->kolabFolderType_SubType = get_post("kolabFolderType_SubType");
+        }
+      }
+
+      /* Collect data and re-assign it to the imapacl array */
+      if ($this->acl_is_writeable("acl")){
+        $this->imapacl= array();
+        $this->imapacl['%members%']= $_POST['member_permissions'];
+        $this->imapacl['anyone']= $_POST['default_permissions'];
+        foreach ($this->indexed_user as $nr => $user){
+          if (!isset($_POST["user_$nr"])){
+            continue;
+          }
+          if ($_POST["user_$nr"] != $user ||
+              $_POST["perm_$nr"] != $this->indexed_acl[$nr]){
+            $this->is_modified= TRUE;
+          }
+          $this->imapacl[$_POST["user_$nr"]]= $_POST["perm_$nr"];
+        }
+      }
+    }
+  }
+  
+  
+  /* Return selected values for multiple edit */
+  function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    $ret['Forward_some'] = $this->gosaMailForwardingAddress_Some;    
+    $ret['Forward_all'] = $this->gosaMailForwardingAddress;    
+    if(in_array('kolabFolderType',$this->multi_boxes)){
+      $ret['kolabFolderType_Type'] = $this->kolabFolderType_Type;
+      $ret['kolabFolderType_SubType'] = $this->kolabFolderType_SubType;
+    }
+    return($ret);
+  }
+
+  function set_multi_edit_values($attrs)
+  {
+    $forward = array();
+    foreach($attrs['Forward_some'] as $addr){
+      if(in_array($addr,$this->gosaMailForwardingAddress)){
+        $forward[] = $addr;
+      }
+    }
+    foreach($attrs['Forward_all'] as $addr){
+      $forward[] = $addr;
+    }
+    plugin::set_multi_edit_values($attrs);
+    $this->gosaMailForwardingAddress = $forward;
+  }
 }
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+  // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index e7eb7083a107238d09331080f58f3744cacdb2ff..f41cf3ebcc917a5036689eb861b3a918dfc6db51 100644 (file)
@@ -9,15 +9,20 @@
     <tr>
      <td><LABEL for="mail">{t}Primary address{/t}</LABEL>{$must}</td>
      <td>
-{render acl=$mailACL}
-       <input id="mail" name="mail" size="25" maxlength="65" value="{$mail}" title="{t}Primary mail address for this shared folder{/t}">
-{/render}
+{if $multiple_support}
+       <input id="dummy1" name="dummy1" size="25" maxlength="65" 
+               value="{t}Multiple edit{/t}" disabled>
+{else}
+       {render acl=$mailACL}
+               <input id="mail" name="mail" size="25" maxlength="65" value="{$mail}" title="{t}Primary mail address for this shared folder{/t}">
+       {/render}
+{/if}
      </td>
     </tr>
     <tr>
      <td><LABEL for="gosaMailServer">{t}Server{/t}</LABEL></td>
      <td>
-{render acl=$gosaMailServerACL}
+{render acl=$gosaMailServerACL checkbox=$multiple_support checked=$use_gosaMailServer}
       <select size="1" name="gosaMailServer" title="{t}Select mail server to place user on{/t}">
        {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
           <option disabled>&nbsp;</option>
     <tr>
      <td>{t}Quota size{/t}</td>
      <td>
-{render acl=$gosaMailQuotaACL}
+{render acl=$gosaMailQuotaACL  checkbox=$multiple_support checked=$use_gosaMailQuota}
        <input id="gosaMailQuota" name="gosaMailQuota" size="6" align=middle maxlength="30" value="{$gosaMailQuota}">
 {/render}
- {t}MB{/t}
-</td>
-    </tr>
       {t}MB{/t}
+       </td>
+</tr>
        {if $kolab}
        <tr>
                <td>
                        {t}Folder type{/t}
                </td>
                <td>
-                       <select name="kolabFolderType_Type" onChange="document.mainform.submit();">
+               
+               {if $multiple_support}
+                       <input type='checkbox' name='use_kolabFolderType' id='use_kolabFolderType' class="center"
+                               {if $use_kolabFolderType} checked {/if}
+                               onClick="changeState('kolabFolderType_Type');changeState('kolabFolderType_SubType');"                   
+                       >
+                       <select id="kolabFolderType_Type" name="kolabFolderType_Type" onChange="document.mainform.submit();"
+                               {if !$use_kolabFolderType} disabled {/if}>
+                               {html_options options=$kolabFolderType_Types selected=$kolabFolderType_Type}
+                       </select>
+                       <select id="kolabFolderType_SubType" name="kolabFolderType_SubType" onChange="document.mainform.submit();"
+                               {if !$use_kolabFolderType} disabled {/if}>
+                               {html_options options=$kolabFolderType_SubTypes selected=$kolabFolderType_SubType}
+                       </select>
+               {else}
+                       <select id="kolabFolderType_Type" name="kolabFolderType_Type" onChange="document.mainform.submit();">
                                {html_options options=$kolabFolderType_Types selected=$kolabFolderType_Type}
                        </select>
-                       <select name="kolabFolderType_SubType" onChange="document.mainform.submit();">
+                       <select id="kolabFolderType_SubType" name="kolabFolderType_SubType" onChange="document.mainform.submit();">
                                {html_options options=$kolabFolderType_SubTypes selected=$kolabFolderType_SubType}
                        </select>
+               {/if}
                        {if !$JS}
                                <input type='image' src='images/list_reload.png' class='center' alt='{t}Reload{/t}'>
                        {/if}
    </table>
      
   </td>
+
+{if $multiple_support}
+
+{else}
+
   <td style="vertical-align:top;padding-left:2px;">
+
+       
+
    <h2><img class="center" alt="" align="middle" src="images/alternatemail.png"> {t}Alternative addresses{/t}</h2>
 
 {render acl=$gosaMailAlternateAddressACL}
 {/render}
 
   </td>
+{/if}
  </tr>
 
 </table>
-
 <p class="seperator">&nbsp;</p>
 
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
  <tr>
   <td style="vertical-align:top;width:50%; border-right:1px solid #A0A0A0">
    <h2><img class="center" alt="" align="middle" src="images/members.png"> {t}IMAP shared folders{/t}</h2>
+{if $multiple_support}
 
+       <input type='checkbox' name="use_acl" value="1" {if $use_acl} checked {/if} 
+               onClick="toggle('acl_div');"
+       >
+       {if $use_acl}
+               <div style="visibility:visible;" id="acl_div">
+       {else}
+               <div style="visibility:hidden;" id="acl_div">
+       {/if}
+{/if}      
    <table summary="" cellpadding=0 border=0>
     <tr>
      <td><LABEL for="default_permissions">{t}Default permission{/t}</LABEL></td>
     </tr>
        {$plusattributes}
    </table>
-      
+{if $multiple_support}
+       </div>
+{/if}
+
   </td>
   <td style="vertical-align:top;width:50%">
    <h2>
 
 {render acl=$gosaMailForwardingAddressACL}
    <select style="width:100%;" name="forwarder_list[]" size=10 multiple>
+
+       {if $multiple_support}
+
+               {foreach from=$Forward_all item=item key=key}
+                       <option value="{$item}">{$item}&nbsp;({t}Used in all groups{/t})</option>
+               {/foreach}
+               {foreach from=$Forward_some item=item key=key}
+                       <option value="{$item}" style='color: #888888; background: #DDDDDD;background-color: #DDDDDD;'>{$item}&nbsp;({t}Not used in all groups{/t})</option>
+               {/foreach}
+       {else}
     {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress}
        <option disabled>&nbsp;</option>
+       {/if}
    </select>
 {/render}
 
        focus_field('mail');
   -->
 </script>
+{if $multiple_support}
+       <input type="hidden" name="multiple_mail_group_posted" value="1">
+{/if}