[SR-Users] Add country code on incoming calls - if not present

Daniel Tryba d.tryba at pocos.nl
Tue Sep 1 17:31:09 CEST 2015


On Tuesday 01 September 2015 16:43:42 Michael Nielsen wrote:
> If I want to load a user specific country code, using avp, how can I do
> this?
> 
> I've added kamctl avp add MY-SUBSCRIBER countrycode 0 +44, so +44 is added
> to usr_preferences.
> 
> But calling $avp(countrycode) doesn't seem to give me +44?

There is more than one way to do it, but I choose to load the usr_preferences 
into avps after authentication with avp_db_query (to have a fixed number of 
queries per call at the expense of memory).

//auth
                if(avp_db_query("SELECT 
replace(replace(concat('src_',attribute),'.','_'),'-','_'),value FROM 
usr_preferences WHERE username='$avp(au)' and domain='$fd' and length(value) > 
0"))
                {
                        while($avp(i:1)!=$null)
                        {
                                $avp($avp(i:1)[*])=$null;
                                $avp($avp(i:1))=$avp(i:2);

                                $avp(i:1)=$null;
                                $avp(i:2)=$null;
                        }
                }




More information about the sr-users mailing list