Updating plugin manager.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 4 Oct 2019 20:08:25 +0000 (16:08 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 4 Oct 2019 20:08:25 +0000 (16:08 -0400)
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
models/admin/plugins/plugins.php
models/admin/plugins/servers.php
models/admin/plugins/sites.php
views/admin/header.html
views/admin/plugins/plugin-detail.html [new file with mode: 0644]
views/admin/plugins/plugins.html
views/admin/plugins/site-detail.html [new file with mode: 0644]
views/admin/plugins/sites.html

index 0c7e746..a1e229a 100644 (file)
@@ -138,7 +138,7 @@ class GlmDataPlugins extends GlmDataAbstract
             'notes' => array (
                 'field'    => 'notes',
                 'type'     => 'text',
-                'required' => true,
+                'required' => false,
                 'use'      => 'a'
             ),
 
index 16ee6b3..b6b6d37 100644 (file)
@@ -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 '<pre>$plugin: ' . print_r( $plugin, true ) . '</pre>';
+            }
+
+        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;
index 2e34853..ddac427 100644 (file)
@@ -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;
index 5485529..1a80575 100644 (file)
@@ -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;
index 37e444b..9431992 100644 (file)
@@ -17,7 +17,7 @@
                     <li class="{if $thisAction == 'servers'}is-active{/if}">
                         <a href="{$thisUrl}?page={$thisPage}&glm_action=servers">Servers</a>
                     </li>
-                    <li class="{if $thisAction == 'import'}is-active{/if}">
+                    <li class="{if $thisAction == 'import'}is-active{/if} hide">
                         <a href="{$thisUrl}?page={$thisPage}&glm_action=import">Import</a>
                     </li>
                 </ul>
diff --git a/views/admin/plugins/plugin-detail.html b/views/admin/plugins/plugin-detail.html
new file mode 100644 (file)
index 0000000..a060d6f
--- /dev/null
@@ -0,0 +1,133 @@
+{* Plugin Detail View File *}
+
+{* Header *}
+{include file="admin/header.html"}
+<h3>{$plugin.fieldData.name|default:'New Plugin'}</h3>
+
+{* 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'}
+
+    <input type="hidden" name="glm_action" value="plugins">
+    <input type="hidden" name="option" value="save">
+    <input type="hidden" name="plugin_id" value="{$plugin.fieldData.id}">
+
+    {$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'}
+
+<style>
+    .row-green {
+        background-color: rgb( 225, 250, 234 );
+    }
+    .row-red {
+        background-color: rgb( 247, 228, 225 );
+    }
+</style>
+
+{if !empty($sites)}
+    <table class="stack hover">
+        <tr>
+            <th class="text-left">Site Name</th>
+            <th class="text-left">Prod Server</th>
+            <th class="text-left">Prod Version</th>
+            <th class="text-left">Dev Server</th>
+            <th class="text-left">Dev Version</th>
+        </tr>
+        {foreach $sites as $site}
+            <tr>
+                <td>{$site.site_name}</td>
+                <td width="110">{$site.prod_server}</td>
+                <td width="110" class="{if !empty($site.prod_version) && version_compare( $plugin.fieldData.latest_version, $site.prod_version, '>' )}row-red{elseif !empty($site.prod_version)}row-green{/if}">{$site.prod_version}</td>
+                <td width="110">{$site.dev_server}</td>
+                <td width="110" class="{if !empty($site.dev_version) && version_compare( $plugin.fieldData.latest_version, $site.dev_version, '>' )}row-red{elseif !empty($site.dev_version)}row-green{/if}">{$site.dev_version}</td>
+            </tr>
+        {/foreach}
+    </table>
+{/if}
+
+{* Grid End *}
+{include file='ui/f6/grid-end.html'}
+
+<script>
+jQuery(document).ready(function($){
+    $(document).foundation();
+
+});
+</script>
+
+{* Footer *}
+{include file="../../admin/footer.html"}
index a987d03..010d4ea 100644 (file)
@@ -18,7 +18,7 @@
             {foreach $plugins as $plugin}
                 <tr>
                     <td>{$plugin.id}</td>
-                    <td>{$plugin.name}</td>
+                    <td><a href="{$thisUrl}?page={$thisPage}&glm_action={$thisAction}&option=view&plugin_id={$plugin.id}">{$plugin.name}</a></td>
                     <td>{$plugin.latest_version}</td>
                     <td>{if $plugin.glm_associate.value}Yes{else}No{/if}</td>
                 </tr>
diff --git a/views/admin/plugins/site-detail.html b/views/admin/plugins/site-detail.html
new file mode 100644 (file)
index 0000000..1935d5d
--- /dev/null
@@ -0,0 +1,180 @@
+{* Site Detail View File *}
+
+{* Header *}
+{include file="admin/header.html"}
+<h3>{$site.fieldData.name|default:'New Site'}</h3>
+
+{* 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'}
+
+    <input type="hidden" name="glm_action" value="sites">
+    <input type="hidden" name="option" value="save">
+    <input type="hidden" name="site_id" value="{$site.fieldData.id}">
+
+    {$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'}
+
+<style>
+    .row-green {
+        background-color: rgb( 225, 250, 234 );
+    }
+    .row-red {
+        background-color: rgb( 247, 228, 225 );
+    }
+</style>
+
+{if !empty($plugins)}
+    <table class="stack hover">
+        <tr>
+            <th class="text-left">Plugin Name</th>
+            <th class="text-left">Prod Version</th>
+            <th class="text-left">Dev Version</th>
+        </tr>
+        {foreach $plugins as $plugin}
+            <tr>
+                <td>{$plugin.name}</td>
+                <td width="110" class="{if !empty($plugin.prod_version) && version_compare( $plugin.latest_version, $plugin.prod_version, '>' )}row-red{elseif !empty($plugin.prod_version)}row-green{/if}">{$plugin.prod_version}</td>
+                <td width="110" class="{if !empty($plugin.dev_version) && version_compare( $plugin.latest_version, $plugin.dev_version, '>' )}row-red{elseif !empty($plugin.dev_version)}row-green{/if}">{$plugin.dev_version}</td>
+            </tr>
+        {/foreach}
+    </table>
+{/if}
+
+{* Grid End *}
+{include file='ui/f6/grid-end.html'}
+
+<script>
+jQuery(document).ready(function($){
+    $(document).foundation();
+
+});
+</script>
+
+{* Footer *}
+{include file="../../admin/footer.html"}
index b0ddc5c..1d98d78 100644 (file)
@@ -18,7 +18,7 @@
             {foreach $sites as $site}
                 <tr>
                     <td>{$site.id}</td>
-                    <td>{$site.name}</td>
+                    <td><a href="{$thisUrl}?page={$thisPage}&glm_action={$thisAction}&option=view&site_id={$site.id}">{$site.name}</a></td>
                     <td>{$site.prod_url}</td>
                     <td>{$site.dev_url}</td>
                 </tr>