$option = '';
$option2 = false;
$viewPath = 'admin/messages/';
- $mergeTags = array(
+ $mergeTags = [
'Member Name', '{$member.name}',
'Contact First Name', '{$contact.fname}',
'Contact Last Name', '{$contact.lname}',
'Contact Office Phone', '{$contact.office_phone}',
'Contact Home Phone', '{$contact.home_phone}',
'Contact Mobile Phone', '{$contact.mobile_phone}',
- );
+ ];
// Setup Foundation 6
wp_enqueue_style( 'Foundation6', GLM_MEMBERS_PLUGIN_URL . 'css/foundation-6.min.css' );
$option2 = $_REQUEST['option2'];
}
- $tData = array();
+ // Initialize $tData array.
+ $tData = array();
+
// Get a count of templates
$templateCount = $this->wpdb->get_var(
"SELECT count(*)
switch ( $option ) {
case 'search':
- // echo '<pre>$this->config: ' . print_r( $this->config, true ) . '</pre>';
$view = 'search';
$searchResults = array();
$messages = array();
if ( isset( $_REQUEST['filterMemberStatus'] ) && $filterStatus = filter_var( $_REQUEST['filterMemberStatus'], FILTER_VALIDATE_INT) ) {
$whereParts[] = " T.id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE status = " . $filterStatus . ")";
} else {
- // $whereParts[] = "T..id IN ( SELECT member FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info WHERE status != " . $this->config['status_numb']['Archived'] . ")";
}
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['filterMemberAccess'] ) && $filterAccess = filter_var( $_REQUEST['filterMemberAccess'], FILTER_VALIDATE_INT) ) {
$whereParts[] = " T.access = ".$filterAccess;
- // $whereParts[] = " T.member IN (SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members where access = ".$filterAccess.")";
}
if ( isset( $_REQUEST['filterMemberName'] ) && $filterMemberName = filter_var( $_REQUEST['filterMemberName'] ) ) {
$textSearch = addslashes(filter_var($_REQUEST['filterMemberName'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES));
if ( isset( $_REQUEST['filterCategories'] ) && count( $_REQUEST['filterCategories'] ) > 0) {
$catsToUse = $_REQUEST['filterCategories'];
}
- // echo '<pre>$catsToUse: ' . print_r( $catsToUse, true ) . '</pre>';
if ( $catsToUse && $catsToUse !== '' ) {
$cats = '';
)";
// $catSelectedString = $cats;
}
- // echo '<pre>$categories: ' . print_r( $categories, true ) . '</pre>';
// Get a list of member_types for filtering
require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberTypes.php';
// Check if there is a member_type filter
if ( isset( $_REQUEST['filterMemberTypes'] ) && $memberTypeFilter = filter_var( $_REQUEST['filterMemberTypes'], FILTER_VALIDATE_INT ) ) {
- // $whereParts[] = " T.member IN (SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members where member_type = $memberTypeFilter) ";
$whereParts[] = " T.member_type = $memberTypeFilter ";
$mTypeSelected = $memberTypeFilter;
}
// Do search
require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMembers.php';
$Members = new GlmDataMembers( $this->wpdb, $this->config );
- // require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
- // $Members = new GlmDataMemberInfo( $this->wpdb, $this->config );
$where = implode( ' AND ', $whereParts );
- // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
$searchResults = $Members->getList( $where );
- // $searchResults = $Members->getSimpleMemberInfoList( $where );
- // echo '<pre>$searchResults: ' . print_r( $searchResults, true ) . '</pre>';
$where = "T.archived <> true";
$messages = $this->getList( $where );
// Setup States
$states = $this->config['states'];
- // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
-
$tData = array(
'searched' => isset($_REQUEST['search']) ? true: false,
'messages' => $messages,
break;
case 'preview':
- trigger_error( 'REQUEST: ' . print_r($_REQUEST, true), E_USER_NOTICE );
$view = 'newsletterFrame';
$viewPath = 'email/messages/';
$emailContent = '';
$messageId = false;
$Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
- trigger_error( '$this: ' . print_r($this->fields, true), E_USER_NOTICE );
if ( isset( $_REQUEST['message_id'] ) && $messageId = filter_var( $_REQUEST['message_id'], FILTER_VALIDATE_INT ) ) {
- trigger_error( 'messageId: ' . print_r($messageId, true), E_USER_NOTICE );
$message = $this->getEntry( $messageId );
- trigger_error( 'message: ' . print_r($message, true), E_USER_NOTICE );
$emailData = array(
'member' => array(
'name' => 'Test Member',
'mobile_phone' => '(231) 555-2424',
),
);
- // echo '<pre>$emailData: ' . print_r( $emailData, true ) . '</pre>';
$smarty = new smartyTemplateSupport();
require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
if ( is_array( $emailData ) && count( $emailData ) > 0 ) {
$smarty->templateAssign( $k, $d );
}
}
- // $htmlMessage = wpautop( $message['message_body'] );
$htmlMessage = nl2br( $message['message_body'] );
$emailContent = $smarty->template->fetch( 'eval:' . $htmlMessage );
} else {
}
if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
$template = $Templates->getEntry( $id );
- trigger_error( 'template: ' . print_r($template, true), E_USER_NOTICE );
}
$tData = array(
'template_id' => $id,
$error = false;
$success = false;
$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 ) ) {
$newEntry = false;
$memberContacts = $Contacts->getList( $where );
if ( $memberContacts && !empty( $memberContacts ) ) {
foreach ( $memberContacts as $contact ) {
- // echo '<pre>$contact: ' . print_r( $contact, true ) . '</pre>';
$emailData = array(
'member' => array(
'name' => $memData['member'],
'mobile_phone' => $contact['mobile_phone'],
)
);
- // echo '<pre>$emailData: ' . print_r( $emailData, true ) . '</pre>';
$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(
function generateHTML( $data, $view, $template )
{
- // Load Smarty Template support
+ // Load Smarty Template support.
$smarty = new smartyTemplateSupport();
- // Add standard parameters
+ // Add standard parameters.
require GLM_MEMBERS_PLUGIN_SETUP_PATH . '/standardTemplateParams.php';
- // Add data from model to Smarty template
+ // Add data from model to Smarty template.
if ( is_array( $data ) && count( $data ) > 0 ) {
foreach ( $data as $k => $d ) {
$smarty->templateAssign( $k, $d );
}
$emailContent = $smarty->template->fetch( 'eval:' . $this->fixImages( $view ) );
-
- $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
- $template = $Templates->getEntry( $template );
- $tData = array(
+ $Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
+ $template = $Templates->getEntry( $template );
+ $tData = array(
'image' => $template['image'],
'content' => $emailContent,
'footer' => $template['footer'],
$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'] );
+ $out = $smarty->template->fetch( $viewFile );
return $out;
}
- public function fixImages( $content )
- {
- $dom = new DOMDocument( '1.0', 'UTF-8' );
- $dom->encoding = 'UTF-8';
- $test = $dom->loadHTML( $content );
- $images = $dom->getElementsByTagName( 'img' );
- foreach ( $images as $image ) {
- $width = $height = $align = null;
- if ( $image->hasAttribute( 'class' ) ) {
- // Is it left or right or center?
- if ( preg_match( '%alignleft%', $image->getAttribute('class'))) {
- $align = 'left';
- }
- if ( preg_match( '%alignright%', $image->getAttribute('class'))) {
- $align = 'right';
- }
- if ( preg_match( '%aligncenter%', $image->getAttribute('class'))) {
- $align = 'center';
- }
- }
- switch ( $align ) {
- case 'left':
- $image->setAttribute( 'style', 'float: left; margin: 10px;' );
- break;
- case 'right':
- $image->setAttribute( 'style', 'float: right; margin: 10px;' );
- break;
- case 'center':
- $image->setAttribute( 'style', 'display: block; text-align: center; margin: 0 auto;' );
- break;
- }
- }
- $content = $dom->saveHTML();
- return $content;
- }
}