index 7518cdcf60d047f3f9aa99c09fd1c3531068e0c4..ad41a149fba046e79b2dd943fa4c53faa773871d 100644 (file)
/* Object information */
var $goImapName= "";
+ var $goImapName_old= "";
var $goImapConnect= "";
var $goImapAdmin= "";
var $goImapPassword= "";
var $goFonPassword= "";
var $goFonAreaCode= "";
var $goFonCountryCode= "";
+ var $ignore_account= TRUE;
/* attribute list for save action */
var $attributes= array("goImapName", "goImapConnect", "goImapAdmin", "goImapPassword",
}
}
+ /* We need to save the historical state of goImapName for later checking */
+ $this->goImapName_old= $this->goImapName;
+
/* Always is account... */
$this->is_account= TRUE;
}
$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");
}
}
/* 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]);
+ }
}
}
}
}
}
}
+ 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);
}
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($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();