Code

Moved kolab stuff
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 08:55:01 +0000 (08:55 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 17 Jan 2008 08:55:01 +0000 (08:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8436 594d385d-05f5-0310-b6e9-bd551577e9d8

12 files changed:
gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc [deleted file]
gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl [deleted file]
gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc [new file with mode: 0644]
gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl [new file with mode: 0644]
gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc [deleted file]
gosa-plugins/kolab/personal/connectivity/kolab.tpl [deleted file]
gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc [new file with mode: 0644]
gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl [new file with mode: 0644]
gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc [deleted file]
gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc [deleted file]
gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc [new file with mode: 0644]
gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc [new file with mode: 0644]

diff --git a/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc b/gosa-core/plugins/admin/systems/services/kolab/class_servKolab.inc
deleted file mode 100644 (file)
index 08b75ea..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-<?php
-
-class servkolab extends goService {
-  /* CLI vars */
-  var $cli_summary = "Manage server basic objects";
-  var $cli_description = "Some longer text\nfor help";
-  var $cli_parameters = array("eins"=>"Eins ist toll", "zwei"=>"Zwei ist noch besser");
-
-  var $postfix_mydomain                 = "";
-  var $cyrus_admins                     = "";
-  var $postfix_mydestination            = "";
-  var $postfix_mynetworks               = "127.0.0.1/8";
-  var $postfix_enable_virus_scan        = "TRUE";
-  var $postfix_relayhost                = "";
-  var $postfix_mxrelayenabled           =  true;
-  var $postfix_allow_unauthenticated     = "FALSE";
-  var $cyrus_quotawarn                  = "80";
-  var $kolabFreeBusyFuture              = "1";
-  var $k                                = "kolab";
-  var $cyrus_imap                       = "TRUE";
-  var $cyrus_pop3                       = "FALSE";
-  var $cyrus_imaps                      = "TRUE";
-  var $cyrus_pop3s                      = "TRUE";
-  var $cyrus_sieve                      = "TRUE";
-  var $apache_allow_unauthenticated_fb  = "TRUE";
-  var $proftpd_ftp                      = "FALSE";
-  var $apache_http                      = "TRUE";
-  var $kolabHost                        = array();
-  var $orig_cn                          = "";
-  var $view_logged                      = FALSE;
-
-  var $attributes =  array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
-      "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
-      "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
-      "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
-      "cyrus_quotawarn");
-  var $objectclasses = array("top", "kolab");
-
-  /* Serverservice vars */
-  var $conflicts    = array("goImapServer","goMailServer");
-  var $DisplayName  = "Kolab mail service";
-  var $StatusFlag   = "";
-
-  function servkolab(&$config, $dn = NULL, $parent= NULL) 
-  {
-    /* Setting the hostname and tell this Plugin that we are the kolab extension*/
-    $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
-    $this->dn       = "k=kolab,".$config->current['BASE'];
-
-    /* Load variables, if given*/
-    plugin::plugin($config, $this->dn);
-
-    /* Copy needed attributes */
-    foreach($this->attributes as $val) {
-      $name = preg_replace('/_/', '-', $val);
-      if (isset($this->attrs["$name"][0])) {
-        $this->$val = $this->attrs["$name"][0];
-      }
-    }
-
-    /* Toggle relayhost */
-    $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost);
-    $this->postfix_relayhost      = preg_replace("/[\[\]]/","",$this->postfix_relayhost);
-
-    /* Is this Server a member of the Kolab extension or not ?*/ 
-    if(isset($this->attrs['kolabHost'])) {
-      $this->kolabHost= $this->attrs['kolabHost'];
-      unset($this->kolabHost['count']);
-    }
-    $this->is_account            = false;
-    $this->initially_was_account = false;
-    foreach($this->kolabHost as $host){
-      if($this->hostname == $host){
-        $this->is_account            = true;
-        $this->initially_was_account = true;
-      }
-    } 
-  }
-
-
-  function execute() 
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","server/".get_class($this),$this->dn);
-    }
-
-    /***************  
-      Variable initialisation
-     ***************/  
-    
-    $smarty     = get_smarty();
-    $display    = "";
-    $ldap       = $this->config->get_ldap_link();
-
-
-    /* Assemble free/busy string */
-    $edit       = sprintf('<input name="kolabFreeBusyFuture" value="%s" type="text" maxlength="3" size="4">',
-                    $this->kolabFreeBusyFuture);
-    $fbfuture   = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit);
-
-    /* Assemble quota string */
-    $edit       = sprintf('<input name="cyrus_quotawarn" value="%s" type="text" maxlength="3" size="4">',
-                    $this->cyrus_quotawarn);
-    $quotastr   = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
-
-    /***************
-      Assign informations to smarty 
-     ***************/
-
-    /* Set relayhost and if we have MX lookup enabled*/ 
-    if($this->postfix_mxrelayenabled) {
-      $smarty->assign("RelayMxSupportCheck"," checked ");
-    } else {
-      $smarty->assign("RelayMxSupportCheck","");
-    }
-
-    /* Set acls */
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $name => $translation){
-      $smarty->assign($name."ACL",$this->getacl($name));
-    }
-
-    /* Initialize all attributes, that were submitted */
-    foreach($this->attributes as $val) 
-    {
-      /* Tell smarty which variables we are useing */
-      $smarty->assign($val, $this->$val);
-      if (($this->$val != "FALSE") && !empty($this->$val)){
-        $smarty->assign($val."Check", "checked");
-      } else {
-        $smarty->assign($val."Check", "");
-      }
-    }
-
-    $smarty->assign("fbfuture", $fbfuture);
-    $smarty->assign("quotastr", $quotastr);
-
-    /* Load Template */
-    $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE));
-    return ($display);
-  }
-
-  function remove_from_parent() 
-  {
-
-     /* Remove status flag, it is not a memeber of
-        this->attributes, so ensure that it is deleted too */
-    if(!empty($this->StatusFlag)){
-      $this->attrs[$this->StatusFlag] = array();
-    }
-
-
-    /* Only walk through following code, if this host 
-       was a member of the kolab hosts, else skip this */
-    if(!$this->initially_was_account){
-      return;
-    }
-
-    /* !!! Don't use "cn" in this function 
-       hostname -> the initial name of the host
-       cn       -> is the new name of the host, in case that it was renamed.
-     */
-
-    $ldap     = $this->config->get_ldap_link();
-    $this->dn = "k=kolab,".$this->config->current['BASE'];
-
-    /* We can't simply remove the whole entry, it is possible that there are 
-       some other hosts assigned to this object. 
-       So, first of all check if we are the last host entry within the host 
-       : Remove k=kolab entry 
-       if we aren't alone, only remove host name from hosts entry and save */
-    /* Are we alone? Remove complete entry... */
-
-    /* Check if we are definitly in kolabHosts */
-    if(!in_array_ics($this->hostname,$this->kolabHost)) {
-      return;
-    }
-
-    /* Integration check, not translated because they can't pop up at all, only for debug */ 
-    if(count($this->kolabHost) == 0){
-      print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
-      return;
-    }
-    if(!isset($this->hostname) || (empty($this->hostname))){
-      print_red("The required attribute hostname seams to empty.");
-    }
-
-    /* Our hostname is in kolabHosts and there is a only one entry 
-       = we are the last host entry, delete k=kolab entry  */
-    if (count($this->kolabHost) == 1){
-
-      /* Remove complete entry */
-      $ldap->rmdir ($this->dn);
-      show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
-    } else {
-
-      /* Only modify kolabHost */
-      $hosts= array();
-      foreach ($this->kolabHost as $host){
-        if($host != $this->hostname){
-          $hosts[]= $host;
-        }
-      }
-      $attrs= array('kolabHost' => $hosts);
-      $ldap->cd($this->dn);
-      $this->cleanup();
-      $ldap->modify ($attrs); 
-      show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
-    }
-
-    new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
-    /* Optionally execute a command after we're done */
-    $this->handle_post_events("remove");
-  }
-
-
-  function save_object()    
-  {
-    if (isset($_POST['kolabtab'])){
-      plugin::save_object();
-
-
-      foreach($this->attributes as $attr){
-        if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){
-          $this->$attr = $_POST[$attr];
-        }
-      }
-
-      /* Save checkboxes */
-      foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated",
-            "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
-            "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
-            "proftpd_ftp", "apache_http") as $cb){
-
-        if($this->acl_is_writeable(preg_replace("/_/","",$cb))){
-          if (isset($_POST[$cb])){
-            $this->$cb= "TRUE";
-          } else {
-            $this->$cb= "FALSE";
-          }
-        }
-      }
-
-      /* Toggell relay check */
-      if($this->acl_is_writeable("postfixmxrelayenabled")){
-        $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
-      }
-    }
-
-  }
-
-
-  function check() 
-  {
-    /* Call common method to give check the hook */
-    $message= plugin::check();
-
-    if(($this->kolabFreeBusyFuture==""))    {
-      $message[] = _("Future days in Free/Busy settings must be set.");
-    }elseif(!tests::is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){
-      $message[] = _("Future days in Free/Busy settings must be a positive value.");
-    }
-
-    if(!is_int((int)($this->cyrus_quotawarn))) {
-      $message[] = _("The given Quota settings value must be a number.");
-    }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){
-      $message[] = _("Please choose a value between 1 and 100 for Quota settings.");
-    }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){
-      $message[] = _("Future days must be a value.");
-    }
-
-    if(empty($this->postfix_mynetworks)) { 
-      $message[] = _("No SMTP privileged networks set.");
-    }
-
-    /*if(empty($this->postfix_relayhost)) {
-      $message[] = _("No SMTP smarthost/relayhost set.");
-      }
-     */
-
-    return ($message);
-  }
-
-
-  /* Save to LDAP */
-  function save() 
-  {
-    /* Set ldap connection */
-    $ldap       = $this->config->get_ldap_link();
-
-    /* Open current dn*/
-    $this->dn   = "k=kolab,".$this->config->current['BASE'];
-
-    /* Adapt relayhost */
-    $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
-    if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
-      $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
-    }
-
-    /* Check if this server was renamed, in this case we have to remove old cn first*/
-    if($this->hostname != $this->cn){
-      $tmp = array();
-      if(in_array_ics($this->hostname,$this->kolabHost)){
-        foreach($this->kolabHost as $host){
-          if($host != $this->hostname){
-            $tmp[] = $host;
-          }
-        }
-        $this->kolabHost = $tmp;
-      }
-    }
-
-    /* Add ourselves to the list of kolabHost's if needed */
-    if (!in_array_ics($this->cn,$this->kolabHost)){
-      $this->kolabHost[]= $this->cn;
-    }
-
-    /* Call parents save to prepare $this->attrs */
-    plugin::save();
-
-    /* Save or modify? */
-    $ldap->cat($this->dn, array('dn'));
-    if (!$ldap->fetch()){
-      $mode= "add"; 
-    } else {
-      $mode= "modify";
-    }
-
-    /* Do attribute conversion */
-    foreach ($this->attrs as $key => $value){
-      if (preg_match('/_/', $key)){
-        $old_key= $key;
-        $key= preg_replace('/_/', '-', $key);
-        $this->attrs[$key]= $value;
-        unset($this->attrs[$old_key]);
-      }
-    }
-    /* Add kolab hosts */
-    $this->attrs['kolabHost']= $this->kolabHost;
-
-    /* Perform LDAP action */
-    $ldap->cd($this->dn);
-    $this->cleanup();;
-    $ldap->$mode($this->attrs);
-
-    if($mode == "add"){
-      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn));
-
-    /* Optionally execute a command after we're done */
-    if ($this->initially_was_account == $this->is_account) {
-      if ($this->is_modified) {
-        $this->handle_post_events("modify");
-      }
-    } else {
-      $this->handle_post_events("add");
-    }
-  }
-
-
-  function getListEntry()
-  {
-    $fields                 = goService::getListEntry();
-    $fields['Message']      = _("Kolab mail service");
-    $fields['AllowEdit']    = true;
-    return($fields);
-  }
-
-
-  /* Return plugin informations for acl handling */
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("Kolab"),
-          "plDescription" => _("Kolab mail service")." ("._("Services").")",
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 85,
-          "plSection"     => array("administration"),
-          "plCategory"    => array("server"),
-
-          "plProvidedAcls"=> array(
-            "postfixmydomain"                => _("Postfix mydomain") ,
-            "postfixmydestination"           => _("My destination") ,
-            "cyrusadmins"                    => _("Cyrus admins") ,
-            "proftpdftp"                     => _("FTP FreeBusy service") ,
-            "postfixmynetworks"              => _("SMTP privileged networks") ,
-            "postfixenablevirusscan"         => _("Enable virus scan") ,
-            "postfixrelayhost"               => _("Relayhost") ,
-            "postfixmxrelayenabled"          => _("Enable MX lookup for relayhost"),
-            "apachehttp"                     => _("HTTP FreeBusy service") ,
-            "apacheallowunauthenticatedfb"   => _("Allow unauthenticated free busy"),
-            "postfixallowunauthenticated"    => _("Accept Internet Mail") ,
-            "cyrusimap"                      => _("IMAP service") ,
-            "kolabFreeBusyFuture"            => _("kolabFreeBusyFuture") ,
-            "cyruspop3"                      => _("POP3 service") ,
-            "cyrusimaps"                     => _("IMAP/SSL service") ,
-            "cyruspop3s"                     => _("POP3/SSL service") ,
-            "cyrussieve"                     => _("Sieve service") ,
-            "cyrusquotawarn"                 => _("Quota settings")) 
-            ));
-  }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl b/gosa-core/plugins/admin/systems/services/kolab/servkolab.tpl
deleted file mode 100644 (file)
index ec83b78..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-<table summary="" style="width:100%">
- <tr>
-  <td style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;" width="50%">
-   <table summary="">
-    <tr>
-        <td colspan="2"><b>{t}Generic{/t}</b></td>
-       </tr>
-       <tr>
-               <td>{t}Postfix mydomain{/t}
-               </td>
-               <td>
-{render acl=$postfixmydomainACL}
-                       <input type="text" name="postfix_mydomain" value="{$postfix_mydomain}">
-{/render}
-               </td>
-       </tr>
-       <tr>
-               <td>{t}Postfix mydestination{/t}
-               </td>
-               <td>
-{render acl=$postfixmydestinationACL}
-                       <input type="text" name="postfix_mydestination" value="{$postfix_mydestination}">
-{/render}
-               </td>
-       </tr>
-       <tr>
-               <td>{t}Cyrus admins{/t}
-               </td>
-               <td>
-{render acl=$cyrusadminsACL}
-                       <input type="text" name="cyrus_admins" value="{$cyrus_admins}">
-{/render}
-               </td>
-       </tr>
-   </table>    
-   <p class="seperator" >&nbsp;</p>
-   <table summary="">
-    <tr>
-        <td colspan="2"><b>{t}Services{/t}</b></td>
-       </tr>
-       <tr>
-               <td>
-{render acl=$cyruspop3ACL}
-                       <input id="cyrus_pop3" name="cyrus_pop3" value="1" type="checkbox" {$cyrus_pop3Check}>
-{/render}
-               </td>
-               <td>
-                       <LABEL for="cyrus_pop3">{t}POP3 service{/t}</LABEL>
-               </td>
-       </tr>
-       <tr>
-        <td>
-{render acl=$cyruspop3sACL}
-            <input id="cyrus_pop3s" name="cyrus_pop3s" value="1" type="checkbox" {$cyrus_pop3sCheck}>
-{/render}
-        </td>
-               <td>
-                       <LABEL for="cyrus_pop3s">{t}POP3/SSL service{/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$cyrusimapACL}
-            <input id="cyrus_imap" name="cyrus_imap" value="1" type="checkbox" {$cyrus_imapCheck}>
-{/render}
-        </td>
-        <td>
-                       <LABEL for="cyrus_imap">{t}IMAP service{/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$cyrusimapsACL}
-            <input id="cyrus_imaps" name="cyrus_imaps" value="1" type="checkbox" {$cyrus_imapsCheck}>
-{/render}
-        </td>
-        <td>
-                       <LABEL for="cyrus_imaps">{t}IMAP/SSL service{/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$cyrussieveACL}
-            <input id="cyrus_sieve" name="cyrus_sieve" value="1" type="checkbox" {$cyrus_sieveCheck}>
-{/render}
-        </td>
-        <td>
-                       <LABEL for="cyrus_sieve">{t}Sieve service{/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$proftpdftpACL}
-            <input id="proftpd_ftp" name="proftpd_ftp" value="1" type="checkbox" {$proftpd_ftpCheck}>
-{/render}
-        </td>  
-        <td>
-                       <LABEL for="proftpd_ftp">{t}FTP FreeBusy service (legacy, not interoperable with Kolab2 FreeBusy){/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$apachehttpACL}
-            <input id="apache_http" name="apache_http" value="1" type="checkbox" {$apache_httpCheck}>
-{/render}
-        </td>
-        <td>
-                       <LABEL for="apache_http">{t}HTTP FreeBusy service (legacy){/t}</LABEL>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$postfixenablevirusscanACL}
-                       <input id="postfix_enable_virus_scan" name="postfix_enable_virus_scan" value="1" type="checkbox" {$postfix_enable_virus_scanCheck}>
-{/render}
-        </td>
-        <td>
-                       <LABEL for="postfix_enable_virus_scan">{t}Amavis email scanning (virus/spam){/t}</LABEL>
-               </td>
-       </tr>
-   </table>
-
-   <p class="seperator">&nbsp;</p>
-   <br>
-
-   <table summary="">
-    <tr>
-               <td> 
-                       <b>{t}Quota settings{/t}</b>
-               </td>
-       </tr>
-       <tr>
-               <td>
-{render acl=$cyrusquotawarnACL}
-                       {$quotastr}
-{/render}
-               </td>
-       </tr>
-   </table>
-  
-  </td>
-  <td style="vertical-align:top" width="50%">
-
-   <table summary="">
-    <tr>
-        <td colspan="2">
-            <b>{t}Free/Busy settings{/t}</b>
-        </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$apacheallowunauthenticatedfbACL}
-            <input name="apache_allow_unauthenticated_fb" value="1" type="checkbox" {$apache_allow_unauthenticated_fbCheck}> {t}Allow unauthenticated downloading of Free/Busy information{/t}
-{/render}
-        </td>
-        </tr>
-        <tr>
-        <td>
-{render acl=$kolabFreeBusyFutureACL}
-               {$fbfuture}
-{/render}
-       </td>
-     </tr>
-   </table>
-
-<p class="seperator">&nbsp;</p>
-<br>
-   <table summary="">
-    <tr>
-        <td>
-               <b>{t}SMTP privileged networks{/t}</b>
-               </td>
-    </tr>
-    <tr>
-         <td>
-           <LABEL for="postfix_mynetworks">{t}Hosts/networks allowed to relay{/t}</LABEL><br>
-{render acl=$postfixmynetworksACL}
-        <input id="postfix_mynetworks" name="postfix_mynetworks" size="60" maxlength="220" value="{$postfix_mynetworks}" type="text">
-{/render}
-               <br>
-               ( {t}Enter multiple values, seperated with{/t} , )
-       </td>
-     </tr>
-   </table>
-
-
-<p class="seperator">&nbsp;</p>
-<br>
-
-
-   <table summary="">
-    <tr>
-        <td>
-               <b>{t}SMTP smarthost/relayhost{/t}</b>
-               </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$postfixrelayhostACL}
-            <input id="RelayMxSupport" name="RelayMxSupport" value="1" type="checkbox" {$RelayMxSupportCheck}>
-{/render}
-                       <LABEL for="RelayMxSupport">{t}Enable MX lookup for relayhost{/t}</LABEL>
-               </td>
-     </tr>
-       <tr>    
-               <td>
-                   <LABEL for="postfix_relayhost">{t}Host used to relay mails{/t}</LABEL>&nbsp;
-{render acl=$postfixrelayhostACL}
-                       <input id="postfix_relayhost" name="postfix_relayhost" size="35" maxlength="120" value="{$postfix_relayhost}" type="text">
-{/render}
-               </td>
-       </tr>
-   </table>
-
-
-<p class="seperator">&nbsp;</p>
-<br>
-
-
-   <table summary="">
-    <tr>
-        <td>
-               <b>{t}Accept Internet Mail{/t}</b>
-               </td>
-    </tr>
-    <tr>
-        <td>
-{render acl=$postfixallowunauthenticatedACL}
-            <input id="postfix_allow_unauthenticated" name="postfix_allow_unauthenticated" value="1" type="checkbox" {$postfix_allow_unauthenticatedCheck}>
-{/render}
-               <LABEL for="postfix_allow_unauthenticated">{t}Accept mail from other domains over non-authenticated SMTP{/t}</LABEL>
-               </td>
-     </tr>
-   </table>
-
-
-  </td>
- </tr>
-</table>
-
-<input type="hidden" name="kolabtab">
-
-<p class="seperator">&nbsp;</p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
-    <input type='submit' name='SaveService' value='{t}Save{/t}'>
-    &nbsp;
-    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</div>
-
diff --git a/gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc b/gosa-plugins/kolab/admin/systems/services/kolab/class_servKolab.inc
new file mode 100644 (file)
index 0000000..08b75ea
--- /dev/null
@@ -0,0 +1,415 @@
+<?php
+
+class servkolab extends goService {
+  /* CLI vars */
+  var $cli_summary = "Manage server basic objects";
+  var $cli_description = "Some longer text\nfor help";
+  var $cli_parameters = array("eins"=>"Eins ist toll", "zwei"=>"Zwei ist noch besser");
+
+  var $postfix_mydomain                 = "";
+  var $cyrus_admins                     = "";
+  var $postfix_mydestination            = "";
+  var $postfix_mynetworks               = "127.0.0.1/8";
+  var $postfix_enable_virus_scan        = "TRUE";
+  var $postfix_relayhost                = "";
+  var $postfix_mxrelayenabled           =  true;
+  var $postfix_allow_unauthenticated     = "FALSE";
+  var $cyrus_quotawarn                  = "80";
+  var $kolabFreeBusyFuture              = "1";
+  var $k                                = "kolab";
+  var $cyrus_imap                       = "TRUE";
+  var $cyrus_pop3                       = "FALSE";
+  var $cyrus_imaps                      = "TRUE";
+  var $cyrus_pop3s                      = "TRUE";
+  var $cyrus_sieve                      = "TRUE";
+  var $apache_allow_unauthenticated_fb  = "TRUE";
+  var $proftpd_ftp                      = "FALSE";
+  var $apache_http                      = "TRUE";
+  var $kolabHost                        = array();
+  var $orig_cn                          = "";
+  var $view_logged                      = FALSE;
+
+  var $attributes =  array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k",
+      "postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
+      "postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
+      "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
+      "cyrus_quotawarn");
+  var $objectclasses = array("top", "kolab");
+
+  /* Serverservice vars */
+  var $conflicts    = array("goImapServer","goMailServer");
+  var $DisplayName  = "Kolab mail service";
+  var $StatusFlag   = "";
+
+  function servkolab(&$config, $dn = NULL, $parent= NULL) 
+  {
+    /* Setting the hostname and tell this Plugin that we are the kolab extension*/
+    $this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
+    $this->dn       = "k=kolab,".$config->current['BASE'];
+
+    /* Load variables, if given*/
+    plugin::plugin($config, $this->dn);
+
+    /* Copy needed attributes */
+    foreach($this->attributes as $val) {
+      $name = preg_replace('/_/', '-', $val);
+      if (isset($this->attrs["$name"][0])) {
+        $this->$val = $this->attrs["$name"][0];
+      }
+    }
+
+    /* Toggle relayhost */
+    $this->postfix_mxrelayenabled = preg_match('/^\[/', $this->postfix_relayhost);
+    $this->postfix_relayhost      = preg_replace("/[\[\]]/","",$this->postfix_relayhost);
+
+    /* Is this Server a member of the Kolab extension or not ?*/ 
+    if(isset($this->attrs['kolabHost'])) {
+      $this->kolabHost= $this->attrs['kolabHost'];
+      unset($this->kolabHost['count']);
+    }
+    $this->is_account            = false;
+    $this->initially_was_account = false;
+    foreach($this->kolabHost as $host){
+      if($this->hostname == $host){
+        $this->is_account            = true;
+        $this->initially_was_account = true;
+      }
+    } 
+  }
+
+
+  function execute() 
+  {
+    /* Call parent execute */
+    plugin::execute();
+
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","server/".get_class($this),$this->dn);
+    }
+
+    /***************  
+      Variable initialisation
+     ***************/  
+    
+    $smarty     = get_smarty();
+    $display    = "";
+    $ldap       = $this->config->get_ldap_link();
+
+
+    /* Assemble free/busy string */
+    $edit       = sprintf('<input name="kolabFreeBusyFuture" value="%s" type="text" maxlength="3" size="4">',
+                    $this->kolabFreeBusyFuture);
+    $fbfuture   = sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit);
+
+    /* Assemble quota string */
+    $edit       = sprintf('<input name="cyrus_quotawarn" value="%s" type="text" maxlength="3" size="4">',
+                    $this->cyrus_quotawarn);
+    $quotastr   = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
+
+    /***************
+      Assign informations to smarty 
+     ***************/
+
+    /* Set relayhost and if we have MX lookup enabled*/ 
+    if($this->postfix_mxrelayenabled) {
+      $smarty->assign("RelayMxSupportCheck"," checked ");
+    } else {
+      $smarty->assign("RelayMxSupportCheck","");
+    }
+
+    /* Set acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+    /* Initialize all attributes, that were submitted */
+    foreach($this->attributes as $val) 
+    {
+      /* Tell smarty which variables we are useing */
+      $smarty->assign($val, $this->$val);
+      if (($this->$val != "FALSE") && !empty($this->$val)){
+        $smarty->assign($val."Check", "checked");
+      } else {
+        $smarty->assign($val."Check", "");
+      }
+    }
+
+    $smarty->assign("fbfuture", $fbfuture);
+    $smarty->assign("quotastr", $quotastr);
+
+    /* Load Template */
+    $display.=$smarty->fetch(get_template_path('servkolab.tpl', TRUE));
+    return ($display);
+  }
+
+  function remove_from_parent() 
+  {
+
+     /* Remove status flag, it is not a memeber of
+        this->attributes, so ensure that it is deleted too */
+    if(!empty($this->StatusFlag)){
+      $this->attrs[$this->StatusFlag] = array();
+    }
+
+
+    /* Only walk through following code, if this host 
+       was a member of the kolab hosts, else skip this */
+    if(!$this->initially_was_account){
+      return;
+    }
+
+    /* !!! Don't use "cn" in this function 
+       hostname -> the initial name of the host
+       cn       -> is the new name of the host, in case that it was renamed.
+     */
+
+    $ldap     = $this->config->get_ldap_link();
+    $this->dn = "k=kolab,".$this->config->current['BASE'];
+
+    /* We can't simply remove the whole entry, it is possible that there are 
+       some other hosts assigned to this object. 
+       So, first of all check if we are the last host entry within the host 
+       : Remove k=kolab entry 
+       if we aren't alone, only remove host name from hosts entry and save */
+    /* Are we alone? Remove complete entry... */
+
+    /* Check if we are definitly in kolabHosts */
+    if(!in_array_ics($this->hostname,$this->kolabHost)) {
+      return;
+    }
+
+    /* Integration check, not translated because they can't pop up at all, only for debug */ 
+    if(count($this->kolabHost) == 0){
+      print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
+      return;
+    }
+    if(!isset($this->hostname) || (empty($this->hostname))){
+      print_red("The required attribute hostname seams to empty.");
+    }
+
+    /* Our hostname is in kolabHosts and there is a only one entry 
+       = we are the last host entry, delete k=kolab entry  */
+    if (count($this->kolabHost) == 1){
+
+      /* Remove complete entry */
+      $ldap->rmdir ($this->dn);
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
+    } else {
+
+      /* Only modify kolabHost */
+      $hosts= array();
+      foreach ($this->kolabHost as $host){
+        if($host != $this->hostname){
+          $hosts[]= $host;
+        }
+      }
+      $attrs= array('kolabHost' => $hosts);
+      $ldap->cd($this->dn);
+      $this->cleanup();
+      $ldap->modify ($attrs); 
+      show_ldap_error($ldap->get_error(), sprintf(_("Removing host entry from system server/kolab with dn '%s' failed."),$this->dn));
+    }
+
+    new log("remove","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    /* Optionally execute a command after we're done */
+    $this->handle_post_events("remove");
+  }
+
+
+  function save_object()    
+  {
+    if (isset($_POST['kolabtab'])){
+      plugin::save_object();
+
+
+      foreach($this->attributes as $attr){
+        if(($this->acl_is_writeable(preg_replace("/_/","",$attr))) && (isset($_POST[$attr]))){
+          $this->$attr = $_POST[$attr];
+        }
+      }
+
+      /* Save checkboxes */
+      foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated",
+            "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
+            "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
+            "proftpd_ftp", "apache_http") as $cb){
+
+        if($this->acl_is_writeable(preg_replace("/_/","",$cb))){
+          if (isset($_POST[$cb])){
+            $this->$cb= "TRUE";
+          } else {
+            $this->$cb= "FALSE";
+          }
+        }
+      }
+
+      /* Toggell relay check */
+      if($this->acl_is_writeable("postfixmxrelayenabled")){
+        $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
+      }
+    }
+
+  }
+
+
+  function check() 
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    if(($this->kolabFreeBusyFuture==""))    {
+      $message[] = _("Future days in Free/Busy settings must be set.");
+    }elseif(!tests::is_uid($this->kolabFreeBusyFuture) || $this->kolabFreeBusyFuture < 0){
+      $message[] = _("Future days in Free/Busy settings must be a positive value.");
+    }
+
+    if(!is_int((int)($this->cyrus_quotawarn))) {
+      $message[] = _("The given Quota settings value must be a number.");
+    }elseif(!(($this->cyrus_quotawarn<=100)&&($this->cyrus_quotawarn>=0))){
+      $message[] = _("Please choose a value between 1 and 100 for Quota settings.");
+    }elseif(strcasecmp($this->cyrus_quotawarn,(int)$this->cyrus_quotawarn)){
+      $message[] = _("Future days must be a value.");
+    }
+
+    if(empty($this->postfix_mynetworks)) { 
+      $message[] = _("No SMTP privileged networks set.");
+    }
+
+    /*if(empty($this->postfix_relayhost)) {
+      $message[] = _("No SMTP smarthost/relayhost set.");
+      }
+     */
+
+    return ($message);
+  }
+
+
+  /* Save to LDAP */
+  function save() 
+  {
+    /* Set ldap connection */
+    $ldap       = $this->config->get_ldap_link();
+
+    /* Open current dn*/
+    $this->dn   = "k=kolab,".$this->config->current['BASE'];
+
+    /* Adapt relayhost */
+    $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
+    if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
+      $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
+    }
+
+    /* Check if this server was renamed, in this case we have to remove old cn first*/
+    if($this->hostname != $this->cn){
+      $tmp = array();
+      if(in_array_ics($this->hostname,$this->kolabHost)){
+        foreach($this->kolabHost as $host){
+          if($host != $this->hostname){
+            $tmp[] = $host;
+          }
+        }
+        $this->kolabHost = $tmp;
+      }
+    }
+
+    /* Add ourselves to the list of kolabHost's if needed */
+    if (!in_array_ics($this->cn,$this->kolabHost)){
+      $this->kolabHost[]= $this->cn;
+    }
+
+    /* Call parents save to prepare $this->attrs */
+    plugin::save();
+
+    /* Save or modify? */
+    $ldap->cat($this->dn, array('dn'));
+    if (!$ldap->fetch()){
+      $mode= "add"; 
+    } else {
+      $mode= "modify";
+    }
+
+    /* Do attribute conversion */
+    foreach ($this->attrs as $key => $value){
+      if (preg_match('/_/', $key)){
+        $old_key= $key;
+        $key= preg_replace('/_/', '-', $key);
+        $this->attrs[$key]= $value;
+        unset($this->attrs[$old_key]);
+      }
+    }
+    /* Add kolab hosts */
+    $this->attrs['kolabHost']= $this->kolabHost;
+
+    /* Perform LDAP action */
+    $ldap->cd($this->dn);
+    $this->cleanup();;
+    $ldap->$mode($this->attrs);
+
+    if($mode == "add"){
+      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving system server/kolab with dn '%s' failed."),$this->dn));
+
+    /* Optionally execute a command after we're done */
+    if ($this->initially_was_account == $this->is_account) {
+      if ($this->is_modified) {
+        $this->handle_post_events("modify");
+      }
+    } else {
+      $this->handle_post_events("add");
+    }
+  }
+
+
+  function getListEntry()
+  {
+    $fields                 = goService::getListEntry();
+    $fields['Message']      = _("Kolab mail service");
+    $fields['AllowEdit']    = true;
+    return($fields);
+  }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Kolab"),
+          "plDescription" => _("Kolab mail service")." ("._("Services").")",
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 85,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("server"),
+
+          "plProvidedAcls"=> array(
+            "postfixmydomain"                => _("Postfix mydomain") ,
+            "postfixmydestination"           => _("My destination") ,
+            "cyrusadmins"                    => _("Cyrus admins") ,
+            "proftpdftp"                     => _("FTP FreeBusy service") ,
+            "postfixmynetworks"              => _("SMTP privileged networks") ,
+            "postfixenablevirusscan"         => _("Enable virus scan") ,
+            "postfixrelayhost"               => _("Relayhost") ,
+            "postfixmxrelayenabled"          => _("Enable MX lookup for relayhost"),
+            "apachehttp"                     => _("HTTP FreeBusy service") ,
+            "apacheallowunauthenticatedfb"   => _("Allow unauthenticated free busy"),
+            "postfixallowunauthenticated"    => _("Accept Internet Mail") ,
+            "cyrusimap"                      => _("IMAP service") ,
+            "kolabFreeBusyFuture"            => _("kolabFreeBusyFuture") ,
+            "cyruspop3"                      => _("POP3 service") ,
+            "cyrusimaps"                     => _("IMAP/SSL service") ,
+            "cyruspop3s"                     => _("POP3/SSL service") ,
+            "cyrussieve"                     => _("Sieve service") ,
+            "cyrusquotawarn"                 => _("Quota settings")) 
+            ));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl b/gosa-plugins/kolab/admin/systems/services/kolab/servkolab.tpl
new file mode 100644 (file)
index 0000000..ec83b78
--- /dev/null
@@ -0,0 +1,249 @@
+<table summary="" style="width:100%">
+ <tr>
+  <td style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;" width="50%">
+   <table summary="">
+    <tr>
+        <td colspan="2"><b>{t}Generic{/t}</b></td>
+       </tr>
+       <tr>
+               <td>{t}Postfix mydomain{/t}
+               </td>
+               <td>
+{render acl=$postfixmydomainACL}
+                       <input type="text" name="postfix_mydomain" value="{$postfix_mydomain}">
+{/render}
+               </td>
+       </tr>
+       <tr>
+               <td>{t}Postfix mydestination{/t}
+               </td>
+               <td>
+{render acl=$postfixmydestinationACL}
+                       <input type="text" name="postfix_mydestination" value="{$postfix_mydestination}">
+{/render}
+               </td>
+       </tr>
+       <tr>
+               <td>{t}Cyrus admins{/t}
+               </td>
+               <td>
+{render acl=$cyrusadminsACL}
+                       <input type="text" name="cyrus_admins" value="{$cyrus_admins}">
+{/render}
+               </td>
+       </tr>
+   </table>    
+   <p class="seperator" >&nbsp;</p>
+   <table summary="">
+    <tr>
+        <td colspan="2"><b>{t}Services{/t}</b></td>
+       </tr>
+       <tr>
+               <td>
+{render acl=$cyruspop3ACL}
+                       <input id="cyrus_pop3" name="cyrus_pop3" value="1" type="checkbox" {$cyrus_pop3Check}>
+{/render}
+               </td>
+               <td>
+                       <LABEL for="cyrus_pop3">{t}POP3 service{/t}</LABEL>
+               </td>
+       </tr>
+       <tr>
+        <td>
+{render acl=$cyruspop3sACL}
+            <input id="cyrus_pop3s" name="cyrus_pop3s" value="1" type="checkbox" {$cyrus_pop3sCheck}>
+{/render}
+        </td>
+               <td>
+                       <LABEL for="cyrus_pop3s">{t}POP3/SSL service{/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$cyrusimapACL}
+            <input id="cyrus_imap" name="cyrus_imap" value="1" type="checkbox" {$cyrus_imapCheck}>
+{/render}
+        </td>
+        <td>
+                       <LABEL for="cyrus_imap">{t}IMAP service{/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$cyrusimapsACL}
+            <input id="cyrus_imaps" name="cyrus_imaps" value="1" type="checkbox" {$cyrus_imapsCheck}>
+{/render}
+        </td>
+        <td>
+                       <LABEL for="cyrus_imaps">{t}IMAP/SSL service{/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$cyrussieveACL}
+            <input id="cyrus_sieve" name="cyrus_sieve" value="1" type="checkbox" {$cyrus_sieveCheck}>
+{/render}
+        </td>
+        <td>
+                       <LABEL for="cyrus_sieve">{t}Sieve service{/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$proftpdftpACL}
+            <input id="proftpd_ftp" name="proftpd_ftp" value="1" type="checkbox" {$proftpd_ftpCheck}>
+{/render}
+        </td>  
+        <td>
+                       <LABEL for="proftpd_ftp">{t}FTP FreeBusy service (legacy, not interoperable with Kolab2 FreeBusy){/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$apachehttpACL}
+            <input id="apache_http" name="apache_http" value="1" type="checkbox" {$apache_httpCheck}>
+{/render}
+        </td>
+        <td>
+                       <LABEL for="apache_http">{t}HTTP FreeBusy service (legacy){/t}</LABEL>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$postfixenablevirusscanACL}
+                       <input id="postfix_enable_virus_scan" name="postfix_enable_virus_scan" value="1" type="checkbox" {$postfix_enable_virus_scanCheck}>
+{/render}
+        </td>
+        <td>
+                       <LABEL for="postfix_enable_virus_scan">{t}Amavis email scanning (virus/spam){/t}</LABEL>
+               </td>
+       </tr>
+   </table>
+
+   <p class="seperator">&nbsp;</p>
+   <br>
+
+   <table summary="">
+    <tr>
+               <td> 
+                       <b>{t}Quota settings{/t}</b>
+               </td>
+       </tr>
+       <tr>
+               <td>
+{render acl=$cyrusquotawarnACL}
+                       {$quotastr}
+{/render}
+               </td>
+       </tr>
+   </table>
+  
+  </td>
+  <td style="vertical-align:top" width="50%">
+
+   <table summary="">
+    <tr>
+        <td colspan="2">
+            <b>{t}Free/Busy settings{/t}</b>
+        </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$apacheallowunauthenticatedfbACL}
+            <input name="apache_allow_unauthenticated_fb" value="1" type="checkbox" {$apache_allow_unauthenticated_fbCheck}> {t}Allow unauthenticated downloading of Free/Busy information{/t}
+{/render}
+        </td>
+        </tr>
+        <tr>
+        <td>
+{render acl=$kolabFreeBusyFutureACL}
+               {$fbfuture}
+{/render}
+       </td>
+     </tr>
+   </table>
+
+<p class="seperator">&nbsp;</p>
+<br>
+   <table summary="">
+    <tr>
+        <td>
+               <b>{t}SMTP privileged networks{/t}</b>
+               </td>
+    </tr>
+    <tr>
+         <td>
+           <LABEL for="postfix_mynetworks">{t}Hosts/networks allowed to relay{/t}</LABEL><br>
+{render acl=$postfixmynetworksACL}
+        <input id="postfix_mynetworks" name="postfix_mynetworks" size="60" maxlength="220" value="{$postfix_mynetworks}" type="text">
+{/render}
+               <br>
+               ( {t}Enter multiple values, seperated with{/t} , )
+       </td>
+     </tr>
+   </table>
+
+
+<p class="seperator">&nbsp;</p>
+<br>
+
+
+   <table summary="">
+    <tr>
+        <td>
+               <b>{t}SMTP smarthost/relayhost{/t}</b>
+               </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$postfixrelayhostACL}
+            <input id="RelayMxSupport" name="RelayMxSupport" value="1" type="checkbox" {$RelayMxSupportCheck}>
+{/render}
+                       <LABEL for="RelayMxSupport">{t}Enable MX lookup for relayhost{/t}</LABEL>
+               </td>
+     </tr>
+       <tr>    
+               <td>
+                   <LABEL for="postfix_relayhost">{t}Host used to relay mails{/t}</LABEL>&nbsp;
+{render acl=$postfixrelayhostACL}
+                       <input id="postfix_relayhost" name="postfix_relayhost" size="35" maxlength="120" value="{$postfix_relayhost}" type="text">
+{/render}
+               </td>
+       </tr>
+   </table>
+
+
+<p class="seperator">&nbsp;</p>
+<br>
+
+
+   <table summary="">
+    <tr>
+        <td>
+               <b>{t}Accept Internet Mail{/t}</b>
+               </td>
+    </tr>
+    <tr>
+        <td>
+{render acl=$postfixallowunauthenticatedACL}
+            <input id="postfix_allow_unauthenticated" name="postfix_allow_unauthenticated" value="1" type="checkbox" {$postfix_allow_unauthenticatedCheck}>
+{/render}
+               <LABEL for="postfix_allow_unauthenticated">{t}Accept mail from other domains over non-authenticated SMTP{/t}</LABEL>
+               </td>
+     </tr>
+   </table>
+
+
+  </td>
+ </tr>
+</table>
+
+<input type="hidden" name="kolabtab">
+
+<p class="seperator">&nbsp;</p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+    <input type='submit' name='SaveService' value='{t}Save{/t}'>
+    &nbsp;
+    <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</div>
+
diff --git a/gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc b/gosa-plugins/kolab/personal/connectivity/class_kolabAccount.inc
deleted file mode 100644 (file)
index a9149d4..0000000
+++ /dev/null
@@ -1,602 +0,0 @@
-<?php
-class kolabAccount extends plugin
-{
-  /* Definitions */
-  var $plHeadline       = "Kolab";
-  var $plDescription    = "This does something";
-
-  /* Kolab attributes */
-  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","kolabDelegate","kolabInvitationPolicy");
-  var $objectclasses  = array("kolabInetOrgPerson");
-
-  /* Helper */
-  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);
-
-    /* Setting uid to default */
-    if(isset($this->attrs['uid'][0])){
-      $this->uid = $this->attrs['uid'][0];
-    }
-
-    /* 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++){
-          $tmp[]=$this->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");
-    }
-
-    /* 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;
-      }
-    } 
-
-    /* Transfer account states for this union */
-    if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){
-      $this->mail_Account = true;
-     }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){
-       $this->mail_Account= true;
-     }else{
-       $this->is_account  = false;
-      $this->mail_Account = false;
-    }
-  }
-
-    
-  /*! \brief Create thml output 
-   */
-  function execute()
-  {
-         /* Call parent execute */
-       plugin::execute();
-
-    /* Log view */
-    if($this->is_account && !$this->view_logged){
-      $this->view_logged = TRUE;
-      new log("view","users/".get_class($this),$this->dn);
-    }
-
-    /* Show tab dialog headers */
-    $display= "";
-
-    /* Show main page */
-    $smarty= get_smarty();
-
-    /* Load attributes */
-    foreach($this->attributes as $val){
-      $smarty->assign("$val", $this->$val);
-    }
-
-    $tmp = $this->plInfo();
-    foreach($tmp['plProvidedAcls'] as $acl => $description){
-      $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly));
-      $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly));
-    }
-    $smarty->assign("is_account" ,  $this->is_account); 
-
-    if($this->ReadOnly){
-      $smarty->assign("is_removeable",false); 
-      $smarty->assign("is_createable",false); 
-    }else{
-      $smarty->assign("is_removeable",$this->acl_is_removeable()); 
-      $smarty->assign("is_createable",$this->acl_is_createable()); 
-    }
-
-    /* Check for invitation action */
-    $nr= 0;
-  
-    foreach($_POST as $name => $value){
-      if(preg_match("/add_inv_/",$name)){
-        $this->kolabInvitationPolicy[]= ": ACT_MANUAL";
-      }
-    }
-    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[$id].":/", $entry)){
-            $new[]= $entry;
-          }
-        }
-        $this->kolabInvitationPolicy= $new;
-      }
-    }
-
-    /* Unify addresses */
-    $new= array();
-    foreach($this->kolabInvitationPolicy as $value){
-      $address= preg_replace('/^([^:]+:).*$/', '\1', $value);
-      $new[$address]= $value;
-    }
-    $this->kolabInvitationPolicy= array();
-    foreach($new as $value){
-      $this->kolabInvitationPolicy[]= $value;
-    }
-
-    /* Add delegation */
-    if (isset($_POST['add_delegation'])){
-      if ($_POST['delegate_address'] != ""){
-
-        /* Valid email address specified? */
-        $address= $_POST['delegate_address'];
-        $valid= FALSE;
-        if (!tests::is_email($address)){
-          if (!tests::is_email($address, TRUE)){
-              msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
-          }
-        } else {
-
-          $ldap= $this->config->get_ldap_link();
-          $ldap->cd ($this->config->current['BASE']);
-          $ldap->search('(mail='.$address.')',array("mail"));
-          if ($ldap->count() == 0){
-            msg_dialog::display(_("Error"), _("Primary mail address already in use by another user!"), ERROR_DIALOG);
-          } else {
-            $valid= TRUE;
-          }
-        }
-
-        if ($valid){
-          /* Add it */
-          if ($this->acl_is_writeable("kolabDelegate")){
-            $this->addDelegate ($address);
-            $this->is_modified= TRUE;
-          }
-
-        }
-      }
-    }
-
-    /* Delete forward email addresses */
-    if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){
-      if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){
-        $this->delDelegate ($_POST['delegate_list']);
-      }
-    }
-
-    /* Assemble policies */
-    $policies= array( 'ACT_ALWAYS_ACCEPT'       => _("Always accept"),
-                      'ACT_ALWAYS_REJECT'       => _("Always reject"),
-                      'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"),
-                      'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"),
-                      'ACT_MANUAL'              => _("Manual"));
-    $smarty->assign('policies', $policies);
-
-    /* Adjust checkbox */
-    if ($this->unrestrictedMailSize){
-      $smarty->assign('unrestrictedMailSizeState', "checked");
-    } else {
-      $smarty->assign('unrestrictedMailSizeState', "");
-    }
-
-    /* Transfer delegation list */
-    if (!count($this->kolabDelegate)){
-      /* Smarty will produce <option value=""></option> and tidy don't like that, so tell smarty to create no option (array();)*/
-      $smarty->assign("kolabDelegate", array());
-    } else {
-      $smarty->assign("kolabDelegate", $this->kolabDelegate);
-    }
-
-    $smarty->assign("mail_account",$this->mail_Account);
-
-    /* Create InvitationPolicy table */
-    $invitation= "";
-    $this->imapping= array();
-    $nr= 0;
-    $changeState  = "";
-    foreach ($this->kolabInvitationPolicy as $entry){
-
-      if($this->acl_is_writeable("kolabInvitationPolicy")){
-        $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n
-          changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
-      }
-
-      if(!$this->acl_is_writeable("kolabInvitationPolicy") && !$this->multiple_support_active){
-        $dis = " disabled ";
-      }else{
-        if($this->is_account || $this->multiple_support_active){
-          $dis = " ";
-        }else{
-          $dis = " disabled ";
-        }
-      }
-      $invitation.= "<tr><td>";
-
-      if(!$this->acl_is_readable("kolabInvitationPolicy"))    {
-      }
-
-      /* The default entry does not have colons... */
-      if (!preg_match('/:/', $entry)){
-        $invitation.= _("Anonymous");
-        $name= "";
-        $mode= $entry;
-      } else {
-        $name= preg_replace('/:.*$/', '', $entry);
-        $mode= preg_replace('/^[^:]*: */', '', $entry);
-
-        if(!$this->acl_is_readable("kolabInvitationPolicy")){
-          $name='';
-        }
-        $invitation.= "<input name=\"address$nr\" size=16 maxlength=60  value=\"$name\" id='address".$nr."' ".$dis.">";
-      }
-      $invitation.= "</td>";
-
-      /* Add mode switch */
-      $invitation.= "<td><select size=\"1\" name=\"policy$nr\" id='policy".$nr."' ".$dis.">";
-      foreach($policies as $key => $value){
-        if ($key == $mode){
-          $invitation.= "<option value=\"$key\" selected>$value</option>";
-        } else {
-          $invitation.= "<option value=\"$key\">$value</option>";
-        }
-      }
-      
-      /* Assign buttons */
-      $button= "";
-      if ($nr == count($this->kolabInvitationPolicy)-1){
-        $button= "<input type='image' name=\"add_inv_".$nr."\" src='images/list_new.png' id='add".$nr."' ".$dis.">";
-      }
-      if ($nr != 0) {
-        $button.= "<input type='image' name=\"del_inv_".$nr."\" src='images/edittrash.png' id='remove".$nr."' ".$dis.">";
-      }
-      
-      $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);
-
-  
-    $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);
-  }
-
-  function remove_from_parent()
-  {
-    if(!$this->initially_was_account){
-      return;
-    }
-  
-    /* 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);
-
-    /* Log last action */
-    new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-
-    $this->handle_post_events('remove',array("uid" => $this->uid));
-    show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn));
-  }
-
-
-  function check()
-  {
-    /* Call common method to give check the hook */
-    $message= plugin::check();
-
-    /* FBFuture is in days... */
-    if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){
-      $message[]= _("The value specified as Free Busy future needs to be an integer.");
-    }
-
-    /* Check for URL scheme... */
-    if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){
-      $message[]= _("The value specified as Free Busy Information URL is invalid.");
-    }
-
-    /* Check invitation policy for existing mail addresses */
-    foreach($this->kolabInvitationPolicy as $policy){
-      
-      /* Ignore anonymous string */
-      if (!preg_match('/:/', $policy)){
-        continue;
-      }
-      
-      $address= preg_replace('/^([^:]+).*$/', '\1', $policy);
-      if (!tests::is_email($address)){
-        if (!tests::is_email($address, TRUE)){
-          $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address);
-        }
-      } else {
-
-        $ldap= $this->config->get_ldap_link();
-        $ldap->cd ($this->config->current['BASE']);
-        $ldap->search('(mail='.$address.')',array("mail"));
-        if ($ldap->count() == 0){
-          $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address);
-        } else {
-          $valid= TRUE;
-        }
-      }
-    }
-
-    return ($message);
-  }
-
-  /* Save data to object */
-  function save_object()
-  {
-    /* Do we need to flip is_account state? */
-    if (isset($_POST['connectivityTab'])){
-
-      if(isset($_POST["kolabState"])){
-        if($this->acl_is_createable()){
-          $this->is_account = true;
-        }
-      }else{
-        if($this->acl_is_removeable()){
-          $this->is_account = false;
-        }
-      }
-      if ($this->acl_is_writeable("unrestrictedMailSize")){
-        if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){
-          $this->unrestrictedMailSize= 1;
-        } else {
-          $this->unrestrictedMailSize= 0;
-        }
-      }
-    }
-
-    plugin::save_object();
-
-    /* Save changes done in invitation policies */
-    if($this->acl_is_writeable("kolabInvitationPolicy")){
-
-      $nr= 0;
-      $this->kolabInvitationPolicy= array();
-      while (isset($_POST["policy$nr"])){
-
-        /* Anonymous? */
-        if (!isset($_POST["address$nr"])){
-          $this->kolabInvitationPolicy[]= $_POST["policy$nr"];
-        } else {
-          $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"];
-        }
-
-        $nr++;
-      }
-
-      /* If this one is empty, preset with ACT_MANUAL for anonymous users */
-      if (count ($this->kolabInvitationPolicy) == 0){
-        $this->kolabInvitationPolicy= array("ACT_MANUAL");
-      }
-    }
-  }
-
-
-  /* Save to LDAP */
-  function save()
-  {
-    /* Check mailmethod before doing something useful */
-    plugin::save();
-
-    /* Transfer arrays */
-    $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); 
-
-    /* Log last action */
-    if($this->initially_was_account){
-      new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }else{
-      new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
-    }
-
-    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){
-      if ($this->is_modified){
-        $this->handle_post_events("modify",array("uid" => $this->uid));
-      }
-    } else {
-      $this->handle_post_events("add",array("uid" => $this->uid));
-    }
-  }
-
-
-  /* Add entry to delegation list */
-  function addDelegate($address)
-  {
-    $this->kolabDelegate[]= $address;
-    $this->kolabDelegate= array_unique ($this->kolabDelegate);
-
-    sort ($this->kolabDelegate);
-    reset ($this->kolabDelegate);
-    $this->is_modified= TRUE;
-  }
-
-  function delDelegate($addresses)
-  {
-    $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate);
-    $this->is_modified= TRUE;
-  }
-
-
-  /* Return plugin informations for acl handling  */
-  static function plInfo()
-  {
-    return (array(     
-          "plShortName"     => _("Kolab"),
-          "plDescription"   => _("Kolab account settings")."&nbsp;:&nbsp;<u>"._("Connectivity addon")."</u>",
-          "plSelfModify"    => TRUE,
-          "plDepends"       => array("user"),
-          "plPriority"      => 20,                                 // Position in tabs
-          "plSection"     => array("personal" => _("My account")),
-          "plCategory"    => array("users"),
-          "plOptions"       => array(),
-
-          "plProvidedAcls"  => array(
-            "kolabFreeBusyFuture"   => _("Free busy future"),
-            "unrestrictedMailSize"  => _("Mail size restriction"),
-            "calFBURL"              => _("Free busy information"),
-            "kolabDelegate"         => _("Delegations"),
-            "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:
-?>
diff --git a/gosa-plugins/kolab/personal/connectivity/kolab.tpl b/gosa-plugins/kolab/personal/connectivity/kolab.tpl
deleted file mode 100644 (file)
index c05bfb1..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-
-{if !$mail_account}
-       <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}
-
-<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}>
-
-{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}
-       onClick="
-       {if $kolabDelegate_W}
-       changeState('delegate_list');
-       changeState('delegate_address');
-       changeState('add_delegation');
-       changeState('delete_delegation');
-       {/if}
-       {if $unrestrictedMailSize_W}
-       changeState('unrestrictedMailSize');
-       {/if}
-       {if $calFBURL_W}
-       changeState('calFBURL');
-       {/if}
-       {if $kolabFreeBusyFuture_W}
-       changeState('kolabFreeBusyFuture');
-       {/if}
-       {if $kolabInvitationPolicy_W}
-       {$changeState}
-       {/if}">
-{/if}
-
-{t}Kolab account{/t}</h2>
-<table summary="" style="width:100%">
- <tr>
-  <td style="width:50%; vertical-align:top;">
-
-{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>
-   <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}
-  </td>
-  <td rowspan=2 style="border-left:1px solid #A0A0A0">
-   &nbsp;
-  </td>
-  <td style="vertical-align:top;">
-
- <h2>{t}Free Busy information{/t}</h2>
- <table summary="">
-  <tr>
-   <td><LABEL for="calFBURL">{t}URL{/t}</LABEL></td>
-   <td>
-{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 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>
-  </tr>
- </table>
-
-
-<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>
-
-{/if}
diff --git a/gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc b/gosa-plugins/kolab/personal/connectivity/kolab/class_kolabAccount.inc
new file mode 100644 (file)
index 0000000..a9149d4
--- /dev/null
@@ -0,0 +1,602 @@
+<?php
+class kolabAccount extends plugin
+{
+  /* Definitions */
+  var $plHeadline       = "Kolab";
+  var $plDescription    = "This does something";
+
+  /* Kolab attributes */
+  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","kolabDelegate","kolabInvitationPolicy");
+  var $objectclasses  = array("kolabInetOrgPerson");
+
+  /* Helper */
+  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);
+
+    /* Setting uid to default */
+    if(isset($this->attrs['uid'][0])){
+      $this->uid = $this->attrs['uid'][0];
+    }
+
+    /* 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++){
+          $tmp[]=$this->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");
+    }
+
+    /* 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;
+      }
+    } 
+
+    /* Transfer account states for this union */
+    if (isset($this->parent->by_object['mailAccount']) && $this->parent->by_object['mailAccount']->is_account){
+      $this->mail_Account = true;
+     }elseif( isset($this->attrs) && isset($this->attrs['kolabHomeServer'])){
+       $this->mail_Account= true;
+     }else{
+       $this->is_account  = false;
+      $this->mail_Account = false;
+    }
+  }
+
+    
+  /*! \brief Create thml output 
+   */
+  function execute()
+  {
+         /* Call parent execute */
+       plugin::execute();
+
+    /* Log view */
+    if($this->is_account && !$this->view_logged){
+      $this->view_logged = TRUE;
+      new log("view","users/".get_class($this),$this->dn);
+    }
+
+    /* Show tab dialog headers */
+    $display= "";
+
+    /* Show main page */
+    $smarty= get_smarty();
+
+    /* Load attributes */
+    foreach($this->attributes as $val){
+      $smarty->assign("$val", $this->$val);
+    }
+
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $acl => $description){
+      $smarty->assign($acl."ACL",$this->getacl($acl,$this->ReadOnly));
+      $smarty->assign($acl."_W", $this->acl_is_writeable($acl,$this->ReadOnly));
+    }
+    $smarty->assign("is_account" ,  $this->is_account); 
+
+    if($this->ReadOnly){
+      $smarty->assign("is_removeable",false); 
+      $smarty->assign("is_createable",false); 
+    }else{
+      $smarty->assign("is_removeable",$this->acl_is_removeable()); 
+      $smarty->assign("is_createable",$this->acl_is_createable()); 
+    }
+
+    /* Check for invitation action */
+    $nr= 0;
+  
+    foreach($_POST as $name => $value){
+      if(preg_match("/add_inv_/",$name)){
+        $this->kolabInvitationPolicy[]= ": ACT_MANUAL";
+      }
+    }
+    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[$id].":/", $entry)){
+            $new[]= $entry;
+          }
+        }
+        $this->kolabInvitationPolicy= $new;
+      }
+    }
+
+    /* Unify addresses */
+    $new= array();
+    foreach($this->kolabInvitationPolicy as $value){
+      $address= preg_replace('/^([^:]+:).*$/', '\1', $value);
+      $new[$address]= $value;
+    }
+    $this->kolabInvitationPolicy= array();
+    foreach($new as $value){
+      $this->kolabInvitationPolicy[]= $value;
+    }
+
+    /* Add delegation */
+    if (isset($_POST['add_delegation'])){
+      if ($_POST['delegate_address'] != ""){
+
+        /* Valid email address specified? */
+        $address= $_POST['delegate_address'];
+        $valid= FALSE;
+        if (!tests::is_email($address)){
+          if (!tests::is_email($address, TRUE)){
+              msg_dialog::display(_("Error"), _("Cannot add invalid mail address!"), ERROR_DIALOG);
+          }
+        } else {
+
+          $ldap= $this->config->get_ldap_link();
+          $ldap->cd ($this->config->current['BASE']);
+          $ldap->search('(mail='.$address.')',array("mail"));
+          if ($ldap->count() == 0){
+            msg_dialog::display(_("Error"), _("Primary mail address already in use by another user!"), ERROR_DIALOG);
+          } else {
+            $valid= TRUE;
+          }
+        }
+
+        if ($valid){
+          /* Add it */
+          if ($this->acl_is_writeable("kolabDelegate")){
+            $this->addDelegate ($address);
+            $this->is_modified= TRUE;
+          }
+
+        }
+      }
+    }
+
+    /* Delete forward email addresses */
+    if ((isset($_POST['delete_delegation'])) && (isset($_POST['delegate_list']))){
+      if (count($_POST['delegate_list']) && $this->acl_is_writeable("kolabDelegate")){
+        $this->delDelegate ($_POST['delegate_list']);
+      }
+    }
+
+    /* Assemble policies */
+    $policies= array( 'ACT_ALWAYS_ACCEPT'       => _("Always accept"),
+                      'ACT_ALWAYS_REJECT'       => _("Always reject"),
+                      'ACT_REJECT_IF_CONFLICTS' => _("Reject if conflicts"),
+                      'ACT_MANUAL_IF_CONFLICTS' => _("Manual if conflicts"),
+                      'ACT_MANUAL'              => _("Manual"));
+    $smarty->assign('policies', $policies);
+
+    /* Adjust checkbox */
+    if ($this->unrestrictedMailSize){
+      $smarty->assign('unrestrictedMailSizeState', "checked");
+    } else {
+      $smarty->assign('unrestrictedMailSizeState', "");
+    }
+
+    /* Transfer delegation list */
+    if (!count($this->kolabDelegate)){
+      /* Smarty will produce <option value=""></option> and tidy don't like that, so tell smarty to create no option (array();)*/
+      $smarty->assign("kolabDelegate", array());
+    } else {
+      $smarty->assign("kolabDelegate", $this->kolabDelegate);
+    }
+
+    $smarty->assign("mail_account",$this->mail_Account);
+
+    /* Create InvitationPolicy table */
+    $invitation= "";
+    $this->imapping= array();
+    $nr= 0;
+    $changeState  = "";
+    foreach ($this->kolabInvitationPolicy as $entry){
+
+      if($this->acl_is_writeable("kolabInvitationPolicy")){
+        $changeState .= "changeState('address".$nr."'); \n changeState('policy".$nr."'); \n
+          changeState('add".$nr."'); \n changeState('remove".$nr."'); \n";
+      }
+
+      if(!$this->acl_is_writeable("kolabInvitationPolicy") && !$this->multiple_support_active){
+        $dis = " disabled ";
+      }else{
+        if($this->is_account || $this->multiple_support_active){
+          $dis = " ";
+        }else{
+          $dis = " disabled ";
+        }
+      }
+      $invitation.= "<tr><td>";
+
+      if(!$this->acl_is_readable("kolabInvitationPolicy"))    {
+      }
+
+      /* The default entry does not have colons... */
+      if (!preg_match('/:/', $entry)){
+        $invitation.= _("Anonymous");
+        $name= "";
+        $mode= $entry;
+      } else {
+        $name= preg_replace('/:.*$/', '', $entry);
+        $mode= preg_replace('/^[^:]*: */', '', $entry);
+
+        if(!$this->acl_is_readable("kolabInvitationPolicy")){
+          $name='';
+        }
+        $invitation.= "<input name=\"address$nr\" size=16 maxlength=60  value=\"$name\" id='address".$nr."' ".$dis.">";
+      }
+      $invitation.= "</td>";
+
+      /* Add mode switch */
+      $invitation.= "<td><select size=\"1\" name=\"policy$nr\" id='policy".$nr."' ".$dis.">";
+      foreach($policies as $key => $value){
+        if ($key == $mode){
+          $invitation.= "<option value=\"$key\" selected>$value</option>";
+        } else {
+          $invitation.= "<option value=\"$key\">$value</option>";
+        }
+      }
+      
+      /* Assign buttons */
+      $button= "";
+      if ($nr == count($this->kolabInvitationPolicy)-1){
+        $button= "<input type='image' name=\"add_inv_".$nr."\" src='images/list_new.png' id='add".$nr."' ".$dis.">";
+      }
+      if ($nr != 0) {
+        $button.= "<input type='image' name=\"del_inv_".$nr."\" src='images/edittrash.png' id='remove".$nr."' ".$dis.">";
+      }
+      
+      $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);
+
+  
+    $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);
+  }
+
+  function remove_from_parent()
+  {
+    if(!$this->initially_was_account){
+      return;
+    }
+  
+    /* 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);
+
+    /* Log last action */
+    new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+
+    $this->handle_post_events('remove',array("uid" => $this->uid));
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/kolab account with dn '%s' failed."),$this->dn));
+  }
+
+
+  function check()
+  {
+    /* Call common method to give check the hook */
+    $message= plugin::check();
+
+    /* FBFuture is in days... */
+    if ($this->kolabFreeBusyFuture != "" && !preg_match('/^[0-9]+$/', $this->kolabFreeBusyFuture)){
+      $message[]= _("The value specified as Free Busy future needs to be an integer.");
+    }
+
+    /* Check for URL scheme... */
+    if(!empty($this->calFBURL) && !preg_match("/http+(s)*:\/\//",$this->calFBURL)){
+      $message[]= _("The value specified as Free Busy Information URL is invalid.");
+    }
+
+    /* Check invitation policy for existing mail addresses */
+    foreach($this->kolabInvitationPolicy as $policy){
+      
+      /* Ignore anonymous string */
+      if (!preg_match('/:/', $policy)){
+        continue;
+      }
+      
+      $address= preg_replace('/^([^:]+).*$/', '\1', $policy);
+      if (!tests::is_email($address)){
+        if (!tests::is_email($address, TRUE)){
+          $message[]= sprintf(_("The invitation policy entry for address '%s' is not valid."), $address);
+        }
+      } else {
+
+        $ldap= $this->config->get_ldap_link();
+        $ldap->cd ($this->config->current['BASE']);
+        $ldap->search('(mail='.$address.')',array("mail"));
+        if ($ldap->count() == 0){
+          $message[]= sprintf(_("There's no mail user with address '%s' for your invitation policy!"), $address);
+        } else {
+          $valid= TRUE;
+        }
+      }
+    }
+
+    return ($message);
+  }
+
+  /* Save data to object */
+  function save_object()
+  {
+    /* Do we need to flip is_account state? */
+    if (isset($_POST['connectivityTab'])){
+
+      if(isset($_POST["kolabState"])){
+        if($this->acl_is_createable()){
+          $this->is_account = true;
+        }
+      }else{
+        if($this->acl_is_removeable()){
+          $this->is_account = false;
+        }
+      }
+      if ($this->acl_is_writeable("unrestrictedMailSize")){
+        if (isset($_POST['unrestrictedMailSize']) && $_POST['unrestrictedMailSize'] == 1){
+          $this->unrestrictedMailSize= 1;
+        } else {
+          $this->unrestrictedMailSize= 0;
+        }
+      }
+    }
+
+    plugin::save_object();
+
+    /* Save changes done in invitation policies */
+    if($this->acl_is_writeable("kolabInvitationPolicy")){
+
+      $nr= 0;
+      $this->kolabInvitationPolicy= array();
+      while (isset($_POST["policy$nr"])){
+
+        /* Anonymous? */
+        if (!isset($_POST["address$nr"])){
+          $this->kolabInvitationPolicy[]= $_POST["policy$nr"];
+        } else {
+          $this->kolabInvitationPolicy[]= $_POST["address$nr"].": ".$_POST["policy$nr"];
+        }
+
+        $nr++;
+      }
+
+      /* If this one is empty, preset with ACT_MANUAL for anonymous users */
+      if (count ($this->kolabInvitationPolicy) == 0){
+        $this->kolabInvitationPolicy= array("ACT_MANUAL");
+      }
+    }
+  }
+
+
+  /* Save to LDAP */
+  function save()
+  {
+    /* Check mailmethod before doing something useful */
+    plugin::save();
+
+    /* Transfer arrays */
+    $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); 
+
+    /* Log last action */
+    if($this->initially_was_account){
+      new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }else{
+      new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+    }
+
+    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){
+      if ($this->is_modified){
+        $this->handle_post_events("modify",array("uid" => $this->uid));
+      }
+    } else {
+      $this->handle_post_events("add",array("uid" => $this->uid));
+    }
+  }
+
+
+  /* Add entry to delegation list */
+  function addDelegate($address)
+  {
+    $this->kolabDelegate[]= $address;
+    $this->kolabDelegate= array_unique ($this->kolabDelegate);
+
+    sort ($this->kolabDelegate);
+    reset ($this->kolabDelegate);
+    $this->is_modified= TRUE;
+  }
+
+  function delDelegate($addresses)
+  {
+    $this->kolabDelegate= array_remove_entries ($addresses, $this->kolabDelegate);
+    $this->is_modified= TRUE;
+  }
+
+
+  /* Return plugin informations for acl handling  */
+  static function plInfo()
+  {
+    return (array(     
+          "plShortName"     => _("Kolab"),
+          "plDescription"   => _("Kolab account settings")."&nbsp;:&nbsp;<u>"._("Connectivity addon")."</u>",
+          "plSelfModify"    => TRUE,
+          "plDepends"       => array("user"),
+          "plPriority"      => 20,                                 // Position in tabs
+          "plSection"     => array("personal" => _("My account")),
+          "plCategory"    => array("users"),
+          "plOptions"       => array(),
+
+          "plProvidedAcls"  => array(
+            "kolabFreeBusyFuture"   => _("Free busy future"),
+            "unrestrictedMailSize"  => _("Mail size restriction"),
+            "calFBURL"              => _("Free busy information"),
+            "kolabDelegate"         => _("Delegations"),
+            "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:
+?>
diff --git a/gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl b/gosa-plugins/kolab/personal/connectivity/kolab/kolab.tpl
new file mode 100644 (file)
index 0000000..c05bfb1
--- /dev/null
@@ -0,0 +1,134 @@
+
+{if !$mail_account}
+       <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}
+
+<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}>
+
+{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}
+       onClick="
+       {if $kolabDelegate_W}
+       changeState('delegate_list');
+       changeState('delegate_address');
+       changeState('add_delegation');
+       changeState('delete_delegation');
+       {/if}
+       {if $unrestrictedMailSize_W}
+       changeState('unrestrictedMailSize');
+       {/if}
+       {if $calFBURL_W}
+       changeState('calFBURL');
+       {/if}
+       {if $kolabFreeBusyFuture_W}
+       changeState('kolabFreeBusyFuture');
+       {/if}
+       {if $kolabInvitationPolicy_W}
+       {$changeState}
+       {/if}">
+{/if}
+
+{t}Kolab account{/t}</h2>
+<table summary="" style="width:100%">
+ <tr>
+  <td style="width:50%; vertical-align:top;">
+
+{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>
+   <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}
+  </td>
+  <td rowspan=2 style="border-left:1px solid #A0A0A0">
+   &nbsp;
+  </td>
+  <td style="vertical-align:top;">
+
+ <h2>{t}Free Busy information{/t}</h2>
+ <table summary="">
+  <tr>
+   <td><LABEL for="calFBURL">{t}URL{/t}</LABEL></td>
+   <td>
+{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 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>
+  </tr>
+ </table>
+
+
+<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>
+
+{/if}
diff --git a/gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc b/gosa-plugins/kolab/personal/mail/class_mail-methods-golab.inc
deleted file mode 100644 (file)
index dc75674..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-<?php
-/*
-   This code is part of GOsa (https://gosa.gonicus.de)
-   Copyright (C) 2004  Cajus Pollmeier
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-class mailMethodGolab extends mailMethodCyrus
-{
-  var $mbox= "-";
-  var $config;
-  var $gosaMailServer= "";
-  var $uattrib= "mail";
-
-  var $attribute_map= array("gosaMailAlternateAddress"  =>  "alias",
-                            "gosaMailQuota"             =>  "cyrus-userquota",
-                            "gosaMailServer"            =>  "kolabHomeServer");
-
-  function mailMethodGolab(&$config)
-  {
-    $this->config= $config->data['SERVERS']['IMAP'];
-  }
-
-  function updateMailbox($folder)
-  {
-  }
-
-  function setQuota($folder, $gosaMailQuota)
-  {
-    return (TRUE);
-  }
-
-  /* Get quota and divide it by 1024, because in gosa we display in MB
-      but we get Kb */
-  function getQuota($folder)
-  {
-    $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
-    /* Only use lower case folder names, if folder name is like "@domain.com" */
-    if(preg_match("/@/",$folder)){
-      $folder = strtolower($folder);
-    }
-
-    error_reporting(0);  
-  
-    /* Load quota settings */
-    $quota_value = @imap_get_quota($this->mbox, $folder);
-    if(is_array($quota_value)) {
-      if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
-        /* use for PHP >= 4.3 */
-        $result['quotaUsage']=    (int) ($quota_value["STORAGE"]['usage'] / 1024);
-        $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
-      } else {
-        /* backward icompatible */
-        $result['quotaUsage']=    (int) ($quota_value['usage'] / 1024);
-        $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
-      }
-    }elseif(!$quota_value){
-      return(false);
-    }
-
-    error_reporting(E_ALL | E_STRICT); 
-    return ($result);
-  }
-
-
-  function fixAttributesOnLoad(&$mailObject)
-  {
-    /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-    if(get_class($mailObject) == "mailgroup"){
-     $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-    }
-
-    /* Convert attributes and objectClasses */
-    foreach ($this->attribute_map as $dest => $source){
-      /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
-      if (isset($mailObject->attrs[$source])){
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        unset ($mailObject->attrs[$source]);
-      */
-
-      if (isset($mailObject->attrs[$source])){
-        unset($mailObject->attrs[$source]['count']);
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        $mailObject->$dest=        $mailObject->attrs[$source];
-
-        unset ($mailObject->$dest['count']);
-        unset ($mailObject->attrs[$source]);
-      }
-    }
-
-    /* Adjust server name if needed */
-    foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
-      if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
-        $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
-        break;
-      }
-    }
-  }
-
-
-  function fixAttributesOnStore(&$mailObject)
-  {
-    global $config;
-  
-    /* If quota is empty, remove quota restrictions by setting quota to 0 */
-    if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
-      $mailObject->attrs['gosaMailQuota'] = 0;
-    }
-
-    /* Convert attributes and objectClasses */
-    foreach ($this->attribute_map as $source => $dest){
-      if (isset($mailObject->attrs[$source])){
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        unset ($mailObject->attrs[$source]);
-      }
-    }
-    $objectclasses= array();
-    foreach ($mailObject->attrs['objectClass'] as $oc){
-      if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
-        $objectclasses[]= $oc;
-      }
-    }
-    $mailObject->attrs['objectClass']= $objectclasses;
-    if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
-  
-      /* Add kolabSharedFoleder Class */
-      $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
-
-      /* Work on acl attribute */
-      $new_acl= array();
-      foreach ($mailObject->attrs['acl'] as $uacl){
-
-        /* Get user=(mail) & acls  */
-        list($user, $acl) = split(" ", $uacl);
-      
-        /* Add al users which have seperated acls 
-           %members% are all users in this group, 
-           which have the standard group acl
-        */
-        if ($user != "%members%"){
-          $new_acl[$user]= $uacl;
-        } else {
-        
-          /* All groupmembers will be added */
-          $ldap = $config->get_ldap_link();
-          $ldap->cd($config->current['BASE']);
-          foreach ($mailObject->members as $member){
-
-            /* Get user mail address .... */
-            $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
-            $res = $ldap->fetch();
-
-            /* Default mail address is set to uid - 
-               So if there is no mail address defined the uid is added 
-             */
-            $mail = $member;
-
-            /* Use mail address if it is available */
-            if(isset($res['mail'][0])){
-              $mail = $res['mail'][0];
-            }
-
-            /* only append this mail/permission string to acl,
-               if there arn't already some (special) configs for this user */
-            $found =false;
-            foreach($mailObject->imapacl as $mailA => $acl){
-              if(strtolower(trim($mailA))==strtolower(trim($mail))){
-                $found = true;
-              }
-            }
-
-            /* Skipp user, with no email adress too */     
-            if($member == $mail){
-              $found = true;
-            }
-   
-            /* Append new user acl */
-            if(!$found){
-              $new_acl[$member]= "$mail $acl";
-            }
-
-            /* Old line */
-            //  $new_acl[$member]= "$member $acl";
-          }
-        }
-      }
-      /* Save shared folder target */
-      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail;
-
-      /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-      $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-  
-      /* Assign new acls */
-      $mailObject->attrs['acl']= array();
-      foreach ($new_acl as $key => $value){
-        $mailObject->attrs['acl'][]= $value;
-      }
-    } else {
-      $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
-    }
-
-    /* Remove imap:// tagging */
-    $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
-    $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
-    $mailObject->attrs['kolabDeleteFlag']= array();
-  }
-
-  function fixAttributesOnRemove(&$mailObject)
-  {
-    /* Add attribute for object deletion and remove GOsa specific
-       values from entry. */
-    foreach($this->attribute_map as $kolabAttr){
-      $mailObject->attrs[$kolabAttr] = array();
-    }  
-
-    /* Only add kolab delete Flag in case of an user.mailAccount */
-    if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
-      $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
-    }else{
-      /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-      $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-      
-    }
-  }
-
-
-  function deleteMailbox($folder)
-  {
-    /* Remove shared folders and skip removing users. 
-       KolabD is not able to remove shared folders yet, so we do it instead */
-    if(!(preg_match("/^user\//",$folder))){
-      return mailMethodCyrus::deleteMailbox($folder);
-    }
-    return (TRUE);
-  }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/class_mail-methods-kolab.inc
deleted file mode 100644 (file)
index c060604..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-<?php
-/*
-   This code is part of GOsa (https://gosa.gonicus.de)
-   Copyright (C) 2004  Cajus Pollmeier
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-class mailMethodKolab extends mailMethodCyrus
-{
-  var $mbox= "-";
-  var $config;
-  var $gosaMailServer= "";
-  var $uattrib= "mail";
-
-  var $attribute_map= array("gosaMailAlternateAddress"  =>  "alias",
-                            "gosaMailQuota"             =>  "cyrus-userquota",
-                            "gosaMailServer"            =>  "kolabHomeServer");
-
-  function mailMethodKolab(&$config)
-  {
-    $this->config= $config->data['SERVERS']['IMAP'];
-  }
-
-  function updateMailbox($folder)
-  {
-  }
-
-  function setQuota($folder, $gosaMailQuota)
-  {
-    return (TRUE);
-  }
-
-  /* Get quota and divide it by 1024, because in gosa we display in MB
-      but we get Kb */
-  function getQuota($folder)
-  {
-    $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
-
-    /* Only use lower case folder names, if folder name is like "@domain.com" */
-    if(preg_match("/@/",$folder)){
-      $folder = strtolower($folder);
-    }
-
-    error_reporting(0);  
-  
-    /* Load quota settings */
-    $quota_value = @imap_get_quota($this->mbox, $folder);
-    if(is_array($quota_value)) {
-      if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
-        /* use for PHP >= 4.3 */
-        $result['quotaUsage']=    (int) ($quota_value["STORAGE"]['usage'] / 1024);
-        $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
-      } else {
-        /* backward icompatible */
-        $result['quotaUsage']=    (int) ($quota_value['usage'] / 1024);
-        $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
-      }
-    }elseif(!$quota_value){
-      return(false);
-    }
-
-    error_reporting(E_ALL | E_STRICT); 
-    return ($result);
-  }
-
-
-  function fixAttributesOnLoad(&$mailObject)
-  {
-    /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-    if(get_class($mailObject) == "mailgroup"){
-     $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-    }
-
-    /* Convert attributes and objectClasses */
-    foreach ($this->attribute_map as $dest => $source){
-      /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
-      if (isset($mailObject->attrs[$source])){
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        unset ($mailObject->attrs[$source]);
-      */
-
-      if (isset($mailObject->attrs[$source])){
-        unset($mailObject->attrs[$source]['count']);
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        $mailObject->$dest=        $mailObject->attrs[$source];
-
-        /* Ensure that cleanup will recognize the ampped attributes too */
-        if(isset($mailObject->saved_attributes)){
-          $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source];
-          $mailObject->saved_attributes[$source] = $mailObject->attrs[$source];
-        }       
-
-        unset ($mailObject->$dest['count']);
-        unset ($mailObject->attrs[$source]);
-      }
-    }
-
-    /* Adjust server name if needed */
-    foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
-      if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
-        $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
-        break;
-      }
-    }
-  }
-
-
-  function fixAttributesOnStore(&$mailObject)
-  {
-    global $config;
-  
-    /* If quota is empty, remove quota restrictions by setting quota to 0 */
-    if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
-      $mailObject->attrs['gosaMailQuota'] = 0;
-    }
-
-    /* Convert attributes and objectClasses */
-    foreach ($this->attribute_map as $source => $dest){
-      if (isset($mailObject->attrs[$source])){
-        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
-        unset ($mailObject->attrs[$source]);
-      }
-    }
-    $objectclasses= array();
-    foreach ($mailObject->attrs['objectClass'] as $oc){
-      if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
-        $objectclasses[]= $oc;
-      }
-    }
-    $mailObject->attrs['objectClass']= $objectclasses;
-    if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
-  
-      /* Add kolabSharedFoleder Class */
-      $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
-
-      /* Work on acl attribute */
-      $new_acl= array();
-      foreach ($mailObject->attrs['acl'] as $uacl){
-
-        /* Get user=(mail) & acls  */
-        list($user, $acl) = split(" ", $uacl);
-      
-        /* Add al users which have seperated acls 
-           %members% are all users in this group, 
-           which have the standard group acl
-        */
-        if ($user != "%members%"){
-          $new_acl[$user]= $uacl;
-        } else {
-        
-          /* All groupmembers will be added */
-          $ldap = $config->get_ldap_link();
-          $ldap->cd($config->current['BASE']);
-          foreach ($mailObject->members as $member){
-
-            /* Get user mail address .... */
-            $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
-            $res = $ldap->fetch();
-
-            /* Default mail address is set to uid - 
-               So if there is no mail address defined the uid is added 
-             */
-            $mail = $member;
-
-            /* Use mail address if it is available */
-            if(isset($res['mail'][0])){
-              $mail = $res['mail'][0];
-            }
-
-            /* only append this mail/permission string to acl,
-               if there arn't already some (special) configs for this user */
-            $found =false;
-            foreach($mailObject->imapacl as $mailA => $acl){
-              if(strtolower(trim($mailA))==strtolower(trim($mail))){
-                $found = true;
-              }
-            }
-
-            /* Skipp user, with no email adress too */     
-            if($member == $mail){
-              $found = true;
-            }
-   
-            /* Append new user acl */
-            if(!$found){
-              $new_acl[$member]= "$mail $acl";
-            }
-
-            /* Old line */
-            //  $new_acl[$member]= "$member $acl";
-          }
-        }
-      }
-      /* Save shared folder target */
-      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail;
-
-      /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-      $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-  
-      /* Assign new acls */
-      $mailObject->attrs['acl']= array();
-      foreach ($new_acl as $key => $value){
-        $mailObject->attrs['acl'][]= $value;
-      }
-    } else {
-      $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
-    }
-
-    /* Remove imap:// tagging */
-    $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
-    $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
-    $mailObject->attrs['kolabDeleteFlag']= array();
-  }
-
-  function fixAttributesOnRemove(&$mailObject)
-  {
-    /* Add attribute for object deletion and remove GOsa specific
-       values from entry. */
-    foreach($this->attribute_map as $kolabAttr){
-      $mailObject->attrs[$kolabAttr] = array();
-    }  
-
-    /* Only add kolab delete Flag in case of an user.mailAccount */
-    if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
-      $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
-    }else{
-      /* Kolab shared folder names are like ' shared.uid@server.de ' 
-        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
-        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
-      $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
-      
-    }
-  }
-
-
-  function deleteMailbox($folder)
-  {
-    /* Remove shared folders and skip removing users. 
-       KolabD is not able to remove shared folders yet, so we do it instead */
-    if(preg_match("/^shared/",$folder)){
-      return mailMethodCyrus::deleteMailbox($folder);
-    }
-    return (TRUE);
-  }
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-golab.inc
new file mode 100644 (file)
index 0000000..dc75674
--- /dev/null
@@ -0,0 +1,261 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2004  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class mailMethodGolab extends mailMethodCyrus
+{
+  var $mbox= "-";
+  var $config;
+  var $gosaMailServer= "";
+  var $uattrib= "mail";
+
+  var $attribute_map= array("gosaMailAlternateAddress"  =>  "alias",
+                            "gosaMailQuota"             =>  "cyrus-userquota",
+                            "gosaMailServer"            =>  "kolabHomeServer");
+
+  function mailMethodGolab(&$config)
+  {
+    $this->config= $config->data['SERVERS']['IMAP'];
+  }
+
+  function updateMailbox($folder)
+  {
+  }
+
+  function setQuota($folder, $gosaMailQuota)
+  {
+    return (TRUE);
+  }
+
+  /* Get quota and divide it by 1024, because in gosa we display in MB
+      but we get Kb */
+  function getQuota($folder)
+  {
+    $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+
+    /* Only use lower case folder names, if folder name is like "@domain.com" */
+    if(preg_match("/@/",$folder)){
+      $folder = strtolower($folder);
+    }
+
+    error_reporting(0);  
+  
+    /* Load quota settings */
+    $quota_value = @imap_get_quota($this->mbox, $folder);
+    if(is_array($quota_value)) {
+      if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
+        /* use for PHP >= 4.3 */
+        $result['quotaUsage']=    (int) ($quota_value["STORAGE"]['usage'] / 1024);
+        $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+      } else {
+        /* backward icompatible */
+        $result['quotaUsage']=    (int) ($quota_value['usage'] / 1024);
+        $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+      }
+    }elseif(!$quota_value){
+      return(false);
+    }
+
+    error_reporting(E_ALL | E_STRICT); 
+    return ($result);
+  }
+
+
+  function fixAttributesOnLoad(&$mailObject)
+  {
+    /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+    if(get_class($mailObject) == "mailgroup"){
+     $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+    }
+
+    /* Convert attributes and objectClasses */
+    foreach ($this->attribute_map as $dest => $source){
+      /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
+      if (isset($mailObject->attrs[$source])){
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        unset ($mailObject->attrs[$source]);
+      */
+
+      if (isset($mailObject->attrs[$source])){
+        unset($mailObject->attrs[$source]['count']);
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        $mailObject->$dest=        $mailObject->attrs[$source];
+
+        unset ($mailObject->$dest['count']);
+        unset ($mailObject->attrs[$source]);
+      }
+    }
+
+    /* Adjust server name if needed */
+    foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
+      if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
+        $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
+        break;
+      }
+    }
+  }
+
+
+  function fixAttributesOnStore(&$mailObject)
+  {
+    global $config;
+  
+    /* If quota is empty, remove quota restrictions by setting quota to 0 */
+    if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
+      $mailObject->attrs['gosaMailQuota'] = 0;
+    }
+
+    /* Convert attributes and objectClasses */
+    foreach ($this->attribute_map as $source => $dest){
+      if (isset($mailObject->attrs[$source])){
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        unset ($mailObject->attrs[$source]);
+      }
+    }
+    $objectclasses= array();
+    foreach ($mailObject->attrs['objectClass'] as $oc){
+      if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
+        $objectclasses[]= $oc;
+      }
+    }
+    $mailObject->attrs['objectClass']= $objectclasses;
+    if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
+  
+      /* Add kolabSharedFoleder Class */
+      $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
+
+      /* Work on acl attribute */
+      $new_acl= array();
+      foreach ($mailObject->attrs['acl'] as $uacl){
+
+        /* Get user=(mail) & acls  */
+        list($user, $acl) = split(" ", $uacl);
+      
+        /* Add al users which have seperated acls 
+           %members% are all users in this group, 
+           which have the standard group acl
+        */
+        if ($user != "%members%"){
+          $new_acl[$user]= $uacl;
+        } else {
+        
+          /* All groupmembers will be added */
+          $ldap = $config->get_ldap_link();
+          $ldap->cd($config->current['BASE']);
+          foreach ($mailObject->members as $member){
+
+            /* Get user mail address .... */
+            $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
+            $res = $ldap->fetch();
+
+            /* Default mail address is set to uid - 
+               So if there is no mail address defined the uid is added 
+             */
+            $mail = $member;
+
+            /* Use mail address if it is available */
+            if(isset($res['mail'][0])){
+              $mail = $res['mail'][0];
+            }
+
+            /* only append this mail/permission string to acl,
+               if there arn't already some (special) configs for this user */
+            $found =false;
+            foreach($mailObject->imapacl as $mailA => $acl){
+              if(strtolower(trim($mailA))==strtolower(trim($mail))){
+                $found = true;
+              }
+            }
+
+            /* Skipp user, with no email adress too */     
+            if($member == $mail){
+              $found = true;
+            }
+   
+            /* Append new user acl */
+            if(!$found){
+              $new_acl[$member]= "$mail $acl";
+            }
+
+            /* Old line */
+            //  $new_acl[$member]= "$member $acl";
+          }
+        }
+      }
+      /* Save shared folder target */
+      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+".$mailObject->mail;
+
+      /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+      $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+  
+      /* Assign new acls */
+      $mailObject->attrs['acl']= array();
+      foreach ($new_acl as $key => $value){
+        $mailObject->attrs['acl'][]= $value;
+      }
+    } else {
+      $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
+    }
+
+    /* Remove imap:// tagging */
+    $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
+    $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
+    $mailObject->attrs['kolabDeleteFlag']= array();
+  }
+
+  function fixAttributesOnRemove(&$mailObject)
+  {
+    /* Add attribute for object deletion and remove GOsa specific
+       values from entry. */
+    foreach($this->attribute_map as $kolabAttr){
+      $mailObject->attrs[$kolabAttr] = array();
+    }  
+
+    /* Only add kolab delete Flag in case of an user.mailAccount */
+    if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
+      $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
+    }else{
+      /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+      $mailObject->uid = $mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+      
+    }
+  }
+
+
+  function deleteMailbox($folder)
+  {
+    /* Remove shared folders and skip removing users. 
+       KolabD is not able to remove shared folders yet, so we do it instead */
+    if(!(preg_match("/^user\//",$folder))){
+      return mailMethodCyrus::deleteMailbox($folder);
+    }
+    return (TRUE);
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc b/gosa-plugins/kolab/personal/mail/kolab/class_mail-methods-kolab.inc
new file mode 100644 (file)
index 0000000..c060604
--- /dev/null
@@ -0,0 +1,267 @@
+<?php
+/*
+   This code is part of GOsa (https://gosa.gonicus.de)
+   Copyright (C) 2004  Cajus Pollmeier
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class mailMethodKolab extends mailMethodCyrus
+{
+  var $mbox= "-";
+  var $config;
+  var $gosaMailServer= "";
+  var $uattrib= "mail";
+
+  var $attribute_map= array("gosaMailAlternateAddress"  =>  "alias",
+                            "gosaMailQuota"             =>  "cyrus-userquota",
+                            "gosaMailServer"            =>  "kolabHomeServer");
+
+  function mailMethodKolab(&$config)
+  {
+    $this->config= $config->data['SERVERS']['IMAP'];
+  }
+
+  function updateMailbox($folder)
+  {
+  }
+
+  function setQuota($folder, $gosaMailQuota)
+  {
+    return (TRUE);
+  }
+
+  /* Get quota and divide it by 1024, because in gosa we display in MB
+      but we get Kb */
+  function getQuota($folder)
+  {
+    $result= array('quotaUsage' => '', 'gosaMailQuota' => '');
+
+    /* Only use lower case folder names, if folder name is like "@domain.com" */
+    if(preg_match("/@/",$folder)){
+      $folder = strtolower($folder);
+    }
+
+    error_reporting(0);  
+  
+    /* Load quota settings */
+    $quota_value = @imap_get_quota($this->mbox, $folder);
+    if(is_array($quota_value)) {
+      if (isset($quota_value["STORAGE"]) && is_array($quota_value["STORAGE"])){
+        /* use for PHP >= 4.3 */
+        $result['quotaUsage']=    (int) ($quota_value["STORAGE"]['usage'] / 1024);
+        $result['gosaMailQuota']= (int) ($quota_value["STORAGE"]['limit'] / 1024);
+      } else {
+        /* backward icompatible */
+        $result['quotaUsage']=    (int) ($quota_value['usage'] / 1024);
+        $result['gosaMailQuota']= (int) ($quota_value['limit'] / 1024);
+      }
+    }elseif(!$quota_value){
+      return(false);
+    }
+
+    error_reporting(E_ALL | E_STRICT); 
+    return ($result);
+  }
+
+
+  function fixAttributesOnLoad(&$mailObject)
+  {
+    /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+    if(get_class($mailObject) == "mailgroup"){
+     $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+    }
+
+    /* Convert attributes and objectClasses */
+    foreach ($this->attribute_map as $dest => $source){
+      /* Hickert 11.11.05 : Alternate email addresses were saved, but not displayed again.
+      if (isset($mailObject->attrs[$source])){
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        unset ($mailObject->attrs[$source]);
+      */
+
+      if (isset($mailObject->attrs[$source])){
+        unset($mailObject->attrs[$source]['count']);
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        $mailObject->$dest=        $mailObject->attrs[$source];
+
+        /* Ensure that cleanup will recognize the ampped attributes too */
+        if(isset($mailObject->saved_attributes)){
+          $mailObject->saved_attributes[$dest] = $mailObject->attrs[$source];
+          $mailObject->saved_attributes[$source] = $mailObject->attrs[$source];
+        }       
+
+        unset ($mailObject->$dest['count']);
+        unset ($mailObject->attrs[$source]);
+      }
+    }
+
+    /* Adjust server name if needed */
+    foreach ($mailObject->config->data['SERVERS']['IMAP'] as $srv => $dummy){
+      if (preg_match("%".$mailObject->attrs['gosaMailServer'][0]."$%", $srv)){
+        $mailObject->attrs['gosaMailServer']= array(0 => $srv, "count" => 1);
+        break;
+      }
+    }
+  }
+
+
+  function fixAttributesOnStore(&$mailObject)
+  {
+    global $config;
+  
+    /* If quota is empty, remove quota restrictions by setting quota to 0 */
+    if(isset($mailObject->gosaMailQuota) && (empty($mailObject->gosaMailQuota))){
+      $mailObject->attrs['gosaMailQuota'] = 0;
+    }
+
+    /* Convert attributes and objectClasses */
+    foreach ($this->attribute_map as $source => $dest){
+      if (isset($mailObject->attrs[$source])){
+        $mailObject->attrs[$dest]= $mailObject->attrs[$source];
+        unset ($mailObject->attrs[$source]);
+      }
+    }
+    $objectclasses= array();
+    foreach ($mailObject->attrs['objectClass'] as $oc){
+      if ($oc !=  'kolabInetOrgPerson' && $oc !=  'kolabSharedFolder'){
+        $objectclasses[]= $oc;
+      }
+    }
+    $mailObject->attrs['objectClass']= $objectclasses;
+    if (in_array("posixGroup", $mailObject->attrs['objectClass'])){
+  
+      /* Add kolabSharedFoleder Class */
+      $mailObject->attrs['objectClass'][]= 'kolabSharedFolder';
+
+      /* Work on acl attribute */
+      $new_acl= array();
+      foreach ($mailObject->attrs['acl'] as $uacl){
+
+        /* Get user=(mail) & acls  */
+        list($user, $acl) = split(" ", $uacl);
+      
+        /* Add al users which have seperated acls 
+           %members% are all users in this group, 
+           which have the standard group acl
+        */
+        if ($user != "%members%"){
+          $new_acl[$user]= $uacl;
+        } else {
+        
+          /* All groupmembers will be added */
+          $ldap = $config->get_ldap_link();
+          $ldap->cd($config->current['BASE']);
+          foreach ($mailObject->members as $member){
+
+            /* Get user mail address .... */
+            $ldap->search("(&(objectClass=person)(|(uid=".$member.")(mail=".$member.")))",array("mail"));
+            $res = $ldap->fetch();
+
+            /* Default mail address is set to uid - 
+               So if there is no mail address defined the uid is added 
+             */
+            $mail = $member;
+
+            /* Use mail address if it is available */
+            if(isset($res['mail'][0])){
+              $mail = $res['mail'][0];
+            }
+
+            /* only append this mail/permission string to acl,
+               if there arn't already some (special) configs for this user */
+            $found =false;
+            foreach($mailObject->imapacl as $mailA => $acl){
+              if(strtolower(trim($mailA))==strtolower(trim($mail))){
+                $found = true;
+              }
+            }
+
+            /* Skipp user, with no email adress too */     
+            if($member == $mail){
+              $found = true;
+            }
+   
+            /* Append new user acl */
+            if(!$found){
+              $new_acl[$member]= "$mail $acl";
+            }
+
+            /* Old line */
+            //  $new_acl[$member]= "$member $acl";
+          }
+        }
+      }
+      /* Save shared folder target */
+      $mailObject->attrs['gosaSharedFolderTarget']= "kolab+shared.".$mailObject->mail;
+
+      /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+      $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+  
+      /* Assign new acls */
+      $mailObject->attrs['acl']= array();
+      foreach ($new_acl as $key => $value){
+        $mailObject->attrs['acl'][]= $value;
+      }
+    } else {
+      $mailObject->attrs['objectClass'][]= 'kolabInetOrgPerson';
+    }
+
+    /* Remove imap:// tagging */
+    $mailObject->attrs['kolabHomeServer']= preg_replace('%imap://%', '', $mailObject->attrs['kolabHomeServer']);
+    $mailObject->attrs['gosaMailServer']= $mailObject->attrs['kolabHomeServer'];
+    $mailObject->attrs['kolabDeleteFlag']= array();
+  }
+
+  function fixAttributesOnRemove(&$mailObject)
+  {
+    /* Add attribute for object deletion and remove GOsa specific
+       values from entry. */
+    foreach($this->attribute_map as $kolabAttr){
+      $mailObject->attrs[$kolabAttr] = array();
+    }  
+
+    /* Only add kolab delete Flag in case of an user.mailAccount */
+    if(!in_array("posixGroup", $mailObject->attrs['objectClass'])){
+      $mailObject->attrs['kolabDeleteFlag']= preg_replace('%imap://%', '', $mailObject->gosaMailServer);
+    }else{
+      /* Kolab shared folder names are like ' shared.uid@server.de ' 
+        So overwrite uid to match these folder names. Else we can't read quota settings etc. 
+        #FIXME is there a better way to detect if it is 'shared.' or 'shared+' or 'kolab+shared.' or what ever ?*/
+      $mailObject->uid = "shared.".$mailObject->uid."@".preg_replace("/^.*@/","",$mailObject->mail);
+      
+    }
+  }
+
+
+  function deleteMailbox($folder)
+  {
+    /* Remove shared folders and skip removing users. 
+       KolabD is not able to remove shared folders yet, so we do it instead */
+    if(preg_match("/^shared/",$folder)){
+      return mailMethodCyrus::deleteMailbox($folder);
+    }
+    return (TRUE);
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>