Skip to content

Commit

Permalink
Merge pull request blak3r#38 from blak3r/Sugar6.5
Browse files Browse the repository at this point in the history
Sugar6.5 Support Added.
  • Loading branch information
blak3r committed Jul 21, 2012
2 parents 121d046 + fb84219 commit 7960e70
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 26 deletions.
26 changes: 16 additions & 10 deletions SugarModules/modules/Asterisk/asteriskLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ function login()
{
$result = parent::call('login', $this->auth_array);
$this->sessionid = $result['id'];
//print_r($result);
if( $this->sessionid == -1 ) {
logLine("! Soap login failed!\n");
print_r($result);
}
return ($result);
}

Expand All @@ -103,7 +106,6 @@ function call($method, $params)
}
//print_r($result);
return ($result);

}
}

Expand Down Expand Up @@ -133,7 +135,7 @@ function call($method, $params)
$calloutPrefix = isset($sugar_config['asterisk_prefix']) ? $sugar_config['asterisk_prefix'] : "";
echo ("# Callout prefix is [$calloutPrefix]\n");

$callinPrefix = isset($sugar_config['asterisk_dialinPrefix']) ? $sugar_config['asterisk_dialinPrefix'] : "+1";
$callinPrefix = isset($sugar_config['asterisk_dialinPrefix']) ? $sugar_config['asterisk_dialinPrefix'] : "";
echo ("# Callin prefix is [$callinPrefix]\n");
echo ("asteriskMatchInternal = $asteriskMatchInternal\n");

Expand All @@ -153,9 +155,11 @@ function call($method, $params)


// Get SOAP config
$sugarSoapEndpoint = $sugar_config['site_url'] . "/soap.php";
$sugarSoapEndpoint = $sugar_config['site_url'] . "/soap.php";//"/soap.php";
$sugarSoapUser = $sugar_config['asterisk_soapuser'];
$sugarSoapCredential = ""; {
$sugarSoapCredential = md5($sugar_config['asterisk_soappass']);
/*
{
$sql = "select user_hash from users where user_name='$sugarSoapUser'";
$sqlResult = mysql_query($sql);
if ($sqlResult) {
Expand All @@ -166,6 +170,7 @@ function call($method, $params)
die();
}
}
*/


//
Expand All @@ -186,12 +191,13 @@ function call($method, $params)
));


if( empty($userGUID) || empty($soapSessionId) ) {
if( empty($userGUID) || empty($soapSessionId) || $userGUID == -1 ) {
logLine( "! FATAL: SOAP login failed, something didnt get set by login... check your site_url:" . $soapSessionId . " user=" . $auth_array['user_auth']['user_name'] . " GUID=" . $userGUID . "\n");
die();
}
else {
logLine( "! Successful SOAP login id=" . $soapSessionId . " user=" . $auth_array['user_auth']['user_name'] . " GUID=" . $userGUID . "\n");
}

logLine( "! Successful SOAP login id=" . $soapSessionId . " user=" . $auth_array['user_auth']['user_name'] . " GUID=" . $userGUID . "\n");




Expand Down Expand Up @@ -315,7 +321,7 @@ function call($method, $params)
)
);
$soapResult = $soapClient->call('set_entry', $set_entry_params);

print_r( $soapResult );
$callRecordId = $soapResult['id'];
logLine("! Successfully created CALL record with id=" . $callRecordId . "\n");

Expand Down
4 changes: 3 additions & 1 deletion SugarModules/modules/Asterisk/include/AsteriskJS.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ function echoJavaScript($event,$arguments){
// If you already have jquery being loaded then you might want to comment out both.
// The Asterisk connector isn't picky as to what version of JQuery is used. Anything 1.3.2 or greater should work fine.
//echo $conditionalJqueryIncludeScript;
echo '<script type="text/javascript" src="custom/include/javascript/jquery/jquery.pack.js"></script>';
if( preg_match("/^6\.[1-4]/",$sugar_config['sugar_version']) ) {
echo '<script type="text/javascript" src="custom/include/javascript/jquery/jquery.pack.js"></script>';
}
// echo '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>';

$pollRate = !empty($sugar_config['asterisk_listener_poll_rate']) ? $sugar_config['asterisk_listener_poll_rate'] : "5000";
Expand Down
2 changes: 1 addition & 1 deletion SugarModules/modules/Asterisk/include/callListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
}

$queryContact = $selectPortion . $wherePortion;
//log_entry($queryContact . "\n","c:\callListenerLog.txt");
//log_entry($queryContacfastert . "\n","c:\callListenerLog.txt");
$innerResultSet = $current_user->db->query($queryContact, false);

//log_entry(printrs($innerResultSet),"c:\callListenerLog.txt");
Expand Down
3 changes: 3 additions & 0 deletions SugarModules/modules/Configurator/asterisk_configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
$asterisk_config['asterisk_context'] = 'from-internal';
$asterisk_config['asterisk_expr'] = '^(sip\/[1-9][0-9][0-9]?[0-9]?-|Local)';
$asterisk_config['asterisk_soapuser'] = 'admin';
$asterisk_config['asterisk_soappass'] = 'soap_password';

$asterisk_config['asterisk_log_file'] = '';
$asterisk_config['asterisk_dialout_channel'] = 'SIP/###';
Expand Down Expand Up @@ -128,6 +129,8 @@
$javascript->addFieldGeneric('asterisk_call_subject_max_length', "varchar", $mod_strings['LBL_ASTERISK_CALL_SUBJECT_MAX_LENGTH'], TRUE, "");
$javascript->addFieldGeneric('asterisk_listener_poll_rate', "varchar", $mod_strings['LBL_ASTERISK_LISTENER_POLL_RATE'], TRUE, "");

// Added in yaai-2.4
$javascript->addFieldGeneric("asterisk_soappass", "varchar", $mod_strings['LBL_ASTERISK_SOAPPASS'], TRUE, "");


echo $javascript->getScript();
Expand Down
35 changes: 26 additions & 9 deletions SugarModules/modules/Configurator/asterisk_configurator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,6 @@
<input type='text' name='asterisk_dialinPrefix' size="45" value='{$asterisk_dialinPrefix}'>
</td>
</tr><tr>
<td nowrap width="10%" class="dataLabel">{$MOD.LBL_ASTERISK_EXPR}: </td>
<td width="25%" class="dataField">
{if empty($config.asterisk_expr )}
{assign var='asterisk_expr' value=$asterisk_config.asterisk_expr}
{else}
{assign var='asterisk_expr' value=$config.asterisk_expr}
{/if}
<input type='text' name='asterisk_expr' size="45" value='{$asterisk_expr}'>
</td>
<td nowrap width="10%" class="dataLabel">{$MOD.LBL_ASTERISK_SOAPUSER}: </td>
<td width="25%" class="dataField">
{if empty($config.asterisk_soapuser )}
Expand All @@ -142,8 +133,34 @@
{assign var='asterisk_soapuser' value=$config.asterisk_soapuser}
{/if}
<input type='text' name='asterisk_soapuser' size="45" value='{$asterisk_soapuser}'>
<br/><span style="font-size:0.7em;color: gray;">*Note this is a SugarCRM user (Not an Asterisk User) that will be used by asteriskLogger when making SOAP calls.</span>
</td>
<td nowrap width="10%" class="dataLabel">{$MOD.LBL_ASTERISK_SOAPPASS}: </td>
<td width="25%" class="dataField">
{if empty($config.asterisk_soappass )}
{assign var='asterisk_soapppass' value=$asterisk_config.asterisk_soappass}
{else}
{assign var='asterisk_soapppass' value=$config.asterisk_soappass}
{/if}
<input type='text' name='asterisk_soappass' size="45" value='{$asterisk_soappass}'>
<br/><span style="font-size:0.9em;color: gray;">*Password may not be displayed here after reloading page. I'm not sure why but saving still works. I thought this behavior was actually ideal for security purposes! When in doubt, look in config.override.ini for asterisk_soappass to confirm..</span>
</td>
</tr>

<tr>
<td nowrap width="10%" class="dataLabel">{$MOD.LBL_ASTERISK_EXPR}: </td>
<td width="25%" class="dataField">
{if empty($config.asterisk_expr )}
{assign var='asterisk_expr' value=$asterisk_config.asterisk_expr}
{else}
{assign var='asterisk_expr' value=$config.asterisk_expr}
{/if}
<input type='text' name='asterisk_expr' size="45" value='{$asterisk_expr}'>
</td>
<TD>&nbsp;</TD>
<td>&nbsp;</td>
</tr>


<!-- Added in yaii 2.0 -->

Expand Down
1 change: 1 addition & 0 deletions SugarModules/modules/Configurator/language/en_us.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$mod_strings['LBL_ASTERISK_EXPR'] = 'Dialpattern for inbound/outbound matching';
$mod_strings['LBL_ASTERISK_EXPR_DESC'] = 'Regular expression to match incoming calls';
$mod_strings['LBL_ASTERISK_SOAPUSER'] = 'Asterisk Soap-User';
$mod_strings['LBL_ASTERISK_SOAPPASS'] = 'Asterisk Soap-Pass';

$mod_strings['LBL_ASTERISK_LOG_FILE'] = 'Log File Path';
$mod_strings['LBL_ASTERISK_DIALOUT_CHANNEL'] = 'Dialout Channel';
Expand Down
6 changes: 3 additions & 3 deletions manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
'regex_matches' =>
array (
1 => '6\.4\.\d',
2 => '6\.\d\.\d', /** matches 6.x.x **/
2 => '6\.[0-5]\.\d', /** matches 6.1.x,6.2.x,6.3.x,6.4.x,6.5.x **/
),
),
'acceptable_sugar_flavors' =>
Expand All @@ -60,9 +60,9 @@
'icon' => '',
'is_uninstallable' => true,
'name' => 'Asterisk SugarCRM Connector',
'published_date' => '2012-06-28',
'published_date' => '2012-07-21',
'type' => 'module',
'version' => '2.3.4.0 for v6.x',
'version' => '2.4.0 for v6.x',
'remove_tables' => 'true', /** This does absolutely nothing since our asterisk log table is created manually instead of as a bean **/
);

Expand Down
18 changes: 16 additions & 2 deletions scripts/post_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,22 @@ function post_install() {

?>
<br /><br />
<span style="font-size: 2em;"><strong>Please review the documentation! There are several additional steps that must be taken.</strong></span>
<br /><span style="font-size: 1.3em;">The User Guide can be found on the Project website here: <a href="https://github.com/blak3r/yaai/wiki/User-Manual">https://github.com/blak3r/yaai/wiki/User-Manual</a></span>
<span style="font-size: 1.6em;"><strong>Please review the documentation! There are several additional steps that must be taken.</strong></span>
<br /><span style="font-size: 1.3em;">The User Guide can be found on the Project website here: <a href="https://github.com/blak3r/yaai/wiki/User-Manual">https://github.com/blak3r/yaai/wiki/User-Manual</a>. Please note the fairly comprehensive troubleshooting section at the end of the manual.</span>
<br>
<BR>
<span style="font-size: 1.6em;"><strong>Donate to YAAI</strong></span>
<br /><span style="font-size:1.3em;">Please consider making a donation to the project. Your contribution allows me to spend more time improving/supporting.
We're also in great need of some help from developers. Please see: <a href="https://github.com/blak3r/yaai/wiki/Project-TODO-List">https://github.com/blak3r/yaai/wiki/Project-TODO-List</a> for ways you can help.</span>
<P>
<BR/>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="FA36DGSYQ3NE6">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</P>

<?php
}
Expand Down

0 comments on commit 7960e70

Please sign in to comment.