Code

Multiple edit
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 Dec 2007 09:27:17 +0000 (09:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 Dec 2007 09:27:17 +0000 (09:27 +0000)
-Added kolab account extensions

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

gosa-core/plugins/personal/connectivity/class_kolabAccount.inc
gosa-core/plugins/personal/connectivity/class_proxyAccount.inc
gosa-core/plugins/personal/connectivity/kolab.tpl
gosa-core/plugins/personal/connectivity/proxy.tpl

index c72977de810d583ad0568e4784bc8cb750aaee92..ddf92a8895e1feb4d268ddd8fc36532cfb104c33 100644 (file)
@@ -17,12 +17,20 @@ class kolabAccount extends plugin
   var $objectclasses  = array("kolabInetOrgPerson");
 
   /* Helper */
-  var $imapping= array();
-  var $mail_Account   = false;
-  var $ReadOnly = false;
-  var $view_logged = FALSE;
-  var $uid = "";
+  var $imapping     = array();
+  var $mail_Account = false;
+  var $ReadOnly     = false;
+  var $view_logged  = FALSE;
+  var $uid          = "";
 
+  var $multiple_support = TRUE;
+
+
+  /*! \brief Initialize Plugin 
+      @param  $config   GOsa configuration object
+      @param  $dn       DN of the currently edited object
+      @param  $parent   The parent object, used to fetch Attributes.
+   */
   function kolabAccount (&$config, $dn= NULL,$parent = NULL)
   {
     plugin::plugin ($config, $dn, $parent);
@@ -70,7 +78,9 @@ class kolabAccount extends plugin
     }
   }
 
-
+    
+  /*! \brief Create thml output 
+   */
   function execute()
   {
          /* Call parent execute */
@@ -110,20 +120,26 @@ class kolabAccount extends plugin
 
     /* Check for invitation action */
     $nr= 0;
-    while (isset($_POST["policy$nr"])){
-      if (isset($_POST["add$nr"])){
+  
+    foreach($_POST as $name => $value){
+      if(preg_match("/add_inv_/",$name)){
         $this->kolabInvitationPolicy[]= ": ACT_MANUAL";
       }
-      if (isset($_POST["remove$nr"])){
+    }
+    foreach($_POST as $name => $value){
+      if(preg_match("/del_inv_/",$name)){
+
+        $id = preg_replace("/del_inv_/","",$name);
+        $id = preg_replace("/_(x|y)$/","",$id);
+  
         $new= array();
         foreach ($this->kolabInvitationPolicy as $entry){
-          if (!preg_match("/^".$this->imapping[$nr].":/", $entry)){
+          if (!preg_match("/^".$this->imapping[$id].":/", $entry)){
             $new[]= $entry;
           }
         }
         $this->kolabInvitationPolicy= $new;
       }
-      $nr++;
     }
 
     /* Unify addresses */
@@ -215,10 +231,10 @@ class kolabAccount extends plugin
           changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
       }
 
-      if(!$this->acl_is_writeable("kolabInvitationPolicy")){
+      if(!$this->acl_is_writeable("kolabInvitationPolicy") && !$this->multiple_support_active){
         $dis = " disabled ";
       }else{
-        if($this->is_account){
+        if($this->is_account || $this->multiple_support_active){
           $dis = " ";
         }else{
           $dis = " disabled ";
@@ -258,22 +274,36 @@ class kolabAccount extends plugin
       /* Assign buttons */
       $button= "";
       if ($nr == count($this->kolabInvitationPolicy)-1){
-        $button= "<input type=submit name=\"add$nr\" value=\""._("Add")."\" id='add".$nr."' ".$dis.">";
+        $button= "<input type='image' name=\"add_inv_".$nr."\" src='images/list_new.png' id='add".$nr."' ".$dis.">";
       }
       if ($nr != 0) {
-        $button.= "<input type=submit name=\"remove$nr\" value=\""._("Remove")."\" id='remove".$nr."' ".$dis.">";
+        $button.= "<input type='image' name=\"del_inv_".$nr."\" src='images/edittrash.png' id='remove".$nr."' ".$dis.">";
       }
       
-      $invitation.= "</select>&nbsp;$button</td></tr>\n";
+      $invitation.= "</select>&nbsp;</td>
+                    <td>$button</td>
+                  </tr>\n";
       $this->imapping[$nr]= $name;
       $nr++;
     }
     $smarty->assign("invitation", $invitation);
     $smarty->assign("changeState", $changeState);
     $smarty->assign("kolabState",$this->is_account);
-    $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__)));
+
+  
+    $smarty->assign("multiple_support",$this->multiple_support_active);
+    foreach($this->attributes as $attr){
+      $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes));
+    }
+    foreach(array("kolabState") as $attr){
+      $smarty->assign("use_".$attr,in_array($attr,$this->multi_boxes));
+    }
+
+    if($this->multiple_support_active){
+    }
 
 
+    $display.= $smarty->fetch (get_template_path('kolab.tpl', TRUE, dirname(__FILE__)));
     return ($display);
   }
 
@@ -362,7 +392,6 @@ class kolabAccount extends plugin
           $this->is_account = false;
         }
       }
-      
       if ($this->acl_is_writeable("unrestrictedMailSize")){
         if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){
           $this->unrestrictedMailSize= 1;
@@ -376,6 +405,7 @@ class kolabAccount extends plugin
 
     /* Save changes done in invitation policies */
     if($this->acl_is_writeable("kolabInvitationPolicy")){
+
       $nr= 0;
       $this->kolabInvitationPolicy= array();
       while (isset($_POST["policy$nr"])){
@@ -480,6 +510,92 @@ class kolabAccount extends plugin
             "kolabInvitationPolicy" => _("Invitation policy"))
           ));
   }
+
+
+  /*! \brief  Enable multiple edit support. \
+              Also sets $this->mail_account to TRUE, which simulates \
+              a valid mail extension.
+   */
+  public function enable_multiple_support()
+  {
+    plugin::enable_multiple_support();
+    $this->mail_Account = TRUE;
+  }
+
+
+  /*! \brief  Save html POSTs in multiple edit.
+   */
+  public function multiple_save_object()
+  {
+    if (isset($_POST['connectivityTab'])){
+      plugin::multiple_save_object();
+      if(isset($_POST['use_kolabState'])){
+        $this->multi_boxes[] = "kolabState";
+      }
+      $this->save_object();
+    }
+  }
+
+
+  /*! \brief  Returns all modified values. \
+              All selected an modified values will be returned \
+              in an array.
+      @return array   Returns an array containing all attribute modifications  
+   */
+  public function get_multi_edit_values()
+  {
+    $ret = plugin::get_multi_edit_values();
+    if(in_array("kolabState",$this->multi_boxes)){
+      $ret['is_account'] = $this->is_account;
+    }
+
+    print_a($ret);
+  
+    return($ret);
+  }
+
+  /*! \brief  Sets modified attributes in mutliple edit. \
+              All collected values from "get_multi_edit_values()" \
+              will be applied to this plugin.
+      @param  array   An array containing modified attributes returned by get_multi_edit_values();
+   */
+  public function set_multi_edit_values($values)
+  {
+    plugin::set_multi_edit_values($values);
+    if(isset($values['is_account'])){
+      $this->is_account = $values['is_account'];
+    }
+  }
+
+
+  /*! \brief  Initialize multiple edit ui for this plugin. \
+              This function sets plugin defaults in multiple edit.
+      @param  array   Attributes used in all object 
+      @param  array   All used attributes.
+   */
+  public function init_multiple_support($attrs,$all)
+  {
+    plugin::init_multiple_support($attrs,$all);
+    if(isset($attrs['objectClass']) && in_array("kolabInetOrgPerson",$attrs['objectClass'])){
+      $this->is_account = TRUE;
+    }
+
+    /* Pull arrays */
+    foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){
+      if (isset($this->multi_attrs["$attr"]["count"])){
+        $tmp = array();
+        for ($i= 0; $i<$this->multi_attrs["$attr"]["count"]; $i++){
+          $tmp[]=$this->multi_attrs["$attr"][$i];
+        }
+        $this->$attr = $tmp;
+      }
+    }
+
+    /* If this one is empty, preset with ACT_MANUAL for anonymous users */
+    if (count ($this->kolabInvitationPolicy) == 0){
+       $this->kolabInvitationPolicy= array("ACT_MANUAL");
+    }
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 8c1568afb9c4f8e9b39f337842893503e530c8d0..3fa7d6d1b64f724e487e94734f22dca7d283f450 100644 (file)
@@ -128,9 +128,6 @@ class proxyAccount extends plugin
         $ProxyWorkingStateChange.=  "changeState('stopHour'); \n";
         $ProxyWorkingStateChange.=  "changeState('stopMinute'); \n";
       }
-      if(preg_match("/F/",$this->gosaProxyAcctFlags)){
-        $changeA .= $ProxyWorkingStateChange;
-      }
       $smarty->assign("ProxyWorkingStateChange",$ProxyWorkingStateChange);
       $changeB = "";
       if($this->acl_is_writeable("gosaProxyFlagB")){
@@ -150,6 +147,7 @@ class proxyAccount extends plugin
         $smarty->assign("use_filter".$attr,FALSE);
       }
     }
+    $smarty->assign("proxyAccountACL",$this->getacl("",$this->ReadOnly));
     $smarty->assign("use_proxy",in_array("proxy",$this->multi_boxes));
     $smarty->assign("multiple_support",$this->multiple_support_active);
     $display.= $smarty->fetch(get_template_path('proxy.tpl', TRUE, dirname(__FILE__)));
index 8b7bd6ed13b1e7d6575bce485bbb58d52dd233f4..c05bfb177f31e87baf8604b5942cdf64557c22e2 100644 (file)
@@ -4,9 +4,17 @@
        {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t}
 {else}
 
+<h2>
+{if $multiple_support}
 
+<input type="checkbox" name="use_kolabState" value="1" {if $use_kolabState} checked {/if}
+       class="center" onClick="changeState('kolabState');">
+<input type="checkbox" id="kolabState" name="kolabState" value="1" {if $kolabState} checked {/if}
+    class="center" {if  !$use_kolabState} disabled {/if}>
 
-<input type="checkbox" id="kolabState" name="kolabState" value="1" {if $kolabState} checked {/if} 
+{else}
+<input type="checkbox" id="kolabState" name="kolabState" value="1" {if $kolabState} checked {/if}
+       class="center" 
        {if (!$is_account && $is_createable) || ($is_account && $is_removeable)}
        {else}
                disabled        
        {if $kolabInvitationPolicy_W}
        {$changeState}
        {/if}">
+{/if}
 
-
-<b>{t}Kolab account{/t}</b>
-<br>
-<br>
+{t}Kolab account{/t}</h2>
 <table summary="" style="width:100%">
  <tr>
   <td style="width:50%; vertical-align:top;">
-   <b><LABEL for="delegate_list">{t}Delegations{/t}</LABEL></b><br>
-{render acl=$kolabDelegateACL}
-   <select id="delegate_list" style="width:350px; height:100px;" name="delegate_list[]" size=15 multiple  {if !$kolabState}disabled{/if} >
-    {html_options values=$kolabDelegate output=$kolabDelegate}
-       <option disabled>&nbsp;</option>
-   </select>
-{/render}
+
+{if $multiple_support}
+       <input type="checkbox" name="use_kolabDelegate" {if $use_kolabDelegate} checked {/if}
+               class="center" onClick="changeState('delegate_list');">
+       <b><LABEL for="delegate_list">{t}Delegations{/t}</LABEL></b><br>
+       <select id="delegate_list" style="width:350px; height:100px;" name="delegate_list[]" size=15 multiple 
+               {if !$use_kolabDelegate }disabled{/if} >
+               {html_options values=$kolabDelegate output=$kolabDelegate}
+               <option disabled>&nbsp;</option>
+       </select>
    <br>
-{render acl=$kolabDelegateACL}
-   <input name="delegate_address" size=30 align=middle maxlength=60 {if !$kolabState} disabled {/if} value="" id="delegate_address">
-{/render}
-{render acl=$kolabDelegateACL}
-   <input type=submit value="{t}Add{/t}" name="add_delegation" {if !$kolabState} disabled {/if} id="add_delegation">&nbsp;
-{/render}
-{render acl=$kolabDelegateACL}
-   <input type=submit value="{t}Delete{/t}" name="delete_delegation" {if !$kolabState} disabled {/if} id="delete_delegation">
-{/render}
-   <p>
-    <b>{t}Mail size{/t}</b><br>
-{render acl=$unrestrictedMailSizeACL}
-     &nbsp;<input type="checkbox" id='unrestrictedMailSize' name="unrestrictedMailSize" value="1" {if !$kolabState} disabled {/if}
-       {$unrestrictedMailSizeState}> {t}No mail size restriction for this account{/t}
+   <input name="delegate_address" size=30 align=middle maxlength=60 value="" id="delegate_address">
+   <input type=submit value="{t}Add{/t}" name="add_delegation" id="add_delegation">&nbsp;
+   <input type=submit value="{t}Delete{/t}" name="delete_delegation" id="delete_delegation">
+
+{else}
+   <b><LABEL for="delegate_list">{t}Delegations{/t}</LABEL></b><br>
+       {render acl=$kolabDelegateACL}
+          <select id="delegate_list" style="width:350px; height:100px;" name="delegate_list[]" size=15 multiple 
+                {if !$kolabState }disabled{/if} >
+               {html_options values=$kolabDelegate output=$kolabDelegate}
+               <option disabled>&nbsp;</option>
+          </select>
+       {/render}
+          <br>
+       {render acl=$kolabDelegateACL}
+          <input name="delegate_address" size=30 align=middle maxlength=60 {if !$kolabState} disabled {/if} value="" id="delegate_address">
+       {/render}
+       {render acl=$kolabDelegateACL}
+          <input type=submit value="{t}Add{/t}" name="add_delegation" {if !$kolabState} disabled {/if} id="add_delegation">&nbsp;
+       {/render}
+       {render acl=$kolabDelegateACL}
+          <input type=submit value="{t}Delete{/t}" name="delete_delegation" {if !$kolabState} disabled {/if} id="delete_delegation">
+       {/render}
+{/if}
+
+    <h2>{t}Mail size{/t}</h2>
+{render acl=$unrestrictedMailSizeACL checkbox=$multiple_support checked=$use_unrestrictedMailSize}
+     &nbsp;<input class="center" type="checkbox" id='unrestrictedMailSize' name="unrestrictedMailSize" value="1" 
+               {if !$kolabState && !$multiple_support} disabled {/if} {$unrestrictedMailSizeState}> 
+       {t}No mail size restriction for this account{/t}
 {/render}
-    </p>
   </td>
   <td rowspan=2 style="border-left:1px solid #A0A0A0">
    &nbsp;
   </td>
   <td style="vertical-align:top;">
 
- <b>{t}Free Busy information{/t}</b><br>
+ <h2>{t}Free Busy information{/t}</h2>
  <table summary="">
   <tr>
    <td><LABEL for="calFBURL">{t}URL{/t}</LABEL></td>
    <td>
-{render acl=$calFBURLACL}
-   <input id="calFBURL" name="calFBURL" size=30 maxlength=60 value="{$calFBURL}" {if !$kolabState} disabled {/if}>
+{render acl=$calFBURLACL checkbox=$multiple_support checked=$use_calFBURL}
+   <input id="calFBURL" name="calFBURL" size=30 maxlength=60 value="{$calFBURL}" 
+       {if !$kolabState && !$multiple_support} disabled {/if}>
 {/render}
    </td>
   </tr>
   <tr>
   <td><LABEL for="kolabFreeBusyFuture">{t}Future{/t}</LABEL></td>
   <td>
-{render acl=$kolabFreeBusyFutureACL}
-   <input id="kolabFreeBusyFuture" name="kolabFreeBusyFuture" size=5 maxlength=6 {if !$kolabState} disabled {/if} value="{$kolabFreeBusyFuture}"> 
+{render acl=$kolabFreeBusyFutureACL checkbox=$multiple_support checked=$use_kolabFreeBusyFuture}
+   <input id="kolabFreeBusyFuture" name="kolabFreeBusyFuture" size=5 maxlength=6 
+       {if !$kolabState && !$multiple_support} disabled {/if} value="{$kolabFreeBusyFuture}" > 
        {t}days{/t}
 {/render}
    </td>
  </table>
 
 
- <b>{t}Invitation policy{/t}</b><br>
+<h2>{t}Invitation policy{/t}</h2>
+{if $multiple_support}
+<input type="checkbox" name="use_kolabInvitationPolicy" {if $use_kolabInvitationPolicy} checked {/if} value="1" class="center">
+{/if}
 {render acl=$kolabInvitationPolicyACL}
  <table summary="">
    {$invitation}
  </table>
 {/render}
 
+
   </td>
  </tr>
 </table>
index 9bde4a29aec5e371b1fb3c70abb07c7a92735082..4f6ac1ea70f0b701b3bd29daa74ba8edeaac405a 100644 (file)
@@ -9,7 +9,8 @@
 
 {else}
 
-       <input type="checkbox" id="proxy" name="proxy" value="B" {$proxyState} {$proxyAccountACL}
+       {render acl=$proxyAccountACL}
+       <input type="checkbox" id="proxy" name="proxy" value="B" {$proxyState}
        class="center" 
        onClick="
 
@@ -31,7 +32,7 @@
        changeTripleSelectState('proxy', 'filterB', 'gosaProxyQuotaPeriod');
        {/if}
        ">
-
+       {/render}
 {/if}
  {t}Proxy account{/t}</h2>