Adding an email template wrapper. using foundation email
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Jun 2019 20:15:03 +0000 (16:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Jun 2019 20:15:03 +0000 (16:15 -0400)
I setup a responsive template for the emails. This is to be wrapped
around the message using the template image and title.

15 files changed:
classes/data/dataEmailTemplates.php
index.php
models/admin/ajax/newsletter.php [new file with mode: 0644]
models/admin/messages/index.php
setup/databaseScripts/create_database_V0.0.3.sql [deleted file]
setup/databaseScripts/create_database_V0.0.4.sql [new file with mode: 0644]
setup/databaseScripts/dbVersions.php
setup/databaseScripts/update_database_V0.0.4.sql [new file with mode: 0644]
setup/validActions.php
views/admin/messages/editTemplate.html
views/admin/messages/listMessagesTable.html
views/admin/messages/listTemplates.html
views/admin/messages/search.html
views/email/messages/newsletter.html [new file with mode: 0644]
views/email/messages/newsletterFrame.html [new file with mode: 0644]

index 43b4fd3..a8f51cd 100644 (file)
@@ -126,14 +126,20 @@ class GlmDataEmailTemplates extends GlmDataAbstract
                 'use'      => 'a'
             ),
 
-            // Contacts
-            'contents' => array (
-                'field'    => 'contents',
+            // Footer
+            'footer' => array (
+                'field'    => 'footer',
                 'type'     => 'text',
-                'required' => true,
+                'required' => false,
                 'use'      => 'a'
             ),
 
+            // image
+            'image' => array(
+                'field' => 'image',
+                'type'  => 'image',
+                'use'   => 'a'
+            ),
          );
 
     }
index b244b59..e80fd81 100644 (file)
--- a/index.php
+++ b/index.php
@@ -44,7 +44,9 @@ if (!defined('ABSPATH')) {
  *  version from this plugin.
  */
 define('GLM_MEMBERS_MESSAGES_PLUGIN_VERSION', '0.0.1');
-define('GLM_MEMBERS_MESSAGES_PLUGIN_DB_VERSION', '0.0.3');
+
+// DB Version
+define('GLM_MEMBERS_MESSAGES_PLUGIN_DB_VERSION', '0.0.4');
 
 // This is the minimum version of the GLM Members DB plugin require for this plugin.
 define('GLM_MEMBERS_MESSAGES_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0');
diff --git a/models/admin/ajax/newsletter.php b/models/admin/ajax/newsletter.php
new file mode 100644 (file)
index 0000000..b7e1a7a
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+/**
+ * detail.php
+ *
+ * This is the Member Event Plugin model for the front detail shortcode.
+ * Handles the view of the detail pages.
+ */
+
+require_once GLM_MEMBERS_MESSAGES_PLUGIN_CLASS_PATH.'/data/dataEmailMessages.php';
+require_once GLM_MEMBERS_MESSAGES_PLUGIN_CLASS_PATH.'/data/dataEmailTemplates.php';
+
+/**
+ * GLmMembersFront_event_detail
+ *
+ * @uses      GlmDataEvents
+ * @package   GlmMemberEvents
+ * @version   0.0.1
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @author    Steve Sutton <steve@gaslightmedia.com>
+ * @license   PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
+ */
+class GlmMembersAdmin_ajax_newsletter extends GlmDataEmailMessages
+{
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ( $wpdb, $config )
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct( false, false );
+
+    }
+
+    /**
+     * modelAction
+     *
+     * @param bool $actionData Action Data passed to the modelAction
+     *
+     * @access public
+     * @return void
+     */
+    public function modelAction($actionData = false)
+    {
+        $view         = 'newsletter';
+        $emailContent = '';
+        $Templates    = new GlmDataEmailTemplates( $this->wpdb, $this->config );
+        if ( isset( $_REQUEST['message_id'] ) && $messageId = filter_var( $_REQUEST['message_id'], FILTER_VALIDATE_INT ) ) {
+            $message      = $this->getEntry( $messageId );
+            $emailData = array(
+                'member' => array(
+                    'name' => 'Test Member',
+                ),
+                'contact' => array(
+                    'fname' => 'John',
+                    'lname' => 'Doe',
+                ),
+            );
+            $smarty = new smartyTemplateSupport();
+            require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
+            if ( is_array( $emailData ) && count( $emailData ) > 0 ) {
+                foreach ( $emailData as $k => $d ) {
+                    $smarty->templateAssign( $k, $d );
+                }
+            }
+            $emailContent = $smarty->template->fetch( 'eval:' . wpautop( $message['message_body'] ) );
+        } else {
+            $emailContent = '<p>Message Content would go here!</p>';
+        }
+        if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+            $template = $Templates->getEntry( $id );
+        }
+        $tData = array(
+            'image'        => $template['image'],
+            'content'      => $emailContent,
+            'footer'       => $template['footer'],
+            'templateName' => $template['name'],
+        );
+
+        // Load Smarty Template support
+        $smarty = new smartyTemplateSupport();
+
+        $viewPath = GLM_MEMBERS_MESSAGES_PLUGIN_PATH . '/views';
+        $smarty->template->setTemplateDir( $viewPath );
+
+        if ( is_array( $tData ) && count( $tData ) > 0 ) {
+            foreach ( $tData as $k => $d ) {
+                $smarty->templateAssign( $k, $d );
+            }
+        }
+
+        // Add standard parameters
+        require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
+
+        $viewFile = 'email/messages/' . $view . '.html';
+
+        // Generate output from model data and view
+        $output = $smarty->template->fetch( $viewFile );
+        echo $output;
+        exit;
+    }
+}
index e32aee3..0636441 100644 (file)
@@ -99,9 +99,11 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
      */
     public function modelAction ( $actionData = false )
     {
-        $view    = 'index';
-        $success = true;
-        $option  = '';
+        $view     = 'index';
+        $success  = true;
+        $option   = '';
+        $option2  = false;
+        $viewPath = 'admin/messages/';
 
         if ( isset( $_REQUEST['option'] ) ) {
             $option = $_REQUEST['option'];
@@ -147,6 +149,15 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
             if ( isset( $_REQUEST['filterMemberCity'] ) && $filterMemberCity = filter_var( $_REQUEST['filterMemberCity'], FILTER_VALIDATE_INT) ) {
                 $whereParts[] = " T.id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE city = " . $filterMemberCity . ")";
             }
+            if ( isset( $_REQUEST['filterMemberCounty'] ) && $filterMemberCounty = filter_var( $_REQUEST['filterMemberCounty'], FILTER_VALIDATE_INT) ) {
+                $whereParts[] = " T.id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE county = " . $filterMemberCounty . ")";
+            }
+            if ( isset( $_REQUEST['filterMemberState'] ) && $filterMemberState = filter_var( $_REQUEST['filterMemberState'], FILTER_SANITIZE_STRING) ) {
+                $whereParts[] = " T.id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE state = '" . $filterMemberState . "')";
+            }
+            if ( isset( $_REQUEST['filterMemberZip'] ) && $filterMemberZip = filter_var( $_REQUEST['filterMemberZip'], FILTER_SANITIZE_STRING) ) {
+                $whereParts[] = " T.id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE zip = '" . $filterMemberZip . "')";
+            }
 
             if ( isset( $_REQUEST['filterMemberAccess'] ) && $filterAccess = filter_var( $_REQUEST['filterMemberAccess'], FILTER_VALIDATE_INT) ) {
                 $whereParts[] = " T.access = ".$filterAccess;
@@ -267,6 +278,23 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
 
             }
 
+            // Setup Counties
+            $counties = array();
+            if ( $this->config['settings']['enable_counties'] ) {
+                require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataCounties.php';
+                $Counties = new GlmDataCounties( $this->wpdb, $this->config );
+                $counties = $Counties->getList( null, 'name' );
+            }
+            // Setup Cities
+            $cities = array();
+            require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataCities.php';
+            $Cities = new GlmDataCities( $this->wpdb, $this->config );
+            $cities = $Cities->getList( null, 'name' );
+            // Setup States
+            $states = $this->config['states'];
+
+            // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+
             $tData = array(
                 'messages'      => $messages,
                 'mTypeSelected' => $mTypeSelected,
@@ -275,15 +303,47 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
                 'searchResults' => $searchResults,
                 'accessTypes'   => $this->config['access'],
                 'statusTypes'   => $this->config['status'],
+                'states'        => $states,
+                'cities'        => $cities,
+                'counties'      => $counties,
             );
             break;
 
-        case 'listTemplates':
-            $view = 'listTemplates';
-            $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
-            $templates = $Templates->getList();
+        case 'preview':
+            $view         = 'newsletterFrame';
+            $viewPath     = 'email/messages/';
+            $emailContent = '';
+            $messageId    = false;
+            $Templates    = new GlmDataEmailTemplates( $this->wpdb, $this->config );
+            if ( isset( $_REQUEST['message_id'] ) && $messageId = filter_var( $_REQUEST['message_id'], FILTER_VALIDATE_INT ) ) {
+                $message      = $this->getEntry( $messageId );
+                // echo '<pre>$message: ' . print_r( $message, true ) . '</pre>';
+                $emailData = array(
+                    'member' => array(
+                        'name' => 'Test Member',
+                    ),
+                    'contact' => array(
+                        'fname' => 'John',
+                        'lname' => 'Doe',
+                    ),
+                );
+                $smarty = new smartyTemplateSupport();
+                require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
+                if ( is_array( $emailData ) && count( $emailData ) > 0 ) {
+                    foreach ( $emailData as $k => $d ) {
+                        $smarty->templateAssign( $k, $d );
+                    }
+                }
+                $emailContent = $smarty->template->fetch( 'eval:' . wpautop( $message['message_body'] ) );
+            } else {
+                $emailContent = '<p>Message Content would go here!</p>';
+            }
+            if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
+                $template = $Templates->getEntry( $id );
+            }
             $tData = array(
-                'templates' => $templates,
+                'template_id' => $id,
+                'message_id'  => $messageId,
             );
             break;
 
@@ -304,16 +364,24 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
             break;
 
         case 'updateTemplate':
-            echo '<pre>'.print_r($_REQUEST, true).'</pre>';
+            $templateData['thisOption'] = 'listTemplates';
+            // echo '<pre>'.print_r($_REQUEST, true).'</pre>';
             $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
             if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
-                $message = $Templates->updateEntry( $id );
+                $template = $Templates->updateEntry( $id );
+                // echo '<pre>$template: ' . print_r( $template, true ) . '</pre>';
             } else {
-                $message = $Templates->insertEntry();
+                $template = $Templates->insertEntry();
             }
-            break;
-
 
+        case 'listTemplates':
+            $view = 'listTemplates';
+            $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
+            $templates = $Templates->getList();
+            $tData = array(
+                'templates' => $templates,
+            );
+            break;
 
         case 'editHtmlEmail':
             $view     = 'editHtmlEmail';
@@ -331,13 +399,15 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
             break;
 
         case 'updateHtmlEmail':
+            // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
+            // echo '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
+            $templateData['thisOption'] = 'list';
             $_REQUEST['last_updated'] = date( 'Y-m-d H:i:s' );
             if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
                 $message = $this->updateEntry( $id );
             } else {
                 $message = $this->insertEntry();
             }
-            break;
 
         case 'list':
             $view = 'list';
@@ -361,7 +431,7 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
             'status'           => $success,
             'menuItemRedirect' => false,
             'modelRedirect'    => false,
-            'view'             => 'admin/messages/' . $view . '.html',
+            'view'             => $viewPath . $view . '.html',
             'data'             => $templateData
         );
 
@@ -377,11 +447,7 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
      */
     public function sendHtmlMessages( $data, $messageId )
     {
-        // echo '<pre>$messageId: ' . print_r( $messageId, true ) . '</pre>';
-        // echo '<pre>$data: ' . print_r( $data, true ) . '</pre>';
         $message = $this->getEntry( $messageId );
-        // echo '<pre>$message: ' . print_r( $message, true ) . '</pre>';
-        // exit;
         $fromEmail    = $message['from_email'];
         $fromName     = $message['from_name'];
         $replyToEmail = $message['reply_to_email'];
@@ -389,8 +455,6 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
 
         if ( $messageId && $message && is_array( $data ) && !empty( $data ) ) {
             foreach ( $data as $memData ) {
-                // echo '<pre>$memData: ' . print_r( $memData, true ) . '</pre>';
-                // get member contact data
                 require_once GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
                 $Contacts  = new GlmDataContacts( $this->wpdb, $this->config );
                 $whereParts = array();
@@ -399,7 +463,6 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
                 $whereParts[] = "T.email like '%@%'";
                 $where = implode( " AND ", $whereParts );
                 $memberContacts = $Contacts->getSimplified( $where );
-                // echo '<pre>$memberContacts: ' . print_r( $memberContacts, true ) . '</pre>';
                 if ( $memberContacts && !empty( $memberContacts ) ) {
                     foreach ( $memberContacts as $contact ) {
                         $emailData = array(
@@ -411,7 +474,8 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
                                 'lname' => $contact['lname'],
                             )
                         );
-                        $messageBody = $this->generateHTML( $emailData, $message['message_body'], $message['template_id']['value'] );
+                        $messageBody = $this->generateHTML( $emailData, wpautop( $message['message_body'] ), $message['template_id']['value'] );
+                        echo '<pre>$messageBody: ' . print_r( $messageBody, true ) . '</pre>';
 
                         // Add this to the email_queue
                         $this->wpdb->insert(
@@ -477,13 +541,27 @@ class GlmMembersAdmin_messages_index extends GlmDataEmailMessages
             }
         }
 
-        $contents = $smarty->template->fetch( 'eval:' . $view );
+        $emailContent = $smarty->template->fetch( 'eval:' . $view );
 
         $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
         $template  = $Templates->getEntry( $template );
+        $tData = array(
+            'image'        => $template['image'],
+            'content'      => $emailContent,
+            'footer'       => $template['footer'],
+            'templateName' => $template['name'],
+        );
+        if ( is_array( $tData ) && count( $tData ) > 0 ) {
+            foreach ( $tData as $k => $d ) {
+                $smarty->templateAssign( $k, $d );
+            }
+        }
 
-        $smarty->templateAssign( 'contents', $contents );
-        $out = $smarty->template->fetch( 'eval:' . $template['contents'] );
+        $viewPath = GLM_MEMBERS_MESSAGES_PLUGIN_PATH . '/views';
+        $smarty->template->setTemplateDir( $viewPath );
+        $viewFile = 'email/messages/newsletter.html';
+        $out = $smarty->template->fetch( $viewFile );
+        // $out = $smarty->template->fetch( 'eval:' . $template['contents'] );
 
         return $out;
 
diff --git a/setup/databaseScripts/create_database_V0.0.3.sql b/setup/databaseScripts/create_database_V0.0.3.sql
deleted file mode 100644 (file)
index b60e3f0..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
--- Gaslight Media Members Database
--- File Created: 5/24/19
--- Database Version: 0.0.2
--- Database Creation Script - Messages Add-On
---
--- To permit each query below to be executed separately,
--- all queries must be separated by a line with four dashes
-
--- email_messages
-CREATE TABLE {prefix}email_messages (
-    id INT NOT NULL AUTO_INCREMENT,
-    template_id INT NOT NULL,
-    archived BOOLEAN DEFAULT false,
-    from_email TINYTEXT NOT NULL,
-    from_name TINYTEXT NULL,
-    reply_to_email TINYTEXT NULL,
-    subject TINYTEXT NOT NULL,
-    last_updated DATETIME NOT NULL,
-    message_body TEXT NOT NULL,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Logs
-CREATE TABLE {prefix}email_logs (
-    id INT NOT NULL AUTO_INCREMENT,
-    message_id INT NOT NULL,
-    to_email TINYTEXT NOT NULL,
-    subject TINYTEXT NOT NULL,
-    from_email TINYTEXT NOT NULL,
-    reply_to_email TINYTEXT NULL,
-    message_body TEXT NOT NULL,
-    send_date DATETIME NOT NULL,
-    email_read BOOLEAN DEFAULT false,
-    read_date DATETIME NULL,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Queue
-CREATE TABLE {prefix}email_queue (
-    id INT NOT NULL AUTO_INCREMENT,
-    message_id INT NOT NULL,
-    to_email TINYTEXT NOT NULL,
-    subject TINYTEXT NOT NULL,
-    from_email TINYTEXT NOT NULL,
-    reply_to_email TINYTEXT NULL,
-    message_body TEXT NOT NULL,
-    queue_date DATETIME NOT NULL,
-    processed BOOLEAN DEFAULT false,
-    PRIMARY KEY (id)
-);
-
-----
-
--- Template
-CREATE TABLE {prefix}email_templates (
-    id INT NOT NULL AUTO_INCREMENT,
-    name TEXT NOT NULL,
-    contents TEXT NOT NULL,
-    PRIMARY KEY (id)
-);
diff --git a/setup/databaseScripts/create_database_V0.0.4.sql b/setup/databaseScripts/create_database_V0.0.4.sql
new file mode 100644 (file)
index 0000000..a1cd37a
--- /dev/null
@@ -0,0 +1,65 @@
+-- Gaslight Media Members Database
+-- File Created: 5/24/19
+-- Database Version: 0.0.2
+-- Database Creation Script - Messages Add-On
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+-- email_messages
+CREATE TABLE {prefix}email_messages (
+    id INT NOT NULL AUTO_INCREMENT,
+    template_id INT NOT NULL,
+    archived BOOLEAN DEFAULT false,
+    from_email TINYTEXT NOT NULL,
+    from_name TINYTEXT NULL,
+    reply_to_email TINYTEXT NULL,
+    subject TINYTEXT NOT NULL,
+    last_updated DATETIME NOT NULL,
+    message_body TEXT NOT NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Logs
+CREATE TABLE {prefix}email_logs (
+    id INT NOT NULL AUTO_INCREMENT,
+    message_id INT NOT NULL,
+    to_email TINYTEXT NOT NULL,
+    subject TINYTEXT NOT NULL,
+    from_email TINYTEXT NOT NULL,
+    reply_to_email TINYTEXT NULL,
+    message_body TEXT NOT NULL,
+    send_date DATETIME NOT NULL,
+    email_read BOOLEAN DEFAULT false,
+    read_date DATETIME NULL,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Queue
+CREATE TABLE {prefix}email_queue (
+    id INT NOT NULL AUTO_INCREMENT,
+    message_id INT NOT NULL,
+    to_email TINYTEXT NOT NULL,
+    subject TINYTEXT NOT NULL,
+    from_email TINYTEXT NOT NULL,
+    reply_to_email TINYTEXT NULL,
+    message_body TEXT NOT NULL,
+    queue_date DATETIME NOT NULL,
+    processed BOOLEAN DEFAULT false,
+    PRIMARY KEY (id)
+);
+
+----
+
+-- Template
+CREATE TABLE {prefix}email_templates (
+    id INT NOT NULL AUTO_INCREMENT,
+    name TEXT NOT NULL,
+    image TINYTEXT NULL,
+    footer TEXT NULL,
+    PRIMARY KEY (id)
+);
index e918016..fbd955e 100644 (file)
@@ -17,5 +17,6 @@ $glmMembersMessagesDbVersions = array(
     '0.0.1' => array('version' => '0.0.1', 'tables' => 2, 'date' => '05/24/2019'),
     '0.0.2' => array('version' => '0.0.2', 'tables' => 3, 'date' => '05/30/2019'),
     '0.0.3' => array('version' => '0.0.3', 'tables' => 4, 'date' => '06/04/2019'),
+    '0.0.4' => array('version' => '0.0.4', 'tables' => 4, 'date' => '06/07/2019'),
 );
 
diff --git a/setup/databaseScripts/update_database_V0.0.4.sql b/setup/databaseScripts/update_database_V0.0.4.sql
new file mode 100644 (file)
index 0000000..58ab04e
--- /dev/null
@@ -0,0 +1,15 @@
+-- Gaslight Media Members Database  - Messages Add-On
+-- File Created: 5/30/2019
+-- Database Version: 0.0.2
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+-- Chaneg contents to footer
+ALTER TABLE {prefix}email_templates CHANGE COLUMN contents footer TEXT NULL;
+
+----
+
+-- Add image to email_templates
+ALTER TABLE {prefix}email_templates ADD COLUMN image TINYTEXT NULL;
index 9775b61..c2e520e 100644 (file)
@@ -59,6 +59,9 @@
 
 $glmMembersMessagesAddOnValidActions = array(
     'adminActions' => array(
+        'ajax' => array(
+            'newsletter' => GLM_MEMBERS_MESSAGES_PLUGIN_SLUG,
+        ),
         'messages' => array(
             'index'              => GLM_MEMBERS_MESSAGES_PLUGIN_SLUG,
             'sendMessagesEmails' => GLM_MEMBERS_MESSAGES_PLUGIN_SLUG,
index 66771f1..c13c4e0 100644 (file)
@@ -1,7 +1,7 @@
 <h2>Html Email</h2>
 {include file='admin/header.html'}
 
-<form action="{$thisUrl}?page={$thisPage}" method="post">
+<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
     <input type="hidden" name="option" value="updateTemplate" />
     {if !$newEntry}
         <input type="hidden" name="id" value="{$template.fieldData.id}" />
             </td>
         </tr>
         <tr>
-            <th {if $template.fieldRequired.contents}class="glm-required"{/if}>Content:</th>
-            <td {if $template.fieldFail.contents}class="glm-form-bad-input" data-tabid="glm-template-contents"{/if}>
+            <th {if $template.fieldRequired.image}class="glm-required"{/if}>Header Image:</th>
+            <td>
+                <div class="glm-row">
+                    <div {if $template.fieldFail.image}class="glm-form-bad-input" data-tabid="glm-member-info-images"{/if}>
+                        {if $template.fieldData.image}
+                            <div class="glm-row">
+                                <div class="glm-small-12 glm-medium-6">
+                                    <div class="glm-galleryImage" data-id="image">
+                                        <img src="{$glmPluginMediaUrl}/images/small/{$template.fieldData.image}">
+                                    </div>
+                                </div>
+                                <div class="glm-small-11 glm-medium-6 glm-right">
+                                    <br>
+                                    <input type="checkbox" name="image_delete"> Delete Image<br>
+                                    <span>{$template.fieldData.image}</span>
+                                    <br>
+                                </div>
+                            </div>
+                        {/if}
+                        <div class="glm-center"><b>New image:</b> <input type="file" name="image_new"></div>
+                        <div id="glm-galleryImageLarger_image" class="glm-imageDialog"><img src="{$glmPluginMediaUrl}/images/large/{$template.fieldData.image}"></div>
+                        {if $template.fieldFail.image}<p>{$template.fieldFail.image}</p>{/if}
+                    </div>
+                </div>
+            </td>
+        </tr>
+        <tr>
+            <th {if $template.fieldRequired.footer}class="glm-required"{/if}>Footer:</th>
+            <td {if $template.fieldFail.footer}class="glm-form-bad-input" data-tabid="glm-template-footer"{/if}>
                 {if $template}
-                    {$textAreaContent = $template.fieldData.contents}
+                    {$textAreaContent = $template.fieldData.footer}
                 {else}
                     {$textAreaContent = ''}
                 {/if}
                 {wp_editor(
                     $textAreaContent,
-                    'contents',
+                    'footer',
                     json_decode('{
                         "media_buttons": true,
                         "quicktags": false,
-                        "textarea_name": "contents",
+                        "textarea_name": "footer",
                         "editor_height": 250
                     }', true)
                 )}
             </td>
         </tr>
-
         <tr>
             <td colspan="2">
                 <p>Place {literal}{$contents}{/literal} where you want the Email Message to be inserted to.</p>
index 4a264ef..d98aa9e 100644 (file)
@@ -6,6 +6,7 @@
             <th align="left">Last Updated</th>
             <th align="left">Last Sent</th>
             <th align="left">Queued</th>
+            <th align="left" style="width: 100px">Preview</th>
         </tr>
     </thead>
     <tbody>
@@ -17,6 +18,7 @@
                     <td> {$message.last_updated.timestamp|date_format:"%D %r"} </td>
                     <td> {$message.sent|date_format:"%D %r"} </td>
                     <td> {$message.stats|date_format:"%D %r"} </td>
+                    <td> <a href="{$thisUrl}?page={$thisPage}&option=preview&id={$message.template_id.value}&message_id={$message.id}">Preview Template</a> </td>
                 </tr>
             {/foreach}
         {/if}
index 663e9ab..0ec173c 100644 (file)
@@ -8,6 +8,7 @@
         <tr>
             <th align="left" style="width: 20px">ID</th>
             <th align="left">Name</th>
+            <th align="left" style="width: 100px">Preview</th>
         </tr>
     </thead>
     <tbody>
@@ -16,6 +17,7 @@
                 <tr>
                     <td> {$template.id} </td>
                     <td> <a href="{$thisUrl}?page={$thisPage}&option=editTemplate&id={$template.id}">{$template.name}</a> </td>
+                    <td> <a href="{$thisUrl}?page={$thisPage}&option=preview&id={$template.id}">Preview Template</a> </td>
                 </tr>
             {/foreach}
         {/if}
index 6256514..ad98816 100644 (file)
         {if $smarty.request.filterMemberTypes}
             <input type="hidden" name="filterMemberTypes" value="{$smarty.request.filterMemberTypes}" />
         {/if}
+        {if $smarty.request.filterMemberName}
+            <input type="hidden" name="filterMemberName" value="{$smarty.request.filterMemberName}" />
+        {/if}
+        {if $smarty.request.filterMemberStatus}
+            <input type="hidden" name="filterMemberStatus" value="{$smarty.request.filterMemberStatus}" />
+        {/if}
+        {if $smarty.request.filterMemberCity}
+            <input type="hidden" name="filterMemberCity" value="{$smarty.request.filterMemberCity}" />
+        {/if}
+        {if $smarty.request.filterMemberCounty}
+            <input type="hidden" name="filterMemberCounty" value="{$smarty.request.filterMemberCounty}" />
+        {/if}
+        {if $smarty.request.filterMemberState}
+            <input type="hidden" name="filterMemberState" value="{$smarty.request.filterMemberState}" />
+        {/if}
+        {if $smarty.request.filterMemberZip}
+            <input type="hidden" name="filterMemberZip" value="{$smarty.request.filterMemberZip}" />
+        {/if}
+        {if $smarty.request.filterContactEmail}
+            <input type="hidden" name="filterContactEmail" value="{$smarty.request.filterContactEmail}" />
+        {/if}
+        {if $smarty.request.filterContactFirstName}
+            <input type="hidden" name="filterContactFirstName" value="{$smarty.request.filterContactFirstName}" />
+        {/if}
+        {if $smarty.request.filterContactLastName}
+            <input type="hidden" name="filterContactLastName" value="{$smarty.request.filterContactLastName}" />
+        {/if}
         <table>
             <tr>
                 <th>Message</th>
                 <label for="filterMemberCity">
                     City
                 </label>
-                {* city need data for select *}
-                <input id="filterMemberCity" name="filterMemberCity" />
-                <label for="filterMemberCounty">
-                    County
-                </label>
-                <input id="filterMemberCounty" name="filterMemberCounty" />
+                <select id="filterMemberCity" name="filterMemberCity">
+                    <option value=""></option>
+                    {foreach $cities as $city}
+                        <option value="{$city.id}">{$city.name}</option>
+                    {/foreach}
+                </select>
+                {if $settings.enable_counties}
+                    <label for="filterMemberCounty">
+                        County
+                    </label>
+                    <select id="filterMemberCounty" name="filterMemberCounty">
+                        <option value=""></option>
+                        {foreach $counties as $county}
+                            <option value="{$county.id}">{$county.name}</option>
+                        {/foreach}
+                    </select>
+                {/if}
                 <label for="filterMemberState">
                     State
                 </label>
-                <input id="filterMemberState" name="filterMemberState" />
+                <select id="filterMemberState" name="filterMemberState">
+                    <option value=""></option>
+                    {foreach $states as $abbr => $state}
+                        <option value="{$abbr}">{$state}</option>
+                    {/foreach}
+                </select>
                 <label for="filterMemberZip">
                     Zip
                 </label>
                 <input id="filterMemberZip" name="filterMemberZip" />
             </div>
-
         </div>
 
         <div class="glma-row">
diff --git a/views/email/messages/newsletter.html b/views/email/messages/newsletter.html
new file mode 100644 (file)
index 0000000..c553915
--- /dev/null
@@ -0,0 +1,51 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="background:#f3f3f3!important">
+  <head>
+
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+    <meta name="viewport" content="width=device-width">
+    <title>My Newsletter Email Template Subject</title>
+    {literal}
+    <style>@media only screen{html{min-height:100%;background:#f3f3f3}}@media only screen and (max-width:596px){.small-float-center{margin:0 auto!important;float:none!important;text-align:center!important}}@media only screen and (max-width:596px){table.body img{width:auto;height:auto}table.body center{min-width:0!important}table.body .container{width:95%!important}table.body .columns{height:auto!important;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:16px!important;padding-right:16px!important}table.body .columns .columns{padding-left:0!important;padding-right:0!important}table.body .collapse .columns{padding-left:0!important;padding-right:0!important}th.small-6{display:inline-block!important;width:50%!important}th.small-12{display:inline-block!important;width:100%!important}.columns th.small-12{display:block!important;width:100%!important}table.menu{width:100%!important}table.menu td,table.menu th{width:auto!important;display:inline-block!important}table.menu.vertical td,table.menu.vertical th{display:block!important}table.menu[align=center]{width:auto!important}}</style>
+    {/literal}
+  </head>
+  <body style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-text-size-adjust:100%;Margin:0;background:#f3f3f3!important;box-sizing:border-box;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;min-width:100%;padding:0;text-align:left;width:100%!important">
+    <span class="preheader" style="color:#f3f3f3;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden"></span>
+    <table class="body" style="Margin:0;background:#f3f3f3!important;border-collapse:collapse;border-spacing:0;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;height:100%;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;width:100%">
+      <tr style="padding:0;text-align:left;vertical-align:top">
+        <td class="center" align="center" valign="top" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+          <center data-parsed style="min-width:580px;width:100%">
+
+            <table align="center" class="container float-center" style="Margin:0 auto;background:#fefefe;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px"><tbody><tr style="padding:0;text-align:left;vertical-align:top"><td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+
+              <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"><tbody><tr style="padding:0;text-align:left;vertical-align:top"><td height="16px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:16px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td></tr></tbody></table>
+
+              <table class="row" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%"><tbody><tr style="padding:0;text-align:left;vertical-align:top">
+                <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:16px;padding-left:16px;padding-right:16px;text-align:left;width:564px"><table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"><tr style="padding:0;text-align:left;vertical-align:top"><th style="Margin:0;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+                <h1 class="text-center" style="Margin:0;Margin-bottom:10px;color:inherit;font-family:Helvetica,Arial,sans-serif;font-size:34px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:center;word-wrap:normal">{$templateName}</h1>
+                  <center data-parsed style="min-width:532px;width:100%">
+                      <img src="{$glmPluginMediaUrl}/images/large/{$image}" align="center" class="float-center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-width:100%;outline:0;text-align:center;text-decoration:none;width:auto">
+                  </center>
+
+                  <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"><tbody><tr style="padding:0;text-align:left;vertical-align:top"><td height="16px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:16px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td></tr></tbody></table>
+
+                    {$content}
+
+                  <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"><tbody><tr style="padding:0;text-align:left;vertical-align:top"><td height="16px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:16px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td></tr></tbody></table>
+                  <p style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left"><small style="color:#cacaca;font-size:80%">{$footer}</small></p>
+                </th>
+<th class="expander" style="Margin:0;color:#0a0a0a;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th></tr></table></th>
+              </tr></tbody></table>
+            </td></tr></tbody></table>
+
+          </center>
+        </td>
+      </tr>
+    </table>
+    <!-- prevent Gmail on iOS font size manipulation -->
+   <div style="display:none;white-space:nowrap;font:15px courier;line-height:0"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
+  </body>
+</html>
+
diff --git a/views/email/messages/newsletterFrame.html b/views/email/messages/newsletterFrame.html
new file mode 100644 (file)
index 0000000..7fa6a6a
--- /dev/null
@@ -0,0 +1,5 @@
+<a class="button" href="#" onClick="window.history.back(1);">Go Back</a>
+
+<iframe
+    style="width: 100%; height: 100vh; border: none;"
+    src="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=newsletter&id={$template_id}&message_id={$message_id}"></iframe>