From 63cd37768221a8928cf07f5c53bd870152c00284 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 4 Oct 2019 16:08:25 -0400 Subject: [PATCH] Updating plugin manager. Adding detail pages for sites and plugins. Plugin detail shows list of sites. Sites detail shows list of plugins. color diff if plugin version is less than the latest. --- classes/data/dataPlugins.php | 2 +- models/admin/plugins/plugins.php | 30 ++++- models/admin/plugins/servers.php | 2 +- models/admin/plugins/sites.php | 22 ++- views/admin/header.html | 2 +- views/admin/plugins/plugin-detail.html | 133 ++++++++++++++++++ views/admin/plugins/plugins.html | 2 +- views/admin/plugins/site-detail.html | 180 +++++++++++++++++++++++++ views/admin/plugins/sites.html | 2 +- 9 files changed, 368 insertions(+), 7 deletions(-) create mode 100644 views/admin/plugins/plugin-detail.html create mode 100644 views/admin/plugins/site-detail.html diff --git a/classes/data/dataPlugins.php b/classes/data/dataPlugins.php index 0c7e746..a1e229a 100644 --- a/classes/data/dataPlugins.php +++ b/classes/data/dataPlugins.php @@ -138,7 +138,7 @@ class GlmDataPlugins extends GlmDataAbstract 'notes' => array ( 'field' => 'notes', 'type' => 'text', - 'required' => true, + 'required' => false, 'use' => 'a' ), diff --git a/models/admin/plugins/plugins.php b/models/admin/plugins/plugins.php index 16ee6b3..b6b6d37 100644 --- a/models/admin/plugins/plugins.php +++ b/models/admin/plugins/plugins.php @@ -124,12 +124,40 @@ class GlmMembersAdmin_plugins_plugins extends GlmDataPlugins switch ( $option ) { + case 'save': + if ( isset( $_REQUEST['plugin_id'] ) && $id = filter_var( $_REQUEST['plugin_id'], FILTER_VALIDATE_INT ) ) { + $plugin = $this->updateEntry( $id ); + // echo '
$plugin: ' . print_r( $plugin, true ) . '
'; + } + + case 'view': + $view = 'plugin-detail'; + if ( isset( $_REQUEST['plugin_id'] ) && $id = filter_var( $_REQUEST['plugin_id'], FILTER_VALIDATE_INT ) ) { + $plugin = $this->editEntry( $id ); + $tData['plugin'] = $plugin; + // Find all sites for this plugin. + $tData['sites'] = $this->wpdb->get_results( + $this->wpdb->prepare( + "SELECT S.name as site_name,SP.prod_version,SP.dev_version,PS.name as prod_server,DS.name as dev_server + FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins SP + LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "sites S ON (S.id = SP.site) + LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "servers PS ON (PS.id = S.prod_server) + LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "servers DS ON (DS.id = S.dev_server) + WHERE SP.plugin = %d + ORDER BY S.name", + $plugin['fieldData']['id'] + ), + ARRAY_A + ); + } + break; + default: break; } // Get all plugins. - $plugins = $this->getList(); + $plugins = $this->getResults( array( 'order' => 'name' ) ); // Setup tData array. $tData['plugins'] = $plugins; diff --git a/models/admin/plugins/servers.php b/models/admin/plugins/servers.php index 2e34853..ddac427 100644 --- a/models/admin/plugins/servers.php +++ b/models/admin/plugins/servers.php @@ -129,7 +129,7 @@ class GlmMembersAdmin_plugins_servers extends GlmDataServers } // Get all plugins. - $servers = $this->getList(); + $servers = $this->getResults( array( 'order' => 'name' ) ); // Setup tData array. $tData['servers'] = $servers; diff --git a/models/admin/plugins/sites.php b/models/admin/plugins/sites.php index 5485529..1a80575 100644 --- a/models/admin/plugins/sites.php +++ b/models/admin/plugins/sites.php @@ -124,12 +124,32 @@ class GlmMembersAdmin_plugins_sites extends GlmDataSites switch ( $option ) { + case 'view': + $view = 'site-detail'; + if ( isset( $_REQUEST['site_id'] ) && $id = filter_var( $_REQUEST['site_id'], FILTER_VALIDATE_INT ) ) { + $site = $this->editEntry( $id ); + $tData['site'] = $site; + $tData['plugins'] = $this->wpdb->get_results( + $this->wpdb->prepare( + "SELECT P.name,P.latest_version,SP.prod_version,SP.dev_version + FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins SP + LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "plugins P ON (P.id = SP.plugin) + WHERE SP.site = %d + ORDER BY P.name", + $site['fieldData']['id'] + ), + ARRAY_A + ); + } + + break; + default: break; } // Get all plugins. - $sites = $this->getList(); + $sites = $this->getResults( array( 'order' => 'name' ) ); // Setup tData array. $tData['sites'] = $sites; diff --git a/views/admin/header.html b/views/admin/header.html index 37e444b..9431992 100644 --- a/views/admin/header.html +++ b/views/admin/header.html @@ -17,7 +17,7 @@
  • Servers
  • -
  • +
  • Import
  • diff --git a/views/admin/plugins/plugin-detail.html b/views/admin/plugins/plugin-detail.html new file mode 100644 index 0000000..a060d6f --- /dev/null +++ b/views/admin/plugins/plugin-detail.html @@ -0,0 +1,133 @@ +{* Plugin Detail View File *} + +{* Header *} +{include file="admin/header.html"} +

    {$plugin.fieldData.name|default:'New Plugin'}

    + +{* Grid Start *} +{$ui = [ + 'nowrap' => false, + 'backgroundColor' => '', + 'sectionColor' => '' +]} +{include file='ui/f6/grid-start.html'} + +{* Form Start *} +{$ui = [ + 'id' => 'id', + 'action' => "{$thisUrl}?page={$thisPage}", + 'method' => 'post', + 'file' => false, + 'validate' => true, + 'validateFocusMsg' => true, + 'leaveModifiedFormCheck' => true +]} +{include file='ui/f6/form-start.html'} + + + + + + {$data = $plugin} + + {* Name *} + {$ui = [ + 'value' => $data.fieldData.name, + 'field' => 'name', + 'label' => 'Name', + 'required' => $data.fieldRequired.name, + 'errorText' => 'Name is Required', + 'dataError' => $data.fieldFail.name + ]} + {include file='ui/f6/text.html'} + + {* Latest Version *} + {$ui = [ + 'value' => $data.fieldData.latest_version, + 'field' => 'latest_version', + 'label' => 'Latest Version', + 'required' => $data.fieldRequired.latest_version, + 'errorText' => 'Latest Version is Required', + 'dataError' => $data.fieldFail.latest_version + ]} + {include file='ui/f6/text.html'} + + {* Notes *} + {$ui = [ + 'value' => $data.fieldData.notes, + 'field' => 'notes', + 'label' => 'Notes', + 'height' => '250', + 'teeny' => true, + 'required' => $data.fieldRequired.notes, + 'errorText' => 'Notes is Required', + 'dataError' => $data.fieldFail.notes + ]} + {include file='ui/f6/editor.html'} + + {* GLMA *} + {$ui = [ + 'value' => $data.fieldData.glm_associate.value, + 'field' => 'glm_associate', + 'label' => 'GLMA', + 'required' => $data.fieldRequired.glm_associate, + 'errorText' => 'GLMA is Required', + 'dataError' => $data.fieldFail.glm_associate + ]} + {include file='ui/f6/checkbox.html'} + + {* Plugin Submit *} + {$ui = [ + 'class' => 'primary', + 'label' => 'Save', + 'submit' => true, + 'id' => 'plugin-submit', + 'cancel' => "" + ]} + {include file='ui/f6/submit.html'} + +{* Form End *} +{include file='ui/f6/form-end.html'} + + + +{if !empty($sites)} + + + + + + + + + {foreach $sites as $site} + + + + + + + + {/foreach} +
    Site NameProd ServerProd VersionDev ServerDev Version
    {$site.site_name}{$site.prod_server}{$site.prod_version}{$site.dev_server}{$site.dev_version}
    +{/if} + +{* Grid End *} +{include file='ui/f6/grid-end.html'} + + + +{* Footer *} +{include file="../../admin/footer.html"} diff --git a/views/admin/plugins/plugins.html b/views/admin/plugins/plugins.html index a987d03..010d4ea 100644 --- a/views/admin/plugins/plugins.html +++ b/views/admin/plugins/plugins.html @@ -18,7 +18,7 @@ {foreach $plugins as $plugin} {$plugin.id} - {$plugin.name} + {$plugin.name} {$plugin.latest_version} {if $plugin.glm_associate.value}Yes{else}No{/if} diff --git a/views/admin/plugins/site-detail.html b/views/admin/plugins/site-detail.html new file mode 100644 index 0000000..1935d5d --- /dev/null +++ b/views/admin/plugins/site-detail.html @@ -0,0 +1,180 @@ +{* Site Detail View File *} + +{* Header *} +{include file="admin/header.html"} +

    {$site.fieldData.name|default:'New Site'}

    + +{* Grid Start *} +{$ui = [ + 'nowrap' => false, + 'backgroundColor' => '', + 'sectionColor' => '' +]} +{include file='ui/f6/grid-start.html'} + +{* Form Start *} +{$ui = [ + 'id' => 'id', + 'action' => "{$thisUrl}?page={$thisPage}", + 'method' => 'post', + 'file' => false, + 'validate' => true, + 'validateFocusMsg' => true, + 'leaveModifiedFormCheck' => true +]} +{include file='ui/f6/form-start.html'} + + + + + + {$data = $site} + + {* Active *} + {$ui = [ + 'value' => $data.fieldData.active.value, + 'field' => 'active', + 'label' => 'Active', + 'required' => $data.fieldRequired.active, + 'errorText' => 'Active is Required', + 'dataError' => $data.fieldFail.active + ]} + {include file='ui/f6/checkbox.html'} + + {* Name *} + {$ui = [ + 'value' => $data.fieldData.name, + 'field' => 'name', + 'label' => 'Name', + 'required' => $data.fieldRequired.name, + 'errorText' => 'Name is Required', + 'dataError' => $data.fieldFail.name + ]} + {include file='ui/f6/text.html'} + + {* Prod Url *} + {$ui = [ + 'value' => $data.fieldData.prod_url, + 'field' => 'prod_url', + 'label' => 'Prod Url', + 'required' => $data.fieldRequired.prod_url, + 'errorText' => 'Prod Url is Required', + 'dataError' => $data.fieldFail.prod_url + ]} + {include file='ui/f6/text.html'} + + {* Dev Url *} + {$ui = [ + 'value' => $data.fieldData.dev_url, + 'field' => 'dev_url', + 'label' => 'Dev Url', + 'required' => $data.fieldRequired.dev_url, + 'errorText' => 'Dev Url is Required', + 'dataError' => $data.fieldFail.dev_url + ]} + {include file='ui/f6/text.html'} + + {* Prod Server *} + {$ui = [ + 'value' => $data.fieldData.prod_server.value, + 'field' => 'prod_server', + 'label' => 'Prod Server', + 'list' => $data.fieldData.prod_server.list, + 'l_label' => 'name', + 'l_value' => 'value', + 'l_blank' => false, + 'required' => $data.fieldRequired.prod_server, + 'errorText' => 'Prod Server is Required', + 'dataError' => $data.fieldFail.prod_server + ]} + {include file='ui/f6/select.html'} + + {* Dev Server *} + {$ui = [ + 'value' => $data.fieldData.dev_server.value, + 'field' => 'dev_server', + 'label' => 'Dev Server', + 'list' => $data.fieldData.dev_server.list, + 'l_label' => 'name', + 'l_value' => 'value', + 'l_blank' => false, + 'required' => $data.fieldRequired.dev_server, + 'errorText' => 'Dev Server is Required', + 'dataError' => $data.fieldFail.dev_server + ]} + {include file='ui/f6/select.html'} + + {* Map Key *} + {$ui = [ + 'value' => $data.fieldData.map_key, + 'field' => 'map_key', + 'label' => 'Map Key', + 'required' => $data.fieldRequired.map_key, + 'errorText' => 'Map Key is Required', + 'dataError' => $data.fieldFail.map_key + ]} + {include file='ui/f6/text.html'} + + {* Has Contacts *} + {$ui = [ + 'value' => $data.fieldData.has_contacts.value, + 'field' => 'has_contacts', + 'label' => 'Has Contacts', + 'required' => $data.fieldRequired.has_contacts, + 'errorText' => 'Has Contacts is Required', + 'dataError' => $data.fieldFail.has_contacts + ]} + {include file='ui/f6/checkbox.html'} + + {* Has Members *} + {$ui = [ + 'value' => $data.fieldData.has_members.value, + 'field' => 'has_members', + 'label' => 'Has Members', + 'required' => $data.fieldRequired.has_members, + 'errorText' => 'Has Members is Required', + 'dataError' => $data.fieldFail.has_members + ]} + {include file='ui/f6/checkbox.html'} + +{* Form End *} +{include file='ui/f6/form-end.html'} + + + +{if !empty($plugins)} + + + + + + + {foreach $plugins as $plugin} + + + + + + {/foreach} +
    Plugin NameProd VersionDev Version
    {$plugin.name}{$plugin.prod_version}{$plugin.dev_version}
    +{/if} + +{* Grid End *} +{include file='ui/f6/grid-end.html'} + + + +{* Footer *} +{include file="../../admin/footer.html"} diff --git a/views/admin/plugins/sites.html b/views/admin/plugins/sites.html index b0ddc5c..1d98d78 100644 --- a/views/admin/plugins/sites.html +++ b/views/admin/plugins/sites.html @@ -18,7 +18,7 @@ {foreach $sites as $site} {$site.id} - {$site.name} + {$site.name} {$site.prod_url} {$site.dev_url} -- 2.17.1