Hi, <br><br>You can use one line to load all user preferences to avps<br><br> avp_db_load("$ru/username","*")<br><br>Assuming that usr_preferences table have records like that:<br><br><span style="font-family: courier new,monospace;">username | attribute | value <br>
------------------------------<br>abcd | callForward | </span>123456<br><span style="font-family: courier new,monospace;">dcba | voicemail | true</span><br><br>Then you can check user settings asking:<br><br>if (is_avp_set($avp(s:callForward)) {<br>
$rU = $avp(s:callForward)<br>}<br>if (is_avp_set($avp(s:voicemail)) {<br>
if ($avp(s:voicemail)=="true" {<br> # Redirect to voicemail server<br> rewritehostport("XXX.XXX.XXX.XXX:5070");<br> }<br>
}<br><br>I hope you get the idea, if not please review documentation usr_preferences and avpops module:<br> <a href="http://www.opensips.org/html/docs/db/db-schema-1.4.x.html#AEN581">http://www.opensips.org/html/docs/db/db-schema-1.4.x.html#AEN581</a><br>
<a href="http://www.opensips.org/html/docs/modules/1.4.x/avpops.html">http://www.opensips.org/html/docs/modules/1.4.x/avpops.html</a><br><br>Cheers,<br><br>Gustavo<br><br><div class="gmail_quote">On Tue, Jan 13, 2009 at 11:19 PM, pjgonzalez <span dir="ltr"><<a href="mailto:pgonzalez@dgtec.net.do">pgonzalez@dgtec.net.do</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi every body, i want to be able route calls from my sip, depending on his<br>
status, For example when the user is online he can change his status to<br>
ringOndevice to ring on his sip-phone, voice-mail to route to asterisk<br>
voicemail, and callforward to forward the call to a given number, the two<br>
first escerany are ok bu, i need to know how can i make a call forward base<br>
on users prefenrece.<br>
<br>
i alredy load the user preference from the usr_preference table.<br>
<br>
here my script part:<br>
<br>
if(nat_uac_test("19"))<br>
{<br>
setbflag(6);<br>
fix_nated_contact();<br>
xlog("L_INFO", "Fixing NAT AGAIN- M=$rm RURI=$ru F=$fu USR=$tU<br>
T=$tu IP=$si ID=$ci\n");<br>
};<br>
<br>
if(!lookup("location")){<br>
avp_db_query("SELECT count(*) FROM usr_preferences WHERE<br>
uuid='$tU'","$avp(s:hasPreference)");<br>
xlog("L_INFO", "User Preference:<br>
atributo:'$avp(s:hasPreference)'\n");<br>
<br>
CHECH IF USR is on preference DB to forward to voice Mail server.<br>
if($avp(s:hasPreference)){<br>
route(9);<br>
exit;<br>
}<br>
#OUTBOUNT CALLS/<br>
if (uri=~"^sip:[0-9]*@") {<br>
route(3);<br>
route(6);<br>
exit;<br>
};<br>
}<br>
else<br>
{<br>
route(13);<br>
}<br>
<br>
route[11]<br>
{<br>
xlog("L_INFO","Here on route 11");<br>
avp_pushto("$ru", "$avp(s:callForward)");<br>
<br>
rewritehostport("XXX.XXX.XXX.XXX:5070");<br>
append_branch();<br>
<br>
xlog("L_INFO", "The call was forwarded to: $avp(s:callForward) - M=$rm<br>
RURI=$ru F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");<br>
#t_on_failure("1");<br>
#t_on_reply("1");<br>
#t_relay();<br>
#xlog("L_INFO", "The call was relay to: $avp(s:callForward) - M=$rm RURI=$ru<br>
F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");<br>
#route(6);<br>
#t_on_branch("1");<br>
route(12);<br>
}<br>
<br>
route[12]{<br>
xlog("L_INFO","Here on route 12");<br>
t_on_failure("3");<br>
t_on_reply("1");<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
xlog("L_INFO", "The error: - M=$rm RURI=$ru F=$fu USR=$tU T=$tu<br>
IP=$si ID=$ci\n");<br>
<br>
};<br>
exit;<br>
}<br>
<br>
My script is base on sipwise sample.<br>
<br>
thanks a lot.<br>
<br>
route[13]<br>
{<br>
<br>
xlog("L_INFO", "User is Online - M=$rm RURI=$ru F=$fu<br>
USR=$tU T=$tu IP=$si ID=$ci\n");<br>
<br>
if(avp_db_load("$ru/username","$avp(s:callForward)"))<br>
{<br>
#xlog("L_INFO", "The call was forwarded to:<br>
$avp(s:callForward) - M=$rm RURI=$ru F=$fu USR=$tU T=$tu IP=$si ID=$ci\n");<br>
#avp_pushto("$tu", "$avp(s:callForward)");<br>
route(11);<br>
exit;<br>
}<br>
else if(avp_db_load("$ru/username","$avp(s:ringOnDevice)"))<br>
{<br>
xlog("L_INFO"," The call is ringing on: $ruri");<br>
route(3);<br>
route(8);<br>
exit;<br>
}<br>
else if(avp_db_load("$ru/username","$avp(s:voiceMail)"))<br>
{<br>
xlog("L_INFO", "Voice Mail HERE!! - M=$rm RURI=$ru<br>
F=$fu T=$tu IP=$si ID=$ci\n");<br>
route(9);<br>
exit;<br>
};<br>
<br>
exit;<br>
}<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://n2.nabble.com/DIferent-call-Status-when-base-on-user-Preference-tp2154604p2154604.html" target="_blank">http://n2.nabble.com/DIferent-call-Status-when-base-on-user-Preference-tp2154604p2154604.html</a><br>
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.<br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Gustavo Mistrinelli<br>