Tue 16 May 2006 03:43:52 PM UTC, comment #4:
in phamm05 module you can find purge_empty_values function, it is very easy but works fine, take a look, I use it to purge all array before use ldap functions to insert or update entry
function purge_empty_values ($data)
{
// Empty array
$res = array();
foreach ($data as $key => $val)
if ($val)
$res[$key] = $val;
return $res;
}
anyway a similar problem is try to update not existing attribute, using related DB this is not a problem, but with LDAP whis produce error
I think will be important use a way to create "on fly" not existing attributes if wanted
|
Sat 08 Apr 2006 08:13:58 PM UTC, comment #2:
I have the same problems when adding aliases. Under some cirtumstances, adding the alias fails because of empty ldap attributes.
I have hacked the add_alias.php a little:
for ($i=0; $i < count($maildrop); $i++)
{
- $info["maildrop"][$i] = "$maildrop[$i]";
+ if ( !empty($maildrop[$i]) ) // only non-empty maildrops are useful
+ $info["maildrop"][$i] = "$maildrop[$i]";
}
this works for me.
The best solution would be a function which kills empty attributes out of the update array.
|
Thu 08 Dec 2005 07:52:31 PM UTC, comment #1:
Your patch do not solve the problem ;-P
Amavi schema provide 3 attributes:
amavisSpamTagLevel
amavisSpamTag2Level
amavisSpamKillLevel
Only if manager are logged phamm provide a form with the 3 select,
in the other cases phamm show only one generic select "Spam kill level" and choose the 3 values as defined in configuration file.
Maybe the mail/config.inc.php file is not contains this values:
$spamTagLevels
$spamTag2Levels
$spamKillLevels
or a bug in those lines
// Value Reference
$refValue = $amavis["amavisspamkilllevel"];
$level = $spamKillLevels["$refValue"];
//
$info["amavisSpamTagLevel"] = array_search($level,$spamTagLevels);
$info["amavisSpamTag2Level"] = array_search($level,$spamTag2Levels);
|
Wed 30 Nov 2005 10:01:59 AM UTC, original submission:
seems that under certain circumstances, when logged as user
and spamcheck is enabled, phamm fails to update the records
because the array passed to ldap modify contains empty values
(amavisSpamTagLevel and amavisSpamTag2Level).
this little hack simply deletes empty tags from the ldap array and so the update is successful.
btw, I think that the correct method is not having these values at all, when logged as user....
--- phamm-0.4.6/plugins/mail/functions/modify_mail.php 2005-05-18 17:29:43.000000000 +0200
+++ phamm/plugins/mail/functions/modify_mail.php 2005-11-21 20:38:48.000000000 +0100
@@ -92,7 +92,16 @@
$info["amavisSpamTag2Level"] = array_search($level,$spamTag2Levels);
}
- $r = ldap_modify($connect, "mail=$mail,vd=$domain,$LDAP_BASE", $info);
+ reset($info);
+ while (list($key, $val) = each($info)) {
+ if($val)
+ $info_clean[$key] = $val;
+ }
+ //print_r($info);
+ //print_r($info_clean);
+
+ error_log("$connect, mail=$mail,vd=$domain,$LDAP_BASE, $info_clean");
+ $r = ldap_modify($connect, "mail=$mail,vd=$domain,$LDAP_BASE", $info_clean);
return $r;
}
|