From: Anthony Talarico Date: Wed, 3 Jan 2018 15:54:37 +0000 (-0500) Subject: adding notifications setting for the jobs X-Git-Tag: v1.0.0~1^2~11 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=5e4ffe63ec86caac7efe7a0219c4487e1d648f1f;p=WP-Plugins%2Fglm-member-db-jobs.git adding notifications setting for the jobs adding email and notifications settings tabf or jobs --- diff --git a/classes/data/dataEmailJobsNotifications.php b/classes/data/dataEmailJobsNotifications.php new file mode 100644 index 0000000..ce7a661 --- /dev/null +++ b/classes/data/dataEmailJobsNotifications.php @@ -0,0 +1,185 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataEvent class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataEmailJobsNotifications extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + /** + * MemberInfo DB object + * + * @var $MemberInfo + * @access public + */ + public $MemberInfo; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . 'email_notifications'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Email Notification Message + 'job_email_notification' => array( + 'field' => 'job_email_notification', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + // Event Declined Message + 'job_declined_message' => array( + 'field' => 'job_declined_message', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + // Event Declined Message + 'job_approved_message' => array( + 'field' => 'job_approved_message', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + // To Email address + 'job_to_email' => array( + 'field' => 'job_to_email', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + // From Email Address + 'job_from_email' => array( + 'field' => 'job_from_email', + 'type' => 'text', + 'required' => false, + 'use' => 'a' + ), + + ); + + } + + /* + * Entry Post Processing Call-Back Method + * + * Perform post-processing for all result entries. + * + * In this case we're using it to append an array of category + * data to each member result and also sort by member name. + * + * @param array $r Array of field result data for a single entry + * @param string $a Action being performed (l, i, g, ...) + * + * @return object Class object + * + */ + public function entryPostProcessing($r, $a) + { + return $r; + } +} + +?> diff --git a/classes/helper/notifications.php b/classes/helper/notifications.php index 28c1a1a..486ccca 100644 --- a/classes/helper/notifications.php +++ b/classes/helper/notifications.php @@ -87,7 +87,7 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers $member = $this->getEntry( $memberId ); // find notify_to // See if there's a primary member contact for this member - $notify_to = apply_filters( 'glm-member-db-admin-get-member-primary-email', '', $memberId ); + $notify_to = $settings['job_to_email']; if ( !$notify_to ) { return false; } @@ -100,7 +100,7 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers $memberInfo = $memberInfoData->getActiveInfoForMember( $memberId ); // get settings $settings = $this->config['settings']; - $notify_from = $settings['from_email']; + $notify_from = $settings['job_from_email']; // Setup the Smarty Engine $smarty = new smartyTemplateSupport(); @@ -151,8 +151,8 @@ class GlmMembersAdmin_jobs_notification extends GlmDataMembers { $member = $this->getEntry( $memberId ); $settings = $this->config['settings']; - $notify_to = $settings['to_email']; - $notify_from = $settings['from_email']; + $notify_to = $settings['job_to_email']; + $notify_from = $settings['job_from_email']; $notify_message = $settings['email_notification']; if ( !$notify_to ) { return false; diff --git a/index.php b/index.php index ab8f507..64eba29 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_JOBS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_JOBS_PLUGIN_DB_VERSION', '0.0.2'); +define('GLM_MEMBERS_JOBS_PLUGIN_DB_VERSION', '0.0.3'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_JOBS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); @@ -147,6 +147,13 @@ if (is_file(GLM_MEMBERS_JOBS_PLUGIN_DB_SCRIPTS.'/dbVersions.php')) { $glmMembersjobsManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A ); unset($glmMembersjobsManagementSettings['id']); */ +// Load Events Management Settings data + +// Grab the new email_notification to_email and from_email to add to these (override) +$emailNotifications = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX."email_notifications WHERE id = 1", ARRAY_A ); +if ( $emailNotifications ) { + $jobsSettings = $emailNotifications ; +} function glmMembersjobsRegisterAddOn($addOns) { @@ -158,6 +165,7 @@ function glmMembersjobsRegisterAddOn($addOns) { 'slug' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, 'actions' => $GLOBALS['glmMembersjobsAddOnValidActions'], 'config' => array( + 'settings' => $GLOBALS['jobsSettings'] ), 'shortcodes' => $GLOBALS['glmMembersjobsShortcodes'], 'shortcodesDescription' => $GLOBALS['glmMembersjobsShortcodesDescription'] diff --git a/models/admin/settings/emailJobsNotifications.php b/models/admin/settings/emailJobsNotifications.php new file mode 100644 index 0000000..ca24735 --- /dev/null +++ b/models/admin/settings/emailJobsNotifications.php @@ -0,0 +1,158 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Event Categories data abstract +require_once GLM_MEMBERS_JOBS_PLUGIN_CLASS_PATH.'/data/dataEmailJobsNotifications.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_emailJobsNotifications extends GlmDataEmailJobsNotifications +{ + + /** + * 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; + $enable_members = $this->config['settings']['enable_members']; + $email_settings = false; + + $jobs_email_settings = $this->getSettings(); + + // If there's an action option + if (isset($_REQUEST['option'])) { + + switch($_REQUEST['option']) { + + case 'update': + $this->updateEntry($jobs_email_settings['id']); + + break; + case 'new': + $this->insertEntry(); + break; + } + + } + + $jobs_email_settings = $this->getSettings(); + // 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( + 'enable_members' => $enable_members, + 'email_settings' => $jobs_email_settings + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/emailJobsNotifications.html', + 'data' => $templateData + ); + + } + private function getSettings(){ + $sql = "SELECT * FROM " . GLM_MEMBERS_JOBS_PLUGIN_DB_PREFIX . 'email_notifications'; + $jobs_email_settings = $this->wpdb->get_results($sql, ARRAY_A); + return !empty($jobs_email_settings) ? $jobs_email_settings[0] : false; + } + +} diff --git a/setup/adminTabs.php b/setup/adminTabs.php index b2570b7..c467e61 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -51,6 +51,22 @@ if (current_user_can('glm_members_members')) { ); } + if (apply_filters('glm_members_permit_admin_members_jobTitles_tab', true)) { + add_filter('glm-member-db-add-tab-for-settings', + function($addOnTabs) { + $newTabs = array( + array( + 'text' => 'Jobs Notifications', + 'menu' => 'settings', + 'action' => 'emailJobsNotifications' + ), + + ); + $addOnTabs = array_merge($addOnTabs, $newTabs); + return $addOnTabs; + } + ); + } if (apply_filters('glm_members_permit_admin_members_management_tab', true)) { add_filter('glm-member-db-add-tab-for-management', diff --git a/setup/databaseScripts/create_database_V0.0.2.sql b/setup/databaseScripts/create_database_V0.0.2.sql deleted file mode 100644 index f6e24fd..0000000 --- a/setup/databaseScripts/create_database_V0.0.2.sql +++ /dev/null @@ -1,68 +0,0 @@ --- Gaslight Media Members Database - Job Postings --- File Created: 11/20/17 15:27:15 --- Database Version: 0.0.2 --- Database Creation Script --- --- This file is called to create a new set of tables for this --- add-on for the most receint database version for this add-on. --- --- There should only be one such file in this directory --- --- To permit each query below to be executed separately, --- all queries must be separated by a line with four dashes - --- Conditions Table -CREATE TABLE {prefix}jobs ( - id INT NOT NULL AUTO_INCREMENT, - old_id int NULL , - title int NULL , - descr TEXT NULL , - salary TINYTEXT NULL , - email_location TINYTEXT NULL , - resume_location TINYTEXT NULL , - contact_name TINYTEXT NULL , - contact_phone TINYTEXT NULL , - post_date DATETIME NULL, - updated DATETIME NULL, - active BOOL NULL, - facility_operation TEXT NULL, - requirements TEXT NULL, - benefits TEXT NULL , - job_location TINYTEXT NULL , - job_expiration INT NULL, - duration TINYTEXT NULL , - deadline TINYTEXT NULL , - company TINYTEXT NULL , - repost TINYTEXT NULL , - position_available TINYTEXT NULL , - member INT NULL, - PRIMARY KEY (id) -); - ----- - --- Job Titles -CREATE TABLE {prefix}job_titles ( - id INT NOT NULL AUTO_INCREMENT, - old_id INT NULL, - job_title TINYTEXT NULL , - PRIMARY KEY (id) -); - ----- - --- Job Titles default entries in table --- INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES --- (1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor'); - ----- - --- Job Titles default entries in table --- INSERT INTO {prefix}jobs ( --- id,old_id,title,descr,salary, email_location,resume_location,contact_name,contact_phone,post_date,updated,visible, --- facility_operation,requirements,job_location,job_expiration,duration,deadline,position_available, --- company,member,benefits --- ) VALUES ( 1,1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'RESUME LOCATION','CONTACT NAME', '453-3443', NOW(),NOW(), true, --- 'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE', --- 'COMPANY', 1, 'JOB BENEFITS' --- ); \ No newline at end of file diff --git a/setup/databaseScripts/create_database_V0.0.3.sql b/setup/databaseScripts/create_database_V0.0.3.sql new file mode 100644 index 0000000..767f74f --- /dev/null +++ b/setup/databaseScripts/create_database_V0.0.3.sql @@ -0,0 +1,90 @@ +-- Gaslight Media Members Database - Job Postings +-- File Created: 11/20/17 15:27:15 +-- Database Version: 0.0.2 +-- Database Creation Script +-- +-- This file is called to create a new set of tables for this +-- add-on for the most receint database version for this add-on. +-- +-- There should only be one such file in this directory +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Conditions Table +CREATE TABLE {prefix}jobs ( + id INT NOT NULL AUTO_INCREMENT, + old_id int NULL , + title int NULL , + descr TEXT NULL , + salary TINYTEXT NULL , + email_location TINYTEXT NULL , + resume_location TINYTEXT NULL , + contact_name TINYTEXT NULL , + contact_phone TINYTEXT NULL , + post_date DATETIME NULL, + updated DATETIME NULL, + active BOOL NULL, + facility_operation TEXT NULL, + requirements TEXT NULL, + benefits TEXT NULL , + job_location TINYTEXT NULL , + job_expiration INT NULL, + duration TINYTEXT NULL , + deadline TINYTEXT NULL , + company TINYTEXT NULL , + repost TINYTEXT NULL , + position_available TINYTEXT NULL , + member INT NULL, + PRIMARY KEY (id) +); + +---- + +-- Job Titles +CREATE TABLE {prefix}job_titles ( + id INT NOT NULL AUTO_INCREMENT, + old_id INT NULL, + job_title TINYTEXT NULL , + PRIMARY KEY (id) +); + +---- + +-- Event Email Notifications +CREATE TABLE {prefix}email_notifications ( + id INT NOT NULL AUTO_INCREMENT, + job_declined_message TEXT NULL, -- Event declined message + job_approved_message TEXT NULL, -- Event approved message + job_to_email TINYTEXT NULL, -- To Email Address + job_from_email TINYTEXT NULL, -- From Email Address + job_email_notification TEXT NULL, -- Email notification message + PRIMARY KEY (id) +); + +---- + +-- Set default event email settings +INSERT INTO {prefix}email_notifications + ( id, job_declined_message, job_approved_message ) + VALUES + ( 1, 'The Job parameters do not comply with our event guidelines.', 'Your Job has been approved.' ) +; + +---- + +-- Job Titles default entries in table +-- INSERT INTO {prefix}job_titles ( id,old_id,job_title) VALUES +-- (1,1, 'Supervisor'),(2,1,'Groundskeeper'),(3,1,'Janitor'); + +---- + +-- Job Titles default entries in table +-- INSERT INTO {prefix}jobs ( +-- id,old_id,title,descr,salary, email_location,resume_location,contact_name,contact_phone,post_date,updated,visible, +-- facility_operation,requirements,job_location,job_expiration,duration,deadline,position_available, +-- company,member,benefits +-- ) VALUES ( 1,1, 1,"DESCRIPTION",'SALARY', 'EMAIL LOCATION', 'RESUME LOCATION','CONTACT NAME', '453-3443', NOW(),NOW(), true, +-- 'facility operations', 'REQUIREMENTS', 'JOB LOCATION', 30, 'JOB DURATION', 'DEADLINE', 'POSITION AVAILABLE', +-- 'COMPANY', 1, 'JOB BENEFITS' +-- ); \ No newline at end of file diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 9e0928b..61a0e8b 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -36,4 +36,5 @@ $glmMembersjobsDbVersions = array( '0.0.1' => array('version' => '0.0.1', 'tables' => 2, 'date' => '09/08/2017'), '0.0.2' => array('version' => '0.0.2', 'tables' => 2, 'date' => '11/21/2017'), + '0.0.3' => array('version' => '0.0.3', 'tables' => 3, 'date' => '12/21/2017'), ); diff --git a/setup/databaseScripts/update_database_V0.0.3.sql b/setup/databaseScripts/update_database_V0.0.3.sql new file mode 100644 index 0000000..0fe4b78 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.3.sql @@ -0,0 +1,26 @@ +-- Gaslight Media Members Database - Events Add-On +-- File Created: 2017-08-04 +-- Database Version: 0.0.3 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Event Email Notifications +CREATE TABLE {prefix}email_notifications ( + id INT NOT NULL AUTO_INCREMENT, + job_declined_message TEXT NULL, -- Event declined message + job_approved_message TEXT NULL, -- Event approved message + job_to_email TINYTEXT NULL, -- To Email Address + job_from_email TINYTEXT NULL, -- From Email Address + PRIMARY KEY (id) +); + +---- + +-- Set default event email settings +INSERT INTO {prefix}email_notifications + ( id, job_declined_message, job_approved_message ) + VALUES + ( 1, 'The Job parameters do not comply with our event guidelines.', 'Your Job has been approved.' ) +; \ No newline at end of file diff --git a/setup/validActions.php b/setup/validActions.php index 5772abf..464e8d9 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -64,6 +64,7 @@ $glmMembersjobsAddOnValidActions = array( ), 'settings' => array( 'jobTitles' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, + 'emailJobsNotifications' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, ), 'management' => array( 'jobsImport' => GLM_MEMBERS_JOBS_PLUGIN_SLUG, diff --git a/views/admin/settings/emailJobsNotifications.html b/views/admin/settings/emailJobsNotifications.html new file mode 100644 index 0000000..eb3d2a9 --- /dev/null +++ b/views/admin/settings/emailJobsNotifications.html @@ -0,0 +1,76 @@ +{include file='admin/settings/header.html'} + + +
+ + {if $email_settings} + + {else if} + + {/if} +
+ + + + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +{include file='admin/footer.html'}