index df7115cf61c5d651d8b6c4d0d4144ec0fc0502bf..a2d36d1a96dcb27210a3a1dcfa32acb3ef21a339 100644 (file)
<?php
class servkolab extends plugin {
<?php
class servkolab extends plugin {
- /* 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 $postfix_mydestination = "";
var $postfix_mydomain = "";
var $postfix_mydestination = "";
+ var $cyrus_admins = "";
var $postfix_mynetworks = "127.0.0.1/8";
var $postfix_enable_virus_scan = "TRUE";
var $postfix_relayhost = "";
var $postfix_mynetworks = "127.0.0.1/8";
var $postfix_enable_virus_scan = "TRUE";
var $postfix_relayhost = "";
var $cyrus_quotawarn = "80";
var $kolabFreeBusyFuture = "1";
var $k = "kolab";
var $cyrus_quotawarn = "80";
var $kolabFreeBusyFuture = "1";
var $k = "kolab";
- var $cyrus_admins = "TRUE";
var $cyrus_imap = "TRUE";
var $cyrus_pop3 = "TRUE";
var $cyrus_imaps = "TRUE";
var $cyrus_imap = "TRUE";
var $cyrus_pop3 = "TRUE";
var $cyrus_imaps = "TRUE";
var $proftpd_ftp = "TRUE";
var $apache_http = "TRUE";
var $kolabHost = array();
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",
"postfix_mynetworks", "postfix_enable_virus_scan", "postfix_relayhost", "apache_http",
"postfix_allow_unauthenticated", "cyrus_admins", "cyrus_imap","kolabFreeBusyFuture",
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_quotawarn");
var $objectclasses = array("top", "kolab");
"cyrus_quotawarn");
var $objectclasses = array("top", "kolab");
- function servkolab($config, $dn = 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);
{
/* Setting the hostname and tell this Plugin that we are the kolab extension*/
$this->hostname = preg_replace('/^cn=([^,]+),.*$/', '\1', $dn);
$this->kolabHost= $this->attrs['kolabHost'];
unset($this->kolabHost['count']);
}
$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){
$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_account = true;
- $this->is_in_there = true;
$this->initially_was_account = 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="";
- }
}
}
/* Call parent execute */
plugin::execute();
/* Call parent execute */
plugin::execute();
- /* Fill templating stuff */
- $smarty = get_smarty();
- $display = "";
+ /***************
+ Variable initialisation
+ ***************/
+
+ $smarty = get_smarty();
+ $display = "";
+ $ldap = $this->config->get_ldap_link();
+
+
+ /* Assemble free/busy string */
+ $edit = sprintf('<input name="kolabFreeBusyFuture" value="%s" %s type="text" maxlength="3" size="4">',
+ $this->kolabFreeBusyFuture,
+ chkacl($this->acl, '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'));
+ $quotastr = sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
- /* The Ldap link is needed to ask ldap some questions */
- $ldap = $this->config->get_ldap_link();
+ /***************
+ Handle Account is_account state
+ ***************/
+
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])) {
$this->is_account = !$this->is_account;
/* Do we need to flip is_account state? */
if (isset($_POST['modify_state'])) {
$this->is_account = !$this->is_account;
return ($display);
}
return ($display);
}
+
+ /***************
+ Assign informations to smarty
+ ***************/
+
/* Set relayhost and if we have MX lookup enabled*/
if($this->postfix_mxrelayenabled) {
$smarty->assign("RelayMxSupportCheck"," checked ");
/* Set relayhost and if we have MX lookup enabled*/
if($this->postfix_mxrelayenabled) {
$smarty->assign("RelayMxSupportCheck"," checked ");
}
}
}
}
- /* Assemble free/busy string */
- $edit= sprintf('<input name="kolabFreeBusyFuture" value="%s" %s type="text" maxlength="3" size="4">',
- $this->kolabFreeBusyFuture, chkacl($this->acl, 'kolabFreeBusyFuture'));
- $fbfuture= sprintf(_("Include data from %s days in the past when creating free/busy lists"), $edit);
$smarty->assign("fbfuture", $fbfuture);
$smarty->assign("fbfuture", $fbfuture);
-
- /* 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'));
- $quotastr= sprintf(_("Warn users when using more than %s%% of their mail quota"), $edit);
$smarty->assign("quotastr", $quotastr);
/* Load Template */
$smarty->assign("quotastr", $quotastr);
/* Load Template */
return;
}
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'];
$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
/* 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
/* Are we alone? Remove complete entry... */
/* Check if we are definitly in kolabHosts */
/* Are we alone? Remove complete entry... */
/* Check if we are definitly in kolabHosts */
- if(!in_array_ics($this->cn,$this->kolabHost)) {
+ if(!in_array_ics($this->hostname,$this->kolabHost)) {
return;
}
return;
}
print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
return;
}
print_red("Server - Kolab tab : This is not possible, we can't remove an account which doesn't exists.");
return;
}
- if(!isset($this->cn) || (empty($this->cn))){
- print_red("The required attribute cn seams to empty.");
+ 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
}
/* Our hostname is in kolabHosts and there is a only one entry
/* Remove complete entry */
$ldap->rmdir ($this->dn);
show_ldap_error($ldap->get_error(), _("Removing kolab host entry failed"));
/* Remove complete entry */
$ldap->rmdir ($this->dn);
show_ldap_error($ldap->get_error(), _("Removing kolab host entry failed"));
- gosa_log("k=kolab entry removed, ".$this->cn." was the last kolabHost entry.");
+ gosa_log("k=kolab entry removed, ".$this->hostname." was the last kolabHost entry.");
} else {
/* Only modify kolabHost */
$hosts= array();
foreach ($this->kolabHost as $host){
} else {
/* Only modify kolabHost */
$hosts= array();
foreach ($this->kolabHost as $host){
- if($host != $this->cn){
+ if($host != $this->hostname){
$hosts[]= $host;
}
}
$hosts[]= $host;
}
}
$this->cleanup();
$ldap->modify ($attrs);
show_ldap_error($ldap->get_error(), _("Removing server from kolab object failed"));
$this->cleanup();
$ldap->modify ($attrs);
show_ldap_error($ldap->get_error(), _("Removing server from kolab object failed"));
- gosa_log("Removing ".$this->cn." from list of kolabHosts");
+ gosa_log("Removing ".$this->hostname." from list of kolabHosts");
}
/* Optionally execute a command after we're done */
}
/* Optionally execute a command after we're done */
/* Save checkboxes */
foreach (array( "postfix_enable_virus_scan", "postfix_allow_unauthenticated",
/* 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])){
"cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb",
"proftpd_ftp", "apache_http") as $cb){
if (isset($_POST[$cb])){
function save()
{
/* Set ldap connection */
function save()
{
/* Set ldap connection */
- $ldap = $this->config->get_ldap_link();
+ $ldap = $this->config->get_ldap_link();
/* Open current dn*/
/* Open current dn*/
- $this->dn = "k=kolab,".$this->config->current['BASE'];
+ $this->dn = "k=kolab,".$this->config->current['BASE'];
/* Adapt relayhost */
$this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
/* Adapt relayhost */
$this->postfix_relayhost= preg_replace('/[\[\]]/', '', $this->postfix_relayhost);
$this->postfix_relayhost= "[".$this->postfix_relayhost."]";
}
$this->postfix_relayhost= "[".$this->postfix_relayhost."]";
}
- /* Add ourselves to the list of kolabHost's if needed */
- if ((!$this->is_in_there)){
- $this->kolabHost[]= $this->cn;
- }
-
-
-
- $tmp = split(";",$this->postfix_mynetworks);
- $this->postfix_mynetworks = array();
- foreach($tmp as $tm){
- trim($tm);
- if(!empty($tm)){
- $this->postfix_mynetworks[]=$tm;
+ /* 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;
}
}
}
}
- $this->attrs['postfix_mynetworks']=$this->postfix_mynetworks;
+ /* 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();
/* Call parents save to prepare $this->attrs */
plugin::save();
unset($this->attrs[$old_key]);
}
}
unset($this->attrs[$old_key]);
}
}
-
/* Add kolab hosts */
$this->attrs['kolabHost']= $this->kolabHost;
/* 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();;
/* Perform LDAP action */
$ldap->cd($this->dn);
$this->cleanup();;
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account) {
if ($this->is_modified) {
/* Optionally execute a command after we're done */
if ($this->initially_was_account == $this->is_account) {
if ($this->is_modified) {
- $this->handle_post_events("mofify");
+ $this->handle_post_events("modify");
}
} else {
$this->handle_post_events("add");
}
}
} else {
$this->handle_post_events("add");
}
-
}
}
-
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: