Skip to content

Commit 4ce17f0

Browse files
committed
3.5.6 --> 3.6.6 Lots of performance changes, new features, bug fixes
1 parent 76870ab commit 4ce17f0

22 files changed

+1640
-1331
lines changed

RELEASE-NOTES

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
IMPORTANT: when upgrading, please see the instructions in the User Manual <http://www.github.com/blak3r/yaai/wiki/User-Manual>
22

3+
##Version 3.6.0 (2013-07-28)
4+
* Enhancements
5+
** Click To Dial is more intelligent, it always relates call to the record clicked. Before if multiple matching phone numbers, before if phone number matched multiple contacts it showed radio buttons.
6+
** New config option "Max Call Popups" controls the maximum number of popups that will appear on a users screen.
7+
** The 'X' button is easier to click to close call popups.
8+
** (Basic/Pro Only) - Calls to Queues and RingGroups now popup on callee's screen before answering.
9+
* Bug Fixes
10+
** dial_events_log in admin config now works.
11+
** Admin Checkboxes always appeared as checked.
12+
13+
314
##Version 3.5.4 (2013-07-08)
415
* New User Interface
516
* Ability to specify which contact and account phone fields are searched.

SugarModules/modules/Asterisk/asteriskLogger.php

+491-291
Large diffs are not rendered by default.

SugarModules/modules/Asterisk/include/AsteriskJS.php

+28-21
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,20 @@ function echoJavaScript() {
7979
echo '<script type="text/javascript">window.callinize_fop_pass = "' . $fop_pass . '";</script>';
8080
echo '<script type="text/javascript">window.callinize_fop_url= "' . $fop_url . '";</script>';
8181
echo '<script type="text/javascript">window.callinize_fop_enabled= ' . $fop_enabled . ';</script>';
82-
echo '<script type="text/javascript">window.callinize_show_transfer_button= ' . $GLOBALS['sugar_config']['asterisk_transfer_button_enabled'] . ';</script>';
83-
echo '<script type="text/javascript">window.callinize_relate_to_account_enabled = ' . $GLOBALS['sugar_config']['asterisk_relate_to_account_enabled'] . ';</script>';
84-
echo '<script type="text/javascript">window.callinize_relate_to_contact_enabled = ' . $GLOBALS['sugar_config']['asterisk_relate_to_contact_enabled'] . ';</script>';
85-
echo '<script type="text/javascript">window.callinize_relate_to_lead_enabled = ' . $GLOBALS['sugar_config']['asterisk_relate_to_lead_enabled'] . ';</script>';
86-
echo '<script type="text/javascript">window.callinize_create_new_contact_enabled = ' . $GLOBALS['sugar_config']['asterisk_create_new_contact_enabled'] . ';</script>';
87-
echo '<script type="text/javascript">window.callinize_create_new_lead_enabled = ' . $GLOBALS['sugar_config']['asterisk_create_new_lead_enabled'] . ';</script>';
88-
echo '<script type="text/javascript">window.callinize_block_button_enabled = ' . $GLOBALS['sugar_config']['asterisk_block_button_enabled'] . ';</script>';
89-
echo '<script type="text/javascript">window.callinize_recording_enabled = ' . $GLOBALS['sugar_config']['asterisk_recordings_enabled'] . ';</script>';
82+
echo '<script type="text/javascript">window.callinize_show_transfer_button= ' . getConfigBool('asterisk_transfer_button_enabled',0) . ';</script>';
83+
echo '<script type="text/javascript">window.callinize_relate_to_account_enabled = ' . getConfigBool('asterisk_relate_to_account_enabled',0) . ';</script>';
84+
echo '<script type="text/javascript">window.callinize_relate_to_contact_enabled = ' . getConfigBool('asterisk_relate_to_contact_enabled',0) . ';</script>';
85+
echo '<script type="text/javascript">window.callinize_relate_to_lead_enabled = ' . getConfigBool('asterisk_relate_to_lead_enabled',0) . ';</script>';
86+
echo '<script type="text/javascript">window.callinize_create_new_contact_enabled = ' . getConfigBool('asterisk_create_new_contact_enabled',0) . ';</script>';
87+
echo '<script type="text/javascript">window.callinize_create_new_lead_enabled = ' . getConfigBool('asterisk_create_new_lead_enabled',0) . ';</script>';
88+
echo '<script type="text/javascript">window.callinize_block_button_enabled = ' . getConfigBool('asterisk_block_button_enabled',0) . ';</script>';
89+
echo '<script type="text/javascript">window.callinize_recording_enabled = ' . getConfigBool('asterisk_recordings_enabled',0) . ';</script>';
9090

9191
echo '<script type="text/javascript"> if (!window.console) console = {log: function() {}}; </script>'; // Prevents bug in IE (See Issue #108)
9292

9393

9494
//JS Third-Party Libraries
95-
if( preg_match("/^6\.[1-4]/",$GLOBALS['sugar_version']) ) {
95+
if( preg_match("/^6\.[1-4]/",$GLOBALS['sugar_version'] && $GLOBALS['sugar_config']['asterisk_jquery_override'] == '0') ) {
9696
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>';
9797
echo '<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript"></script>';
9898
}
@@ -102,10 +102,10 @@ function echoJavaScript() {
102102
echo '<script src="custom/modules/Asterisk/include/javascript/offlineMode/handlebars-1.0.rc.1.js"></script>';
103103
$template = file_get_contents( "custom/modules/Asterisk/include/template/call-template.html" );
104104
echo '<script id="handlebars-dev-template" type="text/x-handlebars-template">' . $template . '</script>';
105-
}
106-
else {
107-
echo '<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars.runtime-1.0.rc.1.js"></script>';
105+
}else {
106+
echo '<script src="custom/modules/Asterisk/include/javascript/handlebars.runtime.js"></script>';
108107
echo '<script src="custom/modules/Asterisk/include/template/call-template.tmpl"></script>';
108+
109109
}
110110

111111
echo '<script src="custom/modules/Asterisk/include/javascript/jquery.fancybox.js" type="text/javascript" ></script>';
@@ -119,16 +119,14 @@ function echoJavaScript() {
119119
echo '<script type="text/javascript" src="custom/modules/Asterisk/include/javascript/dialout.js"></script>';
120120
}
121121

122-
// @@@@ BEGIN CALLINIZE SIP ONLY @@@@
123-
echo '<script type="text/javascript" src="custom/modules/Asterisk/include/javascript/SIPml-api.js"></script>';
124-
echo '<script type="text/javascript" src="custom/modules/Asterisk/include/javascript/sipml-callinize.js"></script>';
125-
// @@@@ END CALLINIZE SIP ONLY @@@@
126-
127122
//CSS Third-Party Libraries
128-
if( $yaaiDevMode ) {
129-
echo '<link rel="stylesheet" href="custom/modules/Asterisk/include/javascript/offlineMode/jquery-ui.css" />';
130-
}else {
131-
echo '<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css" />';
123+
if ($GLOBALS['sugar_config']['asterisk_jquery_override'] == '0') {
124+
if ($callinizeDevMode) {
125+
echo '<link rel="stylesheet" href="custom/modules/Asterisk/include/javascript/offlineMode/jquery-ui.css" />';
126+
} else {
127+
128+
echo '<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css" />';
129+
}
132130
}
133131

134132
echo '<link rel="stylesheet" type="text/css" href="custom/modules/Asterisk/include/css/jquery.fancybox.css" media="screen" />';
@@ -142,7 +140,16 @@ function echoJavaScript() {
142140
}
143141
}
144142
}
143+
}
145144

145+
function getConfigBool($index,$defaultValue=0) {
146+
//return "1";
147+
if( !empty( $GLOBALS['sugar_config'][$index]) ) {
148+
return $GLOBALS['sugar_config'][$index];
149+
}
150+
else {
151+
return $defaultValue;
152+
}
146153
}
147154

148155
?>

SugarModules/modules/Asterisk/include/callCreate.php

+64-44
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
<?php
1+
<?php
22
/**
3-
* Asterisk SugarCRM Integration
3+
* Asterisk SugarCRM Integration
44
* (c) KINAMU Business Solutions AG 2009
5-
*
5+
*
66
* Parts of this code are (c) 2006. RustyBrick, Inc. http://www.rustybrick.com/
7-
* Parts of this code are (c) 2008 vertico software GmbH
7+
* Parts of this code are (c) 2008 vertico software GmbH
88
* Parts of this code are (c) 2009 abcona e. K. Angelo Malaguarnera E-Mail [email protected]
99
* http://www.sugarforge.org/projects/yaai/
10-
*
10+
*
1111
* This program is free software; you can redistribute it and/or modify it under
1212
* the terms of the GNU General Public License version 3 as published by the
1313
* Free Software Foundation with the addition of the following permission added
1414
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
1515
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
1616
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
17-
*
17+
*
1818
* This program is distributed in the hope that it will be useful, but WITHOUT
1919
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2020
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2121
* details.
22-
*
22+
*
2323
* You should have received a copy of the GNU General Public License along with
2424
* this program; if not, see http://www.gnu.org/licenses or write to the Free
2525
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2626
* 02110-1301 USA.
27-
*
27+
*
2828
* You can contact KINAMU Business Solutions AG at [email protected]
29-
*
29+
*
3030
* The interactive user interfaces in modified source and object code versions
3131
* of this program must display Appropriate Legal Notices, as required under
3232
* Section 5 of the GNU General Public License version 3.
33-
*
33+
*
3434
*/
3535
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3636

3737
require_once('include/utils.php');
3838
require_once('include/export_utils.php');
39+
//require_once('callinize_db.php');
3940

4041
global $sugar_config;
4142
global $locale;
@@ -89,39 +90,40 @@
8990
//format Phone Number
9091
$number = $_REQUEST['phoneNr'];
9192
$prefix = $sugar_config['asterisk_prefix'];
92-
$number = str_replace("+", "00", $number);
93+
$number = str_replace("+1", "", $number);
9394
$number = str_replace(array("(", ")", " ", "-", "/", "."), "", $number);
9495
$number = $prefix.$number;
9596
echo "Originate Params: Number: $number, Channel: $channel, Context: $context, Exten: $number...\n";
9697

9798

9899
$socket = fsockopen($server, $port, $errno, $errstr, 20);
99-
100+
100101
if (!$socket) {
101102
echo "errstr ($errno) <br>\n";
102-
103+
103104
} else {
104105

105106
// $result = ReadResponse($socket);
106107
// echo "AMI Header: " . $result;
107108

108109
// log on to Asterisk
109-
fputs($socket, "Action: Login\r\n");
110+
fputs($socket, "Action: Login\r\n");
110111
fputs($socket, $Username);
111112
fputs($socket, $Secret);
112113
fputs($socket, "Events: off\r\n");
113-
fputs($socket, "\r\n");
114+
fputs($socket, "\r\n");
114115
$result = ReadResponse($socket);
115116
echo("Login Response: " . $result . "\n");
116117

117118

118119
// dial number
119-
fputs($socket, "Action: originate\r\n");
120-
fputs($socket, "Channel: ". $channel ."\r\n");
121-
fputs($socket, "Context: ". $context ."\r\n");
122-
fputs($socket, "Exten: " . $number . "\r\n");
123-
fputs($socket, "Priority: 1\r\n");
124-
fputs($socket, "Callerid:" . $_REQUEST['phoneNr'] ."\r\n");
120+
fputs($socket, "Action: originate\r\n");
121+
fputs($socket, "Channel: ". $channel ."\r\n");
122+
fputs($socket, "Context: ". $context ."\r\n");
123+
fputs($socket, "Exten: " . $number . "\r\n");
124+
fputs($socket, "Priority: 1\r\n");
125+
fputs($socket, "Callerid:" . $_REQUEST['phoneNr'] ."\r\n");
126+
fputs($socket, "Account: CLICKTODIAL-" . formatPhoneNumberToE164($_REQUEST['phoneNr']) . "-" . $_REQUEST['module'] . "-" . $_REQUEST['contactId'] . "\r\n");
125127
fputs($socket, "Variable: CALLERID(number)=" . $extension . "\r\n\r\n");
126128

127129
// You will not get an originate response unless you wait for the phone to be answered... so it's impractical to wait.
@@ -130,8 +132,8 @@
130132
echo "Originate Response: " . $result . "\n";
131133

132134
fputs($socket, "Action: Logoff\r\n\r\n");
133-
fputs($socket, "\r\n");
134-
135+
fputs($socket, "\r\n");
136+
135137
$result = ReadResponse($socket);
136138
echo("Logout Response: " . $result);
137139

@@ -142,7 +144,7 @@
142144
//var_dump($context);
143145
//var_dump($number);
144146
//sleep(1);
145-
147+
146148
// close socket
147149
fclose($socket);
148150
}
@@ -175,21 +177,6 @@ function ReadResponse($socket, $timeout = 500000) {
175177
return $retVal;
176178
}
177179

178-
/**
179-
* Performs an async get request (doesn't wait for response)
180-
* Note: One limitation of this approach is it will not work if server does any URL rewriting
181-
*/
182-
function gitimg_log($event) {
183-
$host = "gitimg.com";
184-
$path = "/rs/track/blak3r/yaai-stats/$event/increment";
185-
$fp = fsockopen($host,80, $errno, $errstr, 30);
186-
$out = "GET " . $path . " HTTP/1.1\r\n";
187-
$out.= "Host: " . $host . "\r\n";
188-
$out.= "Connection: Close\r\n\r\n";
189-
fwrite($fp, $out);
190-
fclose($fp);
191-
}
192-
193180
/**
194181
* Another var_dump() alternative, for debugging use.
195182
*
@@ -206,18 +193,51 @@ function printr($data, $exit = TRUE) {
206193
// exit;
207194
// }
208195
}
209-
196+
210197
function logLine($str)
211198
{
212-
// print($str);
213-
199+
// print($str);
200+
214201
// if logging is enabled.
215-
if( !empty($sugar_config['asterisk_log_file']) )
202+
if( !empty($sugar_config['asterisk_log_file']) )
216203
{
217-
$myFile = $sugar_config['asterisk_log_file']; // Might be a performance issue being here...
204+
$myFile = $sugar_config['asterisk_log_file']; // Might be a performance issue being here...
218205
$fh = fopen($myFile, 'a') or die("can't open file");
219206
fwrite($fh, $str);
220207
fclose($fh);
221208
}
222209
}
210+
211+
/**
212+
* Helper method for turning any number into an e164 number
213+
*
214+
* @param string $number The number you want to convert
215+
* @return string
216+
*/
217+
function formatPhoneNumberToE164($number) {
218+
219+
// get rid of any non (digit, + character)
220+
$phone = preg_replace('/[^0-9+]/', '', $number);
221+
222+
// validate intl 10
223+
if (preg_match('/^\+([2-9][0-9]{9})$/', $phone, $matches)) {
224+
return "+{$matches[1]}";
225+
}
226+
227+
// validate US DID
228+
if (preg_match('/^\+?1?([2-9][0-9]{9})$/', $phone, $matches)) {
229+
return "+1{$matches[1]}";
230+
}
231+
232+
// validate INTL DID
233+
if (preg_match('/^\+?([2-9][0-9]{8,14})$/', $phone, $matches)) {
234+
return "+{$matches[1]}";
235+
}
236+
237+
// premium US DID
238+
if (preg_match('/^\+?1?([2-9]11)$/', $phone, $matches)) {
239+
return "+1{$matches[1]}";
240+
}
241+
}
242+
223243
?>

0 commit comments

Comments
 (0)