It can be changed to the following:
Code:
$QUERY = "SELECT name FROM cc_sip_buddies, cc_card WHERE cc_sip_buddies.name=cc_card.username AND name='{$this->destination}'";
This will make sure that sip_friends are being dial by using their name. That's what the Asterisk documentation says that we should be doing. Calling someone using the alias does not make much sense to me since the alias is card specific while account name is sip friend specific. Besides, it is the sip friend that is being called and not the customer card.
In addition to that, a small part of the code has to be slightly adjusted to make sure that it will
never use the username or main account alias as sip_friend username, password or name.
I am testing the code before submitting it. It should allow something that has be so far impossible: having more than one sip_friend account attached to the same card and
able to receive sip calls.
Oh, I almost forgot. That will make it possible to easily send a sip_friend or iax_friend calls through the rate engine by default. It will be up to you to keep it free of charge or to sell it at a cost.
Cheers