[turba] Multiple selection for keywords or categories

Jan Schneider jan at horde.org
Thu Jan 31 18:02:54 UTC 2008


Zitat von Radim Machů <radim at machu.cz>:

>
>>> Hi,
>>>
>>> we use Horde Webmail Edition v1.0.3.
>>>
>>> I was inspired by http://wiki.horde.org/TurbaOutlook2003 which refers
>>> how to configure and address book fields.
>>>
>>> I am not willing to have a mess of Outlook addressbook fields :-)) but I
>>> would like to include a couple of  new fields. One of them should be a
>>> multiple selection keyword/category list. I have found out that
>>> following Horde Form Types could be used
>>> (http://wiki.horde.org/Doc/Dev/FormTypes):
>>> mlenum          n/a      Multi-level drop down lists           Values to
>>> select from, Prompt text
>>> multienum     enum     Multiple selection         Values, Size
>>> keyval_multienum     multienum     Multiple selection         Values, Size
>>>
>>> Could you please help how to set such a multiple selection field:
>>> * in attributes.php,
>>> * in sources.php,
>>> * and in the database?
>>>
>>> My suggestions or questions follows:
>>>
>>> **attributes.php ******************************
>>>
>>> |require_once 'Horde/Prefs/CategoryManager.php';
>>> $cManager = &new Prefs_CategoryManager();
>>> $categories = array_merge(array(_("Unfiled")), $cManager->get());
>>> $attributes['category_multi'] = array(
>>>     'label' => _("Multiple Categories"),
>>>     'type' => '|keyval_multienum|',
>>>     'params' => array($categories),
>>>     'required' => false
>>> );
>>>
>>> |**in sources.php*******************************
>>> |
>>> ...
>>> ,'category_multi' => 'object_category_multi',
>>> ...|
>>>
>>> **in the database******************************
>>> ...,
>>> |object_category ||ENUM('/|value1|/','/|value2|/',...),
>>> !!BUT !!
>>> ENUM is ||a| string object that can have only one value, chosen from
>>> the list of values |'/|value1|/'|,|'/|value2|/'|,
>>> while SET is a string object that can have zero or more values, each
>>> of which must be chosen from the list of values |'/|value1|/'|,
>>> |'/|value2|/'|!!!
>>> ***********************************************
>>>
>>
>> These are the suggestions, but where are your questions?
> Sorry, I wrote the final sentence without summarizing the questions:
>
> 1. is form type "keyval_multienum" a proper form type to manage a  
> field with multiple selection information?

multienum would suffice, but keyval_multienum is fine too.

> 2. before I ask our HORDE admin to test this, I would like to know a  
> piece of sample code for attributes.php and sources.php

You already provided some. Try if it works.

> 3. finally, what is database field type for a such data: ENUM or SET?

Neither, theoretically a VARCHAR would work, though I'm not sure at  
the moment if Turba is properly serializing enums.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the turba mailing list