I managed to get Trixbox working with vTiger this morning. vTiger pissed me off because I read they recommend users to add sip: before all of the phone numbers added to the CRM. Personally, I think a much better way would be to have Asterisk do this so it could decide based on area codes or something...I don't know. The bottom line is, I am not going to require my customers/users to type sip: before each number they put into vTiger. From what I read, this is currently the case and would be unacceptable in my mind. Please correct if wrong, but here goes.
First of all, follow the wiki docs on getting vTiger configured. Details here: http://wiki.vtiger.com/index.php/vtiger510:Module_Asterisk
Next fire up your favorite editor and go into the /etc/asterisk directory. Open manager.conf and add the following:
[vtiger] secret = sugarsucks deny=0.0.0.0/0.0.0.0 permit=127.0.0.1/255.255.255.0 read = system,call,log,verbose,command,agent,user,config,dtmf,reporting,cdr,dialplan write = system,call,log,verbose,agent,user,config,command,reporting,originate
Your username (ie vtiger) and the password here along with the permitted IP address are what goes into the PBXManager module config so they can talk to each other. If you run different boxes, make sure you change the permit info.
Once done, you need to open /var/www/html/crm/modules/PBXManager/utils/AsteriskClass.php (starting location may vary depending on where you installed vtiger...this is the "default location" for trixbox). Go ~80 lines down in the code and look for a function called transfer. Here was the original:
function transfer($from,$to){
$this->log->debug("in function transfer($from, $to)");
if(empty($from) || empty($to)) {
echo "Not sufficient parameters to create the call";
$this->log->debug("Not sufficient parameters to create the call");
return false;
}
//the caller would always be a SIP phone in our case
if(!strstr($from,"SIP")){
$from = "SIP/$from";
}
$arr = explode(":", $to);
if(is_array($arr)){
$typeCalled = $arr[0];
$to = trim($arr[1]);
}
switch($typeCalled){
case "SIP":
$context = "local-extensions";
break;
case "PSTN":
$context = "from-inside";//"outbound-dialing";
break;
default:
$context = "default";
}
$this->createCall($from, $to, $context);
}And here is what I changed:
if(!strstr($from,"SIP")){
$from = "SIP/$from";
}
// this hard codes the sip: in here so the user doesn't have to enter it into vtiger.
$to = "sip:$to";
$arr = explode(":", $to);
if(is_array($arr)){
$typeCalled = $arr[0];
$to = trim($arr[1]);
}
switch($typeCalled){
case "SIP":
// The below context is the correct out-of-the box context for Trixbox.
$context = "from-internal";
break;
case "PSTN":
$context = "from-trunk";
break;
default:
$context = "default";
}That will do it for an easy hack to get this up and running for click to call on Trixbox. I am now going to see if I can get inbound working. Wish me luck. If I do, I will post on that too.
Member Since:
2009-12-16