Code

Updated workstation - Startup
[gosa.git] / plugins / admin / systems / class_servKolab.inc
index e7b78bf035d34de914ed4fa688f374d36604e4cd..7768f2563998017301e02eb4e41fc2663ae54574 100644 (file)
@@ -1,12 +1,13 @@
 <?php
 
-class servkolab extends plugin {
+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";
@@ -16,17 +17,17 @@ class servkolab extends plugin {
   var $cyrus_quotawarn                  = "80";
   var $kolabFreeBusyFuture              = "1";
   var $k                                = "kolab";
-  var $cyrus_admins                     = "TRUE";
   var $cyrus_imap                       = "TRUE";
-  var $cyrus_pop3                       = "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                      = "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",
@@ -40,14 +41,14 @@ class servkolab extends plugin {
   var $DisplayName  = "Kolab mail service";
   var $StatusFlag   = "";
 
-  function servkolab($config, $dn = NULL, $parent= NULL) 
+  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, $parent);
+    plugin::plugin($config, $this->dn);
 
     /* Copy needed attributes */
     foreach($this->attributes as $val) {
@@ -74,7 +75,6 @@ class servkolab extends plugin {
         $this->initially_was_account = true;
       }
     } 
-
   }
 
 
@@ -83,6 +83,11 @@ class servkolab extends plugin {
     /* 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
      ***************/  
@@ -93,33 +98,35 @@ class servkolab extends plugin {
 
 
     /* Assemble free/busy string */
-    $edit       = sprintf('<input name="kolabFreeBusyFuture" value="%s" %s type="text" maxlength="3" size="4">',
-                    $this->kolabFreeBusyFuture, 
-                    chkacl($this->acl, 'kolabFreeBusyFuture'));
+    $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" %s>',
-                    $this->cyrus_quotawarn, 
-                    chkacl($this->acl, 'cyrus_quotawarn'));
+    $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*/
+    /* 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) 
     {
-      $smarty->assign($val."ACL",chkacl($this->acl,str_replace("_","-",$val)));
-
       /* Tell smarty which variables we are useing */
       $smarty->assign($val, $this->$val);
       if (($this->$val != "FALSE") && !empty($this->$val)){
@@ -173,7 +180,7 @@ class servkolab extends plugin {
       return;
     }
 
-    /* Integration check, not translatet because they can't pop up at all, only for debug */ 
+    /* 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;
@@ -189,8 +196,6 @@ class servkolab extends plugin {
       /* 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));
-      gosa_log("k=kolab entry removed, ".$this->hostname." was the last kolabHost entry.");
-
     } else {
 
       /* Only modify kolabHost */
@@ -205,9 +210,10 @@ class servkolab extends plugin {
       $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));
-      gosa_log("Removing ".$this->hostname." from list of kolabHosts");
     }
 
+    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");
   }
@@ -218,20 +224,32 @@ class servkolab extends plugin {
     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_admins", "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
+            "cyrus_imap", "cyrus_pop3", "cyrus_imaps",
             "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
             "proftpd_ftp", "apache_http") as $cb){
-        if (isset($_POST[$cb])){
-          $this->$cb= "TRUE";
-        } else {
-          $this->$cb= "FALSE";
+
+        if($this->acl_is_writeable(preg_replace("/_/","",$cb))){
+          if (isset($_POST[$cb])){
+            $this->$cb= "TRUE";
+          } else {
+            $this->$cb= "FALSE";
+          }
         }
       }
 
-      /* Toggle relay check */
-      $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
+      /* Toggell relay check */
+      if($this->acl_is_writeable("postfixmxrelayenabled")){
+        $this->postfix_mxrelayenabled= isset($_POST['RelayMxSupport']);
+      }
     }
 
   }
@@ -280,7 +298,7 @@ class servkolab extends plugin {
 
     /* Adapt relayhost */
     $this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
-    if (!$this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
+    if ($this->postfix_mxrelayenabled && $this->postfix_relayhost != ""){
       $this->postfix_relayhost= "[".$this->postfix_relayhost."]";
     }
 
@@ -329,6 +347,13 @@ class servkolab extends plugin {
     $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 */
@@ -344,96 +369,44 @@ class servkolab extends plugin {
 
   function getListEntry()
   {
-    $this->updateStatusState();
-    $flag = $this->StatusFlag;
-    if(empty($flag)){
-      $fields['Status']       = "";
-    }else{
-      $fields['Status']       = $this->$flag;
-    }
+    $fields                 = goService::getListEntry();
     $fields['Message']      = _("Kolab mail service");
-    $fields['AllowStart']   = true;
-    $fields['AllowStop']    = true;
-    $fields['AllowRestart'] = true;
-    $fields['AllowRemove']  = true;
     $fields['AllowEdit']    = true;
     return($fields);
   }
 
-    /* Directly save new status flag */
-  function setStatus($value)
-  { 
-    return;
-  
-    if($value == "none") return;
-    if(!$this->initially_was_account) return;
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
-    $ldap->cat($this->dn,array("objectClass"));
-    if($ldap->count()){
-
-      $tmp = $ldap->fetch();
-      for($i = 0; $i < $tmp['objectClass']['count']; $i ++){
-        $attrs['objectClass'][] = $tmp['objectClass'][$i];
-      }
-      $flag = $this->StatusFlag;
-      $attrs[$flag] = $value;
-      $this->$flag = $value;
-      $ldap->modify($attrs);
-      show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for system server/kolab with dn '%s' failed."),$this->dn)); 
-      $this->action_hook();
-    }
-  }
-
-
-  /* Get updates for status flag */
-  function updateStatusState()
-  {
-    if(empty($this->StatusFlag)) return;
-
-    $attrs = array();
-    $flag = $this->StatusFlag;
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->cn);
-    $ldap->cat($this->dn,array($flag));
-    if($ldap->count()){
-      $attrs = $ldap->fetch();
-    }
-    if(isset($attrs[$flag][0])){
-      $this->$flag = $attrs[$flag][0];
-    }
-  }
-
-
 
   /* Return plugin informations for acl handling */
   function plInfo()
   {
     return (array(
           "plShortName"   => _("Kolab"),
-          "plDescription" => _("Kolab service"),
+          "plDescription" => _("Kolab mail service")." ("._("Services").")",
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 85,
           "plSection"     => array("administration"),
           "plCategory"    => array("server"),
 
           "plProvidedAcls"=> array(
-            "postfix_mydomain"                => _("Postfix mydomain") ,
-            "postfix_mydestination"           => _("My destination") ,
-            "proftpd_ftp"                     => _("FTP FreeBusy service") ,
-            "postfix_mynetworks"              => _("SMTP privileged networks") ,
-            "postfix_enable_virus_scan"       => _("Enable virus scan") ,
-            "postfix_relayhost"               => _("Relayhost") ,
-            "apache_http"                     => _("HTTP FreeBusy service") ,
-            "postfix_allow_unauthenticated"   => _("Accept Internet Mail") ,
-            "cyrus_imap"                      => _("IMAP service") ,
-            "kolabFreeBusyFuture"             => _("kolabFreeBusyFuture") ,
-            "cyrus_pop3"                      => _("POP3 service") ,
-            "cyrus_imaps"                     => _("IMAP/SSL service") ,
-            "cyrus_pop3s"                     => _("POP3/SSL service") ,
-            "cyrus_sieve"                     => _("Sieve service") ,
-            "cyrus_quotawarn"                 => _("Quota settings")) 
+            "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")) 
             ));
   }
 }