Submits the form to the saved options.
--- /dev/null
+/* 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%;
+ }
+}
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');
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Event Email Notification
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @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
+ );
+
+ }
+
+}
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'
);
* );
*
*/
+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;
+ }
+);
'support' => array(
'index' => GLM_MEMBERS_SUPPORT_PLUGIN_SLUG,
),
+ 'settings' => array(
+ 'support' => GLM_MEMBERS_SUPPORT_PLUGIN_SLUG,
+ ),
),
'frontActions' => array(
)
--- /dev/null
+{include file='admin/settings/header.html'}
+
+<div class="glm-support-setting-form">
+ <form action="{$thisUrl}">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="glm_action" value="support" />
+ <input type="hidden" name="option" value="update" />
+ <fieldset>
+ <legend>Support Settings</legend>
+
+ <div class="glm-support-field">
+ <div class="glm-support-label glm-required">
+ To Email Address
+ </div>
+ <div class="glm-support-input">
+ <input type="email" name="support_email" required
+ value="{if isset($settings.support_email) && $settings.support_email}{$settings.support_email}{/if}">
+ </div>
+ </div>
+
+ <div class="glm-support-field">
+ <div class="glm-support-label glm-required">
+ From Name
+ </div>
+ <div class="glm-support-input">
+ <input type="text" name="support_from_name" required
+ value="{if isset($settings.support_from_name) && $settings.support_from_name}{$settings.support_from_name}{/if}">
+ </div>
+ </div>
+
+ <div class="glm-support-field">
+ <div class="glm-support-label glm-required">
+ From Email Address
+ </div>
+ <div class="glm-support-input">
+ <input type="text" name="support_from_email" required
+ value="{if isset($settings.support_from_email) && $settings.support_from_email}{$settings.support_from_email}{/if}">
+ </div>
+ </div>
+
+ </fieldset>
+
+ <input class="button button-primary" type="submit" value="Save Settings">
+
+ </form>
+</div>
+
+{include file='admin/footer.html'}
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;
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;
}
margin-right: 5px;
}
</style>
+{debug}
<div id="glm_support_page">
<div id="supportWrapper">
<h1>Support Form</h1>
<p>If you have a screenshot to upload the file must be no larger than 1MB.</p>
</div>
<div>
- <form action="<?php echo $supportFormActionUrl;?>" method="post" enctype="multipart/form-data">
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="option" value="submit" />
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<table>
<tr>
<td colspan="2"><b>Please help us provide the proper support</b></td>
</tr>
- <tr>
- <td colspan="2">
- <span class="req">*</span>
- Can you tell us which area you need assistance with?
- </td>
- </tr>
- <tr>
- <td> </td>
- <td>
- <select name="department" required>
- <option value="">-- select --</option>
- {foreach $email_options as $e}
- <option value="{$e.value}">{$e.label}</option>
- {/foreach}
- </select>
- </td>
- </tr>
<tr>
<td>
<span class="req">*</span>
--- /dev/null
+<style>
+ .wrap {
+ margin-top: 0;
+ }
+ #glm_support_page {
+ margin-top: 0;
+ font: 16px sans-serif;
+ padding: 20px 10px 20px 30px;
+ margin: 0;
+ background: url({$pluginAsset}/lifeB.png) 550px -10px no-repeat;
+ background: url({$pluginAsset}/lifeB.png) 550px -10px no-repeat;
+ }
+ h1 {
+ padding: 10px 0;
+ margin: 0;
+ }
+ #supportWrapper {
+ width: 600px;
+ background: #eaf4eb;
+ background: rgba(255, 255, 255, .6);
+ padding: 10px 20px;
+ border: 1px solid #ccc;
+ -webkit-box-shadow: 1px 1px 2px #000; /* Saf3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
+ -moz-box-shadow: 1px 1px 2px #000; /* FF3.5 - 3.6 */
+ box-shadow: 1px 1px 2px #000; /* Opera 10.5, IE9, FF4+, Chrome 6+, iOS 5 */
+ }
+ input[type=text],input[type=email] {
+ width: 300px;
+ padding: 5px;
+ }
+ textarea {
+ width: 400px;
+ height: 150px;
+ padding: 5px;
+ }
+ #submit {
+ display: block;
+ width: 134px;
+ height: 30px;
+ padding: 0;
+ margin: 0;
+ text-indent: -9000px;
+ background: url({$pluginAsset}/send.png) no-repeat;
+ border: 0;
+ cursor: pointer;
+ }
+ td {
+ vertical-align: middle;
+ }
+ #supportIntro, #supportSucess {
+ border: 2px dashed #ddd;
+ background: #f5faf6;
+ background: rgba(255, 255, 255, .6);
+ padding: 5px 20px;
+ margin-bottom: 2em;
+ }
+ #supportIntro p {
+ margin: 1em 0;
+ }
+ table {
+ width: 600px;
+ }
+ .req {
+ color: red;
+ margin-right: 5px;
+ }
+</style>
+<div id="glm_support_page">
+ <div id="supportSucess">Your Request has been sent.</div>
+</div>