X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_servDB.inc;h=2ee9f873de7001fedb1e3852cd3d82533e282cd2;hb=3644520502707cc1a35a915bfa358105e86c4818;hp=4244e40dd8252b298da643c4aa7a55578883a098;hpb=1e656ba5163d70b93ff6bf00c9c71627f191937e;p=gosa.git diff --git a/plugins/admin/systems/class_servDB.inc b/plugins/admin/systems/class_servDB.inc index 4244e40dd..2ee9f873d 100644 --- a/plugins/admin/systems/class_servDB.inc +++ b/plugins/admin/systems/class_servDB.inc @@ -9,6 +9,7 @@ class servdb extends plugin /* Object information */ var $goImapName= ""; + var $goImapName_old= ""; var $goImapConnect= ""; var $goImapAdmin= ""; var $goImapPassword= ""; @@ -25,13 +26,18 @@ class servdb extends plugin var $goFonPassword= ""; var $goFonAreaCode= ""; var $goFonCountryCode= ""; + var $ignore_account= TRUE; + var $goGlpiAdmin=""; + var $goGlpiDatabase = ""; + var $goGlpiPassword =""; + /* attribute list for save action */ var $attributes= array("goImapName", "goImapConnect", "goImapAdmin", "goImapPassword", "goImapSieveServer", "goImapSievePort", "goKrbRealm", "goKrbAdmin", "goKrbPassword", "goFaxAdmin", "goFaxPassword", "goLogAdmin", "goLogPassword", "goFonAdmin", "goFonPassword", - "goFonAreaCode", "goFonCountryCode"); + "goFonAreaCode", "goFonCountryCode","goGlpiAdmin","goGlpiDatabase","goGlpiPassword"); var $objectclasses= array("top", "goServer"); var $additionaloc= array("goImapServer" => array("goImapName", "goImapConnect", "goImapAdmin", "goImapPassword", @@ -41,6 +47,7 @@ class servdb extends plugin "goKrbPassword"), "goFaxServer" => array("goFaxAdmin", "goFaxPassword"), "goLogDBServer" => array("goLogAdmin", "goLogPassword"), + "goGlpiServer" => array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword"), "goFonServer" => array("goFonAdmin", "goFonPassword", "goFonAreaCode", "goFonCountryCode")); @@ -55,12 +62,18 @@ class servdb extends plugin } } + /* We need to save the historical state of goImapName for later checking */ + $this->goImapName_old= $this->goImapName; + /* Always is account... */ $this->is_account= TRUE; } function execute() { + /* Call parent execute */ + plugin::execute(); + /* Fill templating stuff */ $smarty= get_smarty(); @@ -70,12 +83,19 @@ class servdb extends plugin $smarty->assign("$attr"."ACL", chkacl($this->acl, $attr)); } + /* Don't show Asterisk for non-required attribute ipHostNumber and macAddress */ + $smarty->assign("staticAddress", ""); + /* Classes... */ foreach ($this->additionaloc as $oc => $dummy){ if (isset($this->objectclasses[$oc])){ $smarty->assign("$oc", "checked"); + $smarty->assign("$oc"."State", ""); $smarty->assign("$oc"."ACL", chkacl($this->acl, $oc)); + } else { + $smarty->assign("$oc", ""); + $smarty->assign("$oc"."ACL", chkacl($this->acl, $oc)); $smarty->assign("$oc"."State", "disabled"); } } @@ -92,14 +112,16 @@ class servdb extends plugin /* Save data to object */ function save_object() { - plugin::save_object(); - - /* Save checkbox state */ - foreach ($this->additionaloc as $oc => $dummy){ - if (isset($_POST[$oc]) && $_POST[$oc] == '1'){ - $this->objectclasses[$oc]= $oc; - } else { - unset($this->objectclasses[$oc]); + if (isset($_POST['dbtab'])){ + plugin::save_object(); + + /* Save checkbox state */ + foreach ($this->additionaloc as $oc => $dummy){ + if (isset($_POST[$oc]) && $_POST[$oc] == '1'){ + $this->objectclasses[$oc]= $oc; + } else { + unset($this->objectclasses[$oc]); + } } } } @@ -110,6 +132,14 @@ class servdb extends plugin { $message= array(); + if(in_array("goGlpiServer",$this->objectclasses)){ + foreach(array("goGlpiAdmin","goGlpiDatabase") as $attr){ + if(empty($this->$attr)){ + $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), $attr); + } + } + } + /* All fields are marked as *must* */ if (in_array("goImapServer", $this->objectclasses)){ foreach (array("goImapAdmin", "goImapName") as $attr){ @@ -118,6 +148,7 @@ class servdb extends plugin } } + /* Check connect string */ if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){ $message[]= sprintf(_("The imap connect string needs to be in the form '%s'."), @@ -133,6 +164,10 @@ class servdb extends plugin $message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), $attr); } } + /* goKrbPassword is a must field, if goKrbServer is used as objectClass */ + if ($this->goKrbPassword == "" ){ + $message[]= sprintf(_("The specified kerberos password is empty."), $attr); + } } if (in_array("goFaxServer", $this->objectclasses)){ if ($this->goFaxAdmin == "" || preg_match("/ /", $this->goFaxAdmin)){ @@ -151,6 +186,13 @@ class servdb extends plugin } } } + if (in_array("goImapServer", $this->objectclasses) && + $this->goImapName != $this->goImapName_old) { + // Attribute has changed + if(!preg_match("/^[a-z0-9.-]+$/", $this->goImapName)) { + $message[]= sprintf(_("The imap name string needs to be a hostname or an IP-address.")); + } + } return ($message); } @@ -164,11 +206,12 @@ class servdb extends plugin foreach($this->objectclasses as $oc){ $objectclasses[]= $oc; } - + + /* Move cn to sieve server */ + $this->goImapSieveServer= $this->cn; + plugin::save(); - - $test = $this->objectclasses; $tmp = array_flip($this->attrs['objectClass']); @@ -176,12 +219,6 @@ class servdb extends plugin unset($tmp[$key]); } - foreach($tmp as $val){ - if(in_array($val,$test)){ - $tmp[$val]; - } - } - $classes = (array_flip(array_merge(array_flip($test),$tmp))); unset($this->attrs['objectClass']); @@ -201,7 +238,6 @@ class servdb extends plugin } $this->attrs = array_reverse($this->attrs); - /* Write to LDAP */ $ldap= $this->config->get_ldap_link(); $ldap->cd($this->dn);