Adding new menu for glm notifications
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Jun 2018 20:58:46 +0000 (16:58 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 8 Jun 2018 20:58:46 +0000 (16:58 -0400)
More discussion is needed for how this is going to work.

css/admin.css
models/glmInfoNotifications.php [new file with mode: 0644]
setup/adminMenus.php
views/glmInfoNotifications.html [new file with mode: 0644]

index 913616b..21aa3f9 100644 (file)
@@ -407,3 +407,28 @@ input[type=submit], input[type=file] {
     color: #888;
     font-weight: 400;
 }
+
+/* GLM Info CSS */
+#glm-info-container {
+    background-color: white;
+    border: 1px solid darkgrey;
+    padding: .8rem 1rem;
+    display: inline-block;
+    width: 1200px;
+}
+
+#glm-info-container h2 {
+    width: 100%;
+    clear: both;
+    margin: 1rem 0;
+}
+
+#glm-info-container img {
+    margin: 0 1rem;
+}
+
+.#glm-info-container .glm-info-message {
+    clear: both;
+    margin: 1rem 0;
+    position: relative;
+}
diff --git a/models/glmInfoNotifications.php b/models/glmInfoNotifications.php
new file mode 100644 (file)
index 0000000..4b1df54
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Gaslight Media Server Bandwidth - Stand Alone
+ * Server Bandwidth Support Abstract
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmServerStats
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  serverBandwidthSupport.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+/*
+ * This class provides support for the reporting of server bandwidth stats
+ * for simple day and month values as well as detailed lists of values for
+ * a day (by 10 min intervals), month (by days), or 2 years (by months).
+ *
+ */
+class glmInfoNotifications
+{
+    public function model()
+    {
+        $messages = false;
+        $url = 'http://develop.localhost/wp-admin/admin-ajax.php?action=glm_members_admin_ajax&glm_action=relay';
+
+        // Get the messages from the main plugin.
+        $fetchData   = wp_remote_get( $url );
+        $messageData = wp_remote_retrieve_body( $fetchData );
+        $status      = wp_remote_retrieve_response_code( $fetchData);
+
+        if ( $status == 200 ) {
+            $messages = json_decode( $messageData, true );
+        }
+
+        // If there's no message id then only get the first one.
+        $messages = array_slice( $messages, 0, 1 );
+
+        // Compile template data
+        $templateData = array(
+            'messages'    => $messages,
+            'status'      => $status,
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'view' => 'glmInfoNotifications',
+            'data' => $templateData
+        );
+    }
+}
index 1f074e6..4307f72 100644 (file)
@@ -25,6 +25,17 @@ if (current_user_can('editor') || current_user_can('administrator')) {
         GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
         '3.100'
     );
+    add_menu_page(
+        'GLM Info',
+        'GLM Info',
+        'edit_pages',
+        'glm-info-main-menu',
+        function(){
+            serverStatsController('glmInfoNotifications');
+        },
+        GLM_SERVERSTATS_PLUGIN_ASSETS_URL.'/flame.png',
+        '3.200'
+    );
 }
 
 // Add a sub-submeu for server Stats - For admin users only
diff --git a/views/glmInfoNotifications.html b/views/glmInfoNotifications.html
new file mode 100644 (file)
index 0000000..e6886ca
--- /dev/null
@@ -0,0 +1,19 @@
+<div class="wrap">
+
+    <h1>GLM Notifications</h1>
+
+    <div id="glm-info-container">
+
+        {if $messages}
+            {foreach $messages as $m}
+                <div class="glm-info-message">
+                    <h2>{$m.title}</h2>
+                    <div>posted on {$m.updated.datetime}</div>
+                    {$m.message}
+                </div>
+            {/foreach}
+        {/if}
+
+    </div>
+
+</div>