--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Amenitiess List
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Amenities data abstract
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataAmenities.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataGroups.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_notifications // extends GlmDataAmenities
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Settings 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 );
+
+ }
+
+ /*
+ * 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 successfull 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 contoller 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 )
+ {
+
+ $success = true;
+ $haveAmenities = false;
+ $haveGroups = false;
+ $amenities = false;
+ $error = false;
+ $option2 = '';
+ // $newAmenity = $this->newEntry();
+
+ // Check if a category ID is supplied
+ $id = 0;
+ if ( isset( $_REQUEST['id'] ) ) {
+ $id = $_REQUEST['id'] - 0;
+ }
+
+ // If there's an action option
+ if ( isset( $_REQUEST['option'] ) ) {
+ switch( $_REQUEST['option'] ) {
+ case 'addNew':
+ $return = $this->insertEntry();
+ $id = $return['fieldData']['id'];
+ if ( isset( $_REQUEST['grouped']['group'] ) ) {
+ foreach ( $_REQUEST['grouped']['group'] as $group_id => $group_value ) {
+ if ( $group_value == 1 ) {
+ $this->wpdb->insert(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'grouped_amenities',
+ array(
+ 'group_id' => $group_id,
+ 'amenity_id' => $id,
+ 'searchable' => $_REQUEST['grouped']['searchable'][$group_id]
+ ),
+ array(
+ '%d',
+ '%d',
+ '%s'
+ )
+ );
+ }
+ }
+ }
+ break;
+
+ case 'update':
+ if ( $id > 0 ) {
+ $this->updateEntry( $id );
+ }
+ // Delete the current entries for the grouped amenities
+ $this->wpdb->delete(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'grouped_amenities',
+ array( 'amenity_id' => $id ),
+ array( '%d' )
+ );
+ if ( isset( $_REQUEST['grouped']['group'] ) ) {
+ foreach ( $_REQUEST['grouped']['group'] as $group_id => $group_value ) {
+ if ( $group_value == 1 ) {
+ $this->wpdb->insert(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'grouped_amenities',
+ array(
+ 'group_id' => $group_id,
+ 'amenity_id' => $id,
+ 'searchable' => $_REQUEST['grouped']['searchable'][$group_id]
+ ),
+ array(
+ '%d',
+ '%d',
+ '%s'
+ )
+ );
+ }
+ }
+ }
+ break;
+
+ case 'delete':
+ if ( $id > 0 ) {
+ $this->deleteEntry( $id, true );
+ }
+ break;
+
+ default:
+ $option2 = false;
+ break;
+
+ }
+ }
+
+ if ( isset( $_REQUEST['option2'] ) ) {
+ $option2 = $_REQUEST['option2'];
+ }
+
+ // Get a current list of amenities
+ // $amenities = $this->getList();
+ //echo '<pre>$amenities: ' . print_r($amenities, true) . '</pre>';
+
+ // If we have list entries - even if it's an empty list
+ $success = true;
+ $haveAmenities = false;
+ if ( $amenities !== false ) {
+
+ $success = true;
+
+ // If we have any entries
+ if ( count( $amenities ) > 0 ) {
+ $haveAmenities = true;
+ }
+ }
+
+ if ( $groups !== false ) {
+ $success = true;
+
+ // If we have any entries.
+ if ( count( $groups ) > 0 ) {
+ $haveGroups = true;
+ }
+ }
+
+ // If we had a fatal error, redirect to the error page
+ if ($error) {
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => 'error',
+ 'modelRedirect' => 'index',
+ 'view' => 'admin/error/index.html',
+ 'data' => false,
+ );
+ }
+
+ // Compile template data
+ $templateData = array(
+ 'haveAmenities' => $haveAmenities,
+ 'haveGroups' => $haveGroups,
+ 'amenities' => $amenities,
+ 'option2' => $option2,
+ 'newAmenity' => $newAmenity,
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/settings/notifications.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',
+ 'notifications' => 'glm-member-db',
),
'management' => array(
'index' => 'glm-member-db', // General Options
+{*
+ This template is used for the main header for Member Settings.
+*}
<div class="wrap glm-associate-admin-wrap glm-associate-admin-settings-wrap">
-
<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}
+ {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_admin_menu_configure_member_types}</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=categories" class="nav-tab{if $thisAction==categories} nav-tab-active{/if}">{$terms.term_admin_menu_configure_member_cats}</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=amenities" class="nav-tab{if $thisAction==amenities} nav-tab-active{/if}">{$terms.term_admin_menu_configure_amenities}</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=notifications" class="nav-tab{if $thisAction==notifications} nav-tab-active{/if}">Notifications</a>
+ {/if}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=cities" class="nav-tab{if $thisAction==cities} nav-tab-active{/if}">{$terms.term_admin_menu_configure_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}">{$terms.term_admin_menu_configure_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}
</h2>
<div id="glm-admin-content-container">
-