6. Preferences

6.1. Tables

Currently available tables for preferences are

provisioning.voip_preferences: contains all available preferences, do not contain user data. provisioning.voip_preference_group: contains preference group names, so the preferences can be put into groups. provisioning.voip_preferences_enum: contains enum values for preferences, do not contain user data.

The following tables contain user data and depend on voip_preferences and optionally on voip_preferences_enum:

provisioning.voip_dev_preferences: PBX device model preferences provisioning.voip_devprof_preferences: PBX device profile preferences provisioning.voip_dom_preferences: domain preferences, replicated by triggers to kamailio.dom_preferences provisioning.voip_contract_preferences: customer preferences, replicated by triggers to kamailio.contract_preferences provisioning.voip_peer_preferences: peering server preferences, replicated by triggers to kamailio.peer_preferences provisioning.voip_prof_preferences: subscriber profile preferences provisioning.voip_reseller_preferences: reseller preferences provisioning.voip_usr_preferences: subscriber preferences, replicated by triggers to kamailio.usr_preferences

6.2. Columns

voip_preferences id: primary key, used in user tables as the foreign key voip_preference_groups_id: preference group id attribute: preference name label: tooltip that can be used as a mouseover tooltip on the UI type: 0 - string, 1 - integer/boolean max_occur: how many preferences with the name are allowed 0: list, 1: only one usr_pref: defines if the preference can be used in subscribers prof_pref: defines if the preference can be used in subcsriber profiles dom_pref: defines if the preference can be used in domains peer_pref: defines if the preference can be used in peering servers contract_pref: defines if the preference can be used in customers contract_location_pref: defines if the preference can be used in customer locations dev_pref: defines if the preference can be used in PBX device models devprof_pref: defines if the preference can be used in PBX device profiles fielddev_pref: defines if the preference can be used in PBX devices that are assigned to a subscriber modify_timestamp: preference last modification time internal: preference if for internal use only and not shown in the UI/API expose_to_customer: unused, as now there are dedicated customer preferences table data_type: data type enum, boolean, int, string read_only: ready only flag description: long description of the preference dynamic: set to 1 if it is a custom preference that is created by a user (usually for a PBX device model that requires specific preferences) but can be used for all preferences when needed reseller_pref: defines if the preference can be used in resellers

6.3. Enum

All tables are in database "provisioning".

So called "enum preferences" allow a fixed set of possible values, an enumeration, for preferences. Following the differences between other preferences are described.

Setting the attribute "data_type" of table "voip_preferences" to "enum" marks a preferences as an enum. The list of possible options is stored in table "voip_preferences_enum".

voip_preferences_enum is:

id
    primary key
preference_id
    Reference to table voip_preferences.
label
    A label to be displayed in frontends.
value
    Value that will be written to voip_[usr|dom|peer]_preferences.value
    if it is NOT NULL. Will not be written if it IS NULL. This can be
    used to implement a "default value" for a preference that is visible
    in frontends as such (will be listed first if nothing is actually
    selected), but will not be written to
    voip_[usr|dom|peer]_preferences.value. Usually forcing a domain or peer
    default. Should also be named unambiguous (eg. __"use domain default"__).
    (Note: Therefore will also not be written to any kamailio table.)
usr_pref
dom_pref
peer_pref
    Flag if this is to be used for [usr|dom|peer] preferences.
default_val
    Flag indicating if this should be used as a default value when
    creating new entities or introducing new enum preferences (both done
    via triggers). (Note: For this to work, value must also be set.)

Relevant triggers:

enum_update
    Propagates changes of voip_preferences_enum.value to
    voip_[usr|dom|peer]_preferences.value
enum_set_default
    Will create entries for default values when adding a new enum
    preference. The default value is the tuple from voip_preferences_enum
    WHERE default_val=1 AND value NOT NULL.
trigger voip_dom_crepl_trig
trigger voip_phost_crepl_trig
trigger voip_sub_crepl_trig
    These three triggers will set possible default values (same condition
    as for enum_set_default) when creating new subscribers/domains/peers.

Find a usage example in a section in db-schema/db_scripts/diff/9086.up.