Updating dashboard
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 10 Oct 2019 13:43:55 +0000 (09:43 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 10 Oct 2019 13:43:55 +0000 (09:43 -0400)
Add list of plugins with latest_version and how many prod and dev sites
need to be updated.

classes/data/dataPlugins.php
models/admin/plugins/index.php
views/admin/plugins/index.html

index d41257b..421c380 100644 (file)
@@ -73,7 +73,7 @@ class GlmDataPlugins extends GlmDataAbstract
      */
     public $fields = false;
 
-    public $postOldVersions = false;
+    public $postStats = false;
 
     /**
      * Constructor
@@ -169,15 +169,31 @@ class GlmDataPlugins extends GlmDataAbstract
      */
     public function entryPostProcessing($r, $a)
     {
-        if ( $this->postOldVersions ) {
+        if ( $this->postStats ) {
             // Get sites that have old versions of this plugin.
+            $r['oldProdVersions'] = $this->wpdb->get_results(
+                $this->wpdb->prepare(
+                    "SELECT S.name
+                       FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "sites S
+                            LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins SP ON (S.id = SP.site)
+                      WHERE SP.plugin = %d
+                        AND prod_version != %s
+                        AND prod_version != '-'",
+                    $r['id'],
+                    $r['latest_version']
+                ),
+                ARRAY_A
+            );
             $r['oldDevVersions'] = $this->wpdb->get_results(
                 $this->wpdb->prepare(
                     "SELECT S.name
                        FROM " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "sites S
                             LEFT OUTER JOIN " . GLM_MEMBERS_PLUGINS_PLUGIN_DB_PREFIX . "site_plugins SP ON (S.id = SP.site)
-                      WHERE SP.plugin = %d",
-                    $r['id']
+                      WHERE SP.plugin = %d
+                        AND dev_version != %s
+                        AND dev_version != '-'",
+                    $r['id'],
+                    $r['latest_version']
                 ),
                 ARRAY_A
             );
index 1302784..55d8b71 100644 (file)
@@ -131,7 +131,7 @@ class GlmMembersAdmin_plugins_index // extends GlmDataEmailMessages
 
             // Get list of Plugins.
             // For this list display sites that need an update.
-            // $Plugins->postOldVersions = true;
+            $Plugins->postStats = true;
             $plugins = $Plugins->getResults( array( 'order' => 'T.name' ) );
 
             // echo '<pre>$plugins: ' . print_r( $plugins, true ) . '</pre>';
index 7b59e93..f0e5dc9 100644 (file)
     </div>
 </div>
 
-<div class="glma-row">
-    <div class="glma-small-4 glma-columns">
-        <div class="glma-row">
-            <div class="glma-small-5 glma-columns">
-            </div>
-            <div class="glma-small-5 glma-columns">
-            </div>
-            <div class="glma-small-5 glma-columns">
-            </div>
-        </div>
-    </div>
-</div>
+<table class="stack hover">
+    <tr>
+        <th class="text-left">Plugin</th>
+        <th class="text-left">Latest Version</th>
+        <th class="text-left">Prod Sites needing updates</th>
+        <th class="text-left">Dev Sites needing updates</th>
+    </tr>
+    {foreach $plugins as $plugin}
+        <tr>
+            <td><a href="{$thisUrl}?page={$thisPage}&glm_action=plugins&option=view&plugin_id={$plugin.id}">{$plugin.name}</a></td>
+            <td>{$plugin.latest_version}</td>
+            <td>{count($plugin.oldProdVersions)}</td>
+            <td>{count($plugin.oldDevVersions)}</td>
+        </tr>
+    {/foreach}
+</table>
 
 {include file='admin/footer.html'}