Summary | Photos: storing in LDAP and broken contact sync |
Queue | Turba |
Queue Version | 2.3 |
Type | Bug |
State | Resolved |
Priority | 2. Medium |
Owners | jan (at) horde (dot) org |
Requester | xk3 (at) mompl (dot) org |
Created | 09/29/2008 (6121 days ago) |
Due | |
Updated | 04/13/2010 (5560 days ago) |
Assigned | 10/24/2008 (6096 days ago) |
Resolved | 08/18/2009 (5798 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | Yes |
Filter out empty arrays (
Bug #7407).http://git.horde.org/diff.php/turba/lib/Driver/Ldap.php?rt=horde-git&r1=ddd78a35dc892e2dbdcbab6f077366ed8972fc65&r2=05a4fcce01e105c552dae2f1e2fdd363eaa2464b
State ⇒ Resolved
http://cvs.horde.org/diff.php/framework/SyncML/SyncML/Device/Nokia.php?rt=horde&r1=1.17&r2=1.18&ty=u
http://cvs.horde.org/diff.php/turba/lib/Driver/ldap.php?rt=horde&r1=1.54.4.21&r2=1.54.4.22&ty=u
#1of this ticket is still notsolved. I still have to patch the function _emptyAttributeFilter.
ticket #7407* Turba: H3 (2.3.1)
I would like to add a comment on syncing photos with Nokia E51: data
from the phone is parsed ok now, but syncing to the phone still needs
some tweaking: I added the following function in
./lib/SyncML/Device/Nokia.php
function convertServer2Client($content, $contentType, $database)
{
list($content, $contentType) =
parent::convertServer2Client($content, $contentType);
$content =
preg_replace('/(\r\n|\r|\n)PHOTO;ENCODING=b[^:]*:(.+?)(\r\n|\r|\n)/',
'\1PHOTO;ENCODING=BASE64:\1\2\1\1',
$content, 1);
$GLOBALS['backend']->logFile(
SYNCML_LOGFILE_DATA,
"\noutput converted for client ($contentType):\n$content\n");
return array($content, $contentType);
}
Reasons:
a) Nokia expects "BASE64" as encoding string, not "b" (which is base64)
b) Extra file type info confuses the phone, so strip everything else
before ":"
c) base64 has to end with an extra blank line (the double \1\1)
Finally, the problem 1) of comment
#1of this ticket is still notsolved. I still have to patch the function _emptyAttributeFilter.
cheers,
Martin
a stupid format for contact photos. Otherwise, I could live with as
save as local file button.
Horde_Form_Type_image. Please file a separate enhancement request for
that.
at the code there possibly for implementation, or maybe even somehow
time the editing into Ansel itself.
matching the following vCalender attributes. Otherwise the name of
one following PHOTO will start with a \r\n, so it will be
discarded afterward
extra blank line already.
and set to 'b'. Is that a valid encoding name at all? Changed
it to 'base64' and it worked again. In turba/lib/Driver.php
RFCs. We are reading it now anyway.
tool)? There are no delete and save buttons as for a common file.
a stupid format for contact photos. Otherwise, I could live with as
save as local file button.
Horde_Form_Type_image. Please file a separate enhancement request for
that.
http://cvs.horde.org/diff.php/turba/lib/tests/tohash.phpt?r1=1.14&r2=1.15&ty=u
http://cvs.horde.org/diff.php/turba/lib/Driver.php?r1=1.222&r2=1.223&ty=u
New Attachment: data.txt
kind of stuff.
State ⇒ Feedback
kind of stuff.
State ⇒ Assigned
Patch ⇒ Yes
New Attachment: turba-photo.patch
have created patches for convenience
Milestone ⇒
State ⇒ Unconfirmed
Patch ⇒ No
Queue ⇒ Turba
Summary ⇒ Photos: storing in LDAP and broken conatct sync
Type ⇒ Bug
Priority ⇒ 2. Medium
#5971Hi, just upgraded to current turba 2.3
and run into some problems with PHOTO
1) storing contact without a photo in LDAP
The attribute array always contains an array for the photo item. If
there is no photo set, this array is empty, but is not catched by the
function _emptyAttributeFilter in turba/lib/Driver/ldap.php. This
results in an error in _add to LDAP. Stripping empty arrays too solves
at least this problem.
function _emptyAttributeFilter($var)
{
if (!is_array($var)) {
return ($var != '');
} else {
if (count($var) == 0) { return false; } <<===
foreach ($var as $v) {
...
Storing in turba DB doesn't show this bug, but photos are stored as 0B
blobs instead of NULL blobs.
2) base64 is terminated by a blank line, so eliminate it before
matching the following vCalender attributes. Otherwise the name of
one following PHOTO will start with a \r\n, so it will be
discarded afterward
in /lib/Horde/iCalendar.php
// Unfold any folded lines.
- $vCal = preg_replace('/[\r\n]+[ \t]/', '', $vCal);
+ $vCal = preg_replace('/[\r\n]+[ \t]+/', '', $vCal);
+ $vCal = preg_replace('/\r\n\r\n/', "\r\n", $vCal);
(First line only beautifies the base64 code by stripping all
whitespace. The second line does the necessary work by deleting all
blank lines.)
and add the blank line in /turba/lib/Driver.php again before
sending to mobile:
case 'photo':
case 'logo':
$params = array('ENCODING' => 'base64');
if (isset($hash[$key . 'type'])) {
$params['TYPE'] = $hash[$key . 'type'];
}
$vcard->setAttribute(String::upper($key),
- base64_encode($val),
+ base64_encode($val) . "\r\n",
$params);
break;
3) Browsing the address book with photo as a visible column results in a
warning per entry containing a photo:
Warning: htmlspecialchars() expects parameter 1 to be string, array
given in
/var/www/org.afaik.duff_ssl/mail-new/turba/templates/browse/row.inc
on line 90
if ($ob->hasValue($this->columns[$c - 1])) {
$value = $ob->getValue($this->columns[$c - 1]);
- $shown_columns[$c] = htmlspecialchars($value)
+ $shown_columns[$c] = is_array($value) ? $value :
htmlspecialchars($value);
if ($type == 'email') {
No thinking on my side, just getting rid of this warning, so check
again.
4) In toHash and tovCard, the encoding of a photo is tested against
and set to 'b'. Is that a valid encoding name at all? Changed
it to 'base64' and it worked again. In turba/lib/Driver.php
case 'photo':
case 'logo':
- $params = array('ENCODING' => 'b');
+ $params = array('ENCODING' => 'base64');
if (!isset($item['params']['ENCODING']) ||
- String::lower($item['params']['ENCODING']) != 'b') {
+ String::lower($item['params']['ENCODING']) != 'base64') {
// Invalid property.
break;
5) Finally, how am I supposed to delete a photo from a contact or save
it to a local file (e.g. for doing some cropping stuff in an external
tool)? There are no delete and save buttons as for a common file.
Having this patched, I can add (ldap), change, view and sync photos
Martin
PS: any thoughts on adding crop support? Photos taken by mobiles have
a stupid format for contact photos. Otherwise, I could live with as
save as local file button.