Code

Fixed kolabAccount work in newer connectivity class
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Jul 2006 09:22:42 +0000 (09:22 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 5 Jul 2006 09:22:42 +0000 (09:22 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4027 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/acl_definition.inc
plugins/personal/connectivity/class_kolabAccount.inc
plugins/personal/connectivity/kolab.tpl

index b616cbd26956d7496b952da040cb60a3e4124320..92d285b9d0e5818566b422a903281585460bbf13 100644 (file)
@@ -8,6 +8,17 @@ $ACLD['application']=array("cn" => "LDAP name",
                        "gosaApplicationExecute" => "Execute",
                        "gosaApplicationFlags" => "Modify flags",
                        "gosaApplicationName" => "Visible name");
+$ACLD['mimetype']=array("cn"                           => "LDAP name",
+                       "create"                                                => "Create",
+                       "delete"                                                => "Delete",
+                       "description"                                   => "Description",
+                       "gotoMimeIcon"                                  => "Icon",
+                       "gotoMimeApplication"                   => "Modify flags",
+                       "gotoMimeEmbeddedApplication"   => "Embedded applications",
+                       "gotoMimeLeftClickAction"               => "Left click actions",
+                       "gotoMimeFilePattern"                   => "File patterns",
+                       "gotoMimeGroup"                                 => "Mime group",
+                       "description"                                   => "Description");
 $ACLD['department']= array(
                        "businessCategory",
                        "description",
@@ -314,5 +325,6 @@ $ACLD['FAIclass']   =       array(
                                                                // Allow displaying of FAI menu element
                                                                "FAIclass"      => "FAI management enabled");
 $ACLD['goFonMacro']    =array("goFonMacro","edit","delete");
+$ACLD['kolabAccount']  =array("kolabAccount","kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL","kolabDelegate");
 
 ?>
index 16e23b9fa12cecc0176ba893c4eb4d04f112de33..6fcbd06f9e8a6f6353c05b18d57a7d89a596d99f 100644 (file)
@@ -2,28 +2,29 @@
 class kolabAccount extends plugin
 {
   /* Definitions */
-  var $plHeadline= "Kolab";
-  var $plDescription= "This does something";
+  var $plHeadline       = "Kolab";
+  var $plDescription    = "This does something";
 
   /* CLI vars */
-  var $cli_summary= "Manage users Kolab account";
-  var $cli_description= "Some longer text\nfor help";
-  var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+  var $cli_summary      = "Manage users Kolab account";
+  var $cli_description  = "Some longer text\nfor help";
+  var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
 
   /* Kolab attributes */
-  var $kolabInvitationPolicy= array();
-  var $kolabFreeBusyFuture= 60;
-  var $unrestrictedMailSize= 0;
-  var $calFBURL= "";
-  var $kolabDelegate= array();
+  var $kolabInvitationPolicy  = array();
+  var $kolabFreeBusyFuture    = 60;
+  var $unrestrictedMailSize   = 0;
+  var $calFBURL               = "";
+  var $kolabDelegate          = array();
 
   /* attribute list for save action */
-  var $attributes= array( "kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL");
-  var $objectclasses= array("kolab");
+  var $attributes     = array("kolabFreeBusyFuture", "unrestrictedMailSize", "calFBURL","kolabDelegate");
+  var $objectclasses  = array("kolabInetOrgPerson");
 
   /* Helper */
   var $imapping= array();
 
+
   function kolabAccount ($config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
@@ -31,9 +32,11 @@ class kolabAccount extends plugin
     /* Pull arrays */
     foreach(array("kolabDelegate", "kolabInvitationPolicy") as $attr){
       if (isset($this->attrs["$attr"]["count"])){
+        $tmp = array();
         for ($i= 0; $i<$this->attrs["$attr"]["count"]; $i++){
-          array_push($this->$attr, $this->attrs["$attr"][$i]);
+          $tmp[]=$this->attrs["$attr"][$i];
         }
+        $this->$attr = $tmp;
       }
     }
 
@@ -42,12 +45,23 @@ class kolabAccount extends plugin
        $this->kolabInvitationPolicy= array("ACT_MANUAL");
     }
 
+    /* Check is account state */
+    $this->is_account = false;
+    if(count($this->kolabDelegate)){
+      $this->is_account = true;
+    }
+    foreach(array("calFBURL","unrestrictedMailSize") as $attr){
+      if(!empty($this->$attr)){
+        $this->is_account = true;
+      }
+    } 
   }
 
+
   function execute()
   {
        /* Call parent execute */
-//     plugin::execute();
+       plugin::execute();
 
     /* Show tab dialog headers */
     $display= "";
@@ -60,6 +74,7 @@ class kolabAccount extends plugin
       $smarty->assign("$val", $this->$val);
       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
     }
+    $smarty->assign("kolabAccountACL", chkacl($this->acl, "kolabAccountACL"));
 
     /* Check for invitation action */
     $nr= 0;
@@ -82,9 +97,6 @@ class kolabAccount extends plugin
     /* Unify addresses */
     $new= array();
     foreach($this->kolabInvitationPolicy as $value){
-      if (preg_match('/^:/', $value)){
-        continue;
-      }
       $address= preg_replace('/^([^:]+:).*$/', '\1', $value);
       $new[$address]= $value;
     }
@@ -153,9 +165,11 @@ class kolabAccount extends plugin
 
     /* Transfer account states for this union */
     if (isset($this->parent) && $this->parent->by_object['mailAccount']->is_account){
-      $smarty->assign('is_account', 'true');
-    } else {
-      $smarty->assign('is_account', '');
+      $smarty->assign('mail_account', 'true');
+    } elseif($this-> initially_was_account && (isset($this->attrs['objectClass']) && (in_array("kolabInetOrgPerson",$this->attrs['objectClass'])))){
+      $smarty->assign('mail_account', 'true');
+    }else{
+      $smarty->assign('mail_account', '');
     }
 
     /* Transfer delegation list */
@@ -172,8 +186,19 @@ class kolabAccount extends plugin
     $this->imapping= array();
     $nr= 0;
     $acl= chkacl($this->acl, "kolabInvitationPolicy");
+    $changeState = "";
     foreach ($this->kolabInvitationPolicy as $entry){
+
+      $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n
+                         changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
+
       $invitation.= "<tr><td>";
+      if($this->is_account){
+        $dis = " ";
+      }else{
+        $dis = " disabled ";
+      }
+    
 
       /* The default entry does not have colons... */
       if (!preg_match('/:/', $entry)){
@@ -183,12 +208,12 @@ class kolabAccount extends plugin
       } else {
         $name= preg_replace('/:.*$/', '', $entry);
         $mode= preg_replace('/^[^:]*: */', '', $entry);
-        $invitation.= "<input name=\"address$nr\" size=16 maxlength=60 $acl value=\"$name\">";
+        $invitation.= "<input name=\"address$nr\" size=16 maxlength=60 $acl value=\"$name\" id='address".$nr."' ".$dis.">";
       }
       $invitation.= "</td>";
 
       /* Add mode switch */
-      $invitation.= "<td><select size=\"1\" name=\"policy$nr\" $acl>";
+      $invitation.= "<td><select size=\"1\" name=\"policy$nr\" $acl  id='policy".$nr."' ".$dis.">";
       foreach($policies as $key => $value){
         if ($key == $mode){
           $invitation.= "<option value=\"$key\" selected>$value</option>";
@@ -200,10 +225,10 @@ class kolabAccount extends plugin
       /* Assign buttons */
       $button= "";
       if ($nr == count($this->kolabInvitationPolicy)-1){
-        $button= "<input type=submit name=\"add$nr\" value=\""._("Add")."\">";
+        $button= "<input type=submit name=\"add$nr\" value=\""._("Add")."\" id='add".$nr."' ".$dis.">";
       }
       if ($nr != 0) {
-        $button.= "<input type=submit name=\"remove$nr\" value=\""._("Remove")."\">";
+        $button.= "<input type=submit name=\"remove$nr\" value=\""._("Remove")."\" id='remove".$nr."' ".$dis.">";
       }
       
       $invitation.= "</select>&nbsp;$button</td></tr>\n";
@@ -211,15 +236,30 @@ class kolabAccount extends plugin
       $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__)));
+
+
     return ($display);
   }
 
   function remove_from_parent()
   {
     /* Optionally execute a command after we're done */
+    plugin::remove_from_parent();
+    
+    if(!in_array("kolabInetOrgPerson",$this->attrs['objectClass'])){
+      $this->attrs['objectClass'][] = "kolabInetOrgPerson";
+    }
+
+    $ldap = $this->config->get_ldap_linK(); 
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->cd ($this->dn);
+    $ldap->modify($this->attrs);
+
     $this->handle_post_events('remove');
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn));
   }
 
 
@@ -272,6 +312,13 @@ class kolabAccount extends plugin
   {
     /* Do we need to flip is_account state? */
     if (isset($_POST['connectivityTab'])){
+
+      if(isset($_POST["kolabState"])){
+        $this->is_account = true;
+      }else{
+        $this->is_account = false;
+      }
+
       if (chkacl('unrestrictedMailSize', $this->acl == "")){
         if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){
           $this->unrestrictedMailSize= 1;
@@ -316,13 +363,20 @@ class kolabAccount extends plugin
     $this->attrs['kolabDelegate']= $this->kolabDelegate;
     $this->attrs['kolabInvitationPolicy']= $this->kolabInvitationPolicy;
 
+    /* unrestrictedMailSize is boolean */
+    if($this->attrs['unrestrictedMailSize']){
+      $this->attrs['unrestrictedMailSize'] = "TRUE";
+    }else{
+      $this->attrs['unrestrictedMailSize'] = "FALSE";
+    }
+  
     /* Write back to ldap */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($this->dn);
     $this->cleanup();
     $ldap->modify ($this->attrs); 
 
-    show_ldap_error($ldap->get_error(), _("Saving Kolab account failed"));
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/kolab account with dn '%s' failed."),$this->dn));
 
     /* Optionally execute a command after we're done */
     if ($this->initially_was_account == $this->is_account){
index f5d8c10753f7673b3b53acabcd5a9915be08f3fb..56ef2bbc3cbc96f89b78eac31a495d051bf9b6ac 100644 (file)
@@ -1,27 +1,43 @@
-<h2>{t}Kolab account{/t}</h2>
 
-{if $is_account ne 'true'}
+{if $mail_account ne 'true'}
+       <h2>{t}Kolab account{/t}</h2>
        {t}The kolab account is currently disabled. It's features can be adjusted if you add a mail account.{/t}
 {else}
-
+<input type="checkbox" id="kolabState" name="kolabState" value="1" {if $kolabState} checked {/if} 
+       onClick="
+       changeState('delegate_list');
+       changeState('delegate_address');
+       changeState('add_delegation');
+       changeState('delete_delegation');
+       changeState('unrestrictedMailSize');
+       changeState('calFBURL');
+       changeState('kolabFreeBusyFuture');
+       changeState('kolabInvitationPolicy');
+       {$changeState}"
+       {$kolabAccountACL}
+>
+<b>{t}Kolab account{/t}</b>
+<br>
+<br>
 <table summary="" style="width:100%">
  <tr>
   <td style="width:50%; vertical-align:top;">
    <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>
+   <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>
    <br>
-   <input name="delegate_address" size=30 align=middle maxlength=60
-        {$kolabDelegateACL} value="">
-   <input type=submit value="{t}Add{/t}" name="add_delegation"
-        {$kolabDelegateACL}>&nbsp;
-   <input type=submit value="{t}Delete{/t}" name="delete_delegation"
-        {$kolabDelegateACL}>
+   <input name="delegate_address" size=30 align=middle maxlength=60 {if !$kolabState} disabled {/if}
+        {$kolabDelegateACL} value="" id="delegate_address">
+   <input type=submit value="{t}Add{/t}" name="add_delegation" {if !$kolabState} disabled {/if}
+        {$kolabDelegateACL} id="add_delegation">&nbsp;
+   <input type=submit value="{t}Delete{/t}" name="delete_delegation" {if !$kolabState} disabled {/if}
+        {$kolabDelegateACL} id="delete_delegation">
    <p>
     <b>{t}Mail size{/t}</b><br>
-     &nbsp;<input type="checkbox" name="unrestrictedMailSize" value="1" {$unrestrictedMailSizeACL} {$unrestrictedMailSizeState}> {t}No mail size restriction for this account{/t}
+     &nbsp;<input type="checkbox" id='unrestrictedMailSize' name="unrestrictedMailSize" value="1" {if !$kolabState} disabled {/if}
+       {$unrestrictedMailSizeACL} {$unrestrictedMailSizeState}> {t}No mail size restriction for this account{/t}
     </p>
   </td>
   <td rowspan=2 style="border-left:1px solid #A0A0A0">
  <table summary="">
   <tr>
    <td><LABEL for="calFBURL">{t}URL{/t}</LABEL></td>
-   <td><input id="calFBURL" name="calFBURL" size=30 maxlength=60 {$calFBURLACL} value="{$calFBURL}"></td>
+   <td><input id="calFBURL" name="calFBURL" size=30 maxlength=60 {$calFBURLACL} value="{$calFBURL}" {if !$kolabState} disabled {/if}></td>
   </tr>
   <tr>
   <td><LABEL for="kolabFreeBusyFuture">{t}Future{/t}</LABEL></td>
-   <td><input id="kolabFreeBusyFuture" name="kolabFreeBusyFuture" size=5 maxlength=6 {$kolabFreeBusyFutureACL} value="{$kolabFreeBusyFuture}"> {t}days{/t}</td>
+   <td><input id="kolabFreeBusyFuture" name="kolabFreeBusyFuture" size=5 maxlength=6 i {if !$kolabState} disabled {/if}{$kolabFreeBusyFutureACL} value="{$kolabFreeBusyFuture}"> {t}days{/t}</td>
   </tr>
  </table>