From feedbff9a843bc6c7f7a5ab5127e5b6da732b409 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 9 Jan 2015 16:49:35 -0500 Subject: [PATCH] first support form plugin --- controllers/admin.php | 132 +++++++++++++++++++++++++++++++++++++++ glm-support-form.php | 25 ++++++++ readme.txt | 23 +++++++ views/successMsg.php | 70 +++++++++++++++++++++ views/supportForm.php | 141 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 391 insertions(+) create mode 100644 controllers/admin.php create mode 100644 glm-support-form.php create mode 100644 readme.txt create mode 100644 views/successMsg.php create mode 100644 views/supportForm.php diff --git a/controllers/admin.php b/controllers/admin.php new file mode 100644 index 0000000..8940573 --- /dev/null +++ b/controllers/admin.php @@ -0,0 +1,132 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.1) + * @link <> + */ + +/** + * Gaslight Members Admin Controller + * + * Controller for all admin + * + * @category Toolkit + * @package Package + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> + */ +class SupportAdmin +{ + public $wpdb; + public $pluginPath; + + public function __construct($wpdb) + { + $this->wpdb = $wpdb; + $this->pluginPath = plugin_dir_path(GLM_SUPPORT_PLUGIN_FILE_PATH); + add_action('admin_menu', array($this, 'addMenu')); + } + + public function addMenu() + { + add_menu_page( + 'Gaslight Support Form', + 'GLM Support Form', + 'edit_posts', + 'glm-support-menu', + array($this, 'showForm'), + 'dashicons-sos' + ); + } + + public function showForm() + { + echo '
'; + if ($_POST) { + $this->sendEmail($_POST); + include $this->pluginPath . 'views/successMsg.php'; + } else { + $supportFormActionUrl = 'admin.php?page=glm-support-menu'; + include $this->pluginPath . 'views/supportForm.php'; + } + echo '
'; + } + + /** + * send the email for the Form + * @param type $values + */ + public function sendEmail($values) + { + $email = null; + if (defined('GLM_SUPPORT_SUPPORT_EMAIL') && GLM_SUPPORT_SUPPORT_EMAIL) { + // alse send to the new department email + if ($values['department']) { + switch ($values['department']) { + case 'programming': + $email = GLM_SUPPORT_PROGRAMMING; + break; + case 'web': + $email = GLM_SUPPORT_WEB; + break; + case 'sales': + $email = GLM_SUPPORT_SALES; + break; + case 'billing': + case 'networking': + $email = GLM_SUPPORT_NETWORKING; + break; + case 'seo': + $email = GLM_SUPPORT_SEO; + break; + } + + if ($email) { + + $hdrs = 'From: '.$values['name'].' '; + + $hdrs .= "\nReply-To: {$values['name']} <{$values['email']}>"; + + $department = array( + 'programming' => 'Web site admin errors', + 'web' => 'Web site admin questions/how to?', + 'sales' => 'Additional features you would like to add to Web site', + 'networking' => 'Email or Computer support', + 'billing' => 'Domain names questions/issues', + 'seo' => 'Search Engine Optimization support' + ); + + $msg = + 'Which Area: ' . $department[$values['department']] . "\n" . + 'Name: ' . $values['name'] . "\n" . + 'Email: ' . $values['email'] . "\n" . + 'Problem:' . $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"; + wp_mail( + GLM_SUPPORT_SUPPORT_EMAIL.','.$email.','.$values['email'], + GLM_SUPPORT_SUBJECT, + $msg, + $hdrs + ); + } + } + } + } +} diff --git a/glm-support-form.php b/glm-support-form.php new file mode 100644 index 0000000..dd64b5b --- /dev/null +++ b/glm-support-form.php @@ -0,0 +1,25 @@ + + Author URI: + License: GPLv2 + */ +define('GLM_SUPPORT_PLUGIN_FILE_PATH', __FILE__); +define('GLM_SUPPORT_SUBJECT', 'Support Form'); +define('GLM_SUPPORT_SUPPORT_EMAIL', 'support-form@gaslightmedia.com'); +define('GLM_SUPPORT_WEB', 'sales@gaslightmedia.com'); +define('GLM_SUPPORT_SALES', 'sales@gaslightmedia.com'); +define('GLM_SUPPORT_PROGRAMMING', 'programming@gaslightmedia.com'); +define('GLM_SUPPORT_NETWORKING', 'networking@gaslightmedia.com'); +define('GLM_SUPPORT_BILLING', 'billing@gaslightmedia.com'); +define('GLM_SUPPORT_SEO', 'seo@gaslightmedia.com'); + +if (is_admin()) { + require 'controllers/admin.php'; + $admin = new SupportAdmin($GLOBALS['wpdb']); +} \ No newline at end of file diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..f7d51e3 --- /dev/null +++ b/readme.txt @@ -0,0 +1,23 @@ +=== Plugin Name === +Contributors: Steve Sutton +Tags: +Requires at least: +Tested up to: +Stable tag: +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + + +== Description == +This is a port of our Gaslight Media Support Form +Use this support form to quickly report an issue with your web site. +Please provide as much information as you can. + + +== Installation == +Just install the plugin directory and enable plugin + + +== Changelog == + += 1.0 = diff --git a/views/successMsg.php b/views/successMsg.php new file mode 100644 index 0000000..5444f6e --- /dev/null +++ b/views/successMsg.php @@ -0,0 +1,70 @@ + +
+
Your Request has been sent.
+
\ No newline at end of file diff --git a/views/supportForm.php b/views/supportForm.php new file mode 100644 index 0000000..85fff0a --- /dev/null +++ b/views/supportForm.php @@ -0,0 +1,141 @@ + + +
+
+

Support Form

+
+

Use this support form to quickly report an issue with your web site.

+

Please provide as much information as you can.

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Please help us provide the proper support
+ * + Can you tell us which area you need assistance with? +
  + +
+ * + Your Name: + + +
+ * + Your E-mail: + + +
+ * + Describe the issue: + + +
+ +
+

* denotes required field

+
+
+
+
\ No newline at end of file -- 2.17.1