X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servKolab.inc;h=c1e33222359f83e5d53b9e87fd89076d95105b0f;hb=7385deb3e680ce8a77f131b62907146bbf01075f;hp=4145f5525dd6e45a2e3ff96cc222b105d795b362;hpb=fe503ccdeea34c0bdb10c77d55e6561728b55766;p=gosa.git diff --git a/plugins/admin/systems/class_servKolab.inc b/plugins/admin/systems/class_servKolab.inc index 4145f5525..c1e332223 100644 --- a/plugins/admin/systems/class_servKolab.inc +++ b/plugins/admin/systems/class_servKolab.inc @@ -26,9 +26,6 @@ class servkolab extends plugin { var $proftpd_ftp = "TRUE"; var $apache_http = "TRUE"; var $kolabHost = array(); - var $is_in_there = false; - var $exactName = false; - var $orig_cn = ""; var $attributes = array("postfix_mydomain", "postfix_mydestination", "proftpd_ftp", "k", @@ -38,6 +35,11 @@ class servkolab extends plugin { "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) { /* Setting the hostname and tell this Plugin that we are the kolab extension*/ @@ -64,38 +66,15 @@ class servkolab extends plugin { $this->kolabHost= $this->attrs['kolabHost']; unset($this->kolabHost['count']); } - $this->is_in_there = false; $this->is_account = false; $this->initially_was_account = false; foreach($this->kolabHost as $host){ - if(preg_match("/".$this->hostname.".*/i",$host)){ + if($this->hostname == $host){ $this->is_account = true; - $this->is_in_there = true; $this->initially_was_account = true; } } - - /* Mhh */ - if(in_array($this->hostname, $this->kolabHost)) { - $this->exactName=true; - } else { - $this->exactName=false; - } - - /* Parse mynetworks */ - if(isset($this->attrs['postfix-mynetworks'])){ - if(is_array($this->attrs['postfix-mynetworks'])){ - unset($this->attrs['postfix-mynetworks']['count']); - $tmp=""; - foreach($this->attrs['postfix-mynetworks'] as $tm){ - $tmp.=$tm.";"; - } - $this->postfix_mynetworks = $tmp; - } - }else{ - $this->postfix_mynetworks=""; - } } @@ -125,27 +104,6 @@ class servkolab extends plugin { chkacl($this->acl, 'cyrus_quotawarn')); $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit); - - /*************** - Handle Account is_account state - ***************/ - - /* Do we need to flip is_account state? */ - if (isset($_POST['modify_state'])) { - $this->is_account = !$this->is_account; - } - - /* Show tab dialog headers */ - if ($this->is_account) { - /* call Add Acoount to add account */ - $display = $this->show_header(_("Remove Kolab extension"), _("This server has kolab features enabled. You can disable them by clicking below.")); - } else { - /* call remove Account */ - $display = $this->show_header(_("Add Kolab service"), _("This server has kolab features disabled. You can enable them by clicking below.")); - return ($display); - } - - /*************** Assign informations to smarty ***************/ @@ -181,6 +139,14 @@ class servkolab extends plugin { 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){ @@ -222,7 +188,7 @@ class servkolab extends plugin { /* Remove complete entry */ $ldap->rmdir ($this->dn); - show_ldap_error($ldap->get_error(), _("Removing kolab host entry failed")); + 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 { @@ -238,7 +204,7 @@ class servkolab extends plugin { $ldap->cd($this->dn); $this->cleanup(); $ldap->modify ($attrs); - show_ldap_error($ldap->get_error(), _("Removing server from kolab object failed")); + 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"); } @@ -327,26 +293,15 @@ class servkolab extends plugin { $tmp[] = $host; } } + $this->kolabHost = $tmp; } - $this->kolabHost = $tmp; } - + /* Add ourselves to the list of kolabHost's if needed */ - if (!in_array($this->cn,$this->kolabHost)){ + if (!in_array_ics($this->cn,$this->kolabHost)){ $this->kolabHost[]= $this->cn; } - /* Create mynetworks array by splitting the string with ; */ - $tmp = split(";",$this->postfix_mynetworks); - $this->postfix_mynetworks = array(); - foreach($tmp as $tm){ - trim($tm); - if(!empty($tm)){ - $this->postfix_mynetworks[]=$tm; - } - } - $this->attrs['postfix_mynetworks']=$this->postfix_mynetworks; - /* Call parents save to prepare $this->attrs */ plugin::save(); @@ -370,15 +325,11 @@ class servkolab extends plugin { /* Add kolab hosts */ $this->attrs['kolabHost']= $this->kolabHost; - if(($this->is_in_there)&&(!$this->exactName)){ - unset($this->attrs['kolabHost']); - } - /* Perform LDAP action */ $ldap->cd($this->dn); $this->cleanup();; $ldap->$mode($this->attrs); - show_ldap_error($ldap->get_error(), _("Saving server to kolab object failed")); + 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) { @@ -389,6 +340,102 @@ class servkolab extends plugin { $this->handle_post_events("add"); } } + + + function getListEntry() + { + $this->updateStatusState(); + $flag = $this->StatusFlag; + if(empty($flag)){ + $fields['Status'] = ""; + }else{ + $fields['Status'] = $this->$flag; + } + $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"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "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")) + )); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: