From: Steve Sutton Date: Tue, 27 Feb 2018 19:13:40 +0000 (-0500) Subject: Start notification work X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=12850d94a6e9921630d9c956274cd78da695633e;p=WP-Plugins%2Fglm-member-db.git Start notification work WIP --- diff --git a/models/admin/settings/notifications.php b/models/admin/settings/notifications.php new file mode 100644 index 00000000..9ce7bb8b --- /dev/null +++ b/models/admin/settings/notifications.php @@ -0,0 +1,250 @@ + + * @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 '
$amenities: ' . print_r($amenities, true) . '
'; + + // 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, + ); + + } + + +} diff --git a/setup/validActions.php b/setup/validActions.php index 28f84bc3..89471f50 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -68,12 +68,13 @@ $glmMembersValidActions = array( '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 diff --git a/views/admin/settings/header.html b/views/admin/settings/header.html index 713b88aa..d9865c04 100644 --- a/views/admin/settings/header.html +++ b/views/admin/settings/header.html @@ -1,24 +1,24 @@ +{* + This template is used for the main header for Member Settings. +*}
-

{$glmPluginName} Settings

-
- diff --git a/views/admin/settings/notifications.html b/views/admin/settings/notifications.html new file mode 100644 index 00000000..f567cb87 --- /dev/null +++ b/views/admin/settings/notifications.html @@ -0,0 +1,31 @@ +{include file='admin/settings/header.html'} + + +
+
+ + + + + + + + + + + + +
Email Subject: + +
Description: + +
+

* Required

+ +
+
+ + + +{include file='admin/footer.html'}