From: hickert Date: Thu, 19 May 2005 08:53:43 +0000 (+0000) Subject: Classes will be set right now X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1e656ba5163d70b93ff6bf00c9c71627f191937e;p=gosa.git Classes will be set right now git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@252 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_servDB.inc b/plugins/admin/systems/class_servDB.inc index 7518cdcf6..4244e40dd 100644 --- a/plugins/admin/systems/class_servDB.inc +++ b/plugins/admin/systems/class_servDB.inc @@ -164,36 +164,43 @@ class servdb extends plugin foreach($this->objectclasses as $oc){ $objectclasses[]= $oc; } - $this->objectclasses= $objectclasses; + plugin::save(); - - /* Remove objectclasses */ - foreach(array_merge($this->objectclasses, $this->additionaloc) as $oc){ - foreach ($this->attrs['objectClass'] as $key => $value){ - if ($value == $oc){ - unset ($this->attrs['objectClass'][$key]); + + + + $test = $this->objectclasses; + $tmp = array_flip($this->attrs['objectClass']); + + foreach($this->additionaloc as $key=>$val) { + unset($tmp[$key]); + } + + foreach($tmp as $val){ + if(in_array($val,$test)){ + $tmp[$val]; } } - } - foreach($this->objectclasses as $oc){ - $this->attrs['objectClass'][]= $oc; - } - /* Adapt sieve server if needed */ - if (in_array('goImapServer', $this->objectclasses)){ - $this->attrs['goImapSieveServer']= preg_replace('/:.*$/', '', - preg_replace('/^{([^}]+)}$/', '\\1', - $this->attrs['goImapConnect'])); + $classes = (array_flip(array_merge(array_flip($test),$tmp))); + + unset($this->attrs['objectClass']); + + foreach($classes as $class){ + $this->attrs['objectClass'][]=$class; } + /* Remove unneeded attributes */ foreach ($this->additionaloc as $oc => $attrs){ - if (!in_array($oc, $this->objectclasses)){ + if (!in_array($oc, $this->attrs['objectClass'])){ foreach ($attrs as $attr){ $this->attrs[$attr]= array(); } } } + $this->attrs = array_reverse($this->attrs); + /* Write to LDAP */ $ldap= $this->config->get_ldap_link(); diff --git a/plugins/admin/systems/class_servKolab.inc b/plugins/admin/systems/class_servKolab.inc index e98ce04a1..add99a003 100644 --- a/plugins/admin/systems/class_servKolab.inc +++ b/plugins/admin/systems/class_servKolab.inc @@ -12,20 +12,20 @@ class servkolab extends plugin { var $postfix_mynetworks = ""; var $postfix_enable_virus_scan = ""; var $cyrus_autocreatequota = ""; - var $cyrus_quotawarn = ""; + var $cyrus_quotawarn = "";//ok var $cyrus_admins = ""; - var $cyrus_imap = ""; - var $cyrus_pop3 = ""; - var $cyrus_imaps = ""; - var $cyrus_pop3s = ""; - var $cyrus_sieve = ""; - var $apache_allow_unauthenticated_fb = ""; + var $cyrus_imap = "";//ok + var $cyrus_pop3 = "";//ok + var $cyrus_imaps = "";//ok + var $cyrus_pop3s = "";//ok + var $cyrus_sieve = "";//ok + var $apache_allow_unauthenticated_fb = "";//doing now var $proftpd_ftp = ""; var $apache_http = ""; var $kolabHost = array(""); - + var $postfix_relayhost = ""; var $attributes = array("postfix_mydomain", "postfix_mydestination", - "postfix_mynetworks", "postfix_enable_virus_scan", + "postfix_mynetworks", "postfix_enable_virus_scan","postfix_relayhost", "cyrus_autocreatequota", "cyrus_admins", "cyrus_imap", "cyrus_pop3", "cyrus_imaps", "cyrus_pop3s", "cyrus_sieve", "apache_allow_unauthenticated_fb", "proftpd_ftp", @@ -166,17 +166,38 @@ class servkolab extends plugin { /* There a new Host submitted */ if (isset($_POST['NewHost'])) { - $this->attrs['kolabHost'][] = $_POST['NewkolabHost']; - gosa_log("Adding Host"); + + $abort= false; + if(empty($_POST['NewkolabHost'])) + { + //print_red(_("The given Hostname ist empty.")) + $abort = true; + } + else + { + foreach($this->attrs['kolabHost'] as $host) + { + if(strtolower($host) ==strtolower($_POST['NewkolabHost'])) + { + $abort = true; + //print_red(_("The given Host already exists")); + } + } + } + if(!$abort) + { + $this->attrs['kolabHost'][] = $_POST['NewkolabHost']; + } } /* We need to delete a Host */ if (isset($_POST['DelHost'])) { foreach($this->attrs['kolabHost'] as $key => $host) { - if ($host == $_POST['kolabHost']) + if(isset($_POST['kolabHost'])){ + if ($host == $_POST['kolabHost']) unset($this->attrs['kolabHost'][$key]); + } } - gosa_log("Removing Host".$this->attrs['kolabHost'][$key]); } @@ -197,6 +218,8 @@ class servkolab extends plugin { $smarty->assign($val, $this->$val); if (($this->$val != "FALSE") && (!empty($this->$val))) $smarty->assign($val."Check", "checked"); + else + $smarty->assign($val."Check", ""); } @@ -263,6 +286,12 @@ class servkolab extends plugin { $newattrs[$key2] = $this->$key; } + + + + + + /* Set bool vars */ if ($newattrs['postfix-enable-virus-scan'] == 0) $newattrs['postfix-enable-virus-scan'] = "FALSE"; @@ -302,6 +331,8 @@ class servkolab extends plugin { $newattrs['apache-allow-unauthenticated-fb'] = "TRUE"; + if(empty($newattrs['postfix-relayhost'])) unset( $newattrs['postfix-relayhost']); + /* Reorder Host array, to get constant increasing index */ $newattrs['kolabHost'] = array(); foreach($this->attrs['kolabHost'] as $key=>$val) { @@ -316,19 +347,32 @@ class servkolab extends plugin { /* If we already have an object like this one, we only need to modify the entry */ + + + if ($ldap->dn_exists($this->dn)) { gosa_log("Modifying"); + + /* unset all attributes we won't change*/ + unset($newattrs['cyrus-admins']); + unset($newattrs['postfix-mydomain']); + unset($newattrs['postfix-mydestination']); + //print_a($newattrs); + + + $ldap->cd($this->dn); $ldap->modify($newattrs); } else { /* We must create a new Entry */ - gosa_log("Adding"); $newattrs['k'] = "kolab"; $newattrs['uid'] = "freebusy"; $newattrs['postfix-mydomain'] = "gonicus.de"; $newattrs['postfix-mydestination'] = "\$mydomain"; $newattrs['userPassword'] = "tester"; $newattrs['objectClass'] = $this->objectclasses; + + gosa_log("Adding"); $ldap->cd($this->dn); $ldap->add($newattrs); } diff --git a/plugins/admin/systems/class_servService.inc b/plugins/admin/systems/class_servService.inc index 9403f1d9f..571311494 100644 --- a/plugins/admin/systems/class_servService.inc +++ b/plugins/admin/systems/class_servService.inc @@ -152,7 +152,7 @@ class servservice extends plugin } - if(isset($this->attrs['goXdmcpIsEnabled'])&&($this->attrs['goXdmcpIsEnabled'])) + if(isset($this->attrs['goXdmcpIsEnabled'])&&($this->attrs['goXdmcpIsEnabled']=="1")) $smarty->assign("goXdmcpIsEnabled","checked"); return($smarty->fetch (get_template_path('servservice.tpl', TRUE))); @@ -193,51 +193,54 @@ class servservice extends plugin /* Save to LDAP */ function save() { + /* Normalize lazy objectclass arrays */ $objectclasses= array(); foreach($this->objectclasses as $oc){ $objectclasses[]= $oc; } - - $this->objectclasses= $objectclasses; plugin::save(); - - /* Remove objectclasses */ - foreach(array_merge($this->objectclasses, $this->additionaloc) as $oc){ - foreach ($this->attrs['objectClass'] as $key => $value){ - if ($value == $oc){ - unset ($this->attrs['objectClass'][$key]); + + $test = $this->objectclasses; + $tmp = array_flip($this->attrs['objectClass']); + + foreach($this->additionaloc as $key=>$val) { + unset($tmp[$key]); + } + + foreach($tmp as $val){ + if(in_array($val,$test)){ + $tmp[$val]; } } - } - $this->attrs['objectClass']=array(); - foreach($this->objectclasses as $oc){ - $this->attrs['objectClass'][]= $oc; - } + + $classes = (array_flip(array_merge(array_flip($test),$tmp))); + unset($this->attrs['objectClass']); - /* Adapt sieve server if needed */ - if (in_array('goImapServer', $this->objectclasses)){ - $this->attrs['goImapSieveServer']= preg_replace('/:.*$/', '', - preg_replace('/^{([^}]+)}$/', '\\1', - $this->attrs['goImapConnect'])); + foreach($classes as $class){ + $this->attrs['objectClass'][]=$class; } + /* Remove unneeded attributes */ foreach ($this->additionaloc as $oc => $attrs){ - if (!in_array($oc, $this->objectclasses)){ + if (!in_array($oc, $this->attrs['objectClass'])){ foreach ($attrs as $attr){ $this->attrs[$attr]= array(); } } } + $this->attrs = array_reverse($this->attrs); + + + /* Write to LDAP */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->dn); $ldap->modify($this->attrs); show_ldap_error($ldap->get_error()); - /* Optionally execute a command after we're done */ if ($this->initially_was_account == $this->is_account){ if ($this->is_modified){