index 1df3e2251d610642e9a2c44e02ec25e155238f1e..1275580057ad572b3f278fbbe740a87c4e8fa361 100644 (file)
/* Object information */
var $goImapName= "";
/* Object information */
var $goImapName= "";
+ var $goImapName_old= "";
var $goImapConnect= "";
var $goImapAdmin= "";
var $goImapPassword= "";
var $goImapConnect= "";
var $goImapAdmin= "";
var $goImapPassword= "";
var $goFonPassword= "";
var $goFonAreaCode= "";
var $goFonCountryCode= "";
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",
/* 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",
var $objectclasses= array("top", "goServer");
var $additionaloc= array("goImapServer" => array("goImapName", "goImapConnect",
"goImapAdmin", "goImapPassword",
"goKrbPassword"),
"goFaxServer" => array("goFaxAdmin", "goFaxPassword"),
"goLogDBServer" => array("goLogAdmin", "goLogPassword"),
"goKrbPassword"),
"goFaxServer" => array("goFaxAdmin", "goFaxPassword"),
"goLogDBServer" => array("goLogAdmin", "goLogPassword"),
+ "goGlpiServer" => array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword"),
"goFonServer" => array("goFonAdmin", "goFonPassword",
"goFonAreaCode", "goFonCountryCode"));
"goFonServer" => array("goFonAdmin", "goFonPassword",
"goFonAreaCode", "goFonCountryCode"));
- function servdb ($config, $dn= NULL)
+ function servdb ($config, $dn= NULL, $parent= NULL)
{
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
/* Make dynamic list of objectClasses */
foreach ($this->additionaloc as $oc => $dummy){
/* Make dynamic list of objectClasses */
foreach ($this->additionaloc as $oc => $dummy){
}
}
}
}
+ /* 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()
{
/* Always is account... */
$this->is_account= TRUE;
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
/* Fill templating stuff */
$smarty= get_smarty();
} else {
$smarty->assign("$oc", "");
} else {
$smarty->assign("$oc", "");
- $smarty->assign("$oc"."ACL", "");
+ $smarty->assign("$oc"."ACL", chkacl($this->acl, $oc));
$smarty->assign("$oc"."State", "disabled");
}
}
$smarty->assign("$oc"."State", "disabled");
}
}
/* Save data to object */
function save_object()
{
/* 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]);
+ }
}
}
}
}
}
}
/* Check supplied data */
function check()
{
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ 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)){
/* All fields are marked as *must* */
if (in_array("goImapServer", $this->objectclasses)){
}
}
}
}
+
/* Check connect string */
if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
$message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
/* Check connect string */
if (!preg_match('/^\{[^:]+:[0-9]+.*\}$/', $this->goImapConnect)){
$message[]= sprintf(_("The imap connect string needs to be in the form '%s'."),
$message[]= sprintf(_("The attribute '%s' is empty or contains invalid characters."), $attr);
}
}
$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)){
}
if (in_array("goFaxServer", $this->objectclasses)){
if ($this->goFaxAdmin == "" || preg_match("/ /", $this->goFaxAdmin)){
}
}
}
}
}
}
+ 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);
}
return ($message);
}
foreach($this->objectclasses as $oc){
$objectclasses[]= $oc;
}
foreach($this->objectclasses as $oc){
$objectclasses[]= $oc;
}
-
+
+ /* Move cn to sieve server */
+ $this->goImapSieveServer= $this->cn;
+
plugin::save();
plugin::save();
-
-
$test = $this->objectclasses;
$tmp = array_flip($this->attrs['objectClass']);
$test = $this->objectclasses;
$tmp = array_flip($this->attrs['objectClass']);
}
$this->attrs = array_reverse($this->attrs);
}
$this->attrs = array_reverse($this->attrs);
-
/* Write to LDAP */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
/* Write to LDAP */
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
- // print_a($this->attrs);
- $ldap->modify($this->attrs);
- show_ldap_error($ldap->get_error());
+ $this->cleanup();
+ $ldap->modify ($this->attrs);
+
+ show_ldap_error($ldap->get_error(), _("Saving server db settings failed"));
/* 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");