[Astpp-commit] SF.net SVN: astpp: [2161] trunk
Brought to you by:
darrenkw
|
From: <dar...@us...> - 2007-11-18 00:26:30
|
Revision: 2161
http://astpp.svn.sourceforge.net/astpp/?rev=2161&view=rev
Author: darrenkw
Date: 2007-11-17 16:26:27 -0800 (Sat, 17 Nov 2007)
Log Message:
-----------
Resolved: FS#335 ?\194?\151 Show list of SIP and IAX2 accounts in "View Details"
Modified Paths:
--------------
trunk/astpp-admin.cgi
trunk/astpp-common.pl
trunk/templates/account-info.tpl
Modified: trunk/astpp-admin.cgi
===================================================================
--- trunk/astpp-admin.cgi 2007-11-17 23:15:16 UTC (rev 2160)
+++ trunk/astpp-admin.cgi 2007-11-18 00:26:27 UTC (rev 2161)
@@ -1915,6 +1915,59 @@
}
$template->param( account_ip_list => \@account_ip_list);
$template->param( currency => $currency[0]);
+
+## List the SIP/IAX2 devices belonging to this account. ##
+ my @account_device_list;
+ if ($rt_db) {
+ my @sip_names = &list_sip_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc});
+ my @iax_names = &list_iax_account_rt($rt_db,$config,$accountinfo->{number}, $accountinfo->{cc});
+ foreach my $name (@sip_names) {
+ my $deviceinfo = &get_sip_account_rt($rt_db,$config,$name);
+ my %row;
+ $row{tech} = "SIP";
+ $row{type} = $deviceinfo->{type};
+ $row{username} = $deviceinfo->{username};
+ $row{secret} = $deviceinfo->{secret};
+ $row{context} = $deviceinfo->{context};
+ push(@account_device_list, \%row);
+ }
+ foreach my $name (@iax_names) {
+ my $deviceinfo = &get_iax_account_rt($rt_db,$config,$name);
+ my %row;
+ $row{tech} = "IAX2";
+ $row{type} = $deviceinfo->{type};
+ $row{username} = $deviceinfo->{username};
+ $row{secret} = $deviceinfo->{secret};
+ $row{context} = $deviceinfo->{context};
+ push(@account_device_list, \%row);
+ }
+ }
+ if ($freepbx_db) {
+ my @sip_names = &list_sip_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc});
+ my @iax_names = &list_iax_account_freepbx($freepbx_db,$config,$accountinfo->{number}, $accountinfo->{cc});
+ foreach my $name (@sip_names) {
+ my $deviceinfo = &get_sip_account_freepbx($freepbx_db,$config,$name);
+ my %row;
+ $row{tech} = "SIP";
+ $row{type} = $deviceinfo->{type};
+ $row{username} = $deviceinfo->{username};
+ $row{secret} = $deviceinfo->{secret};
+ $row{context} = $deviceinfo->{context};
+ push(@account_device_list, \%row);
+ }
+ foreach my $name (@iax_names) {
+ my $deviceinfo = &get_iax_account_freepbx($freepbx_db,$config,$name);
+ my %row;
+ $row{tech} = "IAX2";
+ $row{type} = $deviceinfo->{type};
+ $row{username} = $deviceinfo->{username};
+ $row{secret} = $deviceinfo->{secret};
+ $row{context} = $deviceinfo->{context};
+ push(@account_device_list, \%row);
+ }
+ }
+ $template->param(account_device_list => \@account_device_list);
+### End Section ###
($sql, $pagination) =
$ASTPP->pagination( sql_select => "SELECT * FROM cdrs WHERE cardnum ="
. $astpp_db->quote( $accountinfo->{number} )
@@ -9197,6 +9250,9 @@
$rt_db = &rt_connect_db( $config, @output );
push @modes, gettext("Switch Config");
}
+ if ( $config->{users_dids_amp} == 1 ) {
+ $freepbx_db = &freepbx_connect_db( $config, @output );
+ }
if ( $config->{callingcards} == 1 ) {
push @modes, gettext("Calling Cards");
}
Modified: trunk/astpp-common.pl
===================================================================
--- trunk/astpp-common.pl 2007-11-17 23:15:16 UTC (rev 2160)
+++ trunk/astpp-common.pl 2007-11-18 00:26:27 UTC (rev 2161)
@@ -2341,10 +2341,10 @@
sub list_sip_account_rt() {
my ( $rt_db, $config, $name, $cc) = @_;
my ($tmp,$row, $sql, @devicelist);
-# if ($config->{debug} == 1) {
+ if ($config->{debug} == 1) {
print STDERR "NAME: $name";
print STDERR "CC: $cc";
-# }
+ }
$tmp = "SELECT name FROM $config->{rt_sip_table} WHERE accountcode IN ("
. $rt_db->quote($name) . ","
. $rt_db->quote($cc) . ")";
@@ -2358,6 +2358,30 @@
return @devicelist;
}
+sub get_sip_account_rt() {
+ my ($rt_db,$config,$name) = @_;
+ my $tmp = "SELECT * FROM $config->{rt_sip_table} WHERE name = "
+ . $rt_db->quote($name) . " LIMIT 1";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ my $sql = $rt_db->prepare($tmp);
+ $sql->execute;
+ my $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ return $record;
+}
+
+sub get_iax_account_rt() {
+ my ($rt_db,$config,$name) = @_;
+ my $tmp = "SELECT * FROM $config->{rt_iax_table} WHERE name = "
+ . $rt_db->quote($name) . " LIMIT 1";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ my $sql = $rt_db->prepare($tmp);
+ $sql->execute;
+ my $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ return $record;
+}
+
# Add a SIP user to the asterisk realtime DB.
sub add_sip_user_rt() {
my ( $rt_dbh, $config, $name, $secret, $context, $username,
@@ -2598,6 +2622,83 @@
####### OpenSER Integration Ends ###############
####### FreePBX subroutines start here ###########
+sub get_iax_account_freepbx(){
+ my ($freepbx_db,$config,$name) = @_;
+ my ($tmp,$record,$sql,$deviceinfo);
+ $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'context' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{context} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'secret' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{secret} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'type' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{type} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_iax_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'username' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{username} = $record;
+ return $deviceinfo;
+}
+
+sub get_sip_account_freepbx(){
+ my ($freepbx_db,$config,$name) = @_;
+ my ($tmp,$record,$sql,$deviceinfo);
+ $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'context' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{context} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'secret' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{secret} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'type' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{type} = $record;
+ $tmp = "SELECT value FROM $config->{freepbx_sip_table} WHERE id = " . $freepbx_db->quote($name)
+ . " AND keyword = 'username' LIMIT 1)";
+ print STDERR "$tmp\n" if $config->{debug} == 1;
+ $sql = $freepbx_db->prepare($tmp);
+ $sql->execute;
+ $record = $sql->fetchrow_hashref;
+ $sql->finish;
+ $deviceinfo->{username} = $record;
+ return $deviceinfo;
+}
+
+
# Return a list of sip devices belong to a specific account
sub list_sip_account_freepbx() {
my ( $freepbx_db, $config, $name, $cc) = @_;
Modified: trunk/templates/account-info.tpl
===================================================================
--- trunk/templates/account-info.tpl 2007-11-17 23:15:16 UTC (rev 2160)
+++ trunk/templates/account-info.tpl 2007-11-18 00:26:27 UTC (rev 2161)
@@ -176,7 +176,30 @@
<td><input name="action" value="Post Charge..." type="submit"></td>
</tr>
</table>
+
+<table class="default">
+ <tr class="header">
+ <td colspan=5>IAX2 & SIP Accounts</td>
+ </tr>
+ <tr class="header">
+ <td>Tech</td>
+ <td>Type</td>
+ <td>Username</td>
+ <td>Password</td>
+ <td>Context</td>
+ </tr>
+ <TMPL_LOOP NAME="account_device_list">
+ <tr>
+ <td><TMPL_VAR NAME="tech"></td>
+ <td><TMPL_VAR NAME="type"></td>
+ <td><TMPL_VAR NAME="username"></td>
+ <td><TMPL_VAR NAME="secret"></td>
+ <td><TMPL_VAR NAME="context"></td>
+ </tr>
+ </TMPL_LOOP>
+</table>
+
<table class="default">
<tr class="header">
<td>UniqueID</td>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|