[imp] add_source preference value

Vilius Šumskas vilius at lnk.lt
Thu Jul 28 13:51:12 UTC 2011


> > Zitat von Vilius Šumskas <vilius at lnk.lt>:
> >
> > >> Zitat von Vilius Šumskas <vilius at lnk.lt>:
> > >>
> > >> >> Vilius Šumskas <vilius at lnk.lt> a écrit :
> > >> >>
> > >> >> >> Zitat von Vilius ?umskas <vilius at lnk.lt>:
> > >> >> >>
> > >> >> >> > Hello,
> > >> >> >> >
> > >> >> >> > add_source preference description reads:
> > >> >> >> >
> > >> >> >> > // Address book to use for adding addresses.
> > >> >> >> > // Put $cfgSources array element name in the value field.
> > >> >> >> > // Setting value to localsql would allow you to add contacts to
> > >> >> >> > MySQL database
> > >> >> >> > // See turba/config/sources.php for more info
> > >> >> >> >
> > >> >> >> > However with H4 this doesn't work anymore. I get "Unknown
> > >> address
> > >> >> >> > book 'localsql'." every time I send an email. Also, when I re-save
> > >> >> >> > preferences trough GUI and look at MySQL database I see that
> > the
> > >> new
> > >> >> >> > add_source preference value goes like
> > >> "NAkkIDxJBD9OMCV5CTiyKsA".
> > >> >> >> > What is the correct corresponding value for this preference
> under
> > H4
> > >> >> >> > so I can put it to prefs.local.php for all new users?
> > >> >> >>
> > >> >> >> See the example hook.
> > >> >> >
> > >> >> > OK. I have enabled prefs_init hook in imp/config/hooks.php
> > >> >> >
> > >> >> > I have created imp/config/prefs.local.php with a content:
> > >> >> >
> > >> >> > $_prefs['add_source'] = array(
> > >> >> >     'value' => '',
> > >> >> >     'type' => 'enum',
> > >> >> >     'enum' => array(),
> > >> >> >     'hook' => true,
> > >> >> >     'desc' => _("Choose the address book to use when adding
> > >> addresses.")
> > >> >> > );
> > >> >> >
> > >> >> > I still get the same message about unknown address book 'localsql'
> > >> >> > when sending email. Seems like
> > >> >> > $GLOBALS['registry']->call('contacts/getDefaultShare'); returns
> > >> >> > 'localsql' instead of share id.
> > >> >>
> > >> >>
> > >> >> try this :
> > >> >> prefs.local.php :
> > >> >> $_prefs['search_sources']['value'] = '';
> > >> >> $_prefs['search_sources']['locked'] = true;
> > >> >> $_prefs['search_sources']['hook'] = true;
> > >> >> $_prefs['search_fields']['value'] = '';
> > >> >> $_prefs['search_fields']['locked'] = true;
> > >> >> $_prefs['search_fields']['hook'] = true;
> > >> >> $_prefs['add_source']['value'] = '';
> > >> >> $_prefs['add_source']['locked'] = true;
> > >> >> $_prefs['add_source']['hook'] = true;
> > >> >>
> > >> >>
> > >> >> enable hooks using the provided examples for those 3 prefs and
> > remove
> > >> >> the actual values in your prefs backend.
> > >> >
> > >> > Still doesn't work. I have verified that 'localsql' value really
> > >> > comes from $GLOBALS['registry']->call('contacts/getDefaultShare');
> > >> > in a hook by adding "test" string in front of the call and get
> > >> > 'testlocalsql'. So the hook is working but doesn't return correct
> > >> > value of the share id.
> > >>
> > >> Then you probably have a wrong value for the default_dir pref in Turba
> > too.
> > >
> > > I have changed 'default_dir' parameter from 'localsql' to default
> > > empty value. Now I don't get the error message, but recipients are
> > > still not added to the localsql address book. Do I need to configure
> > > corresponding hook in Turba for default_dir too? In
> > > turba/config/hook.php.dist I see only a hook for 'addressbooks'
> > > preference.
> >
> > default_dir is actually just a last resort in getDefaultShare(). Take
> > a look at turba's Api.php to find out why it not returning the user's
> > share.
> 
> I have modified turba/Factory/Driver.php to include additional parameter
> and added it to Api.php call, so I can debug only API getDefaultShare() calls.
> 
> It seems that there is a problem in a factory because $GLOBALS['cfgSources']
> doesn't have 'localsql' key when called from getDefaultShare(). Instead it has
> all the sources with IDs as key. Here is a dump of $GLOBALS['cfgSources'] just
> before if empty check on line 56 in a factory:
> 
> http://p.defau.lt/?n0svWxMxhdOQs5bHHTznOw

Not sure if this is the right way but changing line 137 in turba/lib/Api.php to:

$driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($uid);

worked.

Should I create a ticked and a patch?

-- 
  Vilius



More information about the imp mailing list