From: Anthony Talarico Date: Thu, 13 Sep 2018 20:26:41 +0000 (-0400) Subject: creating modal link with base form, still working on ajax server submission X-Git-Tag: v1.0.0^2~16 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=31edfd66db5bfd1f9571339ff94d41a07a7e08ff;p=WP-Plugins%2Fglm-member-db-staff.git creating modal link with base form, still working on ajax server submission --- diff --git a/models/admin/ajax/staffEmail.php b/models/admin/ajax/staffEmail.php new file mode 100644 index 0000000..7fe9c14 --- /dev/null +++ b/models/admin/ajax/staffEmail.php @@ -0,0 +1,113 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Staff Data +require_once GLM_MEMBERS_STAFF_PLUGIN_CLASS_PATH.'/data/dataStaff.php'; + +/* + * This class performs the work of handling images passed to it via + * an AJAX call that goes through the WorPress AJAX Handler. + * + */ +class GlmMembersAdmin_ajax_staffEmail +{ + + /** + * 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); + + } + + /* + * AJAX Debugging + * + */ + function write_log ( $log ) { + if ( true === WP_DEBUG ) { + if ( is_array( $log ) || is_object( $log ) ) { + error_log( print_r( $log, true ) ); + } else { + error_log( $log ); + } + } + } + /* + * Perform Model Action + * + * This modelAction takes an AJAX image upload and stores the image in the + * media/images directory of the plugin. + * + * This model action does not return, it simply does it's work then calls die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction ($actionData = false) + { + global $wpdb; + $this->write_log("test"); + + if( isset($_REQUEST['staff_id'] ) ){ + $staff_id = filter_var($_REQUEST['staff_id'], FILTER_SANITIZE_STRING); + + $sql = "SELECT email FROM ". GLM_MEMBERS_STAFF_PLUGIN_DB_PREFIX . "staff WHERE id = $staff_id"; + $staff_email_address = $wpdb->get_results($sql); + if( $staff_email_address){ + $staff_email_address = $staff_email_address[0]->email; + }else{ + $staff_email_address = null; + } + + } + $return = array( + 'email' => $staff_email_address, // Where our events list will go + ); + echo json_encode($return); + wp_die(); + } +} diff --git a/setup/validActions.php b/setup/validActions.php index 30a3f92..4efd318 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -59,6 +59,9 @@ $glmMembersStaffAddOnValidActions = array( 'adminActions' => array( + 'ajax' => array( + 'staffEmail' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, + ), 'staff' => array( 'index' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, 'settings' => GLM_MEMBERS_STAFF_PLUGIN_SLUG, diff --git a/views/front/staff/list.html b/views/front/staff/list.html index ce4776b..a4a7ccb 100644 --- a/views/front/staff/list.html +++ b/views/front/staff/list.html @@ -26,9 +26,8 @@ - {$staffVal.email} + Email - {/foreach} @@ -37,4 +36,44 @@ Sorry, no staff members found. {/if} - \ No newline at end of file + + + \ No newline at end of file