From: Steve Sutton Date: Fri, 4 May 2018 18:52:16 +0000 (-0400) Subject: Form now submits X-Git-Tag: v1.0.0^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=9bbe8836d40f30b82c32bdc5c11296dd9ed9f0c2;p=WP-Plugins%2Fglm-member-db-support.git Form now submits Submits the form to the saved options. --- diff --git a/assets/lifeB.png b/assets/lifeB.png new file mode 100755 index 0000000..e3c39e1 Binary files /dev/null and b/assets/lifeB.png differ diff --git a/assets/send.png b/assets/send.png new file mode 100755 index 0000000..e57df49 Binary files /dev/null and b/assets/send.png differ diff --git a/css/admin.css b/css/admin.css new file mode 100644 index 0000000..334ca44 --- /dev/null +++ b/css/admin.css @@ -0,0 +1,96 @@ +/* glm-support-setting-form */ +.glm-support-setting-form { + margin: 10px 0; + max-width: 400px; + padding: 20px 12px 10px 20px; + font-size: .813rem; +} +.glm-support-field { + width: 100%; + padding: 0; + margin: 3px 0 0 0; +} +.glm-support-label { + width: 100%; + font-weight; bold; + padding: 0; + margin: 7px 0 0 0; +} +.glm-support-left-half { + width: 49%; + float: left; + margin: 3px 3px 0 0; +} +.glm-support-right-half { + width: 49%; + float: left; + margin: 3px 0 0 3px; + clear: right; +} +.glm-support-input { + padding: 3px 0; +} +.glm-support-input label { + width: 100%; + display: block; +} +.glm-support-input input[type=text], +.glm-support-input input[type=date], +.glm-support-input input[type=datetime], +.glm-support-input input[type=number], +.glm-support-input input[type=search], +.glm-support-input input[type=time], +.glm-support-input input[type=url], +.glm-support-input input[type=email], +.glm-support-input textarea, +.glm-support-input select{ + height: 2rem; + box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + border:1px solid #BEBEBE; + padding: 4px; + margin:0px; + -webkit-transition: all 0.30s ease-in-out; + -moz-transition: all 0.30s ease-in-out; + -ms-transition: all 0.30s ease-in-out; + -o-transition: all 0.30s ease-in-out; + outline: none; + width: 100%; +} +.glm-support-input input[type=text]:focus, +.glm-support-input input[type=date]:focus, +.glm-support-input input[type=datetime]:focus, +.glm-support-input input[type=number]:focus, +.glm-support-input input[type=search]:focus, +.glm-support-input input[type=time]:focus, +.glm-support-input input[type=url]:focus, +.glm-support-input input[type=email]:focus, +.glm-support-input textarea:focus, +.glm-support-input select:focus{ + -moz-box-shadow: 0 0 8px #88D5E9; + -webkit-box-shadow: 0 0 8px #88D5E9; + box-shadow: 0 0 8px #88D5E9; + border: 1px solid #88D5E9; +} +.glm-support-input table { + width: 100%; +} +.glm-support-setting-form fieldset legend { + font-size: 1rem; + font-weight: bold; + margin-top: 2rem; +} + +.glm-support-setting-form input[type=submit] { + margin-top: 20px; +} + +@media only screen and (max-width: 600px) { + .glm-support-left-half { + width: 100%; + } + .glm-support-right-half { + width: 100%; + } +} diff --git a/defines.php b/defines.php index c19ee20..3269821 100644 --- a/defines.php +++ b/defines.php @@ -69,3 +69,5 @@ define('GLM_MEMBERS_SUPPORT_MAIN_PLUGIN_PATH', $pluginsPath.'/glm-member-db'); define('GLM_MEMBERS_SUPPORT_MAIN_PLUGIN_LIB_PATH', GLM_MEMBERS_SUPPORT_MAIN_PLUGIN_PATH.'/lib'); define('GLM_MEMBERS_SUPPORT_PLUGIN_LIB_PATH', GLM_MEMBERS_SUPPORT_PLUGIN_PATH.'/lib'); +// Setting option +define('GLM_MEMBERS_SUPPORT_SETTING_OPTION_NAME', 'glmMembersSupportSettingOption'); diff --git a/models/admin/settings/support.php b/models/admin/settings/support.php new file mode 100644 index 0000000..c84e1e4 --- /dev/null +++ b/models/admin/settings/support.php @@ -0,0 +1,156 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_settings_support //extends GlmDataEmailNotifications +{ + + /** + * 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); + + } + + /* + * 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 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) + { + + $success = true; + $error = false; + $email_settings = false; + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'update': + + // serialize the request + $value = array( + 'support_email' => $_REQUEST['support_email'], + 'support_from_name' => $_REQUEST['support_from_name'], + 'support_from_email' => $_REQUEST['support_from_email'], + ); + $option_value = serialize( $value ); + + update_option( GLM_MEMBERS_SUPPORT_SETTING_OPTION_NAME, $option_value ); + + break; + } + + } + + $support_option_array = get_option( GLM_MEMBERS_SUPPORT_SETTING_OPTION_NAME ); + if ( $support_option_array ) { + $email_settings = unserialize( $support_option_array ); + } + + // 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( + 'settings' => $email_settings + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/support.html', + 'data' => $templateData + ); + + } + +} diff --git a/models/admin/support/index.php b/models/admin/support/index.php index 286f6cc..724f512 100644 --- a/models/admin/support/index.php +++ b/models/admin/support/index.php @@ -79,25 +79,86 @@ class GlmMembersAdmin_support_index // extends GlmDataLeadEntry public function modelAction($actionData = false) { - $view = 'index'; + $view = 'index'; + $email_settings = false; + $option = false; + + if ( isset( $_REQUEST['option'] ) ) { + $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ); + } switch ( $option ) { + case 'submit': + $view = 'thankyou'; + + $support_option_array = get_option( GLM_MEMBERS_SUPPORT_SETTING_OPTION_NAME ); + if ( $support_option_array ) { + $email_settings = unserialize( $support_option_array ); + $email = $email_settings['support_email']; + $from_name = $email_settings['support_from_name']; + $from = $email_settings['support_from_email']; + } + + if ($email) { + // Setup the Headers. + $hdrs = 'From: '.$from_name.' <' . $from . '>'; + $hdrs .= "\nReply-To: {$values['name']} <{$values['email']}>"; + + // Setup the message. + $msg = 'Name: ' . $values['name'] . "\n" . + 'Email: ' . $values['email'] . "\n" . + 'Problem:' . stripslashes($values['problem']) . "\n\n\n" . + 'SiteName: ' . get_bloginfo('name') . "\n" . + 'SiteUrl: ' . get_bloginfo('url') . "\n" . + 'Date: ' . date('m/d/Y') . "\n" . + 'Time: ' . date('H:i:s ') . "\n" . + 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'] . "\n" . + 'Remote-Addr: ' . $_SERVER['REMOTE_ADDR'] . "\n"; + + // Check for any uploaded files. + $attachment = ''; + if ( isset( $_FILES ) && is_array( $_FILES ) + && isset( $_FILES['file_upload'] ) && !$_FILES['file_upload']['error'] ) { + // Create a directory in uploads for support files if needed + $upPath = wp_upload_dir(); + $filePath = $upPath['basedir'] . '/glm--member-db-support'; + if ( !is_dir( $filePath ) ) { + $oldumask = umask( 0 ); + mkdir( $filePath, 0770 ); + umask( $oldumask ); + } + // move the uploaded file + $fileName = wp_unique_filename( $filePath, $_FILES['file_upload']['name'] ); + $fileUploaded = move_uploaded_file( $_FILES['file_upload']['tmp_name'], $fileName ); + if ( $fileUploaded && $fileName ) { + $attachment = $fileName; + } + } + + wp_mail( + $email.','.$values['email'], + 'Support Form', + $msg, + $hdrs, + $attachment + ); + + + // If there's a file attachment then delete file from server + if ( isset( $fileName ) && $fileName && is_file( $filePath . '/' . $fileName ) ) { + unlink( $filePath . '/' . $fileName ); + } + } + break; default: + $view = 'index'; break; } - // Get the email options - $email_options = array( - array( - 'value' => 'steve@gaslightmedia.com', - 'label' => 'Admin help', - ) - ); - // Common things to place into the $templateData array $templateData = array( - 'email_options' => $email_options, + 'pluginAsset' => GLM_MEMBERS_SUPPORT_PLUGIN_URL . '/assets' ); diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 5fe4bb3..55a7eba 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -32,4 +32,17 @@ * ); * */ +add_filter('glm-member-db-add-tab-for-settings', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Support Settings', + 'menu' => 'settings', + 'action' => 'support' + ), + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } +); diff --git a/setup/validActions.php b/setup/validActions.php index ad12624..73ac17f 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -62,6 +62,9 @@ $glmMembersSupportAddOnValidActions = array( 'support' => array( 'index' => GLM_MEMBERS_SUPPORT_PLUGIN_SLUG, ), + 'settings' => array( + 'support' => GLM_MEMBERS_SUPPORT_PLUGIN_SLUG, + ), ), 'frontActions' => array( ) diff --git a/views/admin/settings/support.html b/views/admin/settings/support.html new file mode 100644 index 0000000..46215df --- /dev/null +++ b/views/admin/settings/support.html @@ -0,0 +1,48 @@ +{include file='admin/settings/header.html'} + +
+
+ + + +
+ Support Settings + +
+
+ To Email Address +
+
+ +
+
+ +
+
+ From Name +
+
+ +
+
+ +
+
+ From Email Address +
+
+ +
+
+ +
+ + + +
+
+ +{include file='admin/footer.html'} diff --git a/views/admin/support/index.html b/views/admin/support/index.html index 275c11e..9154e1f 100644 --- a/views/admin/support/index.html +++ b/views/admin/support/index.html @@ -7,8 +7,8 @@ font: 16px sans-serif; padding: 20px 10px 20px 30px; margin: 0; - background: url(//app.gaslightmedia.com/Common/Support/images/lifeB.png) 550px -10px no-repeat; - background: url(//app.gaslightmedia.com/Common/Support/images/lifeB.png) 550px -10px no-repeat; + background: url({$pluginAsset}/lifeB.png) 550px -10px no-repeat; + background: url({$pluginAsset}/lifeB.png) 550px -10px no-repeat; } h1 { padding: 10px 0; @@ -40,7 +40,7 @@ padding: 0; margin: 0; text-indent: -9000px; - background: url(//app.gaslightmedia.com/Common/Support/images/send.png) no-repeat; + background: url({$pluginAsset}/send.png) no-repeat; border: 0; cursor: pointer; } @@ -65,6 +65,7 @@ margin-right: 5px; } +{debug}

Support Form

@@ -74,29 +75,14 @@

If you have a screenshot to upload the file must be no larger than 1MB.

-
+ + + - - - - - - -
Please help us provide the proper support
- * - Can you tell us which area you need assistance with? -
  - -
* diff --git a/views/admin/support/thankyou.html b/views/admin/support/thankyou.html new file mode 100644 index 0000000..5be710e --- /dev/null +++ b/views/admin/support/thankyou.html @@ -0,0 +1,70 @@ + +
+
Your Request has been sent.
+