[Astpp-commit] SF.net SVN: astpp:[2195] trunk
Brought to you by:
darrenkw
|
From: <dar...@us...> - 2008-09-02 05:17:33
|
Revision: 2195
http://astpp.svn.sourceforge.net/astpp/?rev=2195&view=rev
Author: darrenkw
Date: 2008-09-02 05:17:43 +0000 (Tue, 02 Sep 2008)
Log Message:
-----------
Added support to add and delete configuration items. Somebody still needs to add edit support.
Modified Paths:
--------------
trunk/astpp-admin.cgi
trunk/templates/configuration-list.tpl
Modified: trunk/astpp-admin.cgi
===================================================================
--- trunk/astpp-admin.cgi 2008-09-02 05:15:21 UTC (rev 2194)
+++ trunk/astpp-admin.cgi 2008-09-02 05:17:43 UTC (rev 2195)
@@ -8042,7 +8042,12 @@
. "</td><td>"
. gettext("Protocol")
. "</td><td>"
+ . "<a href=\"\#\">"
. gettext("Peer Name")
+ . "<span class=\"popups\">"
+ . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"")
+ . "</span>"
+ . "</a>"
. "</td><td>"
. gettext("Provider")
. "</td><td>"
@@ -8234,7 +8239,14 @@
. "</td><td>"
. gettext("Protocol")
. "</td><td>"
+ . "<div id=\"popups\">"
+ . "<a href=\"\#\">"
. gettext("Peer Name")
+ . "<span class=\"popups\">"
+ . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"")
+ . "</span>"
+ . "</a>"
+ . "</div>"
. "</td><td>"
. gettext("Provider")
. "</td><td>"
@@ -8322,7 +8334,14 @@
. "</td><td>"
. gettext("Protocol")
. "</td><td>"
- . gettext("Peer/Trunk")
+ . "<div id=\"popups\">"
+ . "<a href=\"\#\">"
+ . gettext("Peer Name")
+ . "<span class=\"popups\">"
+ . gettext("If using freeswitch then use the following formats: \"gateway\",\"gatewayname\" or \"profilename\",\"destinationhost\"")
+ . "</span>"
+ . "</a>"
+ . "</div>"
. "</td><td>"
. gettext("Provider")
. "</td><td>"
@@ -9159,11 +9178,79 @@
}
sub build_configuration() {
- my ( $tmp, $template, @configuration_list );
+ my ( @brands, @resellerlist, $tmp, $template, @configuration_list );
$template =
HTML::Template->new(
filename => '/var/lib/astpp/templates/configuration-list.tpl', die_on_bad_params => $config->{template_die_on_bad_params} );
+ if ( $params->{logintype} == 1 ) {
+ push(@resellerlist, $params->{username});
+ } else {
+ @resellerlist = &list_resellers($astpp_db);
+ push(@resellerlist, "");
+ }
+ $template->param(
+ resellers => popup_menu(
+ -name => "resellers",
+ -values => \@resellerlist
+ )
+ );
+ if ( $params->{logintype} == 1 || $params->{logintype} == 5 ) {
+ @brands = &list_cc_brands_reseller( $astpp_db, $params->{username} );
+ push(@brands, "");
+ }
+ else {
+ @brands = &list_cc_brands($astpp_db);
+ push(@brands, "");
+ }
+ $template->param(
+ brands => popup_menu(
+ -name => "brands",
+ -values => \@brands
+ )
+ );
+
+ if (!$params->{action}) { $params->{action} = "List"; }
+ if ($params->{action} eq "Edit") {
+ } elsif ($params->{action} eq "Add Item") {
+ if ( $params->{logintype} == 1 ) {
+ $params->{reseller} = $params->{username};
+ }
+ $tmp = "INSERT INTO system (reseller,brand,name,value,comment) VALUES ("
+ . $astpp_db->quote($params->{reseller}) . ","
+ . $astpp_db->quote($params->{brand}) . ","
+ . $astpp_db->quote($params->{name}) . ","
+ . $astpp_db->quote($params->{value}) . ","
+ . $astpp_db->quote($params->{comment}) . ")";
+ $ASTPP->debug( user=> $param->{username}, debug => $tmp);
+ if ( $astpp_db->do($tmp) ) {
+ $status .= "Added Configuration Item!";
+ } else {
+ $status .= "Failed to Add Configuration Item!";
+ }
+ $params->{action} = "List";
+ } elsif ($params->{action} eq "Delete") {
if ( $params->{logintype} == 2 ) {
+ if ($params->{reseller} ne "") {
+ $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name})
+ . " AND reseller = " . $astpp_db->quote($params->{reseller}) . " LIMIT 1";
+ } else {
+ $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name})
+ . " AND reseller IS NULL LIMIT 1";
+ }
+ } elsif ( $params->{logintype} == 1 ) {
+ $tmp = "DELETE FROM system WHERE name = " . $astpp_db->quote($params->{name})
+ . " AND reseller = " . $astpp_db->quote($params->{username}) . " LIMIT 1";
+ }
+ $ASTPP->debug( user=> $param->{username}, debug => $tmp);
+ if ( $astpp_db->do($tmp) ) {
+ $status .= "Removed Configuration Item!";
+ } else {
+ $status .= "Failed to Remove Configuration Item!";
+ }
+ $params->{action} = "List";
+ }
+ if ($params->{action} eq "List") {
+ if ( $params->{logintype} == 2 ) {
$tmp = "SELECT * FROM system ORDER BY reseller,name";
}
elsif ( $params->{logintype} == 1 ) {
@@ -9186,6 +9273,7 @@
}
$sql->finish;
$template->param( configuration_list => \@configuration_list );
+ }
return $template->output;
}
Modified: trunk/templates/configuration-list.tpl
===================================================================
--- trunk/templates/configuration-list.tpl 2008-09-02 05:15:21 UTC (rev 2194)
+++ trunk/templates/configuration-list.tpl 2008-09-02 05:17:43 UTC (rev 2195)
@@ -1,25 +1,46 @@
-<form method="post" action="/cgi-bin/astpp-admin/astpp-admin.cgi?mode=Configuration" enctype="multipart/form-data">
-<table>
- <tr>
- <input type="hidden" name="mode" value="Configuration"/>
- <td colspan=9 align=center><TMPL_VAR NAME="status"></td>
- </tr>
- <tr class="header">
- <td>Reseller</td>
- <td>Brand</td>
- <td>Name</td>
- <td>Value</td>
- <td>Comment</td>
- <td>Time Stamp</td>
- </tr>
- <TMPL_LOOP NAME="configuration_list">
- <TR>
- <TD><TMPL_VAR NAME="reseller"></TD>
- <TD><TMPL_VAR NAME="brand"></TD>
- <TD><TMPL_VAR NAME="name"></TD>
- <TD><TMPL_VAR NAME="value"></TD>
- <TD><TMPL_VAR NAME="comment"></TD>
- <TD><TMPL_VAR NAME="timestamp"></TD>
+<table class="default">
+ <tr class="header">
+ <td colspan=10>Configuration Details</td>
+<input name="mode" value="Configuration" type="hidden">
+ </tr>
+ <tr class="header">
+ <td>Reseller</td>
+ <td>Brand</td>
+ <td>Name</td>
+ <td>Value</td>
+ <td>Comment</td>
+ <td>Action</td>
+ </tr>
+ <tr class="header">
+ <td colspan=6>Add Item</td>
+ </tr>
+ <tr class="rowone">
+ <td><TMPL_VAR NAME="resellers"></td>
+ <td><TMPL_VAR NAME="brands"></td>
+ <td><input name="name" size="20" type="text"></td>
+ <td><input name="value" size="20" type="text"></td>
+ <td><input name="comment" size="50" type="text"></td>
+ <td><input name="action" value="Add Item" type="submit"></td>
+ </tr>
+ <tr class="header">
+ <td colspan=5>List</td>
+ </tr>
+ <TMPL_LOOP NAME="configuration_list">
+ <TR>
+ <TD><TMPL_VAR NAME="reseller"></TD>
+ <TD><TMPL_VAR NAME="brand"></TD>
+ <TD><TMPL_VAR NAME="name"></TD>
+ <TD><TMPL_VAR NAME="value"></TD>
+ <TD><TMPL_VAR NAME="comment"></TD>
+ <TD><a href="astpp-admin.cgi?mode=Configuration&action=Delete&name=<TMPL_VAR NAME="name">&reseller=<TMPL_VAR NAME="Reseller">">Delete</a>
+ <a href="astpp-admin.cgi?mode=Configuration&action=Edit&name=<TMPL_VAR NAME="name">&reseller=<TMPL_VAR NAME="Reseller">">Edit</a></TD>
</TR>
- </TMPL_LOOP>
+ </TMPL_LOOP>
</table>
+
+<table>
+ <tr>
+ <td><TMPL_VAR NAME="status"></td>
+ </tr>
+ </table>
+</form>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|