Rework main plugin setting tabs.
Add page in main setting for email settings.
// Check to see if the user is locked to a particular member
$lockedToMember = apply_filters('glm_members_locked_to_member_id', false);
+ // echo '<pre>$lockedToMember: ' . print_r( $lockedToMember, true ) . '</pre>';
+
// If member ID not supplied or someone is tampering with a member id for a locked member - we shouldn't be here, so redirect to an error page
if ($this->memberID <= 0 || ($lockedToMember && $this->memberID != $lockedToMember)) {
$memberUpdated = true;
$memberUpdateError = false;
}
-
+
} else {
$memberUpdateError = true;
}
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Configure
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Members data abstract
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/settings/dataSettingsGeneral.php' ;
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_emailsettings extends GlmDataSettingsGeneral
+{
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This constructor 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 );
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successful and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the controller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ( $actionData = false )
+ {
+ $settings_updated = false;
+ $settings_update_error = false;
+
+ // General settings are always stored in a record with ID=1.
+ $id = 1;
+
+ // Determine if current user can edit configurations
+ if ( !current_user_can( 'glm_members_settings' ) ) {
+ return array(
+ 'status' => false,
+ 'menuItemRedirect' => 'error',
+ 'modelRedirect' => 'index',
+ 'view' => 'admin/error/index.html',
+ 'data' => array(
+ 'reason' => 'User does not have rights to make configuration changes.'
+ )
+ );
+ }
+
+ // Check for submission option
+ $option = '';
+ if ( isset( $_REQUEST[ 'option' ] ) && $_REQUEST[ 'option' ] == 'submit' ) {
+ $option = $_REQUEST['option'];
+ }
+
+ switch( $option ) {
+
+ // Update General Settings and redisplay the form
+ case 'submit':
+
+ // Update all general settings
+ $generalSettings = $this->updateEntry( 1 );
+ if ( $generalSettings[ 'status' ] ) {
+ $settings_updated = true;
+ } else {
+ $settings_update_error = true;
+ }
+
+ break;
+
+ // Default is to get the current settings and display the form
+ default:
+
+ // Try to get the first (should be only) entry for general settings.
+ $generalSettings = $this->editEntry( $id );
+
+ break;
+
+ }
+
+ if( $settings_update_error ){
+ $settings_updated = false;
+ }
+
+ // Compile template data
+ $templateData = array(
+ 'reason' => '',
+ 'genSettings' => $generalSettings,
+ 'settingsUpdated' => $settings_updated,
+ 'settingsUpdateError' => $settings_update_error,
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => true,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/settings/emailsettings.html',
+ 'data' => $templateData,
+ );
+ }
+}
+
+?>
'locations' => 'glm-member-db'
),
'settings' => array(
- 'index' => 'glm-member-db', // Member Types
- 'categories' => 'glm-member-db',
- 'cities' => 'glm-member-db',
- 'regions' => 'glm-member-db',
- 'counties' => 'glm-member-db',
- 'amenities' => 'glm-member-db'
+ 'index' => 'glm-member-db', // Member Types
+ 'categories' => 'glm-member-db',
+ 'cities' => 'glm-member-db',
+ 'regions' => 'glm-member-db',
+ 'counties' => 'glm-member-db',
+ 'amenities' => 'glm-member-db',
+ 'emailsettings' => 'glm-member-db',
),
'management' => array(
'index' => 'glm-member-db', // General Options
<p><span class="glm-required">*</span> Required</p>
<a id="newAmenityCancel" class="button button-primary glm-right">Cancel</a>
<input type="submit" value="Add new Amenity" class="button button-primary">
-
+
</form>
</div>
<p><span class="glm-required">*</span> Required</p>
<a id="editAmenityCancel" class="button button-primary glm-right">Cancel</a>
<input type="submit" value="Update this Amenity">
-
+
</form>
</div>
-
-
+
+
<h2>Amenities</h2>
<table class="wp-list-table wideFat fixed posts glm-admin-table">
</table>
<script type="text/javascript">
jQuery(document).ready(function($) {
-
+
$("#newAmenityDialog").dialog({
autoOpen: false,
minWidth: 400,
// Clear tabl highlights and hide all tables
$('.glm-settings-tab').removeClass('nav-tab-active');
$('.glm-settings-table').addClass('glm-hidden');
-
+
// Highlight selected tab
$(this).addClass('nav-tab-active');
-
+
// Show selected table
var table = $(this).attr('data-show-table');
$('#' + table).removeClass('glm-hidden');
-
+
});
});
<p><span class="glm-required">*</span> Required</p>
<a id="newGroupCancel" class="button button-primary glm-right">Cancel</a>
<input type="submit" value="Add new Group" class="button button-primary">
-
+
</form>
</div>
<p><span class="glm-required">*</span> Required</p>
<a id="editGroupCancel" class="button button-primary glm-right">Cancel</a>
<input type="submit" value="Update this Group">
-
+
</form>
</div>
{if $haveGroups}
{assign var="i" value="0"}
{foreach $groups as $t}
- {if $i++ is odd by 1}
+ {if $i++ is odd by 1}
<tr>
{else}
<tr class="alternate">
</table>
<script type="text/javascript">
jQuery(document).ready(function($) {
-
+
$("#newGroupDialog").dialog({
autoOpen: false,
minWidth: 400,
});
</script>
-
-
+
+
{include file='admin/footer.html'}
--- /dev/null
+{include file='admin/settings/header.html'}
+
+
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="emailsettings">
+ <input type="hidden" name="option" value="submit">
+
+ <h2>
+ {if $settingsUpdated}<span class="glm-notice glm-flash-updated glm-right">Settings Updated</span>{/if}
+ {if $settingsUpdateError}<span class="glm-error glm-flash-updated glm-right">Settings Update Error</span>{/if}
+ </h2>
+
+ <!-- Members Only Settings -->
+
+ <table id="glm-table-members-only" class="glm-admin-table glm-settings-table">
+ <tr><td colspan="2"><h2>Members Only Settings</h2></td></tr>
+ <tr>
+ <th>Updates Notification To:</th>
+ <td>
+ <input type="text" name="updates_notification_to" value="{$genSettings.fieldData.updates_notification_to}" class="glm-form-text-input-medium" />
+ </td>
+ </tr>
+ <tr>
+ <th>Updates Notification From:</th>
+ <td>
+ <input type="text" name="updates_notification_from" value="{$genSettings.fieldData.updates_notification_from}" class="glm-form-text-input-medium" />
+ </td>
+ </tr>
+ <tr>
+ <th>Updates Notification Message:</th>
+ <td>
+ {php}
+ wp_editor('{if $genSettings.fieldData.updates_notification} {$genSettings.fieldData.updates_notification|escape:quotes} {/if}', 'updates_notification', array(
+ 'media_buttons' => false,
+ 'textarea_name' => 'updates_notification',
+ 'editor_height' => 300,
+ ));
+ {/php}
+ </td>
+ </tr>
+ </table>
+ <input id="updateSettings" type="submit" value="Update Settings" class="">
+ </form>
+
+ <script type="text/javascript">
+
+ jQuery(document).ready(function($) {
+
+ // Flash certain elements for a short time after display
+ $(".glm-flash-updated").fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500);
+
+ });
+ </script>
+
+{include file='admin/footer.html'}
<h2>{$glmPluginName} Settings</h2>
<h2 class="nav-tab-wrapper">
-{if apply_filters('glm-member-db-common-members-enabled', false)}
-
- <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">{$terms.term_member_cap} Types</a>
- <a href="{$thisUrl}?page={$thisPage}&glm_action=categories" class="nav-tab{if $thisAction==categories} nav-tab-active{/if}">{$terms.term_member_cap} Categories</a>
- <a href="{$thisUrl}?page={$thisPage}&glm_action=amenities" class="nav-tab{if $thisAction==amenities} nav-tab-active{/if}">Amenities</a>
-{/if}
- <a href="{$thisUrl}?page={$thisPage}&glm_action=cities" class="nav-tab{if $thisAction==cities} nav-tab-active{/if}">Cities</a>
-{if apply_filters('glm-member-db-common-members-enabled', false)}
- <a href="{$thisUrl}?page={$thisPage}&glm_action=regions" class="nav-tab{if $thisAction==regions} nav-tab-active{/if}">Regions</a>
- {if apply_filters('glm-member-db-common-counties-enabled', false)}
- <a href="{$thisUrl}?page={$thisPage}&glm_action=counties" class="nav-tab{if $thisAction==counties} nav-tab-active{/if}">{$terms.term_admin_menu_configure_counties}</a>
- {/if}
-{/if}
-{foreach $addOnTabs as $a}
- <a href="{$thisUrl}?page={$thisPage}&glm_action={$a.action}" class="nav-tab{if $thisAction==$a.action} nav-tab-active{/if}">{$a.text}</a>
-{/foreach}
+
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">GLM Associate</a>
+
+ {foreach $addOnTabs as $a}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action={$a.action}" class="nav-tab{if $thisAction==$a.action} nav-tab-active{/if}">{$a.text}</a>
+ {/foreach}
+
</h2>
+
<div id="glm-admin-content-container">
+ {if isset( $thisAction ) && in_array( $thisAction, array( 'index', 'categories', 'amenities', 'cities', 'regions', 'counties', 'emailsettings' ) )}
+ <h2 class="nav-tab-wrapper">
+ {if apply_filters('glm-member-db-common-members-enabled', false)}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index} nav-tab-active{/if}">{$terms.term_member_cap} Types</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=categories" class="nav-tab{if $thisAction==categories} nav-tab-active{/if}">{$terms.term_member_cap} Categories</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=amenities" class="nav-tab{if $thisAction==amenities} nav-tab-active{/if}">Amenities</a>
+ {/if}
+
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=cities" class="nav-tab{if $thisAction==cities} nav-tab-active{/if}">Cities</a>
+
+ {if apply_filters('glm-member-db-common-members-enabled', false)}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=regions" class="nav-tab{if $thisAction==regions} nav-tab-active{/if}">Regions</a>
+ {if apply_filters('glm-member-db-common-counties-enabled', false)}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=counties" class="nav-tab{if $thisAction==counties} nav-tab-active{/if}">{$terms.term_admin_menu_configure_counties}</a>
+ {/if}
+ {/if}
+
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=emailsettings" class="nav-tab{if $thisAction==emailsettings} nav-tab-active{/if}">Email Settings</a>
+
+ </h2>
+ {/if}