Cor Bosman wrote:
> Hi all, a plugin question ive been wondering about.  What is the
> recommended way for a plugin to save longterm non-user configurable
> data?  Just an example, lets say I want to keep track on if ive shown
> a MOTD page to a user, id have to save that information. But some
> plugins may have much more extensive needs here. Basically any data
> you want to save immediately without going through a save preferences
> click.
>
> It might be nice to have some api functions that allow a plugin to
> save this kind of data without having to construct your own SQL. Any
> ideas about this? Maybe it exists already and I just couldnt find.

The easiest way to do so with the current code is to use
   rcmail::get_instance()->user->save_prefs(array('key' => $value));
and for retrieval
   $value = rcmail::get_instance()->config->get('key');

We currently don't distinguish between config and prefs. This makes it easy 
to set defaults for user prefs by local config.
>
> Also, looking at the code it seems as if plugins through
> save_preferences hook can add saved prefs, but this has a potential
> for unintentional overlap. If 2 plugins decide to use the same name,
> you'll override a previous config with the same name. Maybe RC should
> add the plugin name or something to the prefs key?

You're right. Good developers do this by their own but maybe there should 
be some checking. On the other hand, this would make it impossible for 
plugins to set application settings. Bug or Feature? I don't know.

~Thomas
_______________________________________________
List info: http://lists.roundcube.net/dev/

Reply via email to