From: Chuck Scott Date: Fri, 26 Oct 2018 16:02:42 +0000 (-0400) Subject: Moved website target and E-mail settings to bandwidth display page. X-Git-Tag: v2.0.0~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1e0bca669e197d24306e4ac4f5a0fda5e5d209d7;p=WP-Plugins%2Fglm-serverstats.git Moved website target and E-mail settings to bandwidth display page. Site selection and settings form are only displayed for admins on the following site. www.gaslightmedia.com and 192.168.44.80 (Chuck's development system) See bottom of classes/serverBandwidthSupport.php. --- diff --git a/models/adminServerStats.php b/models/adminServerStats.php index 43c8d09..5219bb3 100755 --- a/models/adminServerStats.php +++ b/models/adminServerStats.php @@ -68,6 +68,13 @@ class adminServerStats extends glmServerStatsBandwidthSupport $thisMonthTime = false; $websiteId = false; $websites = false; + $settings = false; + + // If an update was submitted + $option = 'none'; + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } // Check for a selected site or use website in config $config = $this->getConfig(); @@ -102,6 +109,57 @@ class adminServerStats extends glmServerStatsBandwidthSupport break; } + if ($option == 'update_site') { + + // Update the website table with certain values + $settings = filter_input_array( INPUT_POST, + array( + 'target' => FILTER_VALIDATE_FLOAT, + 'disk_target' => FILTER_VALIDATE_FLOAT, + 'glm_contact' => FILTER_VALIDATE_EMAIL, + 'cust_contact' => FILTER_VALIDATE_EMAIL + ) + ); + $sql = " + UPDATE website + SET target = ".$settings['target'].", + disk_target = ".$settings['disk_target'].", + glm_contact = '".$settings['glm_contact']."', + cust_contact = '".$settings['cust_contact']."' + WHERE name = '$selectedSite' + "; + + $this->bwdb->query($sql); + + // Update our class parameters + $this->target = $settings['target']; + $this->disk_target = $settings['disk_target']; + $this->glm_contact = $settings['glm_contact']; + $this->cust_contact = $settings['glm_contact']; + + } + + // Get sort order + switch ($_REQUEST['site_sort']) { + case 'site_name': + $sortBy = 'name'; + $site_sort = 'site_name'; + break; + + case 'data_total': + $sortBy = 'data_total DESC'; + $site_sort = 'data_total'; + break; + + default: + $sortBy = 'target_percent DESC'; + $site_sort = 'target_percent'; + break; + } + + // Get the settings for the currently selected site + $settings = $this->bandwidthGetWebsiteSettingsFromName($selectedSite); + // Get list of sites in the bandwidth database $websites = $this->bandwidthLastMonthAllSites($sortBy); @@ -143,9 +201,10 @@ class adminServerStats extends glmServerStatsBandwidthSupport 'websiteId' => $this->siteId, 'target' => $this->target, 'websites' => $websites, - 'isProvider' => $this->isProvider(), + 'isProvider' => $this->isProvider(), 'site_sort' => $site_sort, - 'selectedSite' => $selectedSite + 'selectedSite' => $selectedSite, + 'settings' => $settings ); // Return status, suggested view, and data to controller diff --git a/models/adminServerStatsConfig.php b/models/adminServerStatsConfig.php index 131d363..5aa5c20 100755 --- a/models/adminServerStatsConfig.php +++ b/models/adminServerStatsConfig.php @@ -37,7 +37,6 @@ class adminServerStatsConfig extends glmServerStatsBandwidthSupport */ public function __construct() { - $this->bandwidthDataConnect(); } /* @@ -52,11 +51,6 @@ class adminServerStatsConfig extends glmServerStatsBandwidthSupport $connectError = False; $connectionUpdated = false; - $settingsUpdated = false; - $settingsUpdateError = false; - $websites = false; - $selectedSite = false; - $settings = false; // If an update was submitted $option = 'none'; @@ -101,69 +95,6 @@ class adminServerStatsConfig extends glmServerStatsBandwidthSupport $connectError = $this->connectError; } - // Check for a selected site or use website in config - $selectedSite = filter_input(INPUT_GET, 'selected_site', FILTER_SANITIZE_STRING); - if (!$selectedSite) { - $selectedSite = $config['website']; - } - - // If it's OK for the user to update the settings for this site - if ($this->isProvider()) { - - if ($option == 'update_site') { - - // Update the website table with certain values - $settings = filter_input_array( INPUT_POST, - array( - 'target' => FILTER_VALIDATE_FLOAT, - 'disk_target' => FILTER_VALIDATE_FLOAT, - 'glm_contact' => FILTER_VALIDATE_EMAIL, - 'cust_contact' => FILTER_VALIDATE_EMAIL - ) - ); - $sql = " - UPDATE website - SET target = ".$settings['target'].", - disk_target = ".$settings['disk_target'].", - glm_contact = '".$settings['glm_contact']."', - cust_contact = '".$settings['cust_contact']."' - WHERE name = '$selectedSite' - "; - $this->bwdb->query($sql); - - // Update our class parameters - $this->target = $settings['target']; - $this->disk_target = $settings['disk_target']; - $this->glm_contact = $settings['glm_contact']; - $this->cust_contact = $settings['glm_contact']; - - } - - // Get sort order - switch ($_REQUEST['site_sort']) { - case 'site_name': - $sortBy = 'name'; - $site_sort = 'site_name'; - break; - - case 'data_total': - $sortBy = 'data_total DESC'; - $site_sort = 'data_total'; - break; - - default: - $sortBy = 'target_percent DESC'; - $site_sort = 'target_percent'; - break; - } - - // Get list of sites in the bandwidth database - $websites = $this->bandwidthLastMonthAllSites($sortBy); - - // Get the settings for the currently selected site - $settings = $this->bandwidthGetWebsiteSettingsFromName($selectedSite); - - } // if OK to update site settings // Compile template data $templateData = array_merge( @@ -172,12 +103,6 @@ class adminServerStatsConfig extends glmServerStatsBandwidthSupport 'isProvider' => $this->isProvider(), 'connectionUpdated' => $connectionUpdated, 'connectError' => $connectError, - 'settingsUpdated' => $settingsUpdated, - 'settingsUpdateError' => $settingsUpdateError, - 'site_sort' => $site_sort, - 'websites' => $websites, - 'selectedSite' => $selectedSite, - 'settings' => $settings ) ); diff --git a/views/adminServerStats.html b/views/adminServerStats.html index 6d151e9..008586f 100755 --- a/views/adminServerStats.html +++ b/views/adminServerStats.html @@ -45,15 +45,18 @@ {else} {if $isProvider} -
-

Select a site to display (service provider only)

+

Service Provider Section

+ + + + +

Select a site to display

Sort by:   Percent of Target   Total Traffic   Site Name

-
Website                                                Last Month             Target                  
{foreach $websites as $site} @@ -63,6 +66,42 @@ --> {/foreach}
+ {if $selectedSite} + + + + + + + + + + + + + + + + + + +
 

Settings for Selected Site

Monthly Target Traffic: + +
Monthly target traffic is entered in Gigabytes. +
Target Disk Space Used: + +
Disk Space is entered in Gigabytes. +
Gaslight Media Contact E-Mail: + +
E-mail address of Gaslight Media contact who will receive over-target E-Mail. +
Customer Contact E-Mail: + +
E-mail address of customer contact who will receive over-target E-Mail. +
+ +
+ {/if} +

Customer Section

{/if}
diff --git a/views/adminServerStatsConfig.html b/views/adminServerStatsConfig.html index 9115c36..b5b8b82 100755 --- a/views/adminServerStatsConfig.html +++ b/views/adminServerStatsConfig.html @@ -81,68 +81,6 @@ {/if} - -{if !$connectError && $isProvider} -
- - - - - - - - - {if $selectedSite} - - - - - - - - - - - - - - - - - - - {/if} -

 

Site Selection (service provider only)

Select Site to Configure -

- Sort by: - Total Traffic - Percent of Target - Site Name -

- -

 

Settings for Selected Site (service provider only)

Monthly Target Traffic: - -
Monthly target traffic is entered in Gigabytes. -
Target Disk Space Used: - -
Disk Space is entered in Gigabytes. -
Gaslight Media Contact E-Mail: - -
E-mail address of Gaslight Media contact who will receive over-target E-Mail. -
Customer Contact E-Mail: - -
E-mail address of customer contact who will receive over-target E-Mail. -
- {if $selectedSite} - - {/if} -
-{/if}